/* ============================================================================
   CBT PLATFORM DESIGN SYSTEM
   Concept: "Exam Hall, Digitized" — official West African exam-body document
   language (ruled answer sheets, reference codes, seals, OMR scan forms)
   rebuilt as clean modern software. Loaded after Bootstrap; only overrides
   what needs a distinct identity, doesn't fight the grid/utilities.
   ============================================================================ */

/* ---- Type: local, self-hosted — works with zero internet on the offline client ---- */
@font-face {
  font-family: 'Archivo'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/archivo/archivo-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Archivo'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/archivo/archivo-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/inter/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/inter/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/inter/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/ibm-plex-mono/ibm-plex-mono-latin-600-normal.woff2') format('woff2');
}

:root {
  /* ---- Palette: deep exam-navy ink on pale OMR-sheet paper ---- */
  --ink:          #0B2545;   /* headers, sidebar, primary ink */
  --ink-soft:     #1D3A63;
  --sheet:        #EEF2F6;   /* page background — pale scan-sheet blue-grey */
  --paper:        #FFFFFF;   /* card/surface background */
  --rule:         #D7DEE7;   /* hairline rule color, like a ruled answer sheet */
  --graphite:     #2B2E33;   /* body text */
  --graphite-soft:#5B6472;   /* secondary text */
  --seal-green:   #16693F;   /* verified / correct / published / paid */
  --seal-green-bg:#E7F3EC;
  --alert-red:    #C1272D;   /* timer warning / wrong / danger */
  --alert-red-bg: #FBEAEA;
  --stamp-gold:   #A8790F;   /* purchased pack / premium badge */
  --stamp-gold-bg:#FBF3E1;

  --font-display: 'Archivo', 'Segoe UI', sans-serif;
  --font-body:    'Inter', 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

body {
  background: var(--sheet);
  color: var(--graphite);
  font-family: var(--font-body);
}
/* Safety net against horizontal scroll: position:fixed elements (toasts,
   the mobile sidebar toggle, dialogs, etc.) are placed relative to the
   viewport and are NOT contained by a parent's overflow-x, so a single
   pixel of fixed-position overflow anywhere can drag the whole document
   sideways on a phone. This closes that off platform-wide. */
html { overflow-x: hidden; }
body.dark-mode {
  --sheet: #0E1116; --paper: #171B22; --rule: #2A3038; --graphite: #E7ECF1; --graphite-soft: #9AA4B2;
}
h1, h2, h3, h4, h5, h6, .display-font { font-family: var(--font-display); font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 { color: #E7ECF1; }
code, .font-mono, .cbt-serial { font-family: var(--font-mono); }

/* ---- "Admission slip" sidebar: a ribbon of deep exam-ink, not generic Bootstrap navy ---- */
.app-sidebar {
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 100%);
  color: #fff; min-height: 100vh; position: relative;
}
.app-sidebar::after {
  /* perforation edge, like a tear-off admission slip */
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background-image: linear-gradient(var(--sheet) 50%, transparent 0%);
  background-size: 1px 10px; opacity: .35;
}
.app-sidebar .brand { font-family: var(--font-display); font-weight: 700; letter-spacing: .02em; }
.app-sidebar a { color: rgba(255,255,255,.78); text-decoration: none; display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; border-radius: var(--radius-sm); font-size: .925rem; }
.app-sidebar a.active, .app-sidebar a:hover { background: rgba(255,255,255,.12); color: #fff; }
.app-sidebar a.active { box-shadow: inset 3px 0 0 var(--stamp-gold); }

.app-topbar { background: var(--paper); border-bottom: 1px solid var(--rule); }
body.dark-mode .app-topbar { background: var(--paper); border-color: var(--rule); }

/* ============================================================================
   MOBILE APP SHELL — off-canvas sidebar for every internal dashboard page.
   Desktop keeps the original fixed 240px column; below 992px the sidebar
   becomes a slide-in drawer toggled by the fixed hamburger button that's
   injected right after <body>, with a tap-to-dismiss backdrop.
   ============================================================================ */
.app-sidebar-wrap { width: 240px; flex-shrink: 0; }

.cbt-sidebar-toggle {
  position: fixed; top: .75rem; left: .75rem; z-index: 1060;
  width: 2.5rem; height: 2.5rem; border-radius: 50%; border: none;
  background: var(--ink); color: #fff; display: grid; place-content: center;
  font-size: 1.05rem; box-shadow: 0 2px 10px rgba(11,37,69,.35); cursor: pointer;
}
.cbt-sidebar-toggle:hover { background: var(--ink-soft); }

.cbt-sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(11,37,69,.45); z-index: 1040;
  opacity: 0; visibility: hidden; transition: opacity .2s ease;
}
.cbt-sidebar-backdrop.show { opacity: 1; visibility: visible; }

.app-sidebar-close { display: none; }

@media (min-width: 992px) {
  .cbt-sidebar-toggle, .cbt-sidebar-backdrop { display: none !important; }
}

@media (max-width: 991.98px) {
  .app-sidebar-wrap {
    position: fixed; top: 0; left: 0; bottom: 0; width: 270px; max-width: 82vw;
    z-index: 1050; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 6px 0 28px rgba(11,37,69,.3); overflow-y: auto;
  }
  .app-sidebar-wrap.show { transform: translateX(0); }
  .app-sidebar-wrap .app-sidebar { min-height: 100%; }
  .app-sidebar-close {
    display: grid; place-content: center; position: absolute; top: .6rem; right: .6rem;
    width: 2rem; height: 2rem; border-radius: 50%; border: none; background: rgba(255,255,255,.12);
    color: #fff; font-size: 1rem;
  }
  /* Leave clear room so page titles never sit under the fixed hamburger button */
  .app-topbar { padding-left: 3.5rem !important; }
  body.cbt-no-scroll { overflow: hidden; }
}

/* ============================================================================
   MOBILE TABLES — scroll horizontally within their own box instead of
   squeezing every column unreadably narrow. Applies site-wide with no
   per-page markup changes required.
   ============================================================================ */
@media (max-width: 767.98px) {
  table.table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.table thead, table.table tbody { display: table; width: 100%; }
}

/* Notification bell dropdown: cap width so it never overflows a narrow phone */
@media (max-width: 480px) {
  #notifBellPanel { width: calc(100vw - 2rem) !important; right: -.5rem; left: auto !important; }
}

/* ---- Cards styled like an official score/result slip: a small serial tag in the corner ---- */
.card {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(11,37,69,.04);
}
.card.stat-card { border-top: 3px solid var(--ink); }
.card.stat-card .stat-value { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 600; color: var(--ink); }
body.dark-mode .card.stat-card .stat-value { color: #fff; }

/* ---- Buttons: squarer, more "form" than "app store" ---- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; }
.btn-primary { background: var(--ink); border-color: var(--ink); }
.btn-primary:hover, .btn-primary:focus { background: var(--ink-soft); border-color: var(--ink-soft); }
.btn-success { background: var(--seal-green); border-color: var(--seal-green); }
.btn-outline-primary { color: var(--ink); border-color: var(--ink); }
.btn-outline-primary:hover { background: var(--ink); border-color: var(--ink); }

/* ---- Badges: pass/fail/seal language instead of generic Bootstrap pill colors ---- */
.badge.bg-success { background: var(--seal-green) !important; }
.badge.bg-danger  { background: var(--alert-red) !important; }
.badge-seal { display:inline-flex; align-items:center; gap:.3rem; background: var(--seal-green-bg); color: var(--seal-green); border: 1px solid currentColor; border-radius: 999px; padding: .15rem .65rem; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.badge-premium { display:inline-flex; align-items:center; gap:.3rem; background: var(--stamp-gold-bg); color: var(--stamp-gold); border: 1px solid currentColor; border-radius: 999px; padding: .15rem .65rem; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }

/* ---- Reference-code tag: every pack/exam gets a serial, like a real exam paper ---- */
.cbt-ref { font-family: var(--font-mono); font-size: .72rem; color: var(--graphite-soft); letter-spacing: .04em; }

/* ---- Ruled section divider — a nod to the ruled lines of an actual answer sheet ---- */
.cbt-rule { border: 0; border-top: 1px solid var(--rule); margin: 1.25rem 0; }
.cbt-rule.thick { border-top-width: 2px; border-color: var(--ink); opacity: .15; }

table { --bs-table-color: var(--graphite); }
.table thead th { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--graphite-soft); border-bottom: 2px solid var(--rule); font-weight: 600; }

/* ============================================================================
   SIGNATURE COMPONENT: the exam-taking interface.
   Countdown styled like a physical exam-hall wall clock; answer options
   styled like shading a bubble on an OMR sheet — the one moment every
   student spends real time inside, so it's where the identity should show.
   ============================================================================ */
.exam-clock {
  font-family: var(--font-mono); font-weight: 600; font-size: 1.4rem; letter-spacing: .03em;
  display: inline-flex; align-items: center; gap: .5rem; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 999px; padding: .4rem 1rem; color: var(--ink);
}
.exam-clock.low-time { border-color: var(--alert-red); color: var(--alert-red); animation: cbt-pulse 1s ease-in-out infinite; }
@keyframes cbt-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .exam-clock.low-time { animation: none; } }

.cbt-qnum { font-family: var(--font-mono); font-size: .78rem; color: var(--graphite-soft); letter-spacing: .03em; }

/* OMR-style option row: a shaded circle "bubble" instead of a generic radio dot */
.cbt-option { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem .9rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); margin-bottom: .5rem; cursor: pointer; background: var(--paper); transition: border-color .12s, background .12s; }
.cbt-option:hover { border-color: var(--ink); }
.cbt-option input[type="radio"] { appearance: none; width: 1.35rem; height: 1.35rem; flex: none; margin-top: .05rem; border: 2px solid var(--graphite-soft); border-radius: 50%; display: grid; place-content: center; }
.cbt-option input[type="radio"]::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; transform: scale(0); transition: transform .1s; background: var(--ink); }
.cbt-option input[type="radio"]:checked::before { transform: scale(1); }
.cbt-option:has(input:checked) { border-color: var(--ink); background: #F1F5FB; }
body.dark-mode .cbt-option:has(input:checked) { background: #1A2333; }
.cbt-option .cbt-option-letter { font-family: var(--font-mono); font-weight: 600; color: var(--graphite-soft); }

/* Question navigator grid — answered/flagged/unanswered read like a filled-in OMR sheet */
.cbt-navgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.cbt-navgrid button {
  font-family: var(--font-mono); font-weight: 600; font-size: .8rem; aspect-ratio: 1;
  border-radius: 50%; border: 1.5px solid var(--rule); background: var(--paper); color: var(--graphite-soft);
}
.cbt-navgrid button.answered { background: var(--seal-green); border-color: var(--seal-green); color: #fff; }
.cbt-navgrid button.flagged { background: var(--stamp-gold); border-color: var(--stamp-gold); color: #fff; }
.cbt-navgrid button.current { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---- Accessibility floor ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .cbt-option:focus-within {
  outline: 2px solid var(--ink); outline-offset: 2px;
}

/* ---- Print support (Phase 17) ----
   Global, not page-specific: the sidebar/topbar/action-button chrome every
   page already shares (.cbt-sidebar-toggle, .app-sidebar-wrap, .app-topbar)
   is hidden on every page when printed, not just result pages, so "Print"
   anywhere in the app produces a clean page by default. .no-print marks
   anything else (export buttons, nav links) a specific page wants hidden
   too; .print-only marks something (a report header/letterhead) meant to
   appear ONLY in the printed/PDF-adjacent view, never on screen. */
@media print {
  .cbt-sidebar-toggle, .cbt-sidebar-backdrop, .app-sidebar-wrap, .app-topbar, .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }
}
.print-only { display: none; }
