/* =============================================================================
   MindScreen AI — Stylesheet
   Design direction: calm, editorial-but-human wellbeing chat. Avoids clinical
   coldness (no harsh blues/whites) and avoids AI-default looks (no cream+
   terracotta, no black+neon). Palette is a quiet sage/teal, evoking a
   therapy-room rather than a hospital form.

   Type: Fraunces (serif display, used sparingly for the greeting/headline) +
   Inter (body/UI) + IBM Plex Mono (scores/data, for a "quantified" feel on
   numbers specifically).
============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --bg: #F3F5F1;
  --surface: #FFFFFF;
  --surface-2: #E8ECE6;
  --text: #1F2A24;
  --text-muted: #5B6B60;
  --accent: #3F6C56;
  --accent-strong: #2E5443;
  --accent-soft: #DCE8E0;
  --lavender: #8C7AA9;
  --border: #D7DED4;

  --risk-low: #5FA777;
  --risk-moderate: #D9A441;
  --risk-high: #C0605A;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(31,42,36,0.06), 0 8px 24px rgba(31,42,36,0.06);
}

[data-theme="dark"] {
  --bg: #121A16;
  --surface: #182019;
  --surface-2: #1E2A22;
  --text: #ECF0EB;
  --text-muted: #9AAB9E;
  --accent: #6FB899;
  --accent-strong: #8FCBB0;
  --accent-soft: #223B30;
  --lavender: #B3A3D1;
  --border: #2A362E;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: background 0.3s ease, color 0.3s ease;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

/* ---------------------------------------------------------------- header */
header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

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

.brand-orb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-strong), var(--accent) 70%);
  animation: breathe 6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .brand-orb { animation: none; }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 1; }
}

.brand-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
}

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

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- layout */
main {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 120px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.disclaimer-banner {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.disclaimer-banner strong { color: var(--text); }

/* ---------------------------------------------------------------- auth */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 6px;
}
.auth-card p.subhead { color: var(--text-muted); margin: 0 0 20px; font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--text-muted); }
.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:focus-visible { outline: 2px solid var(--lavender); outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.link-toggle {
  text-align: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.link-toggle button {
  background: none; border: none; color: var(--accent); font-weight: 600;
  cursor: pointer; font-size: 13px; padding: 0;
}

.form-error {
  color: var(--risk-high);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

/* ---------------------------------------------------------------- progress */
.progress-track {
  display: flex;
  gap: 6px;
}
.progress-seg {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-seg .fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s ease;
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- chat */
.chat-window {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble-row { display: flex; }
.bubble-row.bot { justify-content: flex-start; }
.bubble-row.user { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble.bot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.safety {
  background: #fdf1f0;
  border: 1px solid var(--risk-high);
  color: #5c2622;
}
[data-theme="dark"] .bubble.safety {
  background: #2a1a19; color: #f2c9c5;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------------------------------------------------------------- composer */
.composer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 20px 16px 24px;
}
.composer-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.composer-inner input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
}
.composer-inner input:focus-visible { outline: none; }
.composer-inner input::placeholder { color: var(--text-muted); }

.send-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.send-btn:hover { background: var(--accent-strong); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------------------------------------------------------------- results */
.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.results-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  margin: 0 0 4px;
}
.results-card .confidence {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.score-row { margin-bottom: 16px; }
.score-row .score-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.score-row .score-label .value { font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.score-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.score-bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s ease; }

.risk-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-left: 8px;
}
.risk-pill.Low { background: rgba(95,167,119,0.15); color: var(--risk-low); }
.risk-pill.Moderate { background: rgba(217,164,65,0.18); color: var(--risk-moderate); }
.risk-pill.High { background: rgba(192,96,90,0.18); color: var(--risk-high); }

.explanation-list {
  margin: 16px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.next-steps-btn {
  margin-top: 18px;
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-tile .stat-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 24px;
  font-weight: 500;
}
.stat-tile .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

canvas { max-width: 100%; }

/* ---------------------------------------------------------------- misc */
.hidden { display: none !important; }

.top-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.top-nav button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.top-nav button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

@media (max-width: 480px) {
  main { padding: 16px 12px 130px; }
  .auth-card { padding: 20px; }
}
