/* ============================================================
   Exam Management System — Responsive Stylesheet (v2)
   Mobile-first · CSS Custom Properties · Fluid layouts
   Breakpoints: sm 480 · md 768 · lg 1024 · xl 1200
   ============================================================ */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* ── Brand palette — Teal (#0891b2 Results-button colour) ── */
  --clr-primary:        #0369a1;   /* Results-button teal — nav, card headers */
  --clr-primary-hover:  #0284c7;   /* slightly deeper — hover on nav          */
  --clr-primary-light:  #0369a1;   /* deeper teal — links, secondary elements */
  --clr-primary-accent: #e0f2fe;   /* very light sky — nav link text on dark  */
  --clr-primary-pale:   #f0f9ff;   /* near-white teal — hover rows, pale bg   */

  /* Gold accent — logo golden glow (complements teal) */
  --clr-gold:           #d97706;   /* amber gold                               */
  --clr-gold-light:     #f59e0b;   /* lighter gold — hover                     */
  --clr-gold-pale:      #fffbeb;   /* pale gold — backgrounds                  */

  /* Semantic */
  --clr-success:  #15803d;
  --clr-danger:   #dc2626;
  --clr-warning:  #d97706;
  --clr-info:     #0891b2;

  /* Neutrals */
  --clr-bg:         #f0f9ff;   /* very light teal tint background */
  --clr-surface:    #ffffff;
  --clr-border:     #bae6fd;
  --clr-border-2:   #7dd3fc;
  --clr-text:       #0c1a2e;
  --clr-text-muted: #374e63;
  --clr-text-faint: #7a9ab5;

  /* Spacing */
  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;
  --space-4: 16px;  --space-5: 20px;  --space-6: 24px;
  --space-8: 32px;

  /* Radius */
  --radius-sm: 4px;  --radius: 8px;  --radius-lg: 12px;  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.09);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);

  /* Nav height — used to offset sticky content */
  --nav-h: 56px;

  /* Transitions */
  --tx: .18s ease;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;   /* prevent horizontal scroll from nav overflow */
}
img { max-width: 100%; display: block; }
a { color: var(--clr-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; color: #0369a1; }
button { font-family: inherit; }

/* ── Navigation Bar ───────────────────────────────────────── */
.navbar {
  background: #1a1a2e;
  box-shadow: 0 2px 12px rgba(0,0,0,.40);
  position: sticky; top: 0; z-index: 500;
  height: var(--nav-h);
}
.navbar-inner {
  display: flex; align-items: center;
  height: 100%; padding: 0 var(--space-4); gap: var(--space-2);
}

/* Logo — lotus image has black bg.
   Trick: outer white ring separates black logo from dark green nav,
   then a gold ring on top gives the branded look.          */
.navbar-logo {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 50%;
  overflow: visible;            /* let box-shadow rings show outside */
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  /* Layer 1: white separator ring (2px)
     Layer 2: gold glow ring
     Layer 3: ambient gold glow */
  box-shadow:
    0 0 0 2px #fff,                          /* white separator */
    0 0 0 4px rgba(192,57,43,.85),          /* Riyatrix red ring */
    0 0 14px 4px rgba(192,57,43,.40);       /* red glow        */
}
.navbar-logo img {
  width: 46px; height: 46px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.navbar-logo-placeholder {
  width: 46px; height: 46px; border-radius: 50%;
  background: #000;
  font-size: .46rem; font-weight: 700;
  color: rgba(186,230,253,.8);
  text-align: center; line-height: 46px; user-select: none;
}

/* Brand — visually distinct from nav links: larger, gold accent, never disappears on hover */
.navbar-brand {
  color: #FFD700;                     /* gold — immediately distinct from white nav links */
  font-size: 1.35rem;                 /* bigger than nav links (.84rem) */
  font-weight: 900;
  letter-spacing: .5px;
  font-family: Georgia, 'Times New Roman', serif;   /* serif differentiates from nav sans-serif */
  padding: 0 var(--space-3);
  white-space: nowrap; text-decoration: none;
  flex-shrink: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.navbar-brand:hover,
.navbar-brand:focus {
  color: #FFD700;           /* keep gold — override global a:hover { color: #0369a1 } */
  text-decoration: none;
  text-shadow: 0 1px 8px rgba(255,215,0,.55);
}
.navbar-brand em { color: #fff; font-style: italic; }

/* Desktop nav links */
.navbar-links {
  display: none; /* hidden on mobile, shown on md+ */
  align-items: center; gap: 0;
  list-style: none; padding-left: var(--space-1); flex: 1; min-width: 0;
}
.navbar-links a {
  color: var(--clr-primary-accent);
  padding: 18px var(--space-3); display: block;
  font-size: .84rem; font-weight: 500; white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: background var(--tx), border-color var(--tx), color var(--tx);
  text-decoration: none;
}
.navbar-links a:hover {
  background: rgba(255,255,255,.10);
  border-bottom-color: rgba(255,196,0,.55);
  color: #fff; text-decoration: none;
}
/* Active nav item — clearly highlighted */
.navbar-links a.active {
  background: rgba(255,196,0,.18);   /* warm gold tint */
  border-bottom: 3px solid var(--clr-gold);
  color: var(--clr-gold);            /* gold text */
  font-weight: 700;
  text-decoration: none;
}

/* ── User info area.
   position:relative + z-index keeps this reliably painted above the
   admin dropdown <li>s (which are position:relative for their own
   dropdown panels) — without it, a positioned nav <li> paints above this
   plain, non-positioned div whenever their boxes touch, which is what
   made "Monitor" visually sit on top of the user pill / Logout button. */
.navbar-user {
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--clr-primary-accent); font-size: .78rem;
  margin-left: auto; flex-shrink: 0;
  position: relative; z-index: 2;
}
.navbar-user .user-name {
  background: rgba(255,255,255,.12); border-radius: 20px;
  padding: 4px var(--space-3); color: #fff; font-weight: 600;
  white-space: nowrap;
}
/* Admin quick-stats (Students / Exams / Live Now) — moved here from the
   left sidebar's old stats widget, so they sit in the top-right instead. */
.navbar-user .navbar-stats {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.08); border-radius: 20px;
  padding: 5px 14px; margin-right: 2px;
}
.navbar-user .navbar-stat { color: rgba(255,255,255,.8); font-size: .74rem; white-space: nowrap; }
.navbar-user .navbar-stat strong { color: #fff; font-weight: 800; }
.navbar-user .navbar-stat-live strong { color: #4ade80; }
.badge-admin      { background: #c9a227; color: #0d1f14; }
.badge-student    { background: #fef3c7; color: #78350f; }
.badge-teacher    { background: #dbeafe; color: #1e3a8a; }
.badge-instadmin  { background: #ddd6fe; color: #4c1d95; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .72rem; font-weight: 700; }

.navbar-user .btn-logout {
  background: var(--clr-danger); color: #fff !important;
  padding: 5px var(--space-3); border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 700;
  border-bottom: none !important; cursor: pointer;
  transition: background var(--tx); white-space: nowrap;
}
.navbar-user .btn-logout:hover { background: #dc2626; text-decoration: none; }

/* Hamburger button — visible only on mobile */
.nav-toggle {
  display: flex; flex-direction: column; justify-content: center;
  gap: 5px; width: 38px; height: 38px;
  background: rgba(255,255,255,.1); border: none; border-radius: var(--radius-sm);
  cursor: pointer; padding: 8px; flex-shrink: 0; margin-left: auto;
  transition: background var(--tx);
}
.nav-toggle:hover { background: rgba(255,255,255,.2); }
.nav-toggle span {
  display: block; height: 2px; background: #fff; border-radius: 2px;
  transition: transform .25s ease, opacity .25s ease, width .25s ease;
  transform-origin: center;
}
/* Animated to X when open */
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
.mobile-nav {
  display: none; /* JS toggles .is-open */
  position: fixed; top: var(--nav-h); left: 0; right: 0;
  background: #1a1a2e;
  border-top: 1px solid rgba(186,230,253,.25);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 490; padding: var(--space-2) 0 var(--space-4);
  max-height: calc(100vh - var(--nav-h)); overflow-y: auto;
}
.mobile-nav.is-open { display: block; animation: slideDown .22s ease; }
@keyframes slideDown { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:none} }
.mobile-nav ul { list-style: none; }
/* Each link gets a hairline divider so rows read as distinct tappable items
   instead of one continuous block of text — the flat, borderless list was
   the main "doesn't look professional" complaint. Subtle on purpose (low-
   opacity white on the dark drawer background); :last-child drops it so the
   list doesn't end on a stray line right before .mobile-user. */
.mobile-nav ul a {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  color: #bae6fd; font-size: .93rem; font-weight: 500;
  text-decoration: none; border-left: 3px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,.06);
  transition: background var(--tx), color var(--tx), border-color var(--tx);
}
.mobile-nav ul li:last-child a { border-bottom: none; }
.mobile-nav ul a:hover, .mobile-nav ul a.active {
  background: rgba(8,145,178,.14);
  border-left-color: var(--clr-gold);
  color: #fff; text-decoration: none;
}
.mobile-nav ul a.active {
  background: rgba(201,162,39,.14);
  box-shadow: inset 0 0 0 1px rgba(201,162,39,.25);
}
.mobile-nav .mobile-sub { padding-left: var(--space-5); background: rgba(0,0,0,.12); }

/* Section headers (Exams / Users / Results / …) — previously plain gold
   text with no background, so they blended straight into the link list
   below them. A tinted band + top/bottom rule makes each section read as a
   clear break when scanning a long admin menu, echoing the gold used for
   the active-link accent so the two read as one consistent color system
   rather than an arbitrary rainbow of section colors. */
.mobile-nav-cat {
  margin-top: var(--space-2);
  padding: 9px var(--space-5) 7px;
  font-size: .7rem; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  color: var(--clr-gold); background: rgba(201,162,39,.08);
  border-top: 1px solid rgba(201,162,39,.22);
  border-bottom: 1px solid rgba(201,162,39,.22);
  pointer-events: none;
}
.mobile-nav ul li:first-child .mobile-nav-cat { margin-top: 0; border-top: none; }

/* User info + Logout — pinned to the bottom of the drawer's own scroll area
   (.mobile-nav already has max-height + overflow-y:auto) rather than sitting
   after ~50 links, so it's reachable in one tap no matter how far down the
   menu the admin has scrolled. Solid background + shadow so the scrolling
   list is clearly going *behind* it, not just stopping short. */
.mobile-nav .mobile-user {
  position: sticky; bottom: 0; z-index: 1;
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4);
  background: #15152a;
  border-top: 1px solid rgba(186,230,253,.25);
  box-shadow: 0 -6px 12px -4px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
}
.mobile-nav .mobile-user .user-name {
  background: rgba(255,255,255,.12); border-radius: 20px;
  padding: 4px var(--space-3); color: #fff; font-weight: 600; font-size: .85rem;
}
.mobile-nav .mobile-user .btn-logout {
  background: var(--clr-danger); color: #fff;
  padding: 7px var(--space-3); border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 700; border: none; cursor: pointer;
  margin-left: auto;
}
.mobile-nav .mobile-user .btn-logout:hover { background: #dc2626; }

/* Backdrop */
.nav-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 480;
}
.nav-backdrop.is-open { display: block; }

/* ── Show desktop nav on lg+ (1024px) ───────────────────────
   Raised from 768 → 1024 so admin's many links don't overflow
   on tablets / mid-size laptops.                              */
@media (min-width: 1024px) {
  .navbar-links { display: flex; }
  .nav-toggle   { display: none; }
  .mobile-nav, .nav-backdrop { display: none !important; }
}

/* ── Responsive nav compaction ───────────────────────────────────────── */

/* 1200px and up: squeeze.
   .navbar-inner used to be capped at max-width:1280px (removed — the shell
   is now full-width, see .app-shell below), so a 9-item admin nav has
   plenty of room on wide screens today. This tier is kept as a deliberate
   density choice with no upper bound (rather than reverting to full-size
   padding/fonts above some breakpoint), since that's what previously
   caused the nav to overflow and overlap .navbar-user on screens ≥1440px
   back when the row's available width was capped regardless of monitor
   size. Safe to revisit now that width scales with the viewport. */
@media (min-width: 1200px) {
  .navbar-links a { padding: 18px 7px; font-size: .77rem; }
  .navbar-brand   { font-size: 1rem; padding: 0 8px; }
  .navbar-user .badge { display: none; }
}

/* 1024–1200px: most compact — hide user-name text, badge hidden */
@media (min-width: 1024px) and (max-width: 1200px) {
  .navbar-links a { padding: 18px 6px; font-size: .74rem; }
  .navbar-brand   { font-size: .9rem; padding: 0 6px; }
  .navbar-logo    { width: 34px; height: 34px; }
  .navbar-logo img, .navbar-logo-placeholder { width: 34px; height: 34px; }
  .navbar-user .user-name { display: none; }
  .navbar-user .badge { display: none; }
  .navbar-user .navbar-stats { display: none; }
  .navbar-user { gap: var(--space-1); }
}

/* Below 1024px: mobile — hide the desktop user pill entirely.
   Root cause of the missing hamburger: navbar-inner has no flex-wrap and
   body uses overflow-x:hidden, so once logo + brand + user-pill + logout
   + toggle exceed the viewport width, the rightmost item (the hamburger)
   got silently clipped off-screen. The same name/badge/logout info is
   already shown in #mobileNav .mobile-user, so it's safe to drop here —
   this guarantees .nav-toggle always has room and stays visible/tappable. */
@media (max-width: 1023px) {
  .navbar-user { display: none; }
}

/* ── Page Wrapper ─────────────────────────────────────────── */
/* Still used by a handful of pages that nest their own inner
   `.page-wrap` inside `.app-main` (write.php's exam-taking screen,
   AddUser/EditUser forms, UserChangeRequests, marks, ExamHistoryList).
   Widened from 1280px rather than uncapped like .app-shell above —
   long-form question text and form fields get hard to read/scan at
   full monitor width, so this keeps a comfortable reading measure while
   still using a lot more of a wide screen than the old 1280px cap did. */
.page-wrap {
  max-width: 1760px; margin: 0 auto;
  padding: var(--space-4);
}
@media (min-width: 768px) {
  .page-wrap { padding: var(--space-6) var(--space-5); }
}
@media (min-width: 1024px) {
  .page-wrap { padding: var(--space-8) var(--space-6); }
}

/* ── App Shell (sidebar + main content) ──────────────────────
   Replaces the old single `.page-wrap` as the outer chrome.
   Mobile/tablet (<1024px): plain block — sidebar is hidden and
   the hamburger `.mobile-nav` drawer (untouched) covers nav instead.
   Desktop (≥1024px): flex row — fixed-width sticky sidebar + fluid main.
   No max-width here (previously capped at 1280px) — on a wide monitor that
   left large empty margins either side of the sidebar/content since
   .app-main is already `flex: 1 1 auto`, i.e. built to fill whatever room
   it's given. Grids inside it (.exam-card-grid, .grid-auto, .filter-bar,
   .subject-grid) already use auto-fill/repeat so they naturally add more
   columns on the extra width instead of leaving it blank. */
@media (min-width: 1024px) {
  .app-shell { display: flex; align-items: flex-start; }
}

.app-main {
  min-width: 0; flex: 1 1 auto;
  padding: var(--space-4);
}
@media (min-width: 768px) {
  .app-main { padding: var(--space-6) var(--space-5); }
}
@media (min-width: 1024px) {
  .app-main { padding: var(--space-8) var(--space-6); }
}

/* ── Left Sidebar ─────────────────────────────────────────────
   Persistent, always-visible (no JS collapse) per design — the
   only "collapsing" affordance is the native <details> per-group
   disclosure below, which keeps a long admin menu scannable. */
.app-sidebar { display: none; }
@media (min-width: 1024px) {
  .app-sidebar {
    display: block;
    flex: 0 0 232px; width: 232px;
    position: sticky; top: var(--nav-h);
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    background: #1a1a2e;
    border-right: none;
    padding: var(--space-2) 0 var(--space-4);
  }
  .app-sidebar::-webkit-scrollbar { width: 5px; }
  .app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 4px; }
}

/* Flat link / group summary — shared base look */
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--space-3);
  border-radius: 0;
  color: rgba(255,255,255,.88);
  font-size: .86rem; font-weight: 600;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background var(--tx), color var(--tx);
}
.sb-link:hover { background: rgba(0,0,0,.18); color: #fff; text-decoration: none; }
.sb-link.active { background: rgba(0,0,0,.28); color: #fff; font-weight: 800; }
.sb-ic { flex-shrink: 0; width: 20px; text-align: center; font-size: 1rem; line-height: 1; }
.sb-label { flex: 1; min-width: 0; }

/* Collapsible group — native <details>, zero JS */
.sb-group { margin-bottom: 1px; }
.sb-group > .sb-summary { list-style: none; }
.sb-group > .sb-summary::-webkit-details-marker { display: none; }
.sb-caret { flex-shrink: 0; font-size: .65em; opacity: .65; transition: transform .18s ease; }
.sb-group[open] > .sb-summary .sb-caret { transform: rotate(90deg); }

.sb-sub {
  display: flex; flex-direction: column;
  margin: 2px 0 6px 19px; padding-left: 12px;
  border-left: 2px solid rgba(255,255,255,.20);
}
.sb-sublink {
  display: flex; align-items: center; gap: 6px;
  padding: 7px var(--space-2) 7px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.78);
  font-size: .80rem; font-weight: 500;
  text-decoration: none;
  transition: background var(--tx), color var(--tx);
}
.sb-sublink:hover { background: rgba(0,0,0,.18); color: #fff; text-decoration: none; }
.sb-sublink.active { background: rgba(0,0,0,.28); color: #fff; font-weight: 700; }

.sb-badge {
  background: #fcd34d; color: #78350f; border-radius: 99px;
  padding: 1px 6px; font-size: .68rem; font-weight: 800;
  margin-left: 2px;
}

.sb-divider { height: 1px; background: rgba(255,255,255,.20); margin: var(--space-3) var(--space-2); }

/* ── Cards / Panels ───────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
  overflow: hidden;
}
.card-header {
  background: var(--clr-primary);
  color: #fff; padding: var(--space-3) var(--space-5);
  font-size: .97rem; font-weight: 700; letter-spacing: .2px;
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
/* Simple text card-headers stay left-aligned without flex side-effects */
.card-header:only-child,
.card-header > :only-child { flex: none; }
.card-body { padding: var(--space-4); }
@media (min-width: 768px) {
  .card-body { padding: var(--space-5); }
}

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

/* Always wrap tables in this for horizontal scroll on mobile */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.tbl {
  width: 100%; border-collapse: collapse;
  font-size: .84rem; min-width: 480px; /* keeps columns intact on scroll */
}
.tbl th {
  background: #0c4a6e; color: #e0e7ff;
  padding: var(--space-2) var(--space-3);
  text-align: left; font-weight: 600; font-size: .80rem;
  white-space: nowrap;
}
.tbl td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--clr-bg);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:nth-child(odd)  td { background: var(--clr-surface); }
.tbl tr:nth-child(even) td { background: var(--clr-bg); }
.tbl tbody tr:hover td { background: var(--clr-primary-pale); transition: background var(--tx); }

/* Exam question table */
.tbl-exam th { background: var(--clr-primary); }
.tbl-exam td { font-size: .85rem; vertical-align: top; padding: 6px 8px; }
.tbl-exam .qnum { text-align: center; font-weight: 700; width: 36px; background: var(--clr-primary-pale); color: #083650; }

/* Result colouring */
.cell-correct { background: #dcfce7 !important; }
.cell-wrong   { background: #fee2e2 !important; }
.cell-skip    { background: var(--clr-bg) !important; }

/* Inject tbl-wrap automatically around .card-body tables via JS (fallback: add manually) */

/* Responsive column visibility helpers — use on <th> and <td> pairs */
/* col-hide-xs: hidden below 640px  |  col-hide-sm: hidden below 480px */
@media (max-width: 639px) { .col-hide-xs { display: none !important; } }
@media (max-width: 479px) { .col-hide-sm { display: none !important; } }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block; margin-bottom: 5px;
  font-weight: 700; color: var(--clr-primary); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .05em;
}
.form-control {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--clr-border-2); border-radius: var(--radius);
  font-size: .9rem; color: var(--clr-text);
  background: var(--clr-surface);
  transition: border-color var(--tx), box-shadow var(--tx);
  -webkit-appearance: none; appearance: none;
  min-height: 44px; /* touch target */
}
.form-control:focus {
  outline: none; border-color: var(--clr-primary-light);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}
.form-control:disabled { background: var(--clr-bg); cursor: not-allowed; color: var(--clr-text-faint); }
.form-control.is-invalid {
  border-color: var(--clr-danger);
}
.form-control.is-invalid:focus {
  border-color: var(--clr-danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.18);
}
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 36px; }
textarea.form-control { min-height: 88px; resize: vertical; }

/* ── Shared phone-number widget (country code + numeric input) ──────────
   Used by any "Mobile Number" field — see Lib/Phone.php (server) and
   assets/phone-input.js (client) for the matching validation rules. */
.phone-input-wrap {
  display: flex; border: 1.5px solid var(--clr-border-2); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--clr-surface);
  transition: border-color var(--tx), box-shadow var(--tx);
}
.phone-input-wrap:focus-within { border-color: var(--clr-primary); box-shadow: 0 0 0 3px var(--clr-primary-pale); }
.phone-input-wrap.error { border-color: var(--clr-danger); box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
.phone-input-wrap.ok    { border-color: #38a169; box-shadow: 0 0 0 3px rgba(56,161,105,.12); }
.phone-cc-select {
  flex-shrink: 0; border: none; border-right: 1px solid var(--clr-border);
  padding: 0 10px; height: 42px; font-size: .84rem;
  background: var(--clr-bg); color: var(--clr-text); cursor: pointer; outline: none;
  max-width: 190px; min-width: 130px;
}
.phone-cc-select:focus { background: var(--clr-primary-pale); }
.phone-num-input {
  flex: 1; border: none; padding: 0 12px; height: 42px;
  font-size: .9rem; outline: none; background: transparent; min-width: 0;
}
.mobile-hint  { display: block; margin-top: 4px; font-size: .78rem; color: var(--clr-text-muted); }
.mobile-error { display: none; margin-top: 4px; font-size: .78rem; color: var(--clr-danger); font-weight: 600; }
.mobile-error.visible { display: block; }

/* Responsive form grids */
.form-row { display: grid; gap: 0 var(--space-4); }
.form-row.cols-2 { grid-template-columns: 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.form-row .span-full { grid-column: 1 / -1; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 10px var(--space-5); border: none;
  border-radius: var(--radius); font-size: .875rem; font-weight: 600;
  cursor: pointer; text-align: center; white-space: nowrap;
  transition: background var(--tx), transform .1s, box-shadow var(--tx), opacity var(--tx);
  text-decoration: none; min-height: 44px; /* touch target */
  -webkit-user-select: none; user-select: none;
}
.btn:hover   { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.14); text-decoration: none; }
.btn:active  { transform: translateY(0); box-shadow: none; }
.btn:disabled{ opacity: .55; pointer-events: none; }
/* btn-primary: gold — stands out against the green theme, mirrors logo's golden glow */
.btn-primary   { background: var(--clr-gold); color: #0d1f14; font-weight: 700; }
.btn-primary:hover   { background: var(--clr-gold-light); color: #0d1f14; }
/* btn-success: forest green — save/confirm actions */
.btn-success   { background: var(--clr-primary-light); color: #fff; }
.btn-success:hover   { background: var(--clr-primary); color: #fff; }
.btn-danger    { background: var(--clr-danger); color: #fff; }
.btn-danger:hover    { background: #b91c1c; color: #fff; }
.btn-secondary { background: var(--clr-bg); color: var(--clr-text-muted); border: 1.5px solid var(--clr-border-2); }
.btn-secondary:hover { background: var(--clr-border); color: var(--clr-text); }
.btn-warning   { background: var(--clr-gold); color: #0d1f14; font-weight: 700; }
.btn-warning:hover   { background: var(--clr-gold-light); color: #0d1f14; }
.btn-sm { padding: 6px var(--space-3); font-size: .79rem; min-height: 34px; border-radius: var(--radius-sm); }
.btn-xs { padding: 3px 7px; font-size: .72rem; min-height: 26px; border-radius: var(--radius-sm); white-space: nowrap; }

/* Full-width button helper */
.btn-block { width: 100%; }

/* Responsive button groups */
.btn-group { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.btn-group.stack-mobile { flex-direction: column; }
@media (min-width: 480px) {
  /* Once there's room to go side-by-side, keep both buttons on one row
     instead of letting them wrap back into a column. */
  .btn-group.stack-mobile { flex-direction: row; flex-wrap: nowrap; gap: 4px; }
}

/* Single-row action strip — never wraps */
.btn-group.nowrap { flex-wrap: nowrap; gap: 3px; }
/* On phones, let admin's compact action row (Preview/Hist/Edit/...) wrap
   into multiple lines instead of squeezing into one unreadable, hard-to-
   tap horizontal-scroll strip. */
@media (max-width: 640px) {
  .btn-group.nowrap { flex-wrap: wrap; }
}

/* ── Alert / Message Boxes ────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  margin-bottom: var(--space-4); font-size: .875rem;
  border-left: 4px solid transparent; line-height: 1.5;
}
.alert-success { background: #ecfdf5; border-color: var(--clr-success); color: #065f46; }
.alert-danger,
.alert-error   { background: #fef2f2; border-color: var(--clr-danger);  color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: var(--clr-warning); color: #92400e; }
.alert-info    { background: #ecfeff; border-color: var(--clr-info);    color: #164e63; }

/* ── Badges & Tags ───────────────────────────────────────── */
.badge-pass   { background: #dcfce7; color: #166534; }
.badge-fail   { background: #fee2e2; color: #991b1b; }
.tag {
  display: inline-block; padding: 2px var(--space-2);
  border-radius: var(--radius-sm); font-size: .73rem; font-weight: 700;
}
.tag-create { background: #dcfce7; color: #166534; }
.tag-edit   { background: var(--clr-primary-pale); color: #083650; }
.tag-delete { background: #fee2e2; color: #991b1b; }
.tag-taken  { background: #fef3c7; color: #78350f; }

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-wrap {
  width: 100%; max-width: 460px;
  margin: var(--space-6) auto;
  background: var(--clr-surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: visible;
}
@media (max-width: 479px) {
  .auth-wrap {
    margin: var(--space-4) var(--space-3);
    width: calc(100% - var(--space-6));
    border-radius: var(--radius-lg);
  }
}
.auth-header {
  background: linear-gradient(155deg, var(--clr-primary) 0%, #083650 60%, #0c4a6e 100%);
  padding: 32px var(--space-5) 24px; text-align: center;
  position: relative; overflow: visible;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;  /* keep card top corners */
}
/* subtle gold shimmer strip at bottom of auth header */
.auth-header::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--clr-gold), transparent);
}
/* Auth logo — much bigger, same white-separator + gold-ring treatment as navbar */
.auth-logo {
  width: 110px; height: 110px;
  border-radius: 50%;
  background: transparent;
  margin: 0 auto var(--space-4);
  display: flex; align-items: center; justify-content: center;
  overflow: visible;
  box-shadow:
    0 0 0 3px #fff,                          /* white separator ring */
    0 0 0 6px rgba(8,145,178,.90),          /* bold gold ring       */
    0 0 28px 8px rgba(8,145,178,.45),       /* wide gold glow       */
    0 8px 24px rgba(0,0,0,.45);             /* drop shadow          */
}
.auth-logo img {
  width: 110px; height: 110px;
  border-radius: 50%; object-fit: cover; display: block;
}
.auth-logo-placeholder {
  width: 110px; height: 110px; border-radius: 50%; background: #000;
  font-size: .7rem; font-weight: 700;
  color: rgba(186,230,253,.8); text-align: center; line-height: 110px;
}
.auth-header h1 { color: #fff; font-size: 1.35rem; margin-bottom: 0; font-weight: 800; }
.auth-header p  { color: var(--clr-primary-accent); font-size: .85rem; }
.auth-body { padding: var(--space-5); }
@media (min-width: 480px) { .auth-body { padding: var(--space-8); } }

/* ── Exam Write Page ─────────────────────────────────────── */
.exam-header {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--clr-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); margin-bottom: var(--space-4);
  position: sticky; top: var(--nav-h); z-index: 100;
}
.exam-header .timer-wrap { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
#countdown {
  font-weight: 800; font-size: 1.2rem;
  color: var(--clr-danger); letter-spacing: 1px;
}
#countdown.warn { animation: pulse .8s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Question cards on mobile */
.question-card {
  background: var(--clr-surface); border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.question-card:focus-within { border-color: var(--clr-primary-accent); }

/* ── Progress Bar ─────────────────────────────────────────── */
.answer-progress {
  background: var(--clr-border); border-radius: 6px;
  height: 8px; overflow: hidden; margin: 6px 0;
}
.answer-progress-bar {
  height: 100%; background: var(--clr-success);
  border-radius: 6px; transition: width .3s;
}

/* ── Filters Bar ─────────────────────────────────────────── */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
@media (min-width: 480px) { .filter-bar { grid-template-columns: 1fr 1fr; } }
@media (min-width: 768px) { .filter-bar { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }
@media (min-width: 1024px) { .filter-bar { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .filter-actions {
  display: flex; align-items: flex-end; gap: var(--space-2); flex-wrap: wrap;
}

/* ── Inline filter-bar labels (horizontal flex rows) ─────── */
/* Used in pages where labels sit beside inputs in a flex row  */
.filter-bar label,
.au-search label,
.filter-row label,
.filter-strip label {
  font-size: .72rem;
  font-weight: 800;
  color: var(--clr-primary);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

/* ── Generic Responsive Grid ─────────────────────────────── */
.grid-auto {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px)  { .grid-auto { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-auto { grid-template-columns: repeat(3, 1fr); } }

/* Stat chips row */
.stat-row {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.stat-chip {
  flex: 1 1 80px;
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-lg); font-size: .75rem;
  text-align: center; min-width: 72px;
}
.stat-chip strong { font-size: 1.45rem; font-weight: 800; line-height: 1.2; }

/* ── Flex utilities ───────────────────────────────────────── */
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 4px; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-4); }
.justify-between { justify-content: space-between; }

/* Stack flex items on mobile */
.flex-col-mobile { flex-direction: column; }
@media (min-width: 480px) { .flex-col-mobile { flex-direction: row; } }

/* ── Spacing utilities ───────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }

/* ── Action bar (admin toolbar) ──────────────────────────── */
.action-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-2); padding: var(--space-3) var(--space-4);
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex; gap: var(--space-1); flex-wrap: wrap;
  margin-top: var(--space-3); justify-content: center;
}
.pg-btn {
  padding: 6px 12px; border: 1.5px solid var(--clr-border-2);
  border-radius: var(--radius-sm); background: var(--clr-surface);
  color: var(--clr-text-muted); font-size: .82rem;
  text-decoration: none; min-height: 38px;
  display: inline-flex; align-items: center;
  transition: background var(--tx), color var(--tx);
}
.pg-btn:hover   { background: var(--clr-bg); text-decoration: none; }
.pg-btn.active  { background: var(--clr-primary-light); color: #fff; border-color: var(--clr-primary-light); font-weight: 700; }
.pg-btn.disabled{ opacity: .4; pointer-events: none; }

/* ── Score bar ───────────────────────────────────────────── */
.score-bar-wrap { display: flex; align-items: center; gap: var(--space-2); }
.score-bar-bg   { flex: 1; height: 7px; background: var(--clr-border); border-radius: 4px; min-width: 40px; }
.score-bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 9000;
  align-items: center; justify-content: center;
  padding: var(--space-4);
}
.modal-backdrop.is-open { display: flex; }
.modal-box {
  background: var(--clr-surface); border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin: 0 0 var(--space-4); font-size: 1.05rem; color: var(--clr-primary); }

/* ── Result banner ───────────────────────────────────────── */
.result-banner {
  border-radius: var(--radius-xl);
  padding: var(--space-5); margin-bottom: var(--space-5);
  text-align: center;
  display: grid; grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 640px) {
  .result-banner { grid-template-columns: 1fr auto 1fr; align-items: center; text-align: left; }
}
.result-banner .res-card {
  background: rgba(255,255,255,.25); border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4); font-size: .82rem;
  display: flex; flex-direction: column; gap: 2px;
}
.result-banner .res-score-big { font-size: 3rem; font-weight: 900; line-height: 1; }

/* ── Subject browse cards ────────────────────────────────── */
.subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 480px) { .subject-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .subject-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px){ .subject-grid { grid-template-columns: repeat(4, 1fr); } }

.subject-card {
  background: var(--clr-surface); border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-xl); padding: var(--space-5);
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--tx), transform var(--tx);
}
.subject-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* ── Coupon / fee form grids ─────────────────────────────── */
.form-grid-2 { display: grid; gap: 0 var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 600px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }
