/* ===== CSS Variables — Dark Studio Theme ===== */
:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #222537;
  --border: #2e3247;
  --text: #e8eaf0;
  --text-muted: #8892a4;
  --text-dim: #555e72;
  --accent: #4f7ef8;
  --accent-hover: #3d6ae0;
  --green: #22c55e;
  --green-bg: #0f2a1a;
  --red: #ef4444;
  --red-bg: #2a0f0f;
  --amber: #f59e0b;
  --amber-bg: #2a1f0a;
  --capture-btn: #1d6cf5;
  --capture-btn-hover: #1558cc;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }

/* ===== Layout ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.page { padding: 20px 16px; }

/* ===== Navigation ===== */
.nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-size: 1.1rem; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.nav-brand span { color: var(--accent); }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-muted); }
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-tab:hover { background: var(--bg3); color: var(--text); }
.nav-tab.active { background: var(--bg3); color: var(--text); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== CAPTURE BUTTON — The Big One ===== */
.btn-capture {
  width: 100%;
  min-height: 72px;
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-radius: var(--radius);
  border: none;
  background: var(--capture-btn);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-capture:hover:not(:disabled) { background: var(--capture-btn-hover); }
.btn-capture:active:not(:disabled) { transform: scale(0.98); }
.btn-capture:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-capture.capturing { background: var(--amber); }
.btn-capture.done { background: var(--green); }
.btn-capture.failed { background: var(--red); }

/* ===== Cards ===== */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.card-title { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.card-client { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Notes / Script ===== */
.read-notes {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  margin-bottom: 14px;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.6;
}
.notes-toggle {
  background: none; border: none; color: var(--accent); font-size: 0.8rem;
  cursor: pointer; padding: 0 0 8px 0; text-decoration: underline;
}

/* ===== Capture Result ===== */
.capture-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--green-bg);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-size: 0.875rem;
}
.capture-result.failed {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}
.capture-result audio { height: 32px; flex: 1; min-width: 0; }

/* ===== Station picker (inline on read card) ===== */
.station-picker {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 10px;
  appearance: none;
  -webkit-appearance: none;
}

/* ===== Status badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-pending { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.badge-processing { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }
.badge-ready { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.badge-failed { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }
.badge-active { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.badge-inactive { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.badge-presenter { background: #1a2a3a; color: #60a5fa; border: 1px solid #2563eb; }
.badge-producer { background: #1a2a20; color: #4ade80; border: 1px solid #16a34a; }
.badge-admin { background: #2a1a2a; color: #c084fc; border: 1px solid #7e22ce; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  background: var(--bg3);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.form-hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.form-row { display: grid; gap: 12px; }
@media (min-width: 600px) { .form-row-2 { grid-template-columns: 1fr 1fr; } }

/* ===== Checkbox ===== */
.check-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.875rem; color: var(--text); }
.check-label input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ===== Station Multi-select ===== */
.station-multiselect { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.station-multiselect-search {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg3);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
}
.station-multiselect-search:focus { outline: none; }
.station-multiselect-list {
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg2);
}
.station-multiselect-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.station-multiselect-list label:last-child { border-bottom: none; }
.station-multiselect-list label:hover { background: var(--bg3); color: var(--text); }
.station-multiselect-list input[type=checkbox] { accent-color: var(--accent); flex-shrink: 0; }
.station-multiselect-list label.selected { color: var(--text); background: rgba(79, 126, 248, 0.08); }
.station-count { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  position: relative;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.4rem; cursor: pointer; line-height: 1;
  padding: 4px; border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== Alerts / Toasts ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 14px;
}
.alert-error { background: var(--red-bg); border: 1px solid var(--red); color: var(--red); }
.alert-success { background: var(--green-bg); border: 1px solid var(--green); color: var(--green); }
.alert-warning { background: var(--amber-bg); border: 1px solid var(--amber); color: var(--amber); }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  z-index: 999;
  box-shadow: var(--shadow);
  transition: opacity 0.3s;
  pointer-events: none;
}
#toast.hidden { opacity: 0; }

/* ===== Loading spinner ===== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Section headings ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.section-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.section-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.filter-bar .form-input, .filter-bar .form-select {
  width: auto;
  flex: 1;
  min-width: 140px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 0.95rem; }
.empty-state-sub { font-size: 0.8rem; margin-top: 6px; color: var(--text-dim); }

/* ===== History list ===== */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.history-item:last-child { border-bottom: none; }
.history-info { flex: 1; min-width: 0; }
.history-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.history-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ===== System health ===== */
.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.health-ok { background: var(--green); }
.health-warn { background: var(--amber); }
.health-error { background: var(--red); }
.health-off { background: var(--text-dim); }
.disk-bar { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.disk-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s; border-radius: 4px; }
.disk-bar-fill.warn { background: var(--amber); }
.disk-bar-fill.danger { background: var(--red); }

/* ===== Login view ===== */
#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; }
.login-logo h1 span { color: var(--accent); }
.login-logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .nav-tabs { display: none; } /* Use dropdown on mobile */
  .card { padding: 16px; }
  .modal { padding: 18px; }
  th, td { padding: 8px 10px; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 768px) {
  .page { padding: 24px; }
  .btn-capture { font-size: 1.2rem; min-height: 80px; }
}

/* ===== Password change overlay ===== */
#view-change-password {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0,0,0,0.8);
  position: fixed;
  inset: 0;
  z-index: 300;
}

/* ===== Utils ===== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
