/* ===== Michigan Blue Branding - Light/Dark/System ===== */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary-50: #e9eff5;
  --primary-100: #c7d7e7;
  --primary-200: #9dbad4;
  --primary-300: #729cc1;
  --primary-400: #4a7fae;
  --primary-500: #2f65a7;
  --primary-600: #004785;
  --primary-700: #00274c;
  --border: var(--primary-100);
  --primary: var(--primary-600);
  --primary-2: var(--primary-700);
  --accent: var(--primary-500);
  --success: #0f9d70;
  --warn: #b45309;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --shadow: 0 4px 12px rgba(17, 24, 39, 0.06);
  --brand-bg: #f8fbff;
}
[data-theme="dark"] {
  --bg: #081321;
  --surface: #0f2138;
  --surface-2: #132944;
  --text: #e4edf9;
  --muted: #9fb2cd;
  --line: #2c4667;
  --primary-50: #173452;
  --primary-100: #235078;
  --primary-200: #3570a2;
  --primary-300: #4b88bd;
  --primary-400: #66a6de;
  --primary-500: #78b8ea;
  --primary-600: #8fc7f4;
  --primary-700: #dbeeff;
  --border: #2b4f74;
  --primary: var(--primary-600);
  --primary-2: var(--primary-700);
  --accent: #5f9ed6;
  --shadow: 0 8px 20px rgba(2, 10, 21, 0.45);
  --brand-bg: #0f2b45;
  --teal: #2dd4bf;
  --teal-light: #0d3d38;
}
* { box-sizing: border-box; margin: 0; }
html { height: 100%; }
body {
  height: 100%;
  overflow: hidden;
  font-family: "Manrope", "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 10%, rgba(199, 215, 231, 0.34) 0, transparent 40%),
    radial-gradient(circle at 95% 0, rgba(74, 127, 174, 0.16) 0, transparent 38%),
    var(--bg);
  transition: background 0.2s, color 0.2s;
}
[data-theme="dark"] body {
  background:
    radial-gradient(circle at 10% 8%, rgba(47, 101, 167, 0.35) 0, transparent 45%),
    radial-gradient(circle at 96% 0, rgba(13, 43, 76, 0.64) 0, transparent 42%),
    var(--bg);
}

/* ===== Full-viewport shell ===== */
.page-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
}
.tb-left { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.tb-logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.tb-brand { display: flex; flex-direction: column; min-width: 0; }
.tb-title { font-size: 1rem; font-weight: 800; color: var(--primary-2); line-height: 1.15; white-space: nowrap; }
.tb-desc { font-size: 0.75rem; color: var(--muted); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-center { display: flex; gap: 0.4rem; }
.tb-right { display: flex; align-items: center; gap: 0.5rem; }
.tb-michigan { width: 32px; height: 32px; object-fit: contain; }

.page-tab-btn {
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.35rem 0.85rem; background: var(--surface-2);
  color: var(--muted); cursor: pointer; font-weight: 600;
  font-size: 0.85rem; transition: all 0.15s;
}
.page-tab-btn:hover { border-color: var(--primary-300); color: var(--primary-2); }
.page-tab-btn.active {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: #fff; border-color: var(--primary);
}
.theme-toggle {
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  height: 32px; padding: 0 0.6rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-weight: 650; cursor: pointer; font-size: 0.8rem;
}
.theme-toggle:hover { border-color: var(--primary-300); }
.theme-toggle-icon { width: 1rem; text-align: center; }

/* ===== Page Panels ===== */
.page-panel { display: none; flex: 1; min-height: 0; overflow: hidden; flex-direction: column; }
.page-panel.active { display: flex; }
.about-scroll { overflow-y: auto; padding: 1rem 1.5rem; }

/* ===== Demo Page ===== */
#demoPage { padding: 0.5rem 0.75rem; gap: 0.4rem; }

/* ===== Controls Row ===== */
.controls-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.65rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; flex-shrink: 0;
}
.step-dots { display: flex; align-items: center; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
  border: 2px solid var(--line); cursor: pointer; transition: all 0.2s;
}
.step-dot.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-dot.completed { background: var(--teal); color: #fff; border-color: var(--teal); }
.step-connector { width: 32px; height: 2px; background: var(--line); }
.step-connector.done { background: var(--teal); }
.phase-label { font-weight: 700; color: var(--primary-2); font-size: 0.9rem; flex: 1; text-align: center; }
.autoplay-wrap { display: flex; align-items: center; gap: 0.4rem; }
.autoplay-label { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }
.autoplay-label input { width: auto; cursor: pointer; }
.delay-select {
  font-size: 0.8rem; padding: 0.15rem 0.3rem; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}

/* ===== Commentary ===== */
.commentary-row {
  padding: 0.35rem 0.65rem;
  background: var(--primary-50); border: 1px solid var(--primary-200);
  border-radius: 8px; flex-shrink: 0;
  font-size: 0.88rem; line-height: 1.4;
  display: flex; align-items: baseline; gap: 0.5rem;
}
.commentary-row strong { color: var(--primary-2); white-space: nowrap; }
.commentary-sep { color: var(--primary-300); }
.commentary-row span:last-child { color: var(--muted); }

/* ===== Buttons ===== */
.btn {
  border: 0; border-radius: 8px; padding: 0.4rem 0.8rem;
  font-weight: 650; cursor: pointer; transition: all 0.12s; font-size: 0.85rem;
}
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.btn-xs { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
.btn-primary { background: linear-gradient(90deg, var(--primary), var(--accent)); color: #fff; }
.btn-primary:hover { box-shadow: 0 4px 10px rgba(0, 71, 133, 0.2); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-outline { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-outline.status-active { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.btn-outline.btn-warn { border-color: var(--warn); color: var(--warn); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Phase Panels ===== */
.phase-panel { display: none; }
.phase-panel.active { display: flex; }
.phase-content { flex: 1; min-height: 0; flex-direction: column; gap: 0.35rem; overflow: hidden; }

/* ===== Phase 1: Intake ===== */
.intake-tabs-row { display: flex; gap: 0.35rem; flex-wrap: wrap; flex-shrink: 0; }
.intake-tab {
  padding: 0.3rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.82rem; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: all 0.12s;
}
.intake-tab.active-itab { background: var(--primary); color: #fff; border-color: var(--primary); }
.intake-progress { height: 4px; background: var(--line); border-radius: 4px; flex-shrink: 0; }
.intake-progress-fill { height: 100%; background: var(--teal); border-radius: 4px; transition: width 0.3s; }
.intake-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.intake-card { max-width: 720px; margin: 0 auto; padding: 0.5rem 0; }
.intake-card h3 {
  margin: 0 0 0.5rem; font-size: 1rem;
  border-bottom: 1px solid var(--line); padding-bottom: 0.35rem;
}
.intake-content.hidden { display: none; }
.intake-actions { text-align: center; flex-shrink: 0; padding: 0.35rem 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.form-grid-single { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
label { display: grid; gap: 0.2rem; color: var(--muted); font-size: 0.85rem; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.4rem 0.5rem; font: inherit; font-size: 0.9rem;
  color: var(--text); background: var(--surface);
}
input:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-100); }
input[disabled], textarea[disabled] { background: var(--surface-2); color: var(--muted); }

/* ===== Phase 2: Questions ===== */
.questions-layout { display: flex; gap: 0.65rem; flex: 1; min-height: 0; overflow: hidden; }
.sidebar-summary {
  width: 200px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.55rem; overflow-y: auto;
}
.sidebar-section {
  font-size: 0.72rem; font-weight: 700; color: var(--primary);
  margin-top: 0.5rem; margin-bottom: 0.15rem; letter-spacing: 0.04em;
}
.sf-row { display: flex; justify-content: space-between; padding: 0.12rem 0; border-bottom: 1px solid var(--surface-2); }
.sf-label { color: var(--muted); font-size: 0.8rem; }
.sf-value { font-weight: 600; font-size: 0.8rem; }
.questions-main { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 0.3rem; }
.questions-top-row { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; }
.q-logo { width: 24px; height: 24px; object-fit: contain; }
.muted-text { color: var(--muted); font-size: 0.85rem; }

/* Mini stepper */
.stepper-mini { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; font-size: 0.78rem; }
.sm-dot { color: var(--muted); padding: 0.12rem 0.35rem; border-radius: 4px; }
.sm-dot.sm-active { color: var(--primary); font-weight: 700; background: var(--primary-50); }
.sm-dot.sm-done { color: var(--teal); }
.sm-line { width: 24px; height: 2px; background: var(--line); }
.sm-line.sm-line-done { background: var(--teal); }

.question-progress {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--muted); flex-shrink: 0;
}
.q-progress-bar { flex: 1; height: 5px; background: var(--line); border-radius: 3px; }
.q-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.question-area {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem; flex: 1; min-height: 0; overflow-y: auto;
}
.q-message { border-radius: 8px; padding: 0.5rem 0.65rem; font-size: 0.9rem; line-height: 1.45; }
.q-message.assistant { background: var(--primary-50); border: 1px solid var(--primary-200); }
.q-message .q-meta { font-size: 0.78rem; color: var(--muted); display: block; margin-bottom: 0.2rem; }
.q-message .q-bold { font-weight: 700; }
.q-form-shell {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.55rem; margin-top: 0.4rem;
}
.q-form-title { font-weight: 700; font-size: 0.88rem; }
.q-form-help { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }
.q-form-required { color: #dc2626; }
.q-check-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0; font-size: 0.88rem; }
.q-check-row input[type="checkbox"], .q-check-row input[type="radio"] { width: auto; }
.q-btn-grid { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.25rem; }
.q-option-btn {
  padding: 0.35rem 0.75rem; border: 1px solid var(--primary-200); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.88rem;
  transition: all 0.12s;
}
.q-option-btn:hover { background: var(--primary-50); border-color: var(--primary); }
.q-option-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.q-slider-row { display: flex; align-items: center; gap: 0.5rem; }
.q-slider-row input[type="range"] { flex: 1; }
.q-slider-row span { font-size: 0.82rem; }
.chat-input-row { display: flex; gap: 0.35rem; flex-shrink: 0; }
.chat-input-row input { flex: 1; font-size: 0.88rem; padding: 0.35rem 0.5rem; }

/* ===== Phase 3 & 4: Three-Panel ===== */
.report-top-row, .clinician-top-row {
  display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap;
}
.clinician-status-btns { display: flex; gap: 0.3rem; margin-left: auto; }
.three-panel { display: grid; grid-template-columns: 1fr 1fr 320px; gap: 0.5rem; flex: 1; min-height: 0; }
.panel-card {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.5rem; box-shadow: var(--shadow);
}
.panel-card h3 { margin: 0 0 0.3rem; font-size: 0.95rem; flex-shrink: 0; }
.panel-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.5rem; font-size: 0.88rem; line-height: 1.5;
}
.chat-panel { display: flex; flex-direction: column; }
.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.4rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.chat-msg { padding: 0.35rem 0.5rem; border-radius: 6px; font-size: 0.85rem; line-height: 1.4; }
.chat-msg.system { background: var(--surface-2); color: var(--muted); font-style: italic; border: 1px solid var(--line); }
.clinician-action-btns { display: flex; flex-wrap: wrap; gap: 0.25rem; flex-shrink: 0; padding: 0.25rem 0; }
.action-btn { font-size: 0.78rem; }

/* Panel tabs */
.panel-tabs { display: flex; gap: 0.25rem; flex-shrink: 0; margin-bottom: 0.3rem; }
.panel-tab {
  padding: 0.28rem 0.6rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); font-size: 0.82rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.panel-tab.active-ptab { background: var(--primary); color: #fff; border-color: var(--primary); }
.ptab-content.hidden { display: none; }

/* Timeline */
.timeline-block { border-left: 3px solid var(--teal); padding: 0.4rem 0 0.4rem 0.7rem; margin-bottom: 0.5rem; }
.timeline-block h4 { margin: 0; font-size: 0.92rem; color: var(--primary-2); }
.timeline-block .tl-date { font-size: 0.78rem; color: var(--muted); }
.timeline-block ul { margin: 0.2rem 0 0; padding-left: 1rem; }
.timeline-block li { font-size: 0.88rem; line-height: 1.4; margin-bottom: 0.1rem; }
.tl-highlight { background: var(--teal-light); padding: 0.08rem 0.25rem; border-radius: 3px; }

/* Report */
.report-section { margin-bottom: 0.5rem; }
.report-section h4 { margin: 0 0 0.2rem; font-size: 0.92rem; color: var(--primary-2); }
.report-section p { margin: 0.1rem 0; font-size: 0.88rem; }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 0.25rem; }
.report-table th, .report-table td { border: 1px solid var(--line); padding: 0.3rem 0.4rem; text-align: left; }
.report-table th { background: var(--primary-50); color: var(--primary-2); font-size: 0.8rem; }
.modality-ip { color: var(--warn); font-weight: 600; }
.modality-tele { color: var(--primary); font-weight: 600; }
.modality-us { color: #7c3aed; font-weight: 600; }
[data-theme="dark"] .modality-us { color: #a78bfa; }

/* Summary */
.summary-field { margin-bottom: 0.3rem; font-size: 0.88rem; }
.summary-field strong { color: var(--primary-2); }

/* Selected text */
.selected-text-indicator {
  background: var(--teal-light); border: 1px solid var(--teal);
  border-radius: 6px; padding: 0.3rem 0.45rem; font-size: 0.82rem;
}
.selected-text-indicator .sti-label { color: var(--teal); font-weight: 600; font-size: 0.78rem; }

/* PDF viewer */
.pdf-viewer { background: #525659; border-radius: 6px; padding: 0.4rem; }
[data-theme="dark"] .pdf-viewer { background: #1e293b; }
.pdf-toolbar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.4rem;
  background: #3f4245; border-radius: 4px; margin-bottom: 0.35rem;
  font-size: 0.8rem; color: #ccc;
}
[data-theme="dark"] .pdf-toolbar { background: #0f172a; }
.pdf-page {
  background: #fff; color: #111827; padding: 0.65rem; border-radius: 4px;
  font-size: 0.88rem; line-height: 1.5; overflow-y: auto;
}
[data-theme="dark"] .pdf-page { background: #f8fafc; color: #111827; }

/* ===== About Page ===== */
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; max-width: 1100px; margin: 0 auto; }
.about-card h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.about-card p { margin: 0; color: var(--text); line-height: 1.55; font-size: 0.95rem; }
.about-card p + p { margin-top: 0.6rem; }
.about-wide { grid-column: 1 / -1; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 1rem;
}
.team-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.team-member {
  margin: 0; padding: 0.6rem;
  border: 1px solid var(--primary-100); border-radius: 10px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--brand-bg) 100%);
  display: grid; justify-items: center; text-align: center;
}
.team-photo {
  width: 72px; height: 72px; border-radius: 999px; object-fit: cover;
  border: 2px solid var(--primary-200);
}
.team-name { display: block; margin-top: 0.35rem; font-size: 0.9rem; font-weight: 650; color: var(--primary-2); }
.team-role { display: block; margin-top: 0.2rem; font-size: 0.8rem; line-height: 1.3; color: var(--muted); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .three-panel { grid-template-columns: 1fr; }
  .questions-layout { flex-direction: column; }
  .sidebar-summary { width: 100%; }
  .about-grid { grid-template-columns: 1fr; }
  /* Allow page scroll on narrow screens since panels stack */
  html, body { overflow: auto; }
  .page-shell { height: auto; min-height: 100vh; }
  .phase-content { overflow: auto; }
}
@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .top-bar { flex-wrap: wrap; }
  .tb-desc { display: none; }
}
