/* admin.css — LSD Portal Admin UI
   Uses only LeedAB design tokens from style.css.
   No new colors, no new fonts, no rounded corners.
*/

/* ── Tab navigation ─────────────────────────────────────────────────────────── */

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 32px;
}

.admin-tab {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 12px 18px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  text-decoration: none;
  display: inline-block;
  position: relative;
  bottom: -2px;
}

.admin-tab:hover {
  color: var(--ink);
}

.admin-tab-active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

/* ── Users table ─────────────────────────────────────────────────────────────── */

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--f-mono);
}

.users-table th {
  text-align: left;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  border-bottom: 2px solid var(--line);
  padding: 10px 12px;
}

.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  color: var(--ink-2);
  vertical-align: middle;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:hover td {
  background: var(--paper-2);
}

.status-badge {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid currentColor;
}

.status-badge.active {
  color: var(--green);
}

.status-badge.inactive {
  color: var(--red);
}

/* ── User edit modal ─────────────────────────────────────────────────────────── */

/* The backdrop SCROLLS. It is position:fixed and inset:0, so without
   overflow-y anything taller than the viewport is simply unreachable —
   which is what happened to this modal: SAVE and CANCEL sat below the fold
   with no way to scroll to them.

   It only surfaced in 11.9. Before that the modal threw a ReferenceError
   after four fields and was always short; fixing that let it render all
   twelve and immediately outgrow the screen. A latent layout bug that the
   earlier bug was hiding. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 19, 0.6);
  z-index: 100;
  display: flex;
  /* NOT align-items:center. Centring a flex item taller than its container
     overflows it equally in BOTH directions, so the top gets clipped and
     scrolling cannot reach it — the classic flex-centring overflow trap.
     `margin:auto` on the item below centres it when it fits and collapses
     to 0 when it doesn't, which is the behaviour we actually want. */
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  /* Bottom padding clears the 16px offset shadow when scrolled to the end. */
  padding: 24px 16px 40px;
}

.user-edit-modal {
  background: var(--paper);
  border: 2px solid var(--line);
  box-shadow: 8px 8px 0 var(--amber), 16px 16px 0 var(--ink);
  padding: 32px 36px;
  width: min(480px, 92vw);
  /* Pairs with align-items:flex-start above — do not replace with
     align-items:center. */
  margin: auto;
  position: relative;
  z-index: 101;
}

.modal-title {
  font-family: var(--f-display);
  font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  color: var(--ink);
}

.modal-field {
  margin-bottom: 16px;
}

.modal-label {
  display: block;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}

.modal-input,
.modal-select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-family: var(--f-mono);
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 0;
}

.modal-input:focus,
.modal-select:focus {
  outline: 2px solid var(--amber);
  outline-offset: 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--f-mono);
  font-size: 12px;
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  letter-spacing: 0.1em;
  padding: 4px 8px;
}

.modal-close-btn:hover {
  color: var(--ink);
}

/* ── Export tab ──────────────────────────────────────────────────────────────── */

.export-btn-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.export-warning {
  border: 1px solid var(--red);
  padding: 14px 18px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--red);
  max-width: 560px;
}

/* ── Stats grid ──────────────────────────────────────────────────────────────── */

.stats-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  margin-bottom: 40px;
}

.stats-tile-grid .cm {
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats-tile-grid .cm:last-child {
  border-right: none;
}

.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

@media (max-width: 700px) {
  .stats-two-col {
    grid-template-columns: 1fr;
  }
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--hair);
  font-family: var(--f-mono);
  font-size: 12px;
}

.score-row:last-child {
  border-bottom: none;
}

.score-val {
  font-family: var(--f-display);
  font-size: 20px;
  color: var(--amber);
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* ── Corrections table ───────────────────────────────────────────────────────── */

.corrections-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.corrections-table th {
  text-align: left;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  border-bottom: 2px solid var(--line);
  padding: 10px 12px;
}

.corrections-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  color: var(--ink-2);
  vertical-align: top;
  font-family: var(--f-mono);
  font-size: 12px;
}

.scores-compact {
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.correction-detail {
  background: var(--paper-2);
  border-top: 1px solid var(--hair);
  padding: 14px 12px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink-2);
  display: none;
}

.correction-detail.open {
  display: block;
}

/* ── Audit table ─────────────────────────────────────────────────────────────── */

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.audit-table th {
  text-align: left;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  border-bottom: 2px solid var(--line);
  padding: 10px 12px;
}

.audit-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  color: var(--ink-2);
  vertical-align: top;
  font-family: var(--f-mono);
  font-size: 12px;
  max-width: 320px;
  word-break: break-word;
}

.payload-toggle {
  color: var(--amber);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--f-mono);
}

.payload-json {
  display: none;
  white-space: pre-wrap;
  font-size: 11px;
  margin-top: 6px;
  color: var(--ink-3);
  max-width: 320px;
}

.payload-json.open {
  display: block;
}

/* ── Conversation drawer ─────────────────────────────────────────────────────── */

.conv-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 19, 0.5);
  z-index: 90;
  display: none;
}

.conv-drawer-backdrop.open {
  display: block;
}

.conv-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 94vw);
  background: var(--paper);
  border-left: 2px solid var(--line);
  box-shadow: -8px 0 0 var(--amber);
  z-index: 95;
  overflow-y: auto;
  padding: 24px 28px;
  transform: translateX(100%);
  transition: transform 0.2s;
}

.conv-drawer.open {
  transform: translateX(0);
}

.drawer-close {
  float: right;
  font-family: var(--f-mono);
  font-size: 12px;
  background: none;
  border: 1px solid var(--line);
  padding: 4px 10px;
  cursor: pointer;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}

.drawer-close:hover {
  color: var(--ink);
}

/* ── Filters row ─────────────────────────────────────────────────────────────── */

.filters-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  align-items: flex-end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

.filter-input,
.filter-select {
  padding: 8px 10px;
  font-family: var(--f-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 0;
}

/* ── Loading / empty states ─────────────────────────────────────────────────── */

.admin-loading {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink-4);
  padding: 32px 0;
  letter-spacing: 0.08em;
}

.admin-empty {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink-4);
  padding: 20px 0;
  letter-spacing: 0.08em;
  border-top: 1px solid var(--hair);
}

/* ── Sub-section headers ─────────────────────────────────────────────────────── */

.sub-section-head {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin: 28px 0 16px;
}

/* ── Invite form ─────────────────────────────────────────────────────────────── */

.invite-form {
  max-width: 440px;
}

.invite-form .modal-field {
  margin-bottom: 20px;
}

/* ── Conversation list ───────────────────────────────────────────────────────── */

.conv-list {
  border-top: 1px solid var(--line);
}

.conv-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--hair);
}

.conv-meta {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
}

.conv-title {
  font-family: var(--f-display);
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

@media (max-width: 600px) {
  .admin-tabs {
    gap: 0;
  }
  .admin-tab {
    padding: 10px 12px;
    font-size: 11px;
  }
  .stats-tile-grid {
    grid-template-columns: 1fr 1fr;
  }
}


/* ── Ikhtebar teacher review (Phase 11.5) ─────────────────────────────────────
   The student's results screen renders the same rubric/mistake data with its
   own `exam-*` classes, but those live in a <style> block inside
   quran-ikhtebar.html rather than a shared sheet, so they can't be reused
   here. These are the admin-side equivalents, deliberately denser: a teacher
   is scanning five questions inside a table row, not reading their own report.
   Same tokens, same no-radius/no-shadow rules as the rest of the portal. */

.review-verdicts {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--hair);
}

.review-verdict-label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.review-verdict-value {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink);
}

.review-question {
  border: 1px solid var(--hair);
  margin-bottom: 10px;
}

.review-question > summary {
  cursor: pointer;
  padding: 8px 10px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-2);
  background: var(--paper);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.review-question-body {
  padding: 10px;
  border-top: 1px solid var(--hair);
}

.review-rubric-title,
.review-mistake-title {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 12px 0 5px;
}

.review-rubric-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.review-rubric-table td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}

.review-rubric-table tr.na td {
  color: var(--ink-3);
  font-style: italic;
}

.review-rubric-criterion {
  font-size: 14px;
  white-space: nowrap;
}

.review-rubric-band {
  font-family: var(--f-mono);
  font-weight: 600;
  white-space: nowrap;
}

.review-rubric-marks {
  font-family: var(--f-mono);
  white-space: nowrap;
  color: var(--ink-2);
}

.review-rubric-desc {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.review-mistake {
  padding: 5px 0;
  border-bottom: 1px solid var(--hair);
  line-height: 1.5;
}

.review-mistake:last-child {
  border-bottom: none;
}

.review-mistake-ayah {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--ink-3);
}

.review-mistake-correct {
  font-size: 15px;
  margin-top: 3px;
  color: var(--ink);
}

.review-mistake-empty {
  color: var(--ink-3);
  font-size: 12px;
  padding: 3px 0;
}

.review-form {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
}

.review-remarks {
  width: 100%;
  min-height: 70px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 0;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink);
  resize: vertical;
}

.review-remarks:focus {
  outline: none;
  border-color: var(--amber);
}

.review-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

/* ── Usage & Cost tab (Phase 11.6) ────────────────────────────────────────── */

.usage-note {
  margin: 16px 0;
  padding: 10px 12px;
  border-left: 2px solid var(--amber);
  background: var(--paper-2);
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 780px;
}

.usage-note-warn {
  border-left-color: var(--red, #c0392b);
  color: var(--ink);
}

/* Daily-spend sparkline. Plain divs rather than a chart library — the CSP
   blocks external scripts and one bar per day needs no more than this. */
.usage-spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 90px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hair);
  overflow-x: auto;
}

.usage-spark-col {
  flex: 1 0 6px;
  min-width: 6px;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.usage-spark-bar {
  width: 100%;
  background: var(--amber);
  min-height: 1px;
}
