/* EquipMedia admin — minimal server-rendered styles. No build step. */

:root {
  --fg: #18181b;
  --fg-muted: #71717a;
  --bg: #fafaf8;
  --card: #ffffff;
  --border: #e5e5e3;
  --accent: #1f6feb;
  --accent-hover: #1858c2;
  --accent-soft: #dbeafe;
  --error: #b91c1c;
  --error-soft: #fee2e2;
  --success: #047857;
  --success-soft: #d1fae5;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --neutral-soft: #f1f5f9;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

p { margin: .5rem 0; }
.muted { color: var(--fg-muted); }
.small { font-size: .875rem; }
.error { color: var(--error); }

/* ─── Layout ────────────────────────────────────────────────── */

.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
}
.topbar .brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--fg);
}
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a {
  color: var(--fg-muted);
  padding: .35rem .75rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: .95rem;
  transition: color .15s, background-color .15s;
}
.topbar nav a:hover { color: var(--fg); background: var(--neutral-soft); text-decoration: none; }
.topbar nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.topbar nav a.active:hover { background: var(--accent-soft); }
.user-menu { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }

.container {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

/* ─── Auth page ─────────────────────────────────────────────── */

body.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ─── Forms ─────────────────────────────────────────────────── */

label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin: 1rem 0 .35rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--fg);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; line-height: 1.5; }

fieldset.source-toggle {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem 1rem;
  margin: 1rem 0 0;
}
fieldset.source-toggle legend { padding: 0 .35rem; font-weight: 500; font-size: .875rem; }
fieldset.source-toggle label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: .25rem 1.25rem .25rem 0;
  font-weight: 400;
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 720px;
}
.form-actions { margin-top: 1.5rem; }

/* ─── Buttons ───────────────────────────────────────────────── */

button, .btn-primary, .btn-secondary {
  display: inline-block;
  padding: .55rem .9rem;
  border-radius: 6px;
  font-size: .95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary, button[type="submit"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover, button[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
}
.btn-secondary {
  background: white;
  color: var(--fg);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--neutral-soft);
  text-decoration: none;
}
.link, a.link { color: var(--accent); }
.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.link-button:hover { color: var(--fg); }

/* ─── Tables ────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .95rem;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table th {
  background: var(--neutral-soft);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--fg-muted);
}

/* ─── Panels ────────────────────────────────────────────────── */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.panel h2 { margin-top: 0; }

.status-block { margin: .5rem 0; }

audio { width: 100%; max-width: 600px; margin-top: .25rem; }

/* ─── Badges ────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: uppercase;
  background: var(--neutral-soft);
  color: var(--fg-muted);
}
.badge-source-audio  { background: var(--accent-soft); color: #1d4ed8; }
.badge-source-text   { background: var(--success-soft); color: var(--success); }

.badge-status-uploaded     { background: var(--accent-soft); color: #1d4ed8; }
.badge-status-transcribing { background: var(--warning-soft); color: var(--warning); }
.badge-status-transcribed  { background: var(--success-soft); color: var(--success); }
.badge-status-reviewing    { background: var(--accent-soft); color: #1d4ed8; }
.badge-status-published    { background: var(--success-soft); color: var(--success); }
.badge-status-failed       { background: var(--error-soft); color: var(--error); }

/* ─── Error pages ───────────────────────────────────────────── */

.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  margin: .5rem 0 1rem;
  font-size: .9rem;
}
.alert.error { background: var(--error-soft); color: var(--error); }
.alert.success { background: var(--success-soft); color: var(--success); }

/* Inline checkbox label */
label.inline-check {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 1rem 0 0;
  font-weight: 500;
  font-size: .9rem;
}

/* Details/summary collapsible */
details {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .75rem;
}
details summary {
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--fg-muted);
}
details[open] summary { color: var(--fg); margin-bottom: .5rem; }

/* Danger form */
.form-card.danger {
  margin-top: 1.5rem;
  border-color: #fecaca;
}
.form-card.danger h2 { color: var(--error); }

/* Generation progress chip on the streams panel */
/* Filter chips on Contents page */
.filter-chips {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.25rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--fg-muted);
  font-size: .9rem;
  text-decoration: none;
}
.filter-chip:hover {
  border-color: var(--accent);
  color: var(--fg);
  text-decoration: none;
}
.filter-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.filter-chip-count {
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  padding: 0 .5rem;
  font-size: .8rem;
  font-weight: 500;
}
.filter-chip.active .filter-chip-count {
  background: rgba(255,255,255,0.25);
}

/* Pagination footer */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Contents page: filter bar (stream + sermon dropdowns) */
.content-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 .25rem;
  padding: .75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.content-filter-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  font-size: .85rem;
  font-weight: 500;
  color: var(--fg-muted);
}
.content-filter-label select {
  padding: .35rem .5rem;
  font-size: .9rem;
  width: auto;
  min-width: 220px;
}

/* Contents page: card grid */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
  margin-top: .5rem;
}

.content-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.content-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.content-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem 0.5rem;
}
.content-card-titles { flex: 1; min-width: 0; }
.content-card-title {
  font-size: 1rem;
  margin: 0 0 .15rem;
  line-height: 1.3;
}
.content-card-title a {
  color: var(--fg);
  text-decoration: none;
}
.content-card-title a:hover { color: var(--accent); }
.content-card-subtitle {
  font-size: .85rem;
  color: var(--fg-muted);
  margin: 0;
  line-height: 1.4;
}
.content-card-subtitle a { color: inherit; }
.content-card-subtitle a:hover { color: var(--fg); text-decoration: underline; }

.content-card-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .25rem;
  flex-shrink: 0;
}

.content-card-body {
  padding: .5rem 1.25rem 0.75rem;
  flex: 1;
}

.content-preview {
  margin: 0;
  font-size: .85rem;
  line-height: 1.55;
  color: var(--fg);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.content-audio {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin: .25rem 0;
}
.content-audio audio {
  width: 100%;
  height: 36px;
}

.content-lyrics {
  margin-top: .75rem;
  border: 0;
  padding: 0;
}
.content-lyrics summary {
  font-size: .85rem;
  color: var(--fg-muted);
  cursor: pointer;
}
.content-lyrics .content-preview {
  margin-top: .5rem;
  font-size: .85rem;
  color: var(--fg-muted);
}

.content-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--neutral-soft);
}
.content-card-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.content-card-actions .btn-primary,
.content-card-actions .btn-secondary {
  padding: .4rem .75rem;
  font-size: .85rem;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .5rem 0 1rem;
  padding: .55rem .75rem;
  background: var(--neutral-soft);
  border-radius: 6px;
  font-size: .9rem;
}

/* Stream cards on sermon detail */
.stream-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
}
.stream-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.stream-card .data-table { font-size: .9rem; }

/* Version list on review page */
.version-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.version-list li {
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
}
.version-list li:last-child { border-bottom: 0; }

/* datetime-local */
input[type="datetime-local"] {
  width: auto;
  font-family: inherit;
}

/* Transcript body */
.transcript-body {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: .75rem 0 0;
  padding: 1rem 1.25rem;
  background: var(--neutral-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .95rem;
  line-height: 1.65;
  /* Three layers of defense against horizontal overflow:
     1) pre-wrap: collapse repeated whitespace but honor real newlines
     2) overflow-wrap: anywhere: break inside words (or non-space scripts)
     3) word-break: break-all: ultimate fallback for runs without break opps */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
  max-height: 65vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Inline-flow article layout for cues. Each cue is a normal inline span so
   the transcript reads as continuous prose, not a list. Within-cue progress
   is shown by the separate .cue-progress bar (see below) — embedding a
   linear-gradient in inline-wrapping spans would render per-line and break.
   Three visual states:
     • default       — unplayed, neutral
     • .played       — fully passed, soft tint persists
     • .active       — currently playing, light tint + bold + accent underline */
.transcript-body.transcript-article {
  text-align: justify;
  hyphens: auto;
}
.transcript-body .cue {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 .15rem;
  transition: background-color .15s ease, box-shadow .15s ease;
}
.transcript-body .cue:hover {
  background: rgba(31, 111, 235, 0.08);
}
.transcript-body .cue.played {
  background: var(--accent-soft);
  color: var(--fg);
}
.transcript-body .cue.active {
  background: var(--accent-soft);
  color: var(--fg);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

/* Within-cue progress bar — sits between the cues' meta-line and article.
   Always visible while there's a SRT transcript; width updates each rAF tick
   in JS. Independent of cue geometry so it works for cues of any length. */
.cue-progress {
  height: 4px;
  background: rgba(31, 111, 235, 0.08);
  border-radius: 999px;
  margin: .65rem 0 .85rem;
  overflow: hidden;
}
.cue-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
  transition: width .12s linear;
}
