/* Exam Sim — clean, minimal, offline-friendly styling. */

:root {
  /* Type — ui-ux-pro-max "Corporate Trust": Lexend headings + Inter body.
     Gracefully falls back to system fonts when offline. */
  --font-heading: 'Lexend', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  /* True-black palette — pure black canvas, neutral surfaces, blue/gold accents */
  --bg: #000000;
  --bg-2: #050505;
  --surface: #0e0e10;
  --surface-2: #18181c;
  --border: #2a2a30;
  --border-strong: #3a3a42;
  --text: #f0f2f6;
  --text-dim: #9a9aa6;
  --text-strong: #ffffff;

  --accent: #3a93ff;
  --accent-hover: #5aa6ff;
  --accent-soft: rgba(58, 147, 255, 0.14);
  --accent-grad: linear-gradient(135deg, #3a93ff 0%, #4fd1e6 100%);
  --gold: #f6c45a;
  --gold-soft: rgba(246, 196, 90, 0.16);

  --correct: #2fd08a;
  --correct-soft: rgba(47, 208, 138, 0.14);
  --wrong: #f06363;
  --wrong-soft: rgba(240, 99, 99, 0.14);
  --warn: #f3b042;
  --warn-soft: rgba(243, 176, 66, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 50px -14px rgba(0, 0, 0, 0.62);
  --glow-accent: 0 6px 20px -4px rgba(58, 147, 255, 0.45);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visible, accessible focus ring on all interactive elements. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings carry the Lexend voice; numeric UI uses tabular figures so
   timers/scores/counters don't jitter as digits change. */
h1, h2, h3, h4, .brand h1, .card h3, .panel h3, .cat-code, .score-pct, .auth-card h2 {
  font-family: var(--font-heading);
}
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.015em; }
.score-pct, .result-stat .n, .qnav-dot, #progress, .timer, .pay-meta code {
  font-variant-numeric: tabular-nums;
}

header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0 0 4px 0; font-size: 28px; }
header .tag { margin: 0; color: var(--text-dim); font-size: 14px; font-weight: 500; }
header .tag-sub { margin: 3px 0 0 0; color: var(--text-dim); font-size: 12.5px; opacity: 0.82; }
header .stats { margin: 6px 0 0 0; color: var(--text-dim); font-size: 13px; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.screen { animation: fadein 0.2s ease-out; }
.screen.hidden { display: none; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

h2 { margin: 0 0 20px 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  text-align: left;
  color: var(--text);
  font: inherit;
  width: 100%;
}
.card:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.card h3 { margin: 0 0 4px 0; font-size: 16px; }
/* Smaller descriptor line under an exam abbreviation, e.g. "(Officer in Charge of a Navigational Watch)" */
.exam-sub { display: block; margin-top: 3px; font-size: 11px; font-weight: 500; color: var(--text-dim); letter-spacing: 0; line-height: 1.25; }
/* On the larger exam-page heading, size the descriptor relative to the big title. */
#cat-title .exam-sub { font-size: 0.45em; margin-top: 5px; }
.card .meta { color: var(--text-dim); font-size: 13px; }
.card[disabled] { opacity: 0.4; cursor: not-allowed; }

button {
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: var(--surface); border-color: var(--accent); }
button.primary {
  background: var(--accent-grad);
  color: white;
  border-color: transparent;
}
button.primary:hover { filter: brightness(1.08); border-color: transparent; }
button.back { background: transparent; border: none; color: var(--text-dim); padding: 4px 0; margin-bottom: 12px; }
button.back:hover { color: var(--text); border: none; background: transparent; }

.quiz-options {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.quiz-options label { color: var(--text-dim); font-size: 14px; }
.quiz-options input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  width: 70px;
  font: inherit;
}

.quiz-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 0 18px 0;
  border-bottom: 1px solid var(--border);
}
.quiz-head > * { padding: 0; }
.quiz-head .back { margin: 0; }
.quiz-head #progress { flex: 1; text-align: center; color: var(--text-dim); }
.timer { font-variant-numeric: tabular-nums; color: var(--warn); font-weight: 600; }

#question-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin: 20px 0;
}
#question-text {
  font-size: 17px;
  margin: 0 0 18px 0;
  line-height: 1.55;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface-2);
  transition: background 0.12s, border-color 0.12s;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.correct { border-color: var(--correct); background: var(--correct-soft); }
.choice.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.choice .letter {
  font-weight: 700;
  background: var(--bg);
  border-radius: 4px;
  width: 26px;
  text-align: center;
  flex-shrink: 0;
}
.choice .text { flex: 1; }

.quiz-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.hidden { display: none !important; }

/* Results page */
.score-box {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 28px;
}
.score-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 4px solid var(--accent);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.score-circle span { font-size: 32px; font-weight: 700; }
#score-detail { font-size: 18px; margin: 0; }
#score-time { color: var(--text-dim); margin: 4px 0 0 0; font-size: 14px; }

.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 10px 0;
}
.review-item.correct { border-left: 4px solid var(--correct); }
.review-item.wrong { border-left: 4px solid var(--wrong); }
.review-item .q { font-weight: 500; margin: 0 0 8px 0; }
.review-item .ans { color: var(--text-dim); font-size: 14px; margin: 2px 0; }
.review-item .ans.user { color: var(--wrong); }
.review-item .ans.correct { color: var(--correct); }

/* ---- Exam-security: block selection / copy on quiz + review ----
   This is a deterrent (DevTools still works), not real security.
   Re-enable for one element by giving it the .selectable class. */
.no-copy,
.no-copy *,
#screen-quiz,
#screen-quiz *,
#screen-results,
#screen-results * {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}
#screen-quiz ::selection,
#screen-results ::selection { background: transparent; color: inherit; }

/* Escape hatch in case any specific element should remain selectable
   (e.g. the timer for screenshots) — opt-in with class="selectable". */
.selectable, .selectable * { user-select: text !important; -webkit-user-select: text !important; }

/* Category-screen subtitle line (used for the random "X questions ready
   (new Item Y total)" hint shown to non-admin users — see app.js). */
.cat-title-meta {
  margin: -10px 0 14px 0;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Small locked-padlock hint badge in the quiz header */
.lock-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---- Header / user chip ---- */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.brand { flex: 1; display: flex; align-items: center; gap: 16px; }
.brand-logo { width: 67px; height: 67px; flex: none; filter: drop-shadow(0 4px 10px rgba(58, 147, 255, 0.28)); }
.brand-text { min-width: 0; }
.header-right { text-align: right; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px 4px 14px;
  font-size: 13px;
  margin-top: 6px;
}
.role-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.role-badge.admin { background: var(--accent); color: white; }
.role-badge.user { background: var(--surface-2); color: var(--text-dim); }
.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.link-btn:hover { color: var(--accent-hover); background: transparent; border: none; text-decoration: underline; }

/* Icon-only buttons (e.g. Account / Logout in the user chip) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }
.icon-btn.danger:hover { background: var(--wrong-soft); color: var(--wrong); }

/* ---- Auth card ---- */
.auth-card {
  max-width: 380px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
}
.auth-card h2 { margin-top: 0; }
.muted { color: var(--text-dim); font-size: 13px; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-dim);
}
.form input, .form select, .form textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form input:disabled {
  background: var(--surface);
  color: var(--text-dim);
  cursor: not-allowed;
}
.form button { align-self: flex-start; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form.inline label { flex: 1; min-width: 140px; }
.range-row { display: flex; gap: 12px; }
.range-row label { flex: 1; }

.form-msg { margin: 4px 0 0 0; font-size: 13px; min-height: 1em; }
.form-msg.error { color: var(--wrong); }
.form-msg.success { color: var(--correct); }

/* ---- Dashboard panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 18px;
}
.panel h3 { margin: 0 0 12px 0; font-size: 15px; }

/* ---- Payment rows ---- */
.payment-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--surface-2);
}
.payment-row.status-pending { border-left: 4px solid var(--warn); }
.payment-row.status-approved { border-left: 4px solid var(--correct); }
.payment-row.status-rejected { border-left: 4px solid var(--wrong); }
.pay-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.pay-meta { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.pay-meta code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}
.pay-notes { font-size: 13px; color: var(--text-dim); margin-top: 6px; font-style: italic; }
.receipt-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.receipt-link:hover { text-decoration: underline; }

/* Receipt upload (payment form) */
.file-input {
  width: 100%;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}
.file-input::file-selector-button {
  margin-right: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.file-input::file-selector-button:hover { color: var(--accent); border-color: var(--accent); }
.receipt-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: -4px;
}
.receipt-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}
.pay-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.pay-actions input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
}

.status-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}
.status-tag.status-pending { background: rgba(243,176,66,0.15); color: var(--warn); }
.status-tag.status-approved { background: rgba(45,190,126,0.15); color: var(--correct); }
.status-tag.status-rejected { background: rgba(226,90,90,0.15); color: var(--wrong); }

/* ---- Admin ---- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  align-items: center;
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 16px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.tab:hover { background: transparent; color: var(--text); border-bottom-color: var(--border); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab.right { margin-left: auto; }
.tab-panel { animation: fadein 0.2s ease-out; }

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.ghost:hover { color: var(--text); border-color: var(--accent); background: transparent; }
button.right { margin-left: auto; }

.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.filter-row label { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; }
.filter-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
}

.create-user {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.create-user summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.create-user summary:hover { color: var(--accent-hover); }
.create-user .form { margin-top: 12px; }

/* Admin "users online" live monitor (Users tab). */
.online-monitor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text-dim);
}
.online-monitor .dot {
  color: #2ecc71;
  font-size: 12px;
  line-height: 1;
  animation: onlinePulse 2s ease-in-out infinite;
}
.online-monitor b { color: var(--text); font-weight: 600; }
.online-monitor .hint { font-size: 12px; opacity: 0.7; }
@keyframes onlinePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* User payment screen — GCash / Maya "pay here" methods */
.pay-note { margin: 0 0 14px; }
.pay-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}
.pay-method {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.pay-method-top {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.pay-badge {
  font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
  padding: 3px 10px; border-radius: 999px; color: #fff;
}
.pay-badge-gcash { background: #0a64f0; }
.pay-badge-maya  { background: #16a34a; }
.pay-num { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: 0.5px; }
.pay-qr {
  display: block; width: 100%; max-width: 200px; margin: 0 auto;
  aspect-ratio: 1 / 1; object-fit: contain;
  background: #fff; border-radius: 8px; padding: 6px;
}
.pay-acct { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }
/* Admin settings — current QR preview + clear row */
.pay-qr-preview {
  display: block; width: 120px; height: 120px; object-fit: contain;
  background: #fff; border-radius: 6px; padding: 4px; margin: 8px 0 4px;
}
.qr-clear-row { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; margin-top: 4px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th { background: var(--surface-2); color: var(--text-dim); font-weight: 500; }
.data-table tr:last-child td { border-bottom: none; }

button.danger {
  background: var(--wrong);
  border-color: var(--wrong);
  color: white;
}
button.danger:hover { background: #d04949; border-color: #d04949; }
button.small { padding: 4px 10px; font-size: 12px; }

/* ---- Exam grouping (Seaman / Government Employee) ---- */
.exam-group { margin-bottom: 20px; }
.exam-group + .exam-group { margin-top: 8px; }
/* Browse-exams: lay the exam GROUPS out as top-anchored columns, wide enough
   that long group titles (e.g. "Licensure Exam for Teachers (LET)") fit on one
   line instead of wrapping and shoving that column's cards down. */
#exam-list.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  align-items: start;
}
.exam-group-title {
  margin: 0 0 10px 0;
  font-size: 13px;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  /* Reserve two lines so 1-line and 2-line group titles occupy equal height,
     keeping the first card of every column aligned on the same row. */
  min-height: 40px;
  display: flex;
  align-items: flex-end;
}

/* optgroup styling inside the payment-form select */
.form select optgroup {
  background: var(--surface);
  color: var(--text-dim);
  font-style: normal;
  font-weight: 600;
}
.form select optgroup option {
  color: var(--text);
  font-weight: normal;
  padding-left: 14px;
}

/* ---- Compact category tiles (C1..C20) ---- */
.card-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.category-tile {
  position: relative;
  text-align: center;
  padding: 18px 12px 14px;
}
.category-tile .cat-code {
  margin: 0 0 6px 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.category-tile .meta { font-size: 12px; }

/* Custom CSS tooltip — shown on hover and keyboard focus.
   Suppresses the native tooltip (which is slow + ugly) by also setting title.
   We keep `title=` for screen readers; visually we use [data-tooltip]. */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  width: max-content;
  max-width: 240px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 10;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 6px solid transparent;
  border-top-color: var(--border);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 10;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   UI/UX polish layer — toasts, spinners, progress bars,
   question navigator, score ring, search bar, empty state,
   coming-soon badge, password toggle, etc.
   ============================================================ */

/* ---- Body refinements ---- */
body {
  background:
    radial-gradient(1200px 620px at 50% -12%, rgba(58, 147, 255, 0.10), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(79, 209, 230, 0.06), transparent 55%),
    linear-gradient(160deg, #0b1224 0%, #000000 55%, #04060e 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Header polish */
header {
  background: linear-gradient(180deg, rgba(58, 147, 255, 0.06), transparent);
  backdrop-filter: blur(2px);
}
header h1 {
  background: linear-gradient(118deg, var(--text-strong) 28%, var(--accent) 72%, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Subtle elevation on resting cards */
.card { box-shadow: var(--shadow-sm); }
.card:hover { box-shadow: var(--shadow-md); }
.category-tile:hover { transform: translateY(-3px); }
.panel { box-shadow: var(--shadow-sm); }

/* Buttons: refined hover/active + loading state */
button {
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.05s var(--ease), box-shadow 0.15s var(--ease);
}
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { box-shadow: var(--glow-accent); }
button.primary:hover { box-shadow: 0 10px 28px -6px rgba(58, 147, 255, 0.55); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
button.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--text);
  animation: spinner 0.7s linear infinite;
}
button.primary.is-loading::after { color: white; }

@keyframes spinner { to { transform: rotate(360deg); } }

/* ---- Toast notifications ---- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px 12px 14px;
  min-width: 260px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in 0.25s var(--ease);
  font-size: 14px;
  color: var(--text);
}
.toast.success { border-left-color: var(--correct); }
.toast.error   { border-left-color: var(--wrong); }
.toast.warn    { border-left-color: var(--warn); }
.toast .toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  border-radius: 50%;
  color: white;
}
.toast.success .toast-icon { background: var(--correct); }
.toast.error   .toast-icon { background: var(--wrong); }
.toast.warn    .toast-icon { background: var(--warn); color: var(--bg); }
.toast.info    .toast-icon { background: var(--accent); }
.toast .toast-body { flex: 1; line-height: 1.4; }
.toast .toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0 0 0 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.toast .toast-close:hover { color: var(--text); background: transparent; border: none; }
.toast.dismiss { animation: toast-out 0.2s var(--ease) forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ---- Password input wrapper ---- */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.pw-wrap input {
  flex: 1;
  padding-right: 38px;
}
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.pw-toggle:hover { color: var(--text); background: var(--surface-2); border: none; }

/* ---- Login captcha ---- */
.captcha-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}
.captcha-img {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 168px;
  height: 56px;
  line-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.captcha-img svg { display: block; }
.captcha-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  height: 56px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.captcha-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.captcha-refresh:hover { color: var(--accent); border-color: var(--border-strong); }
.captcha-refresh svg { width: 18px; height: 18px; }
#login-captcha, #reg-captcha {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-family: var(--font-mono);
}
#login-captcha::placeholder, #reg-captcha::placeholder {
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-body);
}

/* ---- Quiz: progress bar + navigator ---- */
.progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0 4px;
}
.progress-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: 99px;
  transition: width 0.25s var(--ease);
}

/* Timed-exam controls + countdown warning */
.quiz-options input[type="checkbox"] { width: auto; }
.timed-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
#timer.warning { color: var(--wrong); animation: timer-pulse 1s steps(2, start) infinite; }
@keyframes timer-pulse { 50% { opacity: 0.45; } }

/* Resume banner (unfinished quiz) */
.resume-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
}
.resume-text { color: var(--text); font-size: 14px; flex: 1; }
.resume-actions { display: inline-flex; gap: 8px; }

/* Results: per-category performance breakdown */
.cat-breakdown {
  margin: 8px 0 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.cat-breakdown h3 { margin: 0 0 10px; }
.cat-row { margin: 0 0 10px; }
.cat-row:last-of-type { margin-bottom: 0; }
.cat-row-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.cat-name { color: var(--text); }
.cat-score { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.cat-bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s var(--ease); }
.weak-areas { margin: 12px 0 0; font-size: 13px; color: var(--warn); }

/* Results: per-question explanation (forward-compatible with the question bank) */
.review-item .explanation {
  margin: 8px 0 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.qnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 4px;
}
.qnav-dot {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s var(--ease);
  position: relative;
}
.qnav-dot:hover { border-color: var(--accent); color: var(--text); background: var(--surface); }
.qnav-dot.answered {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.qnav-dot.current {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  color: var(--text-strong);
}
.qnav-dot.flagged::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

/* Mark for review button on quiz */
.flag-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.flag-btn:hover { color: var(--warn); border-color: var(--warn); background: transparent; }
.flag-btn.flagged {
  color: var(--warn);
  border-color: var(--warn);
  background: var(--warn-soft);
}

/* Choice cards refinement */
.choice {
  transition: all 0.12s var(--ease);
}
.choice:hover { transform: translateX(4px); }
.choice.selected .letter {
  background: var(--accent);
  color: white;
}

/* Kbd hint chip */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 11px;
  margin-left: auto;
}
.kbd-hint kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}

/* ---- Results: SVG score ring ---- */
.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.score-ring {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}
.score-ring .track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 12;
}
.score-ring .fill {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s var(--ease), stroke 0.3s var(--ease);
}
.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.score-pct {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1;
}
.score-grade {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-top: 4px;
}
.ring-stack { position: relative; width: 160px; height: 160px; }

.pf-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pf-badge.pass { background: var(--correct-soft); color: var(--correct); border: 1px solid var(--correct); }
.pf-badge.fail { background: var(--wrong-soft);   color: var(--wrong);   border: 1px solid var(--wrong); }

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}
.result-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.result-stat .n { font-size: 22px; font-weight: 700; color: var(--text-strong); }
.result-stat.correct .n { color: var(--correct); }
.result-stat.wrong   .n { color: var(--wrong); }
.result-stat .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-top: 2px; }

/* ---- Search bar ---- */
.search-bar {
  position: relative;
  margin-bottom: 12px;
}
.search-bar input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 36px;
  font: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-bar::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
  pointer-events: none;
}

/* ---- Coming soon badge on cards ---- */
.badge-soon {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-dim);
}
.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
}
.empty-state .empty-title {
  font-size: 15px;
  color: var(--text);
  margin: 0 0 4px;
}
.empty-state .empty-hint {
  font-size: 13px;
  margin: 0;
}

/* ---- Approve / Reject action row improvements ---- */
.pay-actions .review-note:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Form polish ---- */
.form input:focus, .form select:focus, .form textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Quiz head layout adjustments ---- */
.quiz-head { padding-bottom: 10px; }
.quiz-head-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 8px;
}

/* Small screens */
@media (max-width: 640px) {
  main { padding: 20px 14px 60px; }
  .auth-card { margin: 24px auto; padding: 22px; }
  .toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; max-width: 100%; }
  .result-breakdown { grid-template-columns: 1fr; }
  header { padding: 16px 18px; flex-direction: column; align-items: stretch; gap: 8px; }
  .header-right { text-align: left; }
}

/* ---- Modal overlay + Privacy Policy consent gate ---- */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0, 0, 0, 0.66);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: pg-fade 0.2s var(--ease);
}
.modal-overlay.hidden { display: none; }
.modal-card {
  display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: min(86vh, 760px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pg-pop 0.22s var(--ease);
}
@keyframes pg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pg-pop { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
.pg-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--border); }
.pg-head h2 { margin: 0 0 6px; }
.pg-sub { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.pg-scroll { flex: 1; overflow-y: auto; padding: 18px 24px; min-height: 180px; -webkit-overflow-scrolling: touch; }
.pg-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pg-loading { color: var(--text-dim); }
.pg-doc { color: var(--text); font-size: 14px; line-height: 1.7; }
.pg-doc .legal-lead { font-weight: 700; font-size: 15px; margin: 0 0 12px; }
.pg-doc p { margin: 0 0 12px; }
.pg-doc h2 { font-size: 16px; margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.pg-doc h3 { font-size: 13.5px; color: var(--accent); margin: 16px 0 8px; }
.pg-doc ul { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 7px; }
.pg-doc li { position: relative; padding-left: 20px; }
.pg-doc li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.pg-doc a { color: var(--accent); }
.pg-doc .legal-contact { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 6px; }
.pg-doc .legal-disclaimer { margin-top: 22px; padding: 16px 18px; border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: var(--radius-sm); background: var(--warn-soft); }
.pg-doc .legal-disclaimer h2 { border: 0; padding: 0; margin: 0 0 8px; color: var(--warn); font-size: 15px; }
.pg-foot { padding: 16px 24px 20px; border-top: 1px solid var(--border); }
.pg-check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text); cursor: pointer; }
.pg-check input { margin-top: 1px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.pg-check input:disabled { cursor: not-allowed; }
.pg-check input:disabled ~ span { color: var(--text-dim); }
.pg-hint { margin: 10px 0 14px; font-size: 12.5px; color: var(--text-dim); }
.pg-hint.ok { color: var(--correct); }
.pg-actions { display: flex; gap: 10px; justify-content: flex-end; }
.pg-actions .primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.pg-actions .primary:disabled:hover { transform: none; }

/* Privacy-consent indicator in the admin users table */
.pp-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--correct); background: var(--correct-soft); border: 1px solid rgba(47, 208, 138, 0.32); }
.pp-no { color: var(--text-dim); }

/* Free-trial dashboard panel */
.trial-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.trial-head h3 { margin: 0; }
#trial-header-meta { font-size: 13px; }
/* Exam/trial card that's disabled (e.g. free mock already used) */
.card.is-disabled { opacity: 0.5; }
.card.is-disabled:hover { transform: none; box-shadow: none; cursor: default; }

/* Admin Users table — trial progress bar + active/inactive status */
.trial-cell { min-width: 92px; }
.trial-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.trial-bar span { display: block; height: 100%; border-radius: 999px; background: var(--correct); transition: width 0.3s var(--ease); }
.trial-bar span.mid { background: var(--warn); }
.trial-bar span.low { background: var(--wrong); }
.trial-bar span.expired { background: var(--wrong); width: 100% !important; opacity: 0.4; }
.trial-label { display: block; margin-top: 3px; font-size: 11px; color: var(--text-dim); }
.trial-label.mid { color: var(--warn); }
.trial-label.low, .trial-label.expired { color: var(--wrong); }
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.status-badge.active { color: var(--correct); background: var(--correct-soft); border: 1px solid rgba(47, 208, 138, 0.3); }
.status-badge.inactive { color: var(--wrong); background: var(--wrong-soft); border: 1px solid rgba(240, 99, 99, 0.3); }
tr.row-inactive { opacity: 0.5; }
.row-actions { white-space: nowrap; }
.row-actions button { margin-right: 4px; }
.row-actions button:last-child { margin-right: 0; }

/* Per-exam pricing */
.pay-price { margin: -2px 0 6px; font-family: var(--font-heading); font-weight: 600; font-size: 14px; color: var(--accent); }
.card-price { color: var(--gold); font-weight: 600; }

@media (max-width: 560px) {
  .pg-actions { flex-direction: column-reverse; }
  .pg-actions button { width: 100%; }
}

