/* =============================================
   LSAT Test Player & Examination UI (test.css)
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #0d0d14;
  --surface: #14141f;
  --surface-card: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: #3b82f6;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.5);
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header & Timer */
.hdr {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(20, 20, 31, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.hdr-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
}

.hdr-pill {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
}

.hdr-module {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 8px;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: #60a5fa;
}

.timer.warning {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Page states */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Registration Page */
.reg-wrap {
  max-width: 480px;
  margin: 60px auto;
  padding: 20px;
}

.reg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.reg-top {
  text-align: center;
  margin-bottom: 24px;
}

.reg-top .icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.reg-top h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.reg-top p {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  margin-bottom: 24px;
  text-align: center;
}

.stat-strip .val {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #60a5fa;
}

.stat-strip .lbl {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  transition: border-color 0.2s;
}

.field input:focus, .field select:focus {
  border-color: var(--accent);
}

.phone-row {
  display: flex;
  gap: 8px;
}

.phone-row select {
  width: 130px;
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: #fff;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-active);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  width: 100%;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* Test Workspace */
.test-wrap {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1300px;
  margin: 24px auto;
  padding: 0 20px;
}

.mod-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.mod-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
}

.mod-info {
  font-size: 0.8rem;
  color: var(--muted);
}

.q-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.q-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}

.q-topic-tag {
  color: var(--muted);
  font-size: 0.8rem;
}

.q-passage {
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
}

.q-text {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 24px;
  color: #f1f5f9;
}

.opts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.opt-btn {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}

.opt-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.opt-btn.selected {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.opt-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.opt-btn.selected .opt-letter {
  background: var(--accent);
  color: #fff;
}

.q-nav {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Sidebar Navigator */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.palette-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.palette-card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  margin-bottom: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.pal-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.pal-num {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.pal-num:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.pal-num.current {
  border-color: var(--accent);
  color: #60a5fa;
  font-weight: 700;
}

.pal-num.answered {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.leg {
  display: flex;
  align-items: center;
  gap: 6px;
}

.leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.prog-wrap {
  margin-top: 10px;
}

.prog-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: width 0.3s;
}

.prog-lbl {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

/* Modals & Overlay */
.saving-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 20, 0.9);
  backdrop-filter: blur(8px);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.saving-overlay.active {
  display: flex;
}

.spin {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-bg.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal h3 {
  font-family: 'Syne', sans-serif;
  margin-bottom: 10px;
}

.modal p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Results Section */
.res-wrap {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 20px;
}

.res-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
}

.res-header {
  text-align: center;
  margin-bottom: 30px;
}

.res-score-badge {
  font-family: 'Syne', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 10px 0;
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 30px;
}

.res-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.res-box .num {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.res-box .lbl {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── PDF Export & Page Break Rules ─────────── */
.res-card, .res-box, .res-grid, .q-review-card, .pdf-avoid, [data-pdf-avoid="true"] {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

@media print {
  body {
    background-color: #0d0d14 !important;
    color: #ffffff !important;
  }
  .res-card, .q-review-card {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}
