/* ==========================================================================
   Yokoito Chatbot System Styles (Dedicated Page & Floating Widget)
   ========================================================================== */

/* --- Dedicated Chat Layout --- */
.cb-body {
  margin: 0;
  background-color: var(--base);
  color: var(--ink);
  font-family: "Noto Sans JP", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.cb-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.cb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.cb-logo__tag {
  background: var(--orange);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  padding: 3px 6px;
  border-radius: 6px;
  text-align: center;
}

.cb-logo__title {
  font-family: "Space Grotesk", "Noto Sans JP", sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.cb-header__nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cb-header__link {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.cb-header__link:hover {
  opacity: 0.7;
}

/* Main Container */
.cb-main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
}

.cb-chat {
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(39, 35, 31, 0.08);
  display: flex;
  flex-direction: column;
  height: min(780px, calc(100vh - 140px));
  /* 会話ログと選択肢を別々にスクロールさせると選択肢側が場所を取り会話が読めないため、
     枠全体を1つのスクロール領域にして選択肢を会話の流れの中に出す */
  overflow-y: auto;
  scroll-behavior: smooth;
  background: var(--base);
}

.c-embedded-chat {
  height: 640px;
  max-height: min(720px, calc(100vh - 160px));
  margin-top: 16px;
}

/* Chat Header Bar */
.cb-chat__head {
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  /* 枠全体がスクロールするため、「最初から」「閉じる」を常に押せるよう上に固定する */
  position: sticky;
  top: 0;
  z-index: 1;
  flex-shrink: 0;
}

.cb-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--orange);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #ffffff;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(242, 136, 75, 0.3);
}

.cb-chat__brand {
  flex: 1;
}

.cb-chat__title {
  margin: 0;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.cb-chat__sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: #666;
}

.cb-chat__restart {
  background: var(--base);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cb-chat__restart:hover {
  background: #e5e5e5;
}

/* Chat Log Transcript Area */
.cb-log {
  flex: none;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Message Bubbles */
.cb-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  animation: cbFadeUp 0.25s ease-out forwards;
}

@keyframes cbFadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ボットは濃色＋アイコン、利用者は白で、誰の発言かを色で見分けられるようにする */
.cb-msg--bot {
  position: relative;
  align-self: flex-start;
  max-width: calc(85% - 48px);
  margin-left: 48px;
  background: var(--ink);
  color: #ffffff;
  border-top-left-radius: 4px;
}

/* アイコンは装飾なので、読み上げ対象の本文に混ぜないよう CSS で付ける */
.cb-msg--bot::before {
  content: "緯";
  position: absolute;
  top: 0;
  left: -48px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--orange);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  font-style: normal;
}

.cb-msg--user {
  align-self: flex-end;
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-right-radius: 4px;
}

.cb-msg--typing {
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

/* Input recap summary inside chat */
.cb-summary {
  align-self: flex-start;
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 2px dashed var(--orange);
  border-radius: 16px;
  padding: 16px;
  margin: 6px 0;
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}

.cb-summary dt {
  font-weight: 700;
  color: #666666;
  margin: 0;
}

.cb-summary dd {
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  word-break: break-word;
}

/* Controls / Options Container */
/* 選択肢はボットの吹き出しの下に並べ、質問への返答だと分かる位置に置く */
.cb-controls {
  flex: 1 0 auto;
  padding: 0 20px 20px 68px;
}

.cb-controls:empty {
  padding-bottom: 0;
}

/* Option Grid Buttons */
/* LINE のクイックリプライのように、文字幅に合わせたピル型ボタンを横に並べて折り返す。
   縦一列の全幅ボタンより場所を取らず、会話の続きとして読める */
.cb-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cb-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 8px 16px;
  background: #ffffff;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
  box-sizing: border-box;
}

.cb-choice:hover, .cb-choice:focus-visible {
  background: var(--ink);
  color: #ffffff;
  outline: none;
}

/* ピル型では色の丸印が文字の邪魔になるため表示しない（JS側のマークアップは残す） */
.cb-choice .cb-mark {
  display: none;
}

.cb-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cb-mark--main { background: var(--orange); }
.cb-mark--sub { background: var(--blue); }
.cb-mark--dim { background: var(--lime); }
.cb-mark--dots { background: var(--peach); }

.cb-choice__label {
  flex: 1;
}

/* Form Controls in Chat */
.cb-input {
  display: flex;
  gap: 8px;
}

.cb-input__field {
  flex: 1;
  /* 入力欄の既定の最小幅でスマホ幅だと送信ボタンが押し出されるため、縮められるようにする */
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 14px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.cb-input__field:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 136, 75, 0.2);
}

.cb-input__send {
  background: var(--orange);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 0 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.cb-input__send:hover {
  background: #e07436;
}

/* 複数選択はピルの塗りで選択状態を示し、✓は選んだときだけ出す（未選択の空の四角はピルの中で窮屈なため） */
.cb-choice__check {
  display: none;
  font-size: 12px;
  font-weight: 800;
}

.cb-choice.is-selected {
  background: var(--orange);
  border-color: var(--orange);
  color: #ffffff;
}

.cb-choice.is-selected .cb-choice__check {
  display: inline;
}

.cb-btn-next {
  margin-top: 8px;
  width: 100%;
  padding: 12px;
  background: var(--orange);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  box-shadow: 0 4px 12px rgba(242, 136, 75, 0.25);
}

.cb-btn-next:hover {
  background: #e07436;
  transform: translateY(-1px);
}

.cb-btn-next:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Contact Form Step Z */
.cb-form-contact {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cb-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cb-form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cb-badge--req {
  background: #e74c3c;
  color: #ffffff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.cb-badge--opt {
  background: #95a5a6;
  color: #ffffff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.cb-form-hint {
  font-size: 11px;
  color: #666666;
  margin-top: 2px;
}

.cb-form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  box-sizing: border-box;
  background: #ffffff;
  color: var(--ink);
}

.cb-form-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 136, 75, 0.2);
  outline: none;
}

.cb-form-submit {
  margin-top: 6px;
  width: 100%;
  padding: 14px;
  background: var(--orange);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 4px 14px rgba(242, 136, 75, 0.3);
}

.cb-form-submit:hover {
  background: #e07436;
  transform: translateY(-1px);
}

/* Thanks Actions Step CV */
.cb-thanks-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.cb-thanks-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.cb-thanks-card:hover {
  border-color: var(--orange);
  box-shadow: 0 4px 12px rgba(242, 136, 75, 0.15);
  transform: translateY(-1px);
}

.cb-thanks-card--primary {
  background: var(--orange);
  color: #ffffff;
  border-color: var(--orange);
}

.cb-thanks-card--primary:hover {
  background: #e07436;
  color: #ffffff;
}

.cb-input__skip {
  display: block;
  margin-top: 8px;
  width: 100%;
  background: transparent;
  border: none;
  color: #666666;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  text-align: center;
}

/* Dedicated Footer */
.cb-footer {
  padding: 20px;
  text-align: center;
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.cb-footer__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.cb-footer__list a {
  color: #666666;
  font-size: 12px;
  text-decoration: none;
}

.cb-footer__list a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Floating Widget Modal Layout (Embedded on index.html etc.)
   ========================================================================== */

.cb-widget-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 36px;
  padding: 8px 18px 8px 8px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(39, 35, 31, 0.3);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cb-widget-launcher:hover {
  transform: scale(1.04);
}

.cb-widget-launcher__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #ffffff;
}

.cb-widget-launcher__text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cb-widget-launcher__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

/* Popup Container */
.cb-widget-modal {
  position: fixed;
  bottom: 84px;
  right: 24px;
  z-index: 1000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  /* .cb-chat と同じく枠全体を1つのスクロール領域にする */
  overflow-y: auto;
  scroll-behavior: smooth;
  background: var(--base);
  animation: cbPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cb-widget-modal.is-active {
  display: flex;
}

@keyframes cbPopIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cb-widget-modal__close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #666;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}

.cb-widget-modal__close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

@media (max-width: 600px) {
  .cb-widget-modal {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 80px;
    height: 520px;
  }
  
  .cb-msg {
    max-width: 90%;
    font-size: 13px;
  }

  .cb-choice {
    font-size: 13px;
    padding: 7px 14px;
  }

  /* iOS Safari は 16px 未満の入力欄にフォーカスすると画面を拡大してしまうため */
  .cb-input__field {
    font-size: 16px;
  }
}
