/* ---------------------------------------------------------------------
   Preekanalyse HHG Ouddorp — dashboard
   Tokens: kille "kerkboek"-neutraal (papier/inkt) + gedoofd boekband-blauw
   als accent. Semantische kleuren (bevestigd/onzeker/artefact/wachtrij)
   staan los van de accent en dragen betekenis, geen decoratie.
   --------------------------------------------------------------------- */

:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #e6e9ee;
  --surface-3: #dde1e8;
  --border: #d2d7e0;
  --border-strong: #b7bdc9;
  --text: #1a1e2a;
  --text-muted: #5b6172;
  --text-faint: #8890a0;

  --accent: #2d4a7c;
  --accent-hover: #1f3a63;
  --accent-soft: #e3e9f6;
  --accent-soft-border: #c3d1e8;

  --ok: #2b7a4f;
  --ok-soft: #e0f0e6;
  --warn: #93600a;
  --warn-soft: #f7ead0;
  --danger: #a52f2b;
  --danger-soft: #f8e2e0;
  --artifact: #6a5f96;
  --artifact-soft: #eae7f5;
  --queue: #6d7383;
  --queue-soft: #e6e8ed;

  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-s: 5px;
  --radius-m: 9px;
  --shadow-card: 0 1px 2px rgba(20, 24, 38, 0.06), 0 1px 1px rgba(20, 24, 38, 0.04);
  --shadow-pop: 0 8px 24px rgba(20, 24, 38, 0.16), 0 2px 6px rgba(20, 24, 38, 0.08);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161d;
    --surface: #1c1f29;
    --surface-2: #242835;
    --surface-3: #2c3140;
    --border: #363c4c;
    --border-strong: #454c5f;
    --text: #e7e9f0;
    --text-muted: #a1a7b8;
    --text-faint: #767c8c;

    --accent: #8caae0;
    --accent-hover: #a9c1ea;
    --accent-soft: #233047;
    --accent-soft-border: #33456b;

    --ok: #6dbb8f;
    --ok-soft: #1c3226;
    --warn: #e0ab52;
    --warn-soft: #3a2c13;
    --danger: #e28c86;
    --danger-soft: #3c211f;
    --artifact: #b3a8e0;
    --artifact-soft: #2a2740;
    --queue: #9298a8;
    --queue-soft: #262a35;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14161d;
  --surface: #1c1f29;
  --surface-2: #242835;
  --surface-3: #2c3140;
  --border: #363c4c;
  --border-strong: #454c5f;
  --text: #e7e9f0;
  --text-muted: #a1a7b8;
  --text-faint: #767c8c;

  --accent: #8caae0;
  --accent-hover: #a9c1ea;
  --accent-soft: #233047;
  --accent-soft-border: #33456b;

  --ok: #6dbb8f;
  --ok-soft: #1c3226;
  --warn: #e0ab52;
  --warn-soft: #3a2c13;
  --danger: #e28c86;
  --danger-soft: #3c211f;
  --artifact: #b3a8e0;
  --artifact-soft: #2a2740;
  --queue: #9298a8;
  --queue-soft: #262a35;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}
.brand-mark { font-size: 1.35rem; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; }
.brand-text span { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 0.02em; }
.topbar-spacer { flex: 1; }

.banner {
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.82rem;
  padding: 0.45rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

main#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* ---------- shared: pills / chips ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.22em 0.65em;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.5;
}
.pill-dot {
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-ok      { background: var(--ok-soft);      color: var(--ok); }
.pill-warn    { background: var(--warn-soft);    color: var(--warn); }
.pill-danger  { background: var(--danger-soft);  color: var(--danger); }
.pill-artifact{ background: var(--artifact-soft);color: var(--artifact); }
.pill-queue   { background: var(--queue-soft);   color: var(--queue); }
.pill-accent  { background: var(--accent-soft);  color: var(--accent); }

.pill-running .pill-dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .pill-running .pill-dot { animation: none; }
}

/* ---------- overview: toolbar + table ---------- */

.view-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.view-header h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}
.view-header .count {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

table.services {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

table.services thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

table.services th.sortable {
  cursor: pointer;
  user-select: none;
}
table.services th.sortable:hover { color: var(--text); }
table.services th .sort-arrow {
  display: inline-block;
  margin-left: 0.3em;
  opacity: 0.5;
  font-size: 0.9em;
}
table.services th[aria-sort="ascending"] .sort-arrow,
table.services th[aria-sort="descending"] .sort-arrow { opacity: 1; color: var(--accent); }

table.services tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 120ms ease;
}
table.services tbody tr:last-child { border-bottom: none; }
table.services tbody tr:hover { background: var(--accent-soft); }
table.services tbody tr:focus-visible { background: var(--accent-soft); }

table.services td {
  padding: 0.65rem 0.9rem;
  vertical-align: middle;
}

.col-date { white-space: nowrap; }
.col-date .date-main { font-weight: 600; }
.col-date .date-time {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85em;
  margin-left: 0.5em;
}

.col-title .title-main {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text);
}
.col-title .title-sub { color: var(--text-muted); font-size: 0.82rem; }

.badge-type {
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 0.1em 0.5em;
  white-space: nowrap;
}

.col-errors { text-align: right; font-family: var(--font-mono); }
.errors-count {
  font-weight: 700;
  font-size: 1rem;
}
.errors-count.zero { color: var(--text-faint); font-weight: 400; }
.errors-count.some { color: var(--danger); }

/* rows for services not yet (fully) processed: recognizable but quiet */
tr.row-unprocessed .title-main { color: var(--text-muted); font-weight: 500; }
tr.row-unprocessed .col-errors { color: var(--text-faint); }
tr.row-unprocessed td { color: var(--text-faint); }
tr.row-unprocessed .badge-type { opacity: 0.75; }

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* ---------- inspectie: layout ---------- */

.service-header {
  margin-bottom: 1rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 0.6rem;
}
.back-link:hover { color: var(--accent); }

.service-header h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  text-wrap: balance;
}
.service-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.service-meta strong { color: var(--text); font-weight: 600; }

/* audio bar */

.audio-bar {
  position: sticky;
  top: 57px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 0.85rem 1rem;
  margin: 1rem 0 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}
.audio-bar audio { flex: 1 1 320px; min-width: 240px; height: 38px; }
.audio-bar .now-playing {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1 1 240px;
  min-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-bar .now-playing .t { color: var(--accent); font-weight: 600; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.toggle input { display: none; }
.toggle .switch {
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background-color 120ms ease;
  flex: none;
}
.toggle .switch::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform 120ms ease;
}
.toggle input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(15px); background: #fff; }

/* main grid */

.inspect-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .inspect-grid { grid-template-columns: 1fr; }
}

.transcript-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 1.5rem 1.75rem;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.75;
  max-width: 74ch;
}

.transcript-empty {
  font-family: var(--font-sans);
  color: var(--text-muted);
  padding: 2rem 0;
}

.segment {
  display: block;
  padding: 0.15rem 0.4rem 0.15rem 0;
  border-radius: 4px;
  scroll-margin-block: 96px;
}
.segment + .segment { margin-top: 0.05rem; }

.segment .tc {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  user-select: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0.5em 0 0;
  vertical-align: super;
}
.segment .tc:hover { color: var(--accent); }

.segment.segment-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.segment.segment-flash {
  animation: flash-in 900ms ease;
}
@keyframes flash-in {
  0% { background: var(--accent-soft-border); }
  100% { background: var(--accent-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .segment.segment-flash { animation: none; }
}

mark.finding-mark {
  background: transparent;
  color: inherit;
  border-radius: 3px;
  padding: 0.02em 0.1em;
  cursor: pointer;
  text-decoration: none;
}
mark.finding-mark.status-confirmed {
  background: var(--danger-soft);
  box-shadow: inset 0 -2px 0 var(--danger);
}
mark.finding-mark.status-inconclusive {
  background: var(--warn-soft);
  box-shadow: inset 0 -2px 0 var(--warn);
}
mark.finding-mark.status-unverified {
  background: var(--queue-soft);
  box-shadow: inset 0 -2px 0 var(--queue);
}
mark.finding-mark.status-artifact {
  background: var(--artifact-soft);
  box-shadow: inset 0 -1px 0 1px var(--artifact);
  text-decoration: line-through;
  text-decoration-color: var(--artifact);
  text-decoration-thickness: 1px;
  opacity: 0.85;
}
/* Standaard onzichtbaar: dit is een transcriptiefout, geen fout van de
   predikant, dus tenzij de schakelaar "toon transcriptiefouten" aan staat
   leest de tekst als gewone, ongemarkeerde tekst — precies zoals de
   predikant het echt zei. */
.transcript-panel:not(.show-artifacts) mark.finding-mark.status-artifact {
  background: none;
  box-shadow: none;
  text-decoration: none;
  cursor: text;
  pointer-events: none;
}
mark.finding-mark:hover,
mark.finding-mark:focus-visible { filter: brightness(0.94); }
:root[data-theme="dark"] mark.finding-mark:hover,
:root[data-theme="dark"] mark.finding-mark:focus-visible { filter: brightness(1.15); }

/* findings sidebar */

.findings-panel {
  position: sticky;
  top: 132px;
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
@media (max-width: 900px) {
  .findings-panel { position: static; max-height: none; }
}

.findings-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.findings-panel-head h2 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}
.findings-panel-head .n {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.artifact-toggle-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 0.55rem 0.75rem;
}
.artifact-toggle-row .toggle { color: var(--text); }
.artifact-toggle-row p {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.findings-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-right: 2px;
}

.finding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  border-left: 3px solid var(--border);
}
.finding-card:hover { border-color: var(--border-strong); }
.finding-card.status-confirmed { border-left-color: var(--danger); }
.finding-card.status-inconclusive { border-left-color: var(--warn); }
.finding-card.status-unverified { border-left-color: var(--queue); }
.finding-card.status-artifact { border-left-color: var(--artifact); background: var(--artifact-soft); }

.finding-card.flash { animation: flash-in 900ms ease; }

.finding-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.finding-time {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.finding-time .play-ic { font-size: 0.9em; }

.finding-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 0.5rem;
  line-height: 1.5;
  border-left: 2px solid var(--border);
  padding-left: 0.6rem;
}

.finding-body dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.6rem;
  font-size: 0.83rem;
}
.finding-body dt {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.finding-body dd { margin: 0; color: var(--text); }
.finding-body .source { color: var(--text-muted); font-size: 0.78rem; }

.finding-artifact-note {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--artifact);
  display: flex;
  gap: 0.4em;
  align-items: flex-start;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.35em; margin-bottom: 0.5rem; }

.panel-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.75rem;
}

/* loading / error states */

.loading, .error-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.error-state strong { color: var(--danger); display: block; margin-bottom: 0.3rem; }

/* responsive: phones shouldn't break */
@media (max-width: 560px) {
  main#app { padding: 1rem 0.75rem 3rem; }
  .transcript-panel { padding: 1rem 1.1rem; }
  table.services thead { display: none; }
  table.services, table.services tbody, table.services tr, table.services td { display: block; width: 100%; }
  table.services tr { padding: 0.6rem 0.9rem; }
  table.services td { padding: 0.15rem 0; border: none; }
  .col-errors { text-align: left; }
  .audio-bar { position: static; top: auto; }
  .findings-panel { top: auto; }
}
