/* بالِ admin — shared styles for every page under public/admin/.
   Dark teal shell; the accent is Forest, the text-on-dark accent is Mint.
   Every authenticated admin page uses the .admin-shell layout: a
   left sidenav + a header bar + a main content area. */

:root {
  /* بالِ admin — DARK shell, rebranded to the teal identity.
     Loads AFTER /bali/theme.css, so these deliberately override it.

     ⚠️ --terra is used two incompatible ways in this file:
        • as a BACKGROUND with white text  (.btn, .badge, .me-avatar)  → must be DARK
        • as a TEXT colour on a dark tint  (.nav-item.active)          → must be LIGHT
     It cannot be both. So --terra stays DARK (white text on it clears AA at
     6.24:1) and the single text-on-dark rule below uses --mint instead. */
  --bg:           #04191D;   /* near-black teal */
  --surface:      #06262B;   /* ink */
  --surface-2:    #0C3B42;
  --paper:        #FFFFFF;
  --rule:         rgba(255,255,255,0.10);
  --rule-strong:  rgba(255,255,255,0.18);
  --text:         #F7F5EF;   /* cream on dark — 14.9:1 */
  --text-dim:     #ADC9CD;   /* g32 */
  --text-muted:   rgba(247,245,239,0.55);

  --terra:        #016B76;   /* button/badge BG. white on it = 6.24:1 ✓ AA */
  --terra-deep:   #015D67;   /* hover */
  --terra-tint:   rgba(0,172,177,0.16);
  --olive:        #00ACB1;
  --olive-tint:   rgba(0,172,177,0.20);

  --display: "Fraunces", Georgia, serif;
  --sans:    "Inter", system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.5;
}
a { color: inherit; }

/* ---------- .admin-shell layout ------------------------------------ */
.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---------- sidenav ------------------------------------------------- */
aside.sidenav {
  background: rgba(255,255,255,0.02);
  border-inline-end: 1px solid var(--rule);
  padding: var(--s-5) var(--s-4);
  display: flex; flex-direction: column;
  position: sticky; top: 0; min-height: 100vh; overflow-y: auto;
}
.sidenav .wordmark {
  font-family: var(--display); font-weight: 700;
  font-size: 19px; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 9px;
  padding: var(--s-1) var(--s-3); margin-bottom: 4px;
}
.sidenav .wordmark::before {
  content: ""; width: 9px; height: 9px;
  background: var(--terra); border-radius: 50%;
}
.sidenav .role-tag {
  margin: 0 12px 28px;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: rgba(1,93,103,0.85);
}
.sidenav h6 {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-muted);
  margin: 0 var(--s-3) var(--s-2); font-weight: 400;
}
.nav-section { display: flex; flex-direction: column; gap: 3px; margin-bottom: 22px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: rgba(247,245,239,0.75); text-decoration: none;
  font-size: var(--t-small); transition: background 140ms, color 140ms;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
  background: var(--terra-tint);
  color: var(--mint);   /* NOT --terra: that is dark here, and would vanish
                           against its own tint on the dark shell */
}
.nav-item.soon {
  color: rgba(247,245,239,0.35); cursor: default;
}
.nav-item.soon:hover { background: transparent; color: rgba(247,245,239,0.35); }
.badge-soon {
  font-family: var(--mono); font-size: 9px;
  background: rgba(255,255,255,0.06);
  color: rgba(247,245,239,0.55);
  padding: 2px 7px; border-radius: var(--r-pill);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.nav-item .badge {
  font-family: var(--mono); font-size: 10px;
  background: var(--terra); color: var(--paper);
  padding: 2px 7px; border-radius: var(--r-pill);
}

.sidenav-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--rule); }
.me-card {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.03);
}
.me-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--terra); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--t-small); flex-shrink: 0;
}
.me-text { min-width: 0; flex: 1; }
.me-name { font-family: var(--display); font-weight: 600; font-size: var(--t-small); color: var(--text); }
.me-email {
  font-size: var(--t-micro); color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.signout {
  background: none; border: 1px solid var(--rule-strong);
  color: var(--text-dim); padding: 6px 10px;
  border-radius: 6px; font-family: inherit; font-size: var(--t-micro);
  cursor: pointer; transition: color 140ms, border-color 140ms;
}
.signout:hover { color: var(--text); border-color: var(--text-dim); }

/* ---------- main content ------------------------------------------- */
/* A dashboard wants the full available width — tables, KPI strips, and
   growth charts all read better wider. No max-width cap: content fills
   the grid track and the side padding gives breathing room. */
main.content {
  padding: 36px 40px 60px;
  min-width: 0;            /* let the grid track shrink below content size */
}

/* Wrap any wide table in <div class="table-wrap"> so it scrolls
   horizontally when the viewport narrows, instead of forcing the page
   layout to widen. Used on every list page. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;          /* hides scrollbar edges that nick the border-radius */
}
.table-wrap > table { min-width: 560px; }

/* Pagination control — rendered above and below every paginated admin
   table. Page-size selector on the left, "X–Y of Z" label + first /
   prev / next / last on the right. Hidden entirely when total <= 10.
   The .pagination-top variant flips the border so it sits cleanly
   under the panel head instead of above empty space. */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 14px 4px 0;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: var(--s-3);
}
.pagination.pagination-top {
  margin-top: 0;
  margin-bottom: 14px;
  padding: 0 4px 14px;
  border-top: none;
  border-bottom: 1px solid var(--rule);
}
.pagination-left,
.pagination-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pagination-nav-group {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
}
.pagination-label {
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--t-micro);
}
.pagination-size,
.pagination-nav {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
}
.pagination-size {
  font-size: 12px;
}
.pagination-size:hover,
.pagination-nav:hover:not(:disabled) {
  background: var(--cream-deep);
  border-color: var(--terra-tint);
}
.pagination-nav {
  min-width: 32px;
  text-align: center;
}
.pagination-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
@media (max-width: 640px) {
  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pagination-right { justify-content: space-between; }
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 28px; gap: var(--s-4); flex-wrap: wrap;
}
.page-head h1 {
  font-family: var(--display); font-size: var(--t-h2); font-weight: 700;
  letter-spacing: -0.02em; margin: 0 0 var(--s-1);
}
.page-head .sub { color: var(--text-dim); font-size: 14px; }

/* ---------- cards / panels ----------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 22px 24px;
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h3 {
  font-family: var(--display); font-size: 16px; font-weight: 600;
  margin: 0; letter-spacing: -0.01em;
}
.panel-head .count {
  font-family: var(--mono); font-size: var(--t-micro);
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
}

/* KPI strip ---------------------------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 18px 20px;
}
.kpi-lbl {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-muted); margin-bottom: 6px;
}
.kpi-val {
  font-family: var(--display); font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
}
.kpi-trend { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* Forms / buttons ---------------------------------------------------- */
.btn {
  background: var(--terra); color: var(--paper);
  border: none; padding: 9px 16px; border-radius: var(--r-sm);
  font-family: inherit; font-size: var(--t-small); font-weight: 500;
  cursor: pointer; transition: background 140ms;
}
.btn:hover { background: var(--terra-deep); }
.btn.quiet {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--rule-strong);
}
.btn.quiet:hover { color: var(--text); border-color: var(--text-dim); background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Empty / placeholder copy ------------------------------------------ */
.placeholder {
  color: var(--text-dim); font-size: 14px; line-height: 1.6;
}

/* ---------- responsive --------------------------------------------- */

/* Tighten the desktop layout a notch on smaller laptops so 13" screens
   stop feeling cramped before they hit the mobile breakpoint. */
@media (max-width: 1100px) {
  .admin-shell { grid-template-columns: 200px 1fr; }
  main.content { padding: 28px 28px 56px; }
}

/* ≤ 900px — the sidenav stops being a side rail and becomes a compact
   horizontal app bar at the top: wordmark on the left, nav items in a
   scrollable row in the middle, sign-out on the right. The full me-card
   collapses to just the avatar (so the email + name don't dominate). */
@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  aside.sidenav {
    position: sticky; top: 0; z-index: 30;
    min-height: 0;
    flex-direction: row; align-items: center;
    gap: var(--s-1); padding: var(--s-2) var(--s-3);
    border-inline-end: none;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
    /* Whole bar scrolls horizontally as one strip when nav items
       overflow — simpler than trying to pin wordmark + foot while a
       middle group scrolls, and works fine since these things are
       all reachable by a single horizontal swipe. */
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  aside.sidenav::-webkit-scrollbar { display: none; }
  .sidenav .wordmark {
    margin: 0; padding: 4px 6px; font-size: 16px;
    flex-shrink: 0;
  }
  .sidenav .role-tag,
  .sidenav h6 { display: none; }    /* hide section headings + role tag */
  .nav-section {
    flex-direction: row; gap: 2px;
    margin: 0;
    flex: 0 0 auto;                 /* natural width — don't fight siblings */
  }
  .nav-item {
    padding: 7px 10px; font-size: var(--t-small);
    white-space: nowrap; flex-shrink: 0;
  }
  .sidenav-foot {
    margin: 0 0 0 auto;             /* push to the far right of the bar */
    padding: 0 0 0 10px;
    border-top: none; border-inline-start: 1px solid var(--rule);
    flex-shrink: 0;
  }
  .me-card {
    padding: 0; background: none;
    gap: 0;
  }
  .me-text { display: none; }       /* avatar-only on mobile */
  .signout {
    margin-top: 0 !important;
    width: auto !important;
    padding: 6px 9px; font-size: var(--t-micro);
    margin-inline-start: 8px;
  }

  main.content { padding: 22px 20px 48px; }
  .page-head h1 { font-size: 24px; }
}

/* ≤ 640px — single-column friendly: tighter padding, drawers go full
   width (already true via min(Xpx, 100%)), filter bars stack neatly. */
@media (max-width: 640px) {
  main.content { padding: 18px 16px 40px; }
  .page-head { margin-bottom: 20px; }
  .page-head h1 { font-size: var(--t-h3); }
  .panel { padding: 18px 16px; }
  .panel-head { flex-wrap: wrap; gap: var(--s-2); }
}

/* ═══ Shared admin shell — extracted 2026-07-25 (UX-0) ══════════════
   One copy of the drawer / data-table / filter-bar / pills / empty /
   reason-modal previously duplicated across users, applications,
   reviews and audit. Page CSS keeps only genuine overrides
   (reviews' wider drawer, audit's denser cells). */

:root {
  --ok-text:     #B8C394;  /* success text on the dark shell */
  --danger-text: #F8DDD3;  /* destructive/suspension text on the dark shell */
}

.filter-bar { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; margin-bottom: 16px; }
.filter-group { display: flex; align-items: center; gap: var(--s-2); }
.filter-label {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--text-muted);
}
.chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--rule-strong); color: var(--text-dim);
  padding: 6px 12px; border-radius: var(--r-pill);
  font-family: inherit; font-size: var(--t-small); cursor: pointer;
  transition: 140ms;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--terra-tint); color: var(--terra); border-color: var(--terra-deep); }
.search-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--rule-strong);
  color: var(--text); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm); font-family: inherit; font-size: var(--t-small);
  min-width: 240px;
}
.search-input:focus { outline: none; border-color: var(--terra); }
@media (max-width: 640px) {
  .filter-group:last-child { flex: 1 1 100%; }
  .search-input { min-width: 0; width: 100%; }
}

table.users, table.applications, table.therapists, table.audit { width: 100%; border-collapse: collapse; }
table.users th, table.applications th, table.therapists th, table.audit th {
  text-align: start; font-family: var(--mono); font-size: var(--t-micro);
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--text-muted); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--rule);
}
table.users td, table.applications td, table.therapists td, table.audit td {
  padding: var(--s-3); border-bottom: 1px solid var(--rule);
  font-size: var(--t-small); vertical-align: middle;
}
table.users tr.row, table.applications tr.row, table.therapists tr.row, table.audit tr.row { cursor: pointer; transition: background 120ms; }
table.users tr.row:hover, table.applications tr.row:hover, table.therapists tr.row:hover, table.audit tr.row:hover { background: rgba(255,255,255,0.03); }

.role-pill, .status-pill {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.10em;
  padding: 3px 10px; border-radius: var(--r-pill); display: inline-block;
}
.role-patient   { background: rgba(167,175,183,0.18); color: var(--text-dim); }
.role-therapist { background: rgba(63,125,82,0.25); color: var(--ok-text); }

.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); font-size: 14px; line-height: 1.6; }

.suspension-banner {
  background: rgba(1,93,103,0.12);
  border: 1px solid var(--terra-deep);
  color: var(--danger-text);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.suspension-banner strong { color: var(--terra); }
.suspension-banner a { color: var(--terra); text-decoration: underline; font-family: var(--mono); font-size: 12px; }

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(7,10,22,0.55);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 180ms;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(540px, 100%);
  background: var(--surface); border-inline-start: 1px solid var(--rule-strong);
  z-index: 101; transform: translateX(100%);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 20px 24px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-head h2 {
  font-family: var(--display); font-size: var(--t-lead); font-weight: 600;
  margin: 0; letter-spacing: -0.01em;
}
.drawer-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 24px; line-height: 1; cursor: pointer; padding: var(--s-1) var(--s-2);
}
.drawer-close:hover { color: var(--text); }
.drawer-body { padding: 20px 24px; flex: 1; overflow-y: auto; }
.drawer-foot {
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--rule);
  display: flex; gap: 10px; justify-content: flex-end;
}

.field { margin-bottom: 16px; }
.field-label {
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--text-muted); margin-bottom: 4px;
}
.field-value { color: var(--text); font-size: var(--t-small); line-height: 1.55; }
.field-value.muted { color: var(--text-dim); font-style: italic; }

.btn.danger { background: transparent; color: var(--terra); border: 1px solid var(--terra-deep); }
.btn.danger:hover { background: var(--terra-tint); }

.reason-modal {
  position: fixed; inset: 0; background: rgba(7,10,22,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: var(--s-5);
  opacity: 0; pointer-events: none; transition: opacity 180ms;
}
.reason-modal.open { opacity: 1; pointer-events: auto; }
.reason-modal .card {
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-radius: var(--r-md); padding: var(--s-5);
  max-width: 480px; width: 100%;
}
.reason-modal h3 { font-family: var(--display); font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.reason-modal .sub { color: var(--text-dim); font-size: var(--t-small); margin-bottom: 14px; }
.reason-input {
  width: 100%; min-height: 100px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm); padding: 10px 12px;
  color: var(--text); font-family: inherit; font-size: var(--t-small);
  line-height: 1.5; resize: vertical;
}
.reason-input:focus { outline: none; border-color: var(--terra); }
.reason-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
