/* ---------- Design tokens ---------- */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --ink: #0f1e2d;
  --ink-soft: #41566b;
  --ink-mute: #7b8a9a;
  --line: #e3e9f0;
  --brand: #0a7c8a;
  --brand-deep: #065866;
  --brand-soft: #e6f4f6;
  --accent: #3b6cf5;
  --danger: #c0392b;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15,30,45,0.06);
  --shadow-md: 0 6px 20px rgba(15,30,45,0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 0.5rem; color: var(--ink); }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
p  { margin: 0 0 1rem; color: var(--ink-soft); line-height: 1.55; }

/* ---------- Brand ---------- */
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; letter-spacing: -0.01em;
}
.brand-mark {
  color: var(--brand);
  font-size: 1.25rem;
}
.brand-name {
  color: var(--ink);
  font-size: 1.1rem;
}

/* ---------- Auth layout ---------- */
.auth-body {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(1200px 600px at 80% -10%, #e8f6f8 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #eef2ff 0%, transparent 60%),
    var(--bg);
}
.auth-header, .auth-footer {
  padding: 1.25rem 1.5rem;
}
.auth-footer { color: var(--ink-mute); }

.auth-main {
  display: grid; place-items: center;
  padding: 1rem;
}

.auth-main.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
  gap: 3rem;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  align-items: center;
}

.hero { max-width: 560px; }
.hero-art {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
  line-height: 0;
}
.hero-art svg { width: 100%; height: auto; display: block; }
.hero-title {
  font-size: 2rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}
.hero-sub {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  line-height: 1.55;
}
.features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}
.features li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.85rem;
  align-items: start;
}
.features strong { display: block; color: var(--ink); margin-bottom: 0.15rem; }
.features p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.45; }
.feat-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  flex: 0 0 36px;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.lede { color: var(--ink-soft); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1rem; margin-top: 1rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.85rem; color: var(--ink-soft); font-weight: 500; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"] {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10,124,138,0.15);
}
.field.checkbox {
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.hint { color: var(--ink-mute); font-size: 0.8rem; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.04s;
}
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: 0.6; cursor: not-allowed; }

.error-text { color: var(--danger); margin: 0; font-size: 0.9rem; }

.demo-hint {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
  font-size: 0.85rem;
  color: var(--ink-mute);
  display: grid; gap: 0.5rem;
}
.link-btn {
  background: none;
  border: none;
  text-align: left;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

/* ---------- App layout ---------- */
.app-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: #0b1e2b;
  color: #d6e2ec;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 100vh;
}
.sidebar .brand-name { color: #fff; }
.sidebar .brand-mark { color: #63d6e2; }

.side-nav { display: grid; gap: 0.25rem; }
.nav-item {
  display: block;
  background: transparent;
  border: none;
  color: #a6b8c7;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(99,214,226,0.12); color: #fff; }

.patient-card {
  margin-top: auto;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #63d6e2; color: #0b1e2b;
  display: grid; place-items: center;
  font-weight: 700;
}
.pname { font-weight: 600; color: #fff; }
.pmeta { font-size: 0.8rem; color: #93a8b8; }

.signout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: #d6e2ec;
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.signout-btn:hover { background: rgba(255,255,255,0.06); }

/* ---------- Chat main ---------- */
.chat-main {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto;
  padding: 1.5rem 2rem 1rem;
  gap: 1rem;
  max-height: 100vh;
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.chat-header h2 { margin-bottom: 0.15rem; }
.subtle { color: var(--ink-mute); margin: 0; font-size: 0.9rem; }

.clinician-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--brand-soft);
  color: var(--brand-deep);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}
.clinician-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(10,124,138,0.2);
}

/* Snapshot cards */
.snapshot {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}
.snap-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}
.snap-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.snap-card .val { font-weight: 600; color: var(--ink); }
.snap-card .sub { color: var(--ink-soft); font-size: 0.85rem; }

/* Chat scroll area */
.chat {
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  min-height: 300px;
}

.messages { display: grid; gap: 1rem; }

.msg { display: flex; gap: 0.75rem; align-items: flex-start; }
.msg .bubble {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  max-width: 78%;
  line-height: 1.5;
  font-size: 0.97rem;
  white-space: pre-wrap;
}
.msg .bubble p { margin: 0 0 0.75rem; color: inherit; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 0.25rem 0 0.5rem 1.15rem; }
.msg .bubble strong { color: inherit; }

.msg.assistant .bubble {
  background: var(--brand-soft);
  color: #073d46;
  border: 1px solid #cde8ec;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--ink);
  color: #fff;
}

.msg .mini-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 700;
  flex: 0 0 28px;
}
.msg.assistant .mini-avatar { background: var(--brand); color: #fff; }
.msg.user .mini-avatar { background: var(--ink); color: #fff; order: 2; }

.typing {
  display: inline-flex; gap: 3px; align-items: center; padding: 0.25rem 0.1rem;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-deep);
  opacity: 0.4;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 50% { opacity: 1; } }

/* Composer */
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  box-shadow: var(--shadow-sm);
}
.composer textarea {
  resize: none;
  border: none;
  outline: none;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: var(--font);
  max-height: 140px;
  min-height: 42px;
  background: transparent;
  color: var(--ink);
}

.suggestions {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.chip {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { background: var(--brand-soft); border-color: #cde8ec; color: var(--brand-deep); }

.disclaimer {
  color: var(--ink-mute);
  font-size: 0.8rem;
  margin: 0;
  text-align: center;
}

/* ---------- Coming-soon ---------- */
.coming-soon-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  max-width: 560px;
  margin: 3rem auto;
  text-align: center;
}
.coming-soon-card .cs-art {
  width: 160px; margin: 0 auto 1rem;
  line-height: 0;
}
.coming-soon-card .cs-art svg { width: 100%; height: auto; }
.coming-soon-card h1 { margin-bottom: 0.5rem; }
.coming-soon-card .lede { margin-bottom: 1.5rem; }
.coming-soon-card .btn-primary {
  display: inline-block;
  text-decoration: none;
  padding: 0.7rem 1.25rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .auth-main.two-col {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .hero { max-width: 100%; }
}
@media (max-width: 860px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; min-height: auto;
    flex-wrap: wrap; gap: 0.75rem; align-items: center;
  }
  .side-nav { display: none; }
  .patient-card { margin-left: auto; margin-top: 0; }
  .chat-main { padding: 1rem; max-height: none; }
  .snapshot { grid-template-columns: 1fr 1fr; }
  .coming-soon-card { padding: 1.5rem; margin: 1.5rem 1rem; }
}
