/* Static ChatBot */

.tcb-chatbot-root {
  --tcb-brand: #4abaa4;
  --tcb-brand-dark: #3ea693;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}

/* FAB button */
/*
 * チャット配下の全要素にルートのフォント（Noto Sans JP）を継承させる。
 * - <button> 等は既定でフォントを継承しない
 * - front-page.css のリセットが p / span / button 等へ font-family: sans-serif を
 *   直接指定しており、継承だけだと上書きされてしまう
 */
.tcb-chatbot-root * {
  font-family: inherit;
}

.tcb-chatbot__fab {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background-color: var(--tcb-brand);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
}

.tcb-chatbot__fab:hover {
  transform: scale(1.06);
}

.tcb-chatbot__fab:focus,
.tcb-chatbot__fab:focus-visible {
  outline: none;
}

.tcb-chatbot__fab-icon {
  display: block;
}

/* 初期表示の吹き出しアイコンは大きめに見せる */
.tcb-chatbot__fab-icon--chat {
  width: 32px;
  height: 32px;
}

/* アイコンはチャット開閉状態でクロス/吹き出しを切り替える */
.tcb-chatbot__fab-icon--close {
  display: none;
  width: 28px;
  height: 28px;
}

.tcb-chatbot-root.tcb-chatbot--open .tcb-chatbot__fab-icon--chat {
  display: none;
}

.tcb-chatbot-root.tcb-chatbot--open .tcb-chatbot__fab-icon--close {
  display: block;
}

/* Chat window */
.tcb-chatbot {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 352px;
  max-width: calc(100vw - 32px);
  height: min(504px, calc(100vh - 120px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s ease;
}

.tcb-chatbot-root.tcb-chatbot--open .tcb-chatbot {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.tcb-chatbot__header {
  background: var(--tcb-brand);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.tcb-chatbot__avatar {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
  padding: 3px;
}

.tcb-chatbot__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tcb-chatbot__headtext {
  flex: 1;
  min-width: 0;
}

.tcb-chatbot__title {
  display: block;
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
}

/* ヘッダーの自動bot注記 */
.tcb-chatbot__status {
  margin-top: 2px;
  color: #fff;
  font-size: 11px;
  line-height: 1.3;
  opacity: 0.85;
}

.tcb-chatbot__close {
  flex: none;
  background: none;
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.tcb-chatbot__close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tcb-chatbot__close:focus,
.tcb-chatbot__close:focus-visible {
  outline: none;
}

.tcb-chatbot__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px;
  background: #f9fafb;
  /* 新しい吹き出しの先頭へスクロールする際の位置基準 */
  position: relative;
}

/* Bubble */
.tcb-chatbot__bubble {
  background: #f3f4f6;
  color: #1f2937;
  border-radius: 16px 16px 16px 4px;
  padding: 12px 14px;
  margin-bottom: 12px;
  max-width: 86%;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: tcb-pop 0.25s ease;
}

.tcb-chatbot__bubble--user {
  background: var(--tcb-brand);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  max-width: 82%;
  margin-left: auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 文字色はテーマ側の p / span 指定に負けないよう要素に直接指定する（継承に頼らない） */
.tcb-chatbot__bubble .tcb-chatbot__message {
  margin: 0;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-line;
}

.tcb-chatbot__bubble--user .tcb-chatbot__message {
  color: #fff;
  line-height: 1.6;
}

.tcb-chatbot__image {
  display: block;
  width: 100%;
  margin-top: 10px;
  border-radius: 10px;
}

.tcb-chatbot__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding: 10px 13px;
  background: #fff;
  border: 1px solid var(--tcb-brand);
  color: var(--tcb-brand-dark);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tcb-chatbot__link:hover {
  background: var(--tcb-brand);
  color: #fff;
}

.tcb-chatbot__link-text {
  color: inherit;
  /* テーマのリセット（line-height:1）で折り返し時に行が重なるのを防ぐ */
  line-height: 1.45;
  word-break: break-all;
}

.tcb-chatbot__link-icon {
  flex: none;
}

/* Option buttons */
.tcb-chatbot__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
  margin-bottom: 12px;
}

.tcb-chatbot__option {
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--tcb-brand);
  color: var(--tcb-brand-dark);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tcb-chatbot__option:hover {
  background: var(--tcb-brand);
  color: #fff;
}

.tcb-chatbot__option:focus,
.tcb-chatbot__option:focus-visible {
  outline: none;
}

/* Typing indicator (くるくる) */
.tcb-chatbot__typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 16px;
  background: #f3f4f6;
  border-radius: 16px 16px 16px 4px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tcb-chatbot__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: tcb-typing-bln 1.2s infinite;
}

.tcb-chatbot__typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.tcb-chatbot__typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes tcb-typing-bln {
  0%, 60%, 100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@keyframes tcb-pop {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Teaser label (FAB 横の誘導ラベル) */
.tcb-chatbot__teaser {
  position: absolute;
  right: 72px;
  bottom: 4px;
  width: 264px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tcb-chatbot-root.tcb-chatbot--teaser-open .tcb-chatbot__teaser {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* チャットウィンドウを開いている間はラベルを隠す */
.tcb-chatbot-root.tcb-chatbot--open .tcb-chatbot__teaser {
  display: none;
}

.tcb-chatbot__teaser-close {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #4a4a4a;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* 吹き出しホバー時のみ閉じるボタンを表示 */
.tcb-chatbot__teaser:hover .tcb-chatbot__teaser-close,
.tcb-chatbot__teaser-close:focus-visible {
  opacity: 1;
  visibility: visible;
}

.tcb-chatbot__teaser-close:focus,
.tcb-chatbot__teaser-close:focus-visible {
  outline: none;
}

.tcb-chatbot__teaser-body {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 13px 15px;
  cursor: pointer;
}

.tcb-chatbot__teaser-body:focus,
.tcb-chatbot__teaser-body:focus-visible {
  outline: none;
}

.tcb-chatbot__teaser-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.4;
}

.tcb-chatbot__teaser-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
  white-space: nowrap;
}

/* Mobile */
@media (max-width: 480px) {
  .tcb-chatbot-root {
    right: 16px;
    bottom: 16px;
  }
  .tcb-chatbot {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    right: 0;
    bottom: 72px;
  }
  /* SP はひと回り小さく表示 */
  .tcb-chatbot__teaser {
    width: 226px;
    right: 64px;
  }
  .tcb-chatbot__teaser-body {
    padding: 10px 12px;
  }
  .tcb-chatbot__teaser-title {
    font-size: 12px;
  }
  .tcb-chatbot__teaser-sub {
    font-size: 10px;
  }
  /* SP はホバーがないため閉じるボタンを常時表示 */
  .tcb-chatbot__teaser-close {
    opacity: 1;
    visibility: visible;
  }
}
