/* ========================================
   遺留分計算シミュレーター - チャットボットUI
   ======================================== */

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

:root {
  --navy: #1a365d;
  --navy-light: #2d4a7a;
  --gold: #b8860b;
  --gold-light: #d4a017;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f0f1f3;
  --gray-200: #e2e4e8;
  --gray-400: #9ca3af;
  --gray-600: #6b7280;
  --gray-800: #374151;
  --red: #dc2626;
  --red-light: #fef2f2;
  --green: #16a34a;
  --green-light: #f0fdf4;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  background: var(--white);
  box-shadow: 0 0 20px rgba(0,0,0,0.08);
  min-height: 0;
}

/* ── ヘッダー ── */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--navy);
  color: var(--white);
}

.header-icon {
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-sub {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}

/* ── チャットコンテナ ── */
.chat-container {
  flex: 1;
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* ── 吹き出し共通 ── */
.msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: fadeSlideIn 0.35s ease-out;
}

.msg.bot {
  align-self: flex-start;
}

.msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.msg.bot .msg-avatar {
  background: var(--navy);
  color: var(--white);
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.8;
  position: relative;
}

.msg.bot .msg-bubble {
  background: var(--gray-100);
  color: var(--gray-800);
  border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
  background: var(--navy);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

/* ── タイピングインジケーター ── */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 20px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--gray-400);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* ── 選択肢ボタン ── */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  animation: fadeSlideIn 0.35s ease-out;
}

.choice-btn {
  padding: 16px 28px;
  border: 2px solid var(--navy);
  border-radius: 28px;
  background: var(--white);
  color: var(--navy);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 52px;
}

.choice-btn:hover {
  background: var(--navy);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,54,93,0.3);
}

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

.choice-btn.selected {
  background: var(--navy);
  color: var(--white);
  pointer-events: none;
  opacity: 0.7;
}

.choices.disabled .choice-btn {
  pointer-events: none;
  opacity: 0.5;
}

/* ── 金額入力エリア ── */
.input-area {
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.amount-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeSlideIn 0.3s ease-out;
}

.amount-input-group input {
  flex: 1;
  padding: 16px 18px;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  font-size: 22px;
  font-weight: 600;
  text-align: right;
  outline: none;
  transition: border-color 0.2s;
  min-height: 56px;
}

.amount-input-group input:focus {
  border-color: var(--navy);
}

.amount-input-group .unit {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
}

.amount-input-group .send-btn {
  padding: 16px 24px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 56px;
}

.amount-input-group .send-btn:hover {
  background: var(--navy-light);
}

.amount-input-group .send-btn:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
}

/* ── 数量ボタン ── */
.number-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.number-btn {
  width: 56px;
  height: 44px;
  border: 2px solid var(--navy);
  border-radius: 12px;
  background: var(--white);
  color: var(--navy);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.number-btn:hover {
  background: var(--navy);
  color: var(--white);
}

/* ── 結果カード ── */
.result-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-radius: 16px;
  padding: 32px 24px;
  color: var(--white);
  text-align: center;
  margin: 16px 0;
  animation: fadeSlideIn 0.5s ease-out;
}

.result-card .label {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.result-card .amount {
  font-size: 36px;
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 4px;
}

.result-card .amount .unit-text {
  font-size: 18px;
  font-weight: 600;
}

.result-card .note {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 8px;
}

/* 権利なしカード */
.result-card.no-right {
  background: linear-gradient(135deg, var(--gray-600) 0%, var(--gray-800) 100%);
}

.result-card.no-right .amount {
  font-size: 20px;
  color: var(--white);
}

/* ── 時効警告 ── */
.warning-card {
  background: var(--red-light);
  border: 2px solid var(--red);
  border-radius: 12px;
  padding: 20px;
  margin: 16px 0;
  animation: fadeSlideIn 0.5s ease-out 0.2s both;
}

.warning-card .warning-title {
  color: var(--red);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}

.warning-card .warning-text {
  font-size: 15px;
  color: var(--gray-800);
  line-height: 1.7;
}

.warning-card .warning-text strong {
  color: var(--red);
}

/* ── CTAボタン ── */
.cta-btn {
  display: block;
  width: 100%;
  padding: 20px;
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 14px;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 24px;
  margin-bottom: 32px;
  transition: all 0.2s;
  text-align: center;
  min-height: 60px;
  animation: fadeSlideIn 0.5s ease-out 0.4s both;
}

.cta-btn:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(184,134,11,0.4);
}

/* ── お問い合わせフォーム ── */
.contact-form {
  background: var(--gray-50);
  border-radius: 16px;
  padding: 24px 20px;
  margin: 8px 0;
  animation: fadeSlideIn 0.4s ease-out;
}

.contact-form h3 {
  font-size: 15px;
  color: var(--navy);
  margin-bottom: 16px;
  text-align: center;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-group label .required {
  color: var(--red);
  font-size: 12px;
  margin-left: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 17px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  min-height: 52px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--navy);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.submit-btn {
  display: block;
  width: 100%;
  padding: 18px;
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
  min-height: 60px;
}

.submit-btn:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
}

.submit-btn:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  transform: none;
}

/* ── 送信完了 ── */
.complete-card {
  text-align: center;
  padding: 32px 24px;
  animation: fadeSlideIn 0.5s ease-out;
}

.complete-card .check-icon {
  width: 64px;
  height: 64px;
  background: var(--green-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.complete-card .check-icon svg {
  width: 32px;
  height: 32px;
  color: var(--green);
}

.complete-card h3 {
  font-size: 18px;
  color: var(--navy);
  margin-bottom: 8px;
}

.complete-card p {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.7;
}

/* ── フッター ── */
.app-footer {
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  padding: 12px 16px;
  text-align: center;
}

.app-footer p {
  font-size: 10px;
  color: var(--gray-400);
  line-height: 1.5;
}

/* ── アニメーション ── */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── レスポンシブ ── */
@media (max-width: 520px) {
  #app {
    box-shadow: none;
  }

  .result-card .amount {
    font-size: 28px;
  }
}
