/* ===================================================================
   AIRA — AI Insurance Advisor
   Premium dark fintech/insurer theme.
   =================================================================== */

:root {
  --bg: #0a0d12;
  --bg-elevated: #0f131a;
  --card: #141922;
  --card-alt: #171d27;
  --border: #232b38;
  --border-soft: #1b212c;
  --text: #eef1f6;
  --text-dim: #9aa5b4;
  --text-faint: #6b7686;
  --accent: #3b82f6;
  --accent-strong: #5b9bff;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --amber: #f0b429;
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* the page itself never scrolls - panels scroll internally */
}

body {
  background-image: radial-gradient(circle at 15% 0%, rgba(59, 130, 246, 0.06), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(34, 197, 94, 0.04), transparent 40%);
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===================== TOP BAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(10, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  letter-spacing: 0.5px;
}

.brand-title { font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }
.brand-subtitle { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

.chip-button {
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chip-button:hover { border-color: var(--accent); background: var(--accent-soft); }

.chip-secure { color: var(--text-dim); }
.lock { font-size: 12px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-offline { background: var(--text-faint); }
.dot-connecting { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: pulse 1.2s infinite; }
.dot-online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-error { background: var(--red); box-shadow: 0 0 8px var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ===================== MAIN LAYOUT ===================== */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 20px;
  padding: 20px 28px 28px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  min-height: 0; /* let the grid track shrink to the remaining viewport space */
  overflow: hidden;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ===================== CONVERSATION PANEL ===================== */
.conversation-panel { padding: 20px; gap: 16px; min-height: 0; }

.agent-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.agent-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: box-shadow 0.2s ease;
}
.agent-avatar.speaking { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18); }
.agent-avatar.listening { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15); }

.agent-meta { flex: 1; min-width: 0; }
.agent-name { font-weight: 600; font-size: 14.5px; }
.agent-status { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  opacity: 0.35;
}
.waveform span {
  width: 3px;
  height: 6px;
  background: var(--accent-strong);
  border-radius: 2px;
  transition: height 0.1s ease;
}
.waveform.active { opacity: 1; }
.waveform.active span { animation: wave 1s ease-in-out infinite; }
.waveform span:nth-child(1) { animation-delay: 0s; }
.waveform span:nth-child(2) { animation-delay: 0.1s; }
.waveform span:nth-child(3) { animation-delay: 0.2s; }
.waveform span:nth-child(4) { animation-delay: 0.3s; }
.waveform span:nth-child(5) { animation-delay: 0.15s; }
.waveform span:nth-child(6) { animation-delay: 0.25s; }
.waveform span:nth-child(7) { animation-delay: 0.05s; }

@keyframes wave {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}

.transcript {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  min-height: 0; /* required so this flex child scrolls instead of growing the panel */
}

.transcript-empty {
  margin: auto 0;
  text-align: center;
  color: var(--text-dim);
  padding: 24px 8px;
}
.transcript-empty p { font-size: 13.5px; margin-bottom: 18px; }

.suggested-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  margin: 0 auto;
}
.suggested-prompt {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.suggested-prompt:hover { border-color: var(--accent); background: var(--accent-soft); }

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.8px;
  line-height: 1.5;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  border-bottom-right-radius: 4px;
}
.bubble-assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble-meta { font-size: 10.5px; opacity: 0.65; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ===================== CONTROLS ===================== */
.controls { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border-soft); padding-top: 16px; }

.mic-row { display: flex; align-items: center; gap: 14px; }

.mic-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.mic-button:not(:disabled):hover { border-color: var(--accent); color: var(--accent-strong); }
.mic-button.active {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  border-color: transparent;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15);
}
.mic-button.muted { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.mic-button:disabled { opacity: 0.4; cursor: not-allowed; }

.mic-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }

.btn {
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:not(:disabled):hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:not(:disabled):hover { border-color: var(--accent); }
.btn-secondary { background: var(--card-alt); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); }

.text-form { display: flex; gap: 8px; }
.text-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.text-input:focus { border-color: var(--accent); }

/* ===================== QUOTE PANEL ===================== */
/* No scrollbar on this side: the fixed-size sections (header/info/breakdown/
   premium/disclaimer) are sized compactly to always fit, and the policy
   cards section below absorbs any remaining space and clips rather than
   scrolling if there simply isn't room for every card. */
.quote-panel { padding: 16px 18px; gap: 12px; overflow: hidden; display: flex; flex-direction: column; }

.quote-empty {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
}
.quote-empty-icon { font-size: 34px; margin-bottom: 10px; opacity: 0.6; }
.quote-empty p { font-size: 14px; max-width: 320px; margin: 0 auto; }

.quote-content { display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; overflow: hidden; }

.quote-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.quote-header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.quote-plan-name { font-weight: 600; font-size: 14px; }

.badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 4px 9px;
  border-radius: 999px;
}
.badge-demo { background: var(--amber); color: #221a02; }

.quote-sum-insured { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
.quote-sum-label { color: var(--text-dim); font-size: 12px; margin-top: 3px; margin-bottom: 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.info-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.info-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.info-value { font-size: 13.5px; font-weight: 600; }

.divider { height: 1px; background: var(--border-soft); }

.breakdown { display: flex; flex-direction: column; gap: 7px; }
.breakdown-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.breakdown-base { font-weight: 600; padding-bottom: 5px; border-bottom: 1px solid var(--border-soft); }
.breakdown-adjustments { display: flex; flex-direction: column; gap: 6px; }
.adj-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); }
.adj-label { display: flex; align-items: center; gap: 7px; }
.adj-mark { width: 15px; text-align: center; font-size: 12px; flex-shrink: 0; }
.adj-mark.discount { color: var(--green); }
.adj-mark.loading { color: var(--amber); }
.adj-percent.discount { color: var(--green); }
.adj-percent.loading { color: var(--amber); }

.premium-highlight {
  background: linear-gradient(160deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.03));
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
}
.premium-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.premium-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); }
.premium-monthly { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.premium-subject {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--amber);
  background: rgba(240, 180, 41, 0.1);
  border: 1px solid rgba(240, 180, 41, 0.3);
  padding: 3px 10px;
  border-radius: 999px;
}

.term-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
}
.term-total span:last-child { font-weight: 700; font-size: 14px; }

.disclaimer {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.4;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}

.policy-section {
  margin-top: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.policy-section-title { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.policy-cards { flex: 1; min-height: 0; overflow: hidden; display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: min-content; gap: 10px; align-content: start; }
.policy-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; animation: fadeIn 0.2s ease; overflow: hidden; }
.policy-card-placeholder { grid-column: 1 / -1; color: var(--text-dim); }
.policy-card-title { font-weight: 600; font-size: 12.5px; margin-bottom: 5px; }
.policy-card-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.policy-card-source { font-size: 10.5px; color: var(--text-faint); margin-top: 6px; }

/* ===================== DEBUG DRAWER ===================== */
.debug-drawer {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  max-height: 46vh;
  background: #0c0f14;
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
  z-index: 50;
  overflow-y: auto;
  padding: 16px 28px 22px;
}
.debug-header { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text-dim); }
.debug-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.debug-item { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.debug-item span { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.debug-item b { font-size: 12.5px; font-weight: 600; word-break: break-word; }
.debug-json-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.debug-json-block { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.debug-json-title { font-size: 11px; color: var(--text-faint); text-transform: uppercase; margin-bottom: 6px; }
.debug-json-block pre { margin: 0; font-size: 11px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow-y: auto; }

/* ===================== TOASTS ===================== */
.toast-stack {
  position: fixed;
  top: 78px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.toast {
  background: var(--card);
  border: 1px solid var(--red);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 12.5px;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.15s ease;
}
.toast-warn { border-color: var(--amber); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .policy-cards { grid-template-columns: 1fr; }
  .debug-grid { grid-template-columns: repeat(2, 1fr); }
  .debug-json-row { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .brand-subtitle { display: none; }
  .main { padding: 14px 14px 20px; }
  .quote-sum-insured { font-size: 22px; }
  .premium-value { font-size: 24px; }
}
