/* ===============================================================
   1. Global Settings & Theme Variables
   グローバル設定とテーマ変数（カラーパレットとシャドウ）
   =============================================================== */
:root {
  /* --- 1. ブランドカラー (メインテーマ) --- */
  --theme-primary: #42bead;
  /* 基本のメインカラー */
  --theme-primary-dark: #32998a;
  /* ホバー時などの濃い色 */
  --theme-primary-light: #00848c;
  /* 選択時などのアクセント色 */
  --theme-white: #ffffff;
  /* 白 */
  --theme-black: #212121;
  /* 黒 */

  /* --- 2. 背景色 --- */
  --bg-body: linear-gradient(135deg, #c5dbef 0%, #CEE8D7 100%);
  /* 画面全体の背景色 */
  --bg-chat-container: var(--theme-white);
  /* チャット枠の背景色 */
  --bg-chat-messages: var(--theme-white);
  /* メッセージエリアの背景色 */
  --bg-bot-message: #f2f2f2;
  /* ボット吹き出しの背景色 */
  --bg-user-message: var(--theme-primary);
  /* ユーザー吹き出しの背景色 */

  /* --- 3. ヘッダー設定 --- */
  --header-background: var(--theme-white);
  /* --header-background: 
    linear-gradient(to top right, transparent 50%, rgba(255, 255, 255, 0.15) 50%),
    linear-gradient(120deg, var(--theme-primary) 46%, #71c7d5 100%); */

  /* --- 4. テキスト・リンク色 --- */
  --text-main: #212121;
  /* 基本の文字色 */
  --text-sub: #555555;
  /* 補足などの薄い文字色 */
  --text-inverse: var(--theme-white);
  /* 背景が濃い場合の文字色 (白) */
  --link-color: #007bff;
  --link-hover-color: #0056b3;
  --error-color: #e53935;
  /* エラーメッセージの赤 */

  /* --- 5. UI要素 (ボタン・入力枠など) --- */
  --ui-border-color: #e0e0e0;
  /* 基本の枠線カラー */
  --ui-focus-shadow: rgba(0, 116, 138, 0.2);
  /* 入力欄フォーカス時の影（枠線用） */
  --button-hover-bg: #e5f1f4;
  /* 選択肢ボタンのホバー背景 */
  --disabled-bg: #e0e0e0;
  /* 無効状態の背景色 */
  --disabled-text: #9e9e9e;
  /* 無効状態の文字色 */
  --modal-overlay: rgba(0, 0, 0, 0.6);
  /* モーダルの背景の黒幕 */
  --progress-bar: var(--ui-border-color);
  /* 進行状況バーの色 */
  --progress-bar-container: var(--theme-black);
  /* 進行状況バーの背景色 */

  /* --- 6. カレンダー特有の色 --- */
  --cal-saturday: #64B5F6;
  /* 土曜日の青 */
  --cal-sunday: #E57373;
  /* 日曜日の赤 */

  /* --- 7. シャドウ（影）設定（3階層に集約） --- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.15);
  /* 階層1: 基本の影 (吹き出し, ボタン, バナー, サマリー) */
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
  /* 階層2: 浮いた影 (全体枠, ヘッダー, 入力欄, ホバー時) */
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);
  /* 階層3: 最前面の影 (モーダル, カレンダー, 複数選択窓) */
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: auto;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text-main);
}

body {
  background: var(--bg-body);
  display: flex;
  justify-content: center;
  align-items: center;
  overscroll-behavior-y: contain;
}

/* ===============================================================
   2. Layout Styles
   主要なレイアウト
   =============================================================== */
.chat-container {
  width: 100%;
  max-width: 560px;
  height: 100%;
  background-color: var(--bg-chat-container);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  /* 階層2: 全体枠 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 560px) {
  .chat-container {
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
  }
}

.chat-header {
  background: var(--header-background);
  color: var(--theme-black);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  text-align: center;
  font-size: 1.1em;
  font-weight: 500;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-md);
  /* 階層2: ヘッダー */
}

.chat-header-title {
  margin-bottom: 5px;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: var(--progress-bar);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background-color: var(--progress-bar-container);
  border-radius: 4px;
  transition: width 0.3s ease-in-out;
}

.chat-messages {
  flex-grow: 1;
  padding: 14px 14px 60px;
  overflow-y: auto;
  background-color: var(--bg-chat-messages);
  display: flex;
  flex-direction: column;
  gap: 13px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ===============================================================
   3. Component: Banner
   バナー画像
   =============================================================== */
.chat-banner-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  box-shadow: var(--shadow-sm);
}

.banner-gift-terms-link {
  font-size: 0.6em;
  color: var(--text-sub);
  text-align: right;
  /* 右寄せにする */
  width: 100%;
  padding-right: 2px;
  margin-top: 2px;
}

.banner-gift-terms-link a {
  color: var(--text-sub);
  text-decoration: underline;
  cursor: pointer;
}

.banner-gift-terms-link a:hover {
  color: var(--text-main);
}

/* ===============================================================
   4. Component: Messages
   メッセージフキダシ
   =============================================================== */

/* --- 4a. ラッパー（左右の配置） --- */
.message-wrapper {
  display: flex;
  width: 100%;
  align-items: flex-end;
}

.bot-message-wrapper {
  justify-content: flex-start;
  /* ボットは左寄せ */
}

.user-message-wrapper {
  justify-content: flex-end;
  /* ユーザーは右寄せ */
}

/* --- 4b. アイコン --- */
.bot-icon {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  margin-right: 5px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  background-color: var(--theme-white);
}

/* --- 4c. 吹き出しの共通ベース --- */
.message {
  max-width: 80%;
  /* ★ボットとユーザーで共通化 */
  padding: 10px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}

/* --- 4d. ボット専用の吹き出しデザイン --- */
.bot-message-wrapper .message {
  background-color: var(--bg-bot-message);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  /* 左下のしっぽを尖らせる */
}

.bot-message-wrapper .message.error-text {
  color: var(--error-color);
}

.bot-message-wrapper .message a {
  color: var(--link-color);
  text-decoration: underline;
}

.bot-message-wrapper .message a:hover {
  color: var(--link-hover-color);
}

/* --- 4e. ユーザー専用の吹き出しデザイン --- */
.user-message-wrapper .message {
  background-color: var(--bg-user-message);
  color: var(--text-inverse);
  border-bottom-right-radius: 4px;
  /* 右下のしっぽを尖らせる */
}

.ebook-button-message-content {
  padding: 0 !important;
  background-color: transparent !important;
  box-shadow: none !important;
  width: 100%;
  max-width: 100% !important;
}

.ebook-button-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 15px;
  background-color: var(--theme-primary);
  color: var(--text-inverse) !important;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 500;
  text-align: center;
  text-decoration: none !important;
  cursor: pointer;
  transition: background-color 0.2s;
  box-sizing: border-box;
}

.ebook-button-link:hover {
  background-color: var(--theme-primary-dark);
}

.ebook-button-link svg {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  stroke: var(--text-inverse);
}

/* ===============================================================
   5. Component: Input Area & Elements
   各種入力フォームと要素
   =============================================================== */
.input-container-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 10px;
  box-sizing: border-box;
}

.input-container-wrapper.inputs-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* --- 5a. Choice Buttons (選択肢ボタン) --- */
.choices-container {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.choice-button {
  background-color: var(--theme-white);
  border: 1px solid var(--theme-primary);
  color: var(--theme-black);
  padding: 12px 6px;
  border-radius: 20px;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  font-size: 0.98rem;
  /* 階層1: 通常ボタン */
}

.choice-button:hover:not(:disabled) {
  background-color: var(--button-hover-bg);
  box-shadow: var(--shadow-md);
  /* 階層2: ホバー時少し浮く */
}

.choice-button:disabled {
  background-color: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--ui-border-color);
  cursor: not-allowed;
  box-shadow: none;
}

.multi-choice-check {
  display: none;
  margin-right: 6px;
  font-weight: bold;
  font-size: 1.1em;
}

.multi-choice-label {
  display: inline-block;
}

.choice-button.multi-selected {
  background-color: var(--theme-primary-light);
  color: var(--text-inverse);
  border-color: var(--theme-primary-light);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  /* 階層2: 選択状態 */
}

.choice-button.multi-selected:hover:not(:disabled) {
  background-color: var(--theme-primary-dark);
  border-color: var(--theme-primary-dark);
}

.choice-button.multi-selected .multi-choice-check {
  display: inline;
}

.multi-choice-inner-wrapper {
  background-color: var(--theme-white);
  border-radius: 8px;
  padding: 15px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  /* 階層3: 複数選択のポップアップ */
}

.multi-choice-submit-actions,
.time-table-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--ui-border-color);
}

/* 最終確認画面の送信ボタン */
.final-consent-submit-button {
  background-color: var(--theme-primary);
  color: var(--text-inverse);
  border-color: var(--theme-primary-dark);
  max-width: 480px;
  padding: 12px;
  font-size: 1em;
  box-shadow: var(--shadow-sm);
}

.final-consent-submit-button:hover:not(:disabled),
.final-consent-submit-button:not(:disabled).enabled:hover {
  background-color: var(--theme-primary-dark);
  box-shadow: var(--shadow-md);
}

.final-consent-submit-button:not(:disabled).enabled {
  background-color: var(--theme-primary);
  cursor: pointer;
}

.final-consent-submit-button:disabled {
  background-color: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--ui-border-color);
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

.final-consent-submit-button svg {
  margin-left: 8px;
  stroke: var(--text-inverse);
  width: 16px;
  height: 16px;
}

/* --- 5b. Text Inputs (テキスト入力欄) --- */
.input-area,
.paired-input-container {
  display: flex;
  width: 100%;
  max-width: 480px;
  background-color: var(--theme-white);
  border-radius: 30px;
  box-shadow: var(--shadow-md);
  /* 階層2: 入力枠 */
  padding: 15px;
}

.paired-input-container {
  flex-direction: column;
  gap: 7px;
  border-radius: 16px;
}

.input-area {
  align-items: center;
}

.paired-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.paired-input-row label {
  font-size: 0.9em;
  color: var(--text-sub);
  flex-shrink: 0;
  width: 30px;
  text-align: center;
}

.input-icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  margin: 0 8px 0 5px;
}

.input-icon-container svg {
  stroke: var(--text-sub);
}

.input-area input,
.paired-input-row input {
  flex-grow: 1;
  border: none;
  background-color: transparent;
  outline: none;
  padding: 8px;
  min-width: 0;
  font-size: 1em;
}

.paired-input-row input {
  padding: 10px 15px;
  border: 1px solid var(--ui-border-color);
  border-radius: 15px;
  font-size: 1em;
  background-color: var(--theme-white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.paired-input-row input:hover {
  border-color: #a0a0a0;
}

/* フォーカス時だけは影ではなく枠線(box-shadowを使ったハック)なので --ui-focus-shadow を使用 */
.paired-input-row input:focus {
  border-color: var(--theme-primary) !important;
  box-shadow: 0 0 0 2px var(--ui-focus-shadow) !important;
}

/* --- 5c. 共通: 円形の送信ボタン --- */
.circular-submit-btn {
  padding: 0;
  width: 38px;
  height: 38px;
  background-color: var(--disabled-bg);
  color: var(--theme-white);
  border: none;
  border-radius: 50%;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.circular-submit-btn.enabled {
  background-color: var(--theme-primary) !important;
  cursor: pointer;
}

.circular-submit-btn.enabled:hover {
  background-color: var(--theme-primary-dark) !important;
}

.circular-submit-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--theme-white);
}

.circular-submit-btn.placeholder {
  visibility: hidden;
  background-color: transparent;
}

/* --- 5d. Time Table (タイムテーブル) --- */
.time-table-container {
  background-color: var(--theme-white);
  border-radius: 8px;
  padding: 15px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  /* 階層3: カレンダーのポップアップ */
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.time-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 3px;
}

.time-table-header span {
  font-weight: 500;
  font-size: 1.1em;
  padding-bottom: 3px;
}

.time-table-nav {
  background: none;
  border: 1px solid var(--theme-primary);
  color: var(--theme-primary);
  cursor: pointer;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  transition: background-color 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.time-table-nav:hover:not(:disabled) {
  background-color: var(--theme-primary);
  color: var(--theme-white);
}

.time-table-nav:disabled {
  border-color: var(--disabled-bg);
  color: var(--disabled-bg);
  cursor: not-allowed;
}

.time-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  table-layout: fixed;
}

.time-table th {
  font-weight: normal;
  padding-bottom: 5px;
}

.time-table th span {
  font-size: 0.8em;
  color: var(--text-sub);
}

.time-table th.saturday span,
.time-table th.saturday {
  color: var(--cal-saturday) !important;
}

.time-table th.sunday span,
.time-table th.sunday {
  color: var(--cal-sunday) !important;
}

.time-slot-cell {
  border: 1px solid #eee;
  color: var(--theme-primary);
  padding: 8px 0;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.time-slot-cell.disabled {
  background-color: #f9f9f9;
  color: #ccc;
  cursor: not-allowed;
}

.time-slot-cell.disabled span {
  color: #ddd;
}

.time-slot-cell:not(.selected):not(.disabled):hover {
  background-color: var(--button-hover-bg);
}

.time-slot-cell.selected {
  background-color: var(--theme-primary);
  color: var(--theme-white);
  font-weight: bold;
}

/* ===============================================================
   6. Component: Summary & Consent
   最終確認画面と同意文
   =============================================================== */
.summary-area-wrapper {
  background-color: var(--theme-white);
  border-radius: 20px;
  padding: 15px;
  overflow-y: auto;
  font-size: 0.9em;
  border: 1px solid var(--ui-border-color);
  box-shadow: var(--shadow-sm);
  /* 階層1: サマリー */
}

.summary-area-wrapper h3 {
  font-size: 1em;
  font-weight: 500;
  color: var(--theme-primary);
  margin: 0 0 10px 0;
}

.summary-area-wrapper ul {
  list-style: none;
}

.summary-area-wrapper li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.summary-item-label {
  font-weight: 500;
  color: var(--text-sub);
}

.summary-item-value {
  color: #222;
  word-break: break-all;
}

.summary-adjacent-consent-text {
  font-size: 0.7em;
  color: var(--text-sub);
  text-align: left;
  padding: 0 0 0 48px;
  max-width: calc(100% - 48px);
  word-wrap: break-word;
}

.summary-adjacent-consent-text a {
  color: var(--link-color);
  text-decoration: underline;
}

.summary-adjacent-consent-text a:hover {
  color: var(--link-hover-color);
}

/* ===============================================================
   7. Component: Modal
   モーダルウィンドウ
   =============================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--modal-overlay);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background-color: var(--bg-bot-message);
  padding: 25px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  /* 階層3: モーダル */
}

.modal-close-button {
  position: sticky;
  top: 10px;
  float: right;
  margin: -10px -10px 0 0;
  font-size: 1.8em;
  font-weight: bold;
  cursor: pointer;
  border: none;
  background: none;
  color: #888;
  z-index: 1001;
}

.modal-close-button:hover {
  color: #000;
}

#modalBody h3 {
  font-size: 1.1em;
  text-align: center;
  font-weight: bold;
  margin-bottom: 1em;
}

#modalBody h4 {
  font-size: 1em;
  font-weight: bold;
  margin-top: 1.5em;
  margin-bottom: 0.8em;
  border-left: 4px solid var(--theme-primary);
  padding-left: 8px;
}

#modalBody p,
#modalBody ul {
  font-size: 0.8em;
  line-height: 1.6;
}

#modalBody ul {
  padding-left: 20px;
  list-style-type: disc;
}

#modalBody li {
  margin-bottom: 0.5em;
}

/* --- レイアウト調整用ユーティリティクラス（JSから付与） --- */
.input-container-wrapper.column-layout {
  flex-direction: column;
  align-items: center;
}

/* --- 表示・非表示切り替え用クラス（JSから付与） --- */
.input-error-message.show {
  display: block;
}

.modal-overlay.show {
  display: flex;
}

/* ===============================================================
   8. Animations
   アニメーション（ローディングなど）
   =============================================================== */
.loading-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background-color: currentColor;
  border-radius: 50%;
  margin-left: 2px;
  animation: loadingDots 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0s;
}

@keyframes loadingDots {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1.0);
  }
}

/* --- リアルタイムエラー（ヒント）メッセージ --- */
.input-error-message {
  color: var(--error-color);
  font-size: 0.75em;
  margin-top: 8px;
  padding-left: 15px;
  text-align: left;
  width: 100%;
  max-width: 480px;
  display: none;
  /* 初期状態は非表示 */
  animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}