/* ===================================
   CSS Variables - ブランドカラー
=================================== */
:root {
  --primary: #6B5B95;
  --primary-dark: #5A4A84;
  --primary-light: #8677A9;
  --accent: #2DD4BF;
  --accent-dark: #14B8A6;
  --accent-light: #5EEAD4;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --bg-primary: #F8FAFA;
  --bg-secondary: #FFFFFF;
  --bg-chat: #F0F9F8;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.2s ease;
}

/* ===================================
   リセット・基本スタイル
=================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #E0F2F1 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===================================
   レイアウト
=================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  padding: 16px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

/* ===================================
   ヘッダー・進捗表示
=================================== */
.header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
}

.logo-image {
  height: 36px;
  width: auto;
}

.btn-exit {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  background-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
  transition: var(--transition);
}

.btn-exit:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-exit-icon {
  font-size: 14px;
  font-weight: 600;
}

.progress-view {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.9;
}

.progress-percent-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-light);
}

.progress-bar {
  height: 8px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-step {
  display: block;
  font-size: 11px;
  opacity: 0.7;
  text-align: right;
}

/* ===================================
   チャットエリア
=================================== */
.chat-view {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-color: #E8F5F3;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(45, 212, 191, 0.08) 0%, transparent 50px),
    radial-gradient(circle at 80% 20%, rgba(45, 212, 191, 0.06) 0%, transparent 80px),
    radial-gradient(circle at 40% 70%, rgba(45, 212, 191, 0.1) 0%, transparent 60px),
    radial-gradient(circle at 90% 80%, rgba(45, 212, 191, 0.07) 0%, transparent 40px),
    radial-gradient(circle at 10% 90%, rgba(45, 212, 191, 0.05) 0%, transparent 70px),
    radial-gradient(circle at 60% 50%, rgba(107, 91, 149, 0.04) 0%, transparent 90px);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* メッセージ共通 */
.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
  animation: messageIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

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

/* Botメッセージ（左側） */
.message-bot {
  align-self: flex-start;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  padding-left: 48px;
}

.message-bot::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  width: 32px;
  height: 32px;
  background-image: url('assets/bot-avatar.png');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

/* Userメッセージ（右側） */
.message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-md);
}

/* 注意書きメッセージ */
.message-note {
  align-self: flex-start;
  background-color: #FEF3C7;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding-left: 48px;
}

.message-note::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  width: 32px;
  height: 32px;
  background-image: url('assets/bot-avatar.png');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

/* ===================================
   入力エリア
=================================== */
.input-area {
  padding: 16px 20px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.input-form {
  margin-bottom: 12px;
}

/* テキスト入力 */
.input-text {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
  background-color: var(--bg-primary);
}

.input-text:focus {
  border-color: var(--accent);
  background-color: var(--bg-secondary);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.1);
}

.input-text::placeholder {
  color: var(--text-light);
}

/* 複数フィールド（姓名など） */
.input-double {
  display: flex;
  gap: 12px;
}

.input-double .input-group {
  flex: 1;
}

.input-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* 住所入力 */
.input-address {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-address .input-row {
  display: flex;
  gap: 12px;
}

.input-address .input-group {
  flex: 1;
}

.input-address .input-group.postal {
  flex: 0 0 140px;
}

/* 選択肢ボタン */
.input-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-btn {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  background-color: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-xl);
  color: var(--accent-dark);
  cursor: pointer;
  transition: var(--transition);
}

.option-btn:hover {
  background-color: rgba(45, 212, 191, 0.1);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.option-btn.selected {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border-color: var(--accent-dark);
  box-shadow: var(--shadow-md);
}

/* 複数選択時のチェックマーク */
.option-btn.multi.selected::before {
  content: "✓ ";
}

/* アクションボタン */
.input-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon {
  font-size: 16px;
}

.btn-back {
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  border: 2px solid var(--border);
}

.btn-back:hover:not(:disabled) {
  background-color: var(--border);
  color: var(--text-primary);
}

.btn-back:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-send {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-send:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-send:active {
  transform: translateY(0);
}

/* エラー表示 */
.input-error {
  color: var(--error);
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-error::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background-color: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
}

/* ===================================
   確認画面
=================================== */
.confirm-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  background-color: var(--bg-secondary);
}

.confirm-header {
  text-align: center;
  margin-bottom: 24px;
}

.confirm-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.confirm-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.confirm-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.confirm-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.confirm-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.confirm-item-content {
  flex: 1;
}

.confirm-item-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.confirm-item-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.confirm-item-edit {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  background-color: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent-dark);
  cursor: pointer;
  transition: var(--transition);
}

.confirm-item-edit:hover {
  background-color: var(--accent);
  color: #fff;
}

.confirm-actions {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn-submit {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-submit-icon {
  margin-right: 4px;
}

/* ===================================
   完了画面
=================================== */
.done-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.done-content {
  text-align: center;
  max-width: 320px;
}

.done-illustration {
  width: 180px;
  height: auto;
  margin-bottom: 24px;
  animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.05);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.done-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--success);
}

.done-message {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.8;
}

.done-note {
  font-size: 12px;
  color: var(--text-light);
  padding: 12px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-sm);
}

/* ===================================
   離脱画面
=================================== */
.exit-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  overflow-y: auto;
}

.exit-content {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.exit-illustration {
  width: 140px;
  height: auto;
  margin-bottom: 20px;
}

.exit-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--warning);
}

.exit-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.exit-stats {
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
  border: 1px solid var(--border);
}

.exit-stat-section {
  margin-bottom: 16px;
}

.exit-stat-section:last-child {
  margin-bottom: 0;
}

.exit-stat-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

.exit-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.exit-stat-row:last-child {
  border-bottom: none;
}

.exit-stat-label {
  color: var(--text-secondary);
}

.exit-stat-value {
  color: var(--text-primary);
  font-weight: 600;
}

.exit-stat-value.highlight {
  color: var(--error);
}

.exit-stat-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.exit-stat-list li {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-primary);
}

.exit-stat-list li.completed {
  color: var(--success);
}

.exit-stat-list li.completed::before {
  content: "✓ ";
  font-weight: 700;
}

.exit-stat-list li.current {
  color: var(--warning);
  font-weight: 600;
}

.exit-stat-list li.current::before {
  content: "▶ ";
}

.exit-stat-list li.pending {
  color: var(--text-light);
}

.exit-stat-list li.pending::before {
  content: "○ ";
}

.exit-actions {
  text-align: center;
}

.btn-resume {
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-resume:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ===================================
   デバッグパネル
=================================== */
.debug-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
}

.debug-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  background-color: var(--text-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.debug-toggle:hover {
  background-color: #374151;
  transform: translateY(-2px);
}

.debug-icon {
  font-size: 14px;
}

.debug-content {
  position: absolute;
  bottom: 48px;
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background-color: #1F2937;
  color: #E5E7EB;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
}

.debug-title {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  background-color: #111827;
  color: #fff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

#debug-json {
  padding: 16px;
  font-size: 11px;
  font-family: "Monaco", "Consolas", "Fira Code", monospace;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* ===================================
   ユーティリティ
=================================== */
.hidden {
  display: none !important;
}

/* ===================================
   スクロールバー
=================================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--text-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-secondary);
}

/* ===================================
   レスポンシブ（PC）
=================================== */
@media (min-width: 992px) {
  .app-container {
    padding: 24px;
  }

  .main-area {
    min-height: calc(100vh - 48px);
    max-width: 480px;
  }

  .debug-panel {
    top: 24px;
    right: 24px;
    bottom: auto;
  }

  .debug-content {
    position: static;
    margin-top: 12px;
  }
}

/* ===================================
   レスポンシブ（SP）
=================================== */
@media (max-width: 480px) {
  .app-container {
    padding: 0;
  }

  .main-area {
    border-radius: 0;
    max-width: 100%;
  }

  .header {
    padding: 12px 16px;
  }

  .logo-image {
    height: 28px;
  }

  .btn-exit-text {
    display: none;
  }

  .progress-view {
    padding: 10px 12px;
  }

  .chat-view {
    padding: 16px;
  }

  .message {
    max-width: 90%;
    font-size: 13px;
  }

  .message-bot,
  .message-note {
    padding-left: 44px;
  }

  .message-bot::before,
  .message-note::before {
    width: 28px;
    height: 28px;
  }

  .input-area {
    padding: 12px 16px;
  }

  .input-double {
    flex-direction: column;
  }

  .input-address .input-row {
    flex-direction: column;
  }

  .input-address .input-group.postal {
    flex: 1;
  }

  .option-btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  .btn {
    padding: 12px 20px;
    font-size: 13px;
  }

  .debug-content {
    width: 280px;
    max-height: 320px;
  }

  .done-illustration {
    width: 140px;
  }

  .exit-illustration {
    width: 100px;
  }
}
