/* フローティングボタン */
.chatbot-floating-btn {
  position: fixed;
  bottom: var(--back-to-top-bottom, 45px);
  right: max(60px, calc((100% - 1200px) / 2 + 60px));
  background: #000e4ecc;
  color: #ffffff;
  border: 1px solid #999999;
  border-radius: 28px;
  cursor: pointer;
  z-index: 1000;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  height: 50px;
  font-size: 14px;
  font-weight: bold;
  line-height: 1.4;
  white-space: nowrap;
}

.chatbot-floating-btn:hover {
  background: #ffffff;
  color: #000e4e;
}

.chatbot-floating-btn-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

/* トグルコンテンツ */
.chatbot-toggle-content {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 440px;
  max-width: calc(100vw - 40px);
  height: 640px;
  /* ビューポートからはみ出さないよう上下に余白を確保 */
  max-height: calc(100dvh - 40px);
  top: auto;
  background: white;
  border: 4px solid #000e4e;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 1001; /* ボタン(1000)より前面に描画 */
  overflow: hidden;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    visibility 0.3s;
  display: flex;
  flex-direction: column;
}

.chatbot-toggle-content.chatbot-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* オーバーレイヘッダー（iframeのヘッダー領域上に重ねる） */
.chatbot-content-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #000e4e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 16px;
  z-index: 2;
  box-sizing: border-box;
}

.chatbot-header-title {
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chatbot-reload-btn,
.chatbot-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition:
    background 0.2s,
    color 0.2s;
  color: #ffffff;
  line-height: 1;
}

.chatbot-reload-btn {
  width: auto;
  height: auto;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 12px;
  gap: 4px;
  font-size: 12px;
}

.chatbot-reload-btn span.fas {
  font-size: 14px;
}

.chatbot-reload-btn:hover,
.chatbot-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.chatbot-reload-btn:focus,
.chatbot-close-btn:focus {
  outline: 2px solid #0078d4;
  outline-offset: -2px;
}

/* ツールチップ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  transform: none;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 11px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ボディ */
.chatbot-content-body {
  position: relative;
  overflow: hidden;
  flex: 1;
  color: #333;
}

/* 600px未満（スマートフォン） */
@media (max-width: 599px) {
  .chatbot-toggle-content {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 70px;
    max-height: calc(100dvh - 90px);
  }

  .chatbot-floating-btn {
    bottom: 18px;
    right: 72px;
    font-size: 12px;
    padding: 9px 14px;
    gap: 6px;
    height: 40px;
  }

  .chatbot-floating-btn-icon {
    font-size: 18px;
  }

  .chatbot-content-header {
    padding: 12px 16px;
  }
}

/* 600px～768px（小型タブレット・大型スマートフォン） */
@media (min-width: 600px) and (max-width: 768px) {
  .chatbot-toggle-content {
    width: calc(100vw - 40px);
    max-height: calc(100dvh - 100px);
    bottom: 80px;
  }

  .chatbot-floating-btn {
    bottom: var(--back-to-top-bottom, 45px);
    right: 80px;
    font-size: 13px;
    padding: 10px 16px;
    gap: 6px;
    height: 45px;
  }

  .chatbot-floating-btn-icon {
    font-size: 18px;
  }

  .chatbot-content-header {
    padding: 12px 16px;
  }
}

/* タブレット */
@media (min-width: 769px) and (max-width: 1024px) {
  .chatbot-toggle-content {
    width: 460px;
  }

  .chatbot-floating-btn {
    right: 80px;
  }
}

/* デスクトップ大画面 */
@media (min-width: 1025px) and (max-width: 1279px) {
  .chatbot-toggle-content {
    width: 520px;
    max-height: 700px;
  }

  .chatbot-floating-btn {
    right: max(100px, calc((100% - 1200px) / 2 + 10px));
  }
}

@media (min-width: 1280px) {
  .chatbot-toggle-content {
    width: 560px;
  }

  .chatbot-floating-btn {
    right: max(100px, calc((100% - 1200px) / 2 + 60px));
  }
}

/* ボタン非表示クラス（サイトのCSSを確実に上書き） */
.chatbot-floating-btn.chatbot-btn-hidden {
  display: none !important;
}

/* アクセシビリティ：モーション削減設定時 */
@media (prefers-reduced-motion: reduce) {
  .chatbot-floating-btn,
  .chatbot-toggle-content,
  .chatbot-close-btn {
    transition: none;
  }
}

.bubble {
  border: #000e4e 3px solid !important;
}
