/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text-primary: #1a1d23;
  --text-secondary: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --success: #10b981;
  --error: #ef4444;
  --message-user: #2563eb;
  --message-bot: #f3f4f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

#app { height: 100%; position: relative; }

/* ── Screens ─────────────────────────────────────────────────────────── */
.screen {
  display: none;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.screen.active { display: flex; }

/* ── Loading ─────────────────────────────────────────────────────────── */
#loading { flex-direction: column; gap: 16px; }
#loading p { color: var(--text-secondary); font-size: 14px; }

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────────────────────── */
.error-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.error-card h2 { color: var(--error); margin-bottom: 12px; font-size: 20px; }
.error-card p { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.error-hint { margin-top: 16px; font-size: 13px !important; }

/* ── Welcome ──────────────────────────────────────────────────────────── */
.welcome-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.logo {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: white;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto 24px;
}

.welcome-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.3;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: var(--font);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.disclaimer {
  font-size: 12px !important;
  color: var(--text-secondary) !important;
  margin-top: 16px;
  margin-bottom: 0 !important;
}

/* ── Chat ─────────────────────────────────────────────────────────────── */
#chat {
  flex-direction: column;
  padding: 0;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-sm {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.header-title {
  font-weight: 600;
  font-size: 15px;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 28px;
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.message-user {
  background: var(--message-user);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-bot {
  background: var(--message-bot);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  padding: 8px 16px;
  display: flex;
  gap: 4px;
  align-self: flex-start;
}
.typing-indicator.hidden { display: none; }
.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.4; transform: scale(1); } 30% { opacity: 1; transform: scale(1.2); } }

/* Input */
.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--font);
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s;
}
#message-input:focus { border-color: var(--accent); }
#message-input::placeholder { color: var(--text-secondary); }

.btn-send {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Complete ─────────────────────────────────────────────────────────── */
.complete-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.checkmark {
  width: 64px;
  height: 64px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 20px;
}

.complete-card h2 { font-size: 24px; margin-bottom: 12px; }
.complete-card p { color: var(--text-secondary); font-size: 15px; line-height: 1.5; }
.next-steps { margin-top: 20px; background: var(--accent-light); padding: 16px; border-radius: var(--radius-sm); }
.next-steps strong { color: var(--text-primary); }

/* ── Mobile adjustments ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .welcome-card { padding: 32px 20px; }
  .welcome-card h1 { font-size: 20px; }
  .message { max-width: 90%; }
  .progress-bar { width: 60px; }
}

/* ── Safe area for iOS ───────────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .input-container { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
