/* ============================================================
   Judiciary Prep — Design tokens (Clean Professional theme)
   Direction: restrained SaaS look. One accent color used only
   for actions and active states, neutral grays for everything
   else, tight borders instead of shadows, no decoration that
   doesn't carry information.
   ============================================================ */

:root {
  --ink: #111827;
  --ink-secondary: #4B5563;
  --muted: #9CA3AF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --accent: #2563EB;
  --accent-dark: #1D4ED8;
  --accent-soft: #EFF6FF;
  --success: #059669;
  --success-soft: #ECFDF5;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --amber: #D97706;
  --amber-soft: #FFFBEB;
  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --sidebar-w: 224px;
  --bottom-nav-h: 60px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.2s ease; }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95rem;
}

h1, h2, h3, h4, h5 {
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* ---------- App shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.side-nav {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1020;
  height: 100vh;
}
@media (min-width: 992px) {
  .side-nav { display: flex; }
}

.side-nav .brand {
  padding: 1.35rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.side-nav .brand .mark {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem;
}
.side-nav .brand span.name { font-weight: 600; font-size: 0.95rem; color: var(--ink); }

.side-nav-links { padding: 0.85rem 0.75rem; flex: 1; }
.side-nav-links a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink-secondary);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.1rem;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-nav-links a i { font-size: 1rem; width: 1.15rem; text-align: center; color: var(--muted); }
.side-nav-links a:hover { background: var(--bg); color: var(--ink); }
.side-nav-links a.active { background: var(--accent-soft); color: var(--accent); }
.side-nav-links a.active i { color: var(--accent); }

.side-nav .nav-footer { padding: 0.85rem 1rem 1rem; border-top: 1px solid var(--border); }
.side-nav .nav-footer a { color: var(--ink-secondary); font-size: 0.82rem; font-weight: 500; }
.side-nav .nav-footer a:hover { color: var(--danger); }

.content-area { flex: 1; min-width: 0; }
@media (min-width: 992px) { .content-area { margin-left: var(--sidebar-w); } }
.content-inner { max-width: 1320px; padding: 1.75rem 2rem calc(2.5rem + var(--bottom-nav-h)); }

/* Mobile top bar */
.mobile-topbar {
  display: none;
  width: 100%;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.mobile-topbar .brand { display: flex; align-items: center; gap: 0.5rem; }
.mobile-topbar .brand .mark {
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.7rem;
}
.mobile-topbar .brand span { font-weight: 600; color: var(--ink); font-size: 0.92rem; }

/* Mobile bottom tab bar */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(17, 24, 39, 0.04);
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav .row-inner { display: flex; height: var(--bottom-nav-h); }
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s ease;
}
.bottom-nav a i { font-size: 1.2rem; line-height: 1; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a:active { opacity: 0.6; }

@media (max-width: 991.98px) {
  .side-nav { display: none; }
  .mobile-topbar { display: flex; }
  .bottom-nav { display: block; }
  .content-inner { padding: 1.25rem 1rem calc(1.5rem + var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Page furniture ---------- */

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.3rem;
}

.page-title { font-weight: 600; color: var(--ink); margin-bottom: 0.2rem; font-size: 1.4rem; letter-spacing: -0.02em; }
.page-subtitle { color: var(--ink-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* ---------- Cards ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
  background: var(--card);
}

.subject-card {
  border-radius: var(--radius-lg);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.subject-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(17,24,39,0.06);
}
.subject-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

/* ---------- List rows (subjects / topics) ---------- */

.list-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg); }
.list-row .list-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.list-row .list-main { flex: 1; min-width: 0; }
.list-row .list-title { font-weight: 600; font-size: 0.92rem; color: var(--ink); margin-bottom: 0.1rem; }
.list-row .list-desc { font-size: 0.82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list-row-question { align-items: flex-start; }
.list-row-question .list-title { font-weight: 500; line-height: 1.4; white-space: normal; }
.list-row-question .list-desc { white-space: normal; overflow: visible; text-overflow: clip; }
.list-row-question .list-icon { margin-top: 0.15rem; }
.list-row-question .list-meta { margin-top: 0.1rem; }
.list-row .list-meta { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.list-row .list-divider { width: 1px; height: 18px; background: var(--border); margin: 0 0.15rem; }
.list-row .list-open {
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
}
.list-row .list-open:hover { color: var(--ink); }
.list-row .list-delete {
  color: var(--muted);
  opacity: 0.55;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.list-row .list-delete:hover { opacity: 1; color: var(--danger); background: var(--danger-soft); }

@media (max-width: 420px) {
  .list-row { gap: 0.6rem; padding: 0.75rem 0.85rem; }
  .list-row .list-icon { width: 30px; height: 30px; font-size: 0.8rem; }
  .list-row .list-meta { gap: 0.4rem; }
}

@media (max-width: 575.98px) {
  .list-row .list-desc { display: none; }
  .list-row-question .list-desc { display: block; }
}

/* ---------- Stat tiles ---------- */

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
}
.stat-tile .stat-icon-wrap {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.6rem; font-size: 0.9rem;
  background: var(--bg); color: var(--ink-secondary);
  border: 1px solid var(--border);
}
.stat-tile .stat-figure { font-size: 1.55rem; font-weight: 700; color: var(--ink); line-height: 1; letter-spacing: -0.02em; }
.stat-tile .stat-label { font-size: 0.76rem; color: var(--muted); margin-top: 0.3rem; font-weight: 500; }

/* ---------- Buttons ---------- */

.btn { border-radius: var(--radius-sm); font-weight: 500; font-size: 0.88rem; }
.btn-primary { background-color: var(--ink); border-color: var(--ink); }
.btn-primary:hover, .btn-primary:focus { background-color: #000; border-color: #000; }
.btn-outline-primary { color: var(--ink); border-color: var(--border-strong); }
.btn-outline-primary:hover { background-color: var(--ink); border-color: var(--ink); color: #fff; }
.btn-sm { border-radius: var(--radius-sm); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  top: 50%; left: 50%;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btnspin 0.6s linear infinite;
}
.btn-outline-primary.is-loading::after { border-color: rgba(17,24,39,0.25); border-top-color: var(--ink); }
@keyframes btnspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.is-loading::after { animation: none; } }

@media (max-width: 767.98px) {
  .btn { min-height: 42px; }
  .form-control, .form-select { min-height: 42px; }
}

/* ---------- Badges ---------- */

.badge-pill {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

/* ---------- Progress bars ---------- */

.progress { border-radius: 4px; background: var(--border); height: 6px; }
.progress-bar { border-radius: 4px; background-color: var(--ink); }

/* ---------- Empty states ---------- */

.empty-state {
  text-align: center;
  padding: 2.75rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-secondary);
  background: var(--card);
}
.empty-state .empty-icon-wrap {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; margin: 0 auto 0.8rem;
  border: 1px solid var(--border);
}
.empty-state .empty-title { color: var(--ink); font-weight: 600; margin-bottom: 0.25rem; font-size: 0.95rem; }

/* ---------- Session layout: constrained question column + desktop sidebar ---------- */

.session-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  max-width: 1020px;
  margin: 0 auto;
}
.session-main {
  flex: 1;
  min-width: 0;
  max-width: 720px;
}
.session-side {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 1.5rem;
}

/* ---------- Practice ---------- */

.practice-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  max-height: calc(100dvh - 230px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.practice-card .meta-line { font-size: 0.75rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.practice-card .question-text { font-size: 1.1rem; font-weight: 600; line-height: 1.5; color: var(--ink); margin: 0.75rem 0 1.4rem; letter-spacing: -0.01em; }
.practice-card form { display: flex; flex-direction: column; min-height: 0; }
.practice-card .option-row { overflow-y: auto; min-height: 0; }
.practice-card .btn-submit-answer { flex-shrink: 0; }

@media (max-width: 575.98px) {
  .practice-card { padding: 1.1rem; max-height: calc(100dvh - 260px - env(safe-area-inset-bottom, 0px)); }
  .practice-card .question-text { font-size: 1rem; margin: 0.6rem 0 1rem; }
  .practice-card .meta-line { font-size: 0.68rem; }
}

.btn-submit-answer { width: 100%; }
@media (min-width: 576px) { .btn-submit-answer { width: auto; min-width: 160px; } }
.timer-chip {
  background: var(--bg); color: var(--ink-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.25rem 0.6rem;
  font-size: 0.75rem; font-weight: 500;
}

.option-row label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.opt-letter {
  width: 1.5rem; height: 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink-secondary);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.75rem; flex-shrink: 0;
}
.option-row label:hover { border-color: var(--border-strong); }
.option-row input:checked + label,
.option-row label.selected {
  border-color: var(--ink);
  background: var(--bg);
}
.option-row input:checked + label .opt-letter,
.option-row label.selected .opt-letter {
  background: var(--ink); color: #fff; border-color: var(--ink);
}

/* Answered state — after submitting, options lock and show correct/incorrect */
.option-row.answered label { cursor: default; pointer-events: none; }
.option-row label.correct-option {
  border-color: var(--success); background: var(--success-soft);
}
.option-row label.correct-option .opt-letter {
  background: var(--success); color: #fff; border-color: var(--success);
}
.option-row label.wrong-option {
  border-color: var(--danger); background: var(--danger-soft);
}
.option-row label.wrong-option .opt-letter {
  background: var(--danger); color: #fff; border-color: var(--danger);
}

/* Feedback banner */
.feedback-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  margin-bottom: 1.15rem;
}
.feedback-banner.correct { background: var(--success-soft); border-color: #A7F3D0; }
.feedback-banner.incorrect { background: var(--danger-soft); border-color: #FECACA; }
.feedback-banner .icon-wrap {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.feedback-banner.correct .icon-wrap { background: var(--success); color: #fff; }
.feedback-banner.incorrect .icon-wrap { background: var(--danger); color: #fff; }
.feedback-banner .title { font-weight: 600; font-size: 0.92rem; }
.feedback-banner.correct .title { color: #047857; }
.feedback-banner.incorrect .title { color: #B91C1C; }

/* ---------- Forms ---------- */

.form-control, .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--ink-secondary); }

/* ---------- Auth pages ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 100%;
  max-width: 380px;
}
.auth-card .mark {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  margin: 0 auto 1rem;
}
.auth-card h4 { text-align: center; margin-bottom: 1.5rem; font-size: 1.2rem; }

/* ---------- Question bank table -> cards on mobile ---------- */

.table thead th { font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom-color: var(--border); }
.table td { border-color: var(--border); font-size: 0.88rem; vertical-align: middle; }

@media (max-width: 767.98px) {
  .q-table thead { display: none; }
  .q-table, .q-table tbody, .q-table tr, .q-table td { display: block; width: 100%; }
  .q-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.6rem;
    padding: 0.75rem;
  }
  .q-table td { border: none; padding: 0.2rem 0; }
  .q-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
  }
}
