/* Tathakir correction studio */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1c2430; --muted: #6b7686;
  --line: #dfe4ea; --accent: #2563eb; --accent-ink: #ffffff;
  --ok: #15803d; --ok-bg: #e9f7ee; --warn: #b45309; --warn-bg: #fdf3e3;
  --bad: #b91c1c; --bad-bg: #fdecec; --chip: #eef1f5;
  --mono: ui-monospace, Consolas, monospace;
  --arabic: "Segoe UI", "Noto Naskh Arabic", "Amiri", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --panel: #1a2029; --ink: #e8ecf1; --muted: #8a95a5;
    --line: #2a3340; --accent: #3b82f6; --ok: #4ade80; --ok-bg: #10281a;
    --warn: #fbbf24; --warn-bg: #2c2211; --bad: #f87171; --bad-bg: #2d1515;
    --chip: #242c37;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
code { font-family: var(--mono); background: var(--chip); padding: 0 4px; border-radius: 4px; }

.view { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.tiny.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.wide { width: 100%; }
.btn.play { font-size: 16px; min-width: 46px; }
.btn.approve { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.btn.retake  { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.btn.reject  { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn .ar { font-family: var(--arabic); font-size: 12px; opacity: .8; margin-inline-start: 4px; }

/* ---- login ---- */
#view-login { align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 34px 38px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.08);
}
.login-card h1 { margin: 0; letter-spacing: .5px; }
.login-card .sub { margin-top: 2px; color: var(--muted); font-family: var(--arabic); }
.login-card label { display: block; margin: 14px 0 4px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.login-card button { margin-top: 18px; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 600; }
.batch-title { font-weight: 600; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.progress-track { width: 140px; height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--ok); transition: width .2s; }

/* ---- batches ---- */
.batches-main { padding: 20px; max-width: 980px; margin: 0 auto; width: 100%; }
.upload-box {
  background: var(--panel); border: 1px dashed var(--line); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 22px;
}
.upload-box h2 { margin: 0 0 4px; font-size: 15px; }
.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.chk { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.report {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-family: var(--mono); font-size: 12px; overflow: auto;
  max-height: 260px; white-space: pre-wrap;
}
.batch-list { display: flex; flex-direction: column; gap: 10px; }
.batch-card {
  display: flex; align-items: center; gap: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px;
}
.batch-card .name { font-size: 18px; font-weight: 700; font-family: var(--mono); }
.batch-card .bar { width: 180px; height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.batch-card .bar > div { height: 100%; background: var(--ok); }
.batch-card .stats { color: var(--muted); font-size: 13px; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: var(--chip); color: var(--muted);
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }

/* ---- user management ---- */
.users-list { margin: 8px 0 14px; }
.user-row {
  display: flex; gap: 10px; align-items: center; padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.user-row .uname { font-weight: 600; min-width: 150px; }
#users-box select, #users-box input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}

/* ---- filters ---- */
.filters {
  display: flex; gap: 10px; align-items: center; padding: 8px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 3px 12px; cursor: pointer; font: inherit; font-size: 13px;
}
.fchip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#search {
  margin-inline-start: auto; width: 240px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}

/* ---- review layout ---- */
.review-main { flex: 1; display: flex; min-height: 0; }
.line-list {
  width: 300px; overflow-y: auto; border-inline-end: 1px solid var(--line);
  background: var(--panel); padding: 6px;
}
.line-row {
  display: flex; gap: 8px; align-items: center; width: 100%; text-align: start;
  padding: 7px 9px; border: 0; background: transparent; color: var(--ink);
  border-radius: 8px; cursor: pointer; font: inherit;
}
.line-row:hover { background: var(--chip); }
.line-row.selected { background: var(--accent); color: var(--accent-ink); }
.line-row.selected .muted, .line-row.selected .lid { color: var(--accent-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.approved { background: var(--ok); }
.dot.retake { background: var(--warn); }
.dot.rejected { background: var(--bad); }
.dot.unreviewed { background: transparent; border: 2px solid var(--muted); width: 7px; height: 7px; }
.lid { font-family: var(--mono); font-size: 12px; color: var(--muted); flex: none; }
.line-row .snippet {
  flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  direction: rtl; text-align: right; font-family: var(--arabic);
}
.line-row .snippet.empty { color: var(--warn); font-style: italic; direction: ltr; text-align: left; }

.editor { flex: 1; padding: 16px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.audio-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.time { font-family: var(--mono); font-size: 13px; color: var(--muted); min-width: 90px; }
.speed { display: flex; gap: 4px; }

.banner { border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.banner.danger { background: var(--bad-bg); color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.asr-original {
  background: var(--chip); border-radius: 10px; padding: 12px 14px;
  font-family: var(--arabic); font-size: 18px; color: var(--muted);
}
.asr-original::before {
  content: "ASR original"; display: block; direction: ltr; text-align: left;
  font: 11px "Segoe UI", sans-serif; letter-spacing: .4px; text-transform: uppercase;
  margin-bottom: 6px; opacity: .7;
}
#text {
  width: 100%; min-height: 130px; resize: vertical; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  color: var(--ink); font-family: var(--arabic); font-size: 21px; line-height: 1.8;
}
#text:focus { outline: 2px solid var(--accent); border-color: transparent; }
#text.needs-typing { border-color: var(--warn); }

.issues { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--warn); }
.issues .issue::before { content: "&#9888; "; }

.status-row, .nav-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-row { display: flex; gap: 8px; }
.note-row input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.hint { font-size: 12px; margin-inline-start: auto; }

/* ---- help ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.help-card {
  background: var(--panel); border-radius: 14px; padding: 26px 30px; width: 460px;
  max-height: 80vh; overflow: auto; border: 1px solid var(--line);
}
.help-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.help-card input[type=password] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.help-card table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.help-card td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.help-card td:first-child { font-family: var(--mono); font-size: 13px; white-space: nowrap; }

@media (max-width: 900px) {
  .line-list { width: 200px; }
  #text { font-size: 18px; }
  .progress-wrap { display: none; }
}
