/* CLINiQA Demo — Design System */
/* Zero-framework, zero-build, pure CSS */

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --text: #1A1A18;
  --text-2: #6B6B66;
  --text-3: #9C9C96;
  --border: rgba(0,0,0,0.08);
  --border-h: rgba(0,0,0,0.15);

  --blue-50:#E6F1FB; --blue-100:#B5D4F4; --blue-600:#185FA5; --blue-800:#0C447C;
  --teal-50:#E1F5EE; --teal-100:#9FE1CB; --teal-600:#0F6E56; --teal-800:#085041;
  --amber-50:#FAEEDA;--amber-100:#FAC775;--amber-600:#854F0B;--amber-800:#633806;
  --coral-50:#FAECE7;--coral-100:#F5C4B3;--coral-600:#993C1D;--coral-800:#712B13;
  --green-50:#EAF3DE;--green-600:#3B6D11;--green-800:#27500A;
  --red-50:#FCEBEB;  --red-600:#A32D2D;  --red-800:#791F1F;
  --gray-50:#F1EFE8; --gray-100:#D3D1C7;--gray-600:#5F5E5A;

  --r: 8px;
  --r-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

html { font-size: 15px; line-height: 1.6; color: var(--text); font-family: var(--font); background: var(--bg); }
body { min-height: 100vh; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── NAV ── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo {
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.02em;
  margin-right: 2rem;
  color: var(--blue-800);
}
.nav-logo span { color: var(--text-3); font-weight: 400; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--r);
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-link:hover { background: var(--gray-50); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--blue-50); color: var(--blue-800); }

/* ── LAYOUT ── */
.container { max-width: 1120px; margin: 0 auto; padding: 1.5rem; }
.page-title { font-size: 17px; font-weight: 500; margin-bottom: 1.25rem; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-2); margin-bottom: 1.5rem; }
.back-link { font-size: 13px; color: var(--text-3); margin-bottom: 0.75rem; display: inline-block; }
.back-link:hover { color: var(--text); }

/* ── METRIC CARDS ── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.metric-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { font-size: 26px; font-weight: 500; line-height: 1.2; }
.metric-sub { font-size: 12px; color: var(--text-2); }

.metric-value[data-level="excellent"]  { color: var(--green-600); }
.metric-value[data-level="acceptable"] { color: var(--blue-600); }
.metric-value[data-level="concerning"] { color: var(--amber-600); }
.metric-value[data-level="inadequate"] { color: var(--red-600); }

/* dimension colors on metric cards */
.metric-card[data-dim="PA"] { border-left: 3px solid var(--blue-600); }
.metric-card[data-dim="IN"] { border-left: 3px solid var(--teal-600); }
.metric-card[data-dim="PQ"] { border-left: 3px solid var(--amber-600); }
.metric-card[data-dim="CQ"] { border-left: 3px solid var(--coral-600); }
.metric-card[data-dim="GQI"] { border-left: 3px solid var(--gray-600); }

/* ── CARD (generic) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 0.5rem 0.75rem; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; user-select: none; white-space: nowrap; }
th:hover { color: var(--text); }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--gray-50); }
tr { cursor: pointer; transition: background 0.1s; }
.td-score { font-family: var(--mono); font-size: 12px; font-weight: 500; }

/* ── SCORE PILL ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pill--excellent { background: var(--green-50); color: var(--green-800); }
.pill--acceptable { background: var(--blue-50); color: var(--blue-800); }
.pill--concerning { background: var(--amber-50); color: var(--amber-800); }
.pill--inadequate { background: var(--red-50); color: var(--red-800); }

.pill--pa { background: var(--blue-50); color: var(--blue-800); }
.pill--in { background: var(--teal-50); color: var(--teal-800); }
.pill--pq { background: var(--amber-50); color: var(--amber-800); }
.pill--cq { background: var(--coral-50); color: var(--coral-800); }

/* ── TABS ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab {
  padding: 0.5rem 1rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--blue-800); border-bottom-color: var(--blue-600); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── TRANSCRIPT ── */
.transcript { display: flex; flex-direction: column; gap: 6px; max-height: 600px; overflow-y: auto; padding-right: 0.5rem; }
.turn { padding: 0.6rem 0.85rem; border-radius: var(--r); max-width: 85%; position: relative; }
.turn--clinician { background: var(--blue-50); align-self: flex-start; border-left: 3px solid var(--blue-600); }
.turn--patient { background: var(--gray-50); align-self: flex-end; border-right: 3px solid var(--gray-100); }
.turn-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.turn-speaker { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.03em; }
.turn-time { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.turn-question {
  font-size: 10px; font-weight: 500;
  background: var(--blue-600); color: white;
  padding: 1px 6px; border-radius: 4px;
}
.turn-text { font-size: 14px; line-height: 1.5; color: var(--text); }
.turn-flags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.flag { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.flag--good { background: var(--green-50); color: var(--green-800); }
.flag--warning { background: var(--amber-50); color: var(--amber-800); }
.flag--error { background: var(--red-50); color: var(--red-800); }

/* ── TIMELINE HEATMAP ── */
.timeline-strip { display: flex; gap: 4px; padding: 0.5rem 0; overflow-x: auto; flex-wrap: wrap; }
.timeline-group { display: flex; gap: 0; border-radius: 3px; overflow: hidden; }
.timeline-cell {
  min-width: 6px;
  height: 32px;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.1s;
  flex-shrink: 0;
}
.timeline-cell:hover { opacity: 0.7; }
.timeline-cell[data-level="good"] { background: var(--green-600); }
.timeline-cell[data-level="ok"] { background: var(--blue-600); }
.timeline-cell[data-level="warning"] { background: var(--amber-600); }
.timeline-cell[data-level="error"] { background: var(--red-600); }
.timeline-cell[data-speaker="patient"] { background: var(--gray-100); height: 20px; margin-top: 6px; }
.timeline-detail { font-size: 13px; padding: 0.75rem; background: var(--gray-50); border-radius: var(--r); margin-top: 0.5rem; display: none; }
.timeline-detail.visible { display: block; }

/* ── MODULE COMPLETION MATRIX ── */
.matrix { display: grid; gap: 2px; font-size: 11px; }
.matrix-header { font-weight: 500; color: var(--text-3); text-align: center; padding: 4px; }
.matrix-cell { padding: 4px 6px; text-align: center; border-radius: 3px; font-weight: 500; }
.matrix-cell[data-q="good"] { background: var(--green-50); color: var(--green-800); }
.matrix-cell[data-q="ok"] { background: var(--blue-50); color: var(--blue-800); }
.matrix-cell[data-q="warning"] { background: var(--amber-50); color: var(--amber-800); }
.matrix-cell[data-q="error"] { background: var(--red-50); color: var(--red-800); }
.matrix-cell[data-q="na"] { background: var(--gray-50); color: var(--text-3); }
.matrix-module-label { text-align: left; cursor: pointer; padding: 6px 4px; }
.matrix-module-name { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matrix-module-sub { font-size: 10px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── CHART CONTAINERS ── */
.chart-container { position: relative; width: 100%; max-height: 300px; }
.chart-container canvas { width: 100% !important; }
.sankey-container { width: 100%; min-height: 400px; }
.sankey-container svg { width: 100%; }

/* ── FORMS ── */
textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.15s;
}
textarea:focus { outline: none; border-color: var(--blue-600); }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border-h);
  border-radius: var(--r);
  background: var(--surface);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--gray-50); border-color: var(--text-3); }
.btn--primary { background: var(--blue-600); color: white; border-color: var(--blue-600); }
.btn--primary:hover { background: var(--blue-800); }

/* ── TWO-COL LAYOUT ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── LEGEND ── */
.legend { display: flex; gap: 1rem; font-size: 12px; color: var(--text-2); margin-bottom: 0.75rem; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ── LOADING ── */
.loading { text-align: center; padding: 3rem; color: var(--text-3); font-size: 14px; }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 3rem; color: var(--text-3); }
.empty p { font-size: 14px; }

/* ── DEMO WARNING (prominent) ── */
.demo-warning {
  background: #FEF3CD;
  border: 2px solid #D4A017;
  border-radius: var(--r);
  padding: 1rem 1.25rem;
  font-size: 13px;
  color: #6B4A00;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.demo-warning strong { color: #4A3200; }

/* ── DEMO NOTICE ── */
.demo-notice {
  background: var(--amber-50);
  border: 1px solid var(--amber-600);
  border-radius: var(--r);
  padding: 0.75rem 1rem;
  font-size: 13px;
  color: var(--amber-800);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.demo-disabled { opacity: 0.5; pointer-events: none; user-select: none; }

/* ── WELCOME SECTION ── */
.welcome-section { margin-bottom: 1.5rem; }
.welcome-title { font-size: 20px; font-weight: 500; color: var(--text); margin-bottom: 0.25rem; }
.welcome-subtitle { font-size: 14px; color: var(--text-2); }

/* ── SELECT INPUT ── */
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface);
  transition: border-color 0.15s;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--blue-600); }

/* ── DEMO BANNER ── */
.demo-banner {
  background: #1B3A5C;
  color: white;
  font-size: 12px;
  text-align: center;
  padding: 6px 16px;
  position: sticky;
  top: 0;
  z-index: 200;
  line-height: 1.4;
}
.demo-banner strong { font-weight: 500; }
.nav { top: 30px; }

/* ── DEMO FOOTER ── */
.demo-footer {
  background: var(--bg);
  color: var(--text-3);
  font-size: 11px;
  text-align: center;
  padding: 1rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
}

/* ── UPLOAD PAGE ── */
.dropzone {
  border: 2px dashed var(--border-h);
  border-radius: var(--r-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone--active {
  border-color: var(--blue-600);
  background: var(--blue-50);
}
.dropzone-content p { font-size: 14px; color: var(--text-2); margin-top: 0.5rem; }
.dropzone-sub { font-size: 12px; color: var(--text-3); }
.dropzone-icon { font-size: 32px; }

.file-name { font-size: 13px; margin-top: 0.5rem; min-height: 1.2em; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; } }
.form-group label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-group input:focus { outline: none; border-color: var(--blue-600); }

.btn--lg { padding: 0.6rem 1.5rem; font-size: 14px; margin-top: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-area { margin-top: 1.5rem; }
.status-step { font-size: 13px; color: var(--text-2); margin-bottom: 0.5rem; }
.progress-bar { height: 4px; background: var(--gray-50); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue-600); width: 0; transition: width 0.3s ease; border-radius: 2px; }

.result-card { border-left: 3px solid var(--green-600); margin-top: 1.5rem; }
.result-card p { font-size: 14px; color: var(--text-2); }

/* ── SANKEY TOOLTIP ── */
.sankey-tooltip {
  position: absolute;
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  pointer-events: none;
  z-index: 250;
  max-width: 280px;
  line-height: 1.4;
}

/* ── SANKEY LAYOUT ── */
.sankey-layout { display: flex; gap: 12px; margin-top: 0.75rem; }
.sankey-main { flex: 1; min-width: 0; }
.sankey-panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--gray-50);
  border-radius: var(--r);
  padding: 0.75rem;
  font-size: 12px;
  line-height: 1.5;
  max-height: 500px;
  overflow-y: auto;
}
.sankey-panel-label { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.sankey-panel-content { color: var(--text-2); }
.sankey-panel-content strong { color: var(--text); }
@media (max-width: 900px) { .sankey-layout { flex-direction: column; } .sankey-panel { width: 100%; } }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r);
}
.modal-close:hover { background: var(--gray-50); color: var(--text); }
.modal-title { font-size: 15px; font-weight: 500; margin-bottom: 0.75rem; padding-right: 2rem; }

/* ── FEATURES TAB ── */
.features-subtitle { font-size: 13px; color: var(--text-2); margin-bottom: 1.5rem; }
.features-category { font-size: 14px; font-weight: 500; color: var(--text); margin: 1.5rem 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.features-category:first-child { margin-top: 0; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
}
.feature-card.feature--computed { border-left: 3px solid var(--green-600); }
.feature-card.feature--partial { border-left: 3px solid var(--amber-600); }
.feature-card.feature--model { border-left: 3px solid var(--gray-100); opacity: 0.7; }
.feature-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.feature-id { font-size: 11px; font-family: var(--mono); color: var(--text-3); }
.feature-name { font-size: 13px; font-weight: 500; margin-bottom: 0.25rem; }
.feature-value { font-size: 22px; font-weight: 500; color: var(--blue-800); display: block; margin: 0.25rem 0; }
.feature-desc { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.feature-model-note { font-size: 11px; color: var(--text-3); margin-top: 0.5rem; font-style: italic; }
.feature-badge { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.feature-badge--model { background: var(--gray-50); color: var(--gray-600); }
.feature-badge--partial { background: var(--amber-50); color: var(--amber-800); }
