/* IT Scoping Recorder — two-panel desktop layout.
   Design tokens, base resets, recorder controls, transcript panel,
   questionnaire panel, saved sessions, and settings dialog. */

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:         #0f1115;
  --surface:    #181b22;
  --surface-2:  #1e222b;
  --fg:         #e7eaf0;
  --muted:      #8b93a3;
  --accent:     #4f7cff;
  --success:    #36d399;
  --warn:       #f59e0b;
  --danger:     #ff4f5e;
  --border:     #262b34;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
}

h1 { font-size: 1.1rem; margin: 0; }
h2 { font-size: 0.9rem; margin: 0; color: var(--muted); }

/* ── App shell ──────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Two-panel layout ───────────────────────────────────────────────────── */
.panels {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
  gap: 18px;
}

.panel-left  { border-right: 1px solid var(--border); }
.panel-right { background: var(--surface); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost   { background: transparent; border-color: transparent; }
.btn-sm      { padding: 7px 13px; font-size: 0.82rem; }
.btn-xs      { padding: 4px 9px;  font-size: 0.78rem; }
.btn-icon    { padding: 6px 10px; font-size: 1rem; }

/* ── Source row ─────────────────────────────────────────────────────────── */
.source-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select {
  flex: 1;
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

/* ── Source setup note (shown for system audio mode) ────────────────────── */
.source-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  background: rgba(79,124,255,0.06);
  border: 1px solid rgba(79,124,255,0.2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.source-note a { color: var(--accent); }

/* ── Level meter ────────────────────────────────────────────────────────── */
.meter {
  height: 6px;
  background: #0c0e12;
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: transform 60ms linear;
}

/* ── Timer + status ─────────────────────────────────────────────────────── */
.timer {
  text-align: center;
  font-size: 2.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
}
.status {
  text-align: center;
  color: var(--muted);
  min-height: 1.2em;
  font-size: 0.82rem;
}
body.recording .status { color: var(--danger); }

/* ── Controls ───────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ── Save card (shown after recording stops, before S3 upload) ───────────── */
.save-card {
  background: var(--surface-2);
  border: 1px solid rgba(79,124,255,0.35);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.save-card h2       { font-size: 0.88rem; color: var(--fg); }
.save-card-row      { display: flex; flex-direction: column; gap: 4px; }
.save-card-meta     { margin: 0; line-height: 1.4; }
.save-card-actions  { display: flex; gap: 8px; margin-top: 2px; }

audio { width: 100%; }

/* ── Transcript section ─────────────────────────────────────────────────── */
.transcript-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.transcript-actions { display: flex; gap: 6px; }

.transcript-box {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  background: #0c0e12;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.6;
  word-break: break-word;
}

/* Default transcript colour — overridden by speaker-N when diarization is active. */
.transcript-final { color: var(--fg); }

/* Speaker colour palette (cycles mod 5 for 5+ speakers). */
.speaker-0 { color: #60a5fa; }   /* blue   */
.speaker-1 { color: #34d399; }   /* green  */
.speaker-2 { color: #fbbf24; }   /* amber  */
.speaker-3 { color: #a78bfa; }   /* purple */
.speaker-4 { color: #f472b6; }   /* pink   */

/* Interim text lives inline at the end of the transcript box. */
.transcript-interim {
  color: var(--muted);
  font-style: italic;
}

/* ── Saved sessions ─────────────────────────────────────────────────────── */
.saved h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.count {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
}
.empty   { color: var(--muted); font-size: 0.82rem; margin: 0; }
.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.saved-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.saved-meta { display: flex; flex-direction: column; gap: 2px; }
.saved-name { font-weight: 600; word-break: break-all; font-size: 0.85rem; }
.saved-sub  { color: var(--muted); font-size: 0.76rem; }
.saved-actions { display: flex; gap: 6px; }

/* ── Right panel: questionnaire ─────────────────────────────────────────── */
.panel-right-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.panel-right-header h2 { font-size: 1rem; color: var(--fg); }

.questionnaire-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Unanswered summary */
.q-unanswered {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.q-unanswered-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.85rem;
}
.q-warn-icon { font-size: 0.95rem; }
.q-badge {
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}
.q-badge--warn { background: var(--warn);    color: #000; }
.q-badge--ok   { background: var(--success); color: #000; }

.q-unanswered-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.q-unanswered-item {
  font-size: 0.8rem;
  color: var(--warn);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.q-unanswered-item:hover { background: rgba(245,158,11,0.12); }

/* Field rows */
.q-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.q-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.q-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.q-label-row label {
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

/* Status dot */
.q-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s;
}
.q-dot--empty   { background: var(--danger); }
.q-dot--partial { background: var(--warn); }
.q-dot--filled  { background: var(--success); }

/* Inputs */
.q-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  padding: 8px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}
.q-input:focus {
  outline: none;
  border-color: var(--accent);
}
.q-field[data-status="filled"]  .q-input { border-color: rgba(54,211,153,0.4); }
.q-field[data-status="partial"] .q-input { border-color: rgba(245,158,11,0.4); }

/* AI suggestion bar */
.q-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(79,124,255,0.08);
  border: 1px solid rgba(79,124,255,0.25);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.q-suggestion-text {
  flex: 1;
  color: #a5b4fc;
  font-style: italic;
  min-width: 0;
}
.q-accept  { border-color: rgba(54,211,153,0.4);  color: var(--success); }
.q-dismiss { border-color: var(--border); color: var(--muted); }

/* Empty state */
.q-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 32px 16px;
  margin: 0;
}


/* ── Utilities ──────────────────────────────────────────────────────────── */
.muted    { color: var(--muted); }
.muted-sm { color: var(--muted); font-size: 0.78rem; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
