/* =========================================================
   Assessment Practice App — main stylesheet
   ========================================================= */

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

:root {
  --bg:       #f0f2f5;
  --card-bg:  #ffffff;
  --border:   #e0e4ea;
  --primary:  #2563eb;
  --primary-dk: #1d4ed8;
  --success:  #16a34a;
  --danger:   #dc2626;
  --warning:  #d97706;
  --text:     #1e293b;
  --muted:    #64748b;
  --radius:   10px;
  --shadow:   0 2px 12px rgba(0,0,0,.08);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar { background: #fff; border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.nav-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: -.3px; text-decoration: none; }
.nav-brand:hover { text-decoration: none; }
.nav-logo { height: 34px; width: auto; display: block; }
.brand-text { line-height: 1; }
.brand-accent { color: var(--warning); }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; }
.login-logo img { height: 72px; width: auto; }
.login-wordmark { font-weight: 800; font-size: 1.5rem; letter-spacing: -.5px; color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 20px; font-size: .9rem; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-user { font-weight: 600; color: var(--text); }

/* ---- Main layout ---- */
.main-content { flex: 1; padding: 32px 16px; max-width: 960px; margin: 0 auto; width: 100%; }

/* ---- Flash messages ---- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .92rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- Cards ---- */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; margin-bottom: 24px; }
.card-narrow { max-width: 420px; margin: 0 auto; }
.card-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.card-subtitle { color: var(--muted); margin-bottom: 24px; font-size: .95rem; line-height: 1.5; }
.section-title { font-size: 1.1rem; font-weight: 600; margin: 28px 0 12px; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .88rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input, .form-group select { padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: .97rem; color: var(--text); background: #fff; outline: none; transition: border-color .15s; }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 12px; line-height: 1.5; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: 8px; font-size: .92rem; font-weight: 600; cursor: pointer; border: 2px solid transparent; text-decoration: none; transition: background .15s, border-color .15s, transform .07s; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-full  { width: 100%; }
.btn-large { padding: 14px 32px; font-size: 1rem; }
.btn-sm    { padding: 6px 12px; font-size: .82rem; }

/* ---- Home: category grid ---- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.category-card { cursor: pointer; }
.category-card input[type=radio] { position: absolute; opacity: 0; width: 0; height: 0; }
.category-card-inner { padding: 16px; border: 2px solid var(--border); border-radius: var(--radius); transition: border-color .15s, background .15s; }
.category-card:hover .category-card-inner { border-color: var(--primary); }
.category-card.selected .category-card-inner { border-color: var(--primary); background: #eff6ff; }
.category-name { font-weight: 600; margin-bottom: 4px; }
.category-count { font-size: .82rem; color: var(--muted); }

.options-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.options-row .form-group { flex: 1; min-width: 160px; }

.info-box { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; font-size: .88rem; color: var(--muted); line-height: 1.6; margin-top: 24px; }
.info-box a { color: var(--primary); }

/* ---- Exam: top bar ---- */
.exam-wrap { max-width: 1100px; margin: 0 auto; }
.exam-topbar { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border-radius: var(--radius); padding: 10px 18px; margin-bottom: 16px; box-shadow: var(--shadow); flex-wrap: wrap; gap: 8px; }
.step-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.step-dot { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 2px solid var(--border); text-decoration: none; transition: background .12s; }
.step-dot.answered { background: #dcfce7; color: var(--success); border-color: #86efac; }
.step-dot.current  { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-dot:hover { border-color: var(--primary); text-decoration: none; }

.timer { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); background: var(--bg); padding: 6px 16px; border-radius: 8px; border: 2px solid var(--border); }
.timer-warning { color: var(--warning); border-color: var(--warning); background: #fffbeb; }
.timer-expired { color: var(--danger); border-color: var(--danger); background: #fee2e2; }

/* ---- Exam: two-column body ---- */
.exam-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 700px) { .exam-body { grid-template-columns: 1fr; } }

.stimulus-col, .question-col { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.stimulus-box { max-width: 100%; }

/* Stimulus styles */
.passage-title { font-size: 1rem; font-weight: 700; margin-bottom: 10px; color: #0d1a52; }
.passage-text  { font-size: .93rem; line-height: 1.7; color: var(--text); }

.master-table, .weblog-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-bottom: 10px; }
.master-table thead { background: #374151; color: #fff; }
.weblog-table thead { background: #1e40af; color: #fff; }
.master-table th, .weblog-table th, .master-table td, .weblog-table td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; }
.master-table tbody tr:nth-child(even) { background: #f8fafc; }
.weblog-header { font-size: .85rem; font-weight: 700; color: #1e40af; margin: 12px 0 4px; }
.type-key { font-size: .8rem; color: var(--muted); margin-top: 6px; }

.sequence-stimulus { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.seq-cell { border: 2px solid var(--border); border-radius: 8px; padding: 4px; background: #f8fafc; }
.seq-placeholder { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; font-size: 1.6rem; font-weight: 700; color: var(--muted); border: 2px dashed var(--border); border-radius: 8px; }
.pie-stimulus { text-align: center; padding: 28px 24px; }
.pie-stimulus svg { overflow: visible; display: block; margin: 0 auto; max-width: 300px; width: 100%; height: auto; }
.table-compare-stimulus { overflow-x: auto; }

/* ---- Question side ---- */
.question-number { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.question-prompt { font-size: 1rem; font-weight: 500; line-height: 1.6; margin-bottom: 20px; }

.options-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.option-label { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color .12s, background .12s; }
.option-label:hover { border-color: var(--primary); background: #f0f6ff; }
.option-label.selected, .option-label.checked { border-color: var(--primary); background: #eff6ff; }
.option-label input { flex-shrink: 0; accent-color: var(--primary); width: 16px; height: 16px; }
.option-text { font-size: .92rem; line-height: 1.4; }

/* SVG tile options */
.svg-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.svg-tile { position: relative; cursor: pointer; border: 3px solid var(--border); border-radius: 8px; padding: 4px; transition: border-color .12s; background: #fff; }
.svg-tile:hover { border-color: var(--primary); }
.svg-tile.selected { border-color: var(--primary); background: #eff6ff; }
.svg-tile input { position: absolute; opacity: 0; width: 0; height: 0; }
.svg-tile svg { display: block; width: 80px; height: 80px; }
.seq-cell svg { display: block; width: 72px; height: 72px; }

/* Nav buttons */
.nav-buttons { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; }

/* ---- Results ---- */
.results-summary { margin-bottom: 24px; }
.results-category { font-size: 1.1rem; font-weight: 600; color: var(--muted); margin-bottom: 16px; }
.results-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-box { background: var(--bg); border-radius: var(--radius); padding: 16px 24px; text-align: center; min-width: 100px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.stat-good .stat-value { color: var(--success); }
.stat-ok .stat-value { color: var(--warning); }
.stat-poor .stat-value { color: var(--danger); }

.results-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }

/* Review items */
.review-item { border: 2px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.review-item.correct   { border-color: #86efac; background: #f0fdf4; }
.review-item.incorrect { border-color: #fca5a5; background: #fff5f5; }
.review-item.unanswered { border-color: #e2e8f0; background: #f8fafc; }
.review-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.review-num { font-weight: 700; font-size: .9rem; }
.review-badge { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.badge-correct   { background: #dcfce7; color: var(--success); }
.badge-incorrect { background: #fee2e2; color: var(--danger); }
.badge-unanswered { background: #e2e8f0; color: var(--muted); }
.stimulus-details { margin-bottom: 10px; }
.stimulus-details summary { cursor: pointer; font-size: .82rem; color: var(--muted); user-select: none; }
.review-stimulus { margin-top: 10px; padding: 10px; background: #f8fafc; border-radius: 8px; }
.review-prompt { font-weight: 500; margin-bottom: 10px; line-height: 1.5; }
.review-answers { font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.review-explanation { margin-top: 10px; font-size: .85rem; color: var(--muted); background: #fefce8; border-left: 3px solid var(--warning); padding: 8px 12px; border-radius: 0 6px 6px 0; }

/* SVG review tiles */
.svg-review-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.svg-review-tile { border: 3px solid var(--border); border-radius: 8px; padding: 4px; text-align: center; }
.svg-review-tile svg { display: block; width: 80px; height: 80px; }
.svg-review-tile.chosen { border-color: var(--primary); }
.svg-review-tile.correct-tile { border-color: var(--success); }
.svg-review-tile.chosen.correct-tile { border-color: var(--success); background: #f0fdf4; }
.tile-label { font-size: .7rem; font-weight: 600; margin-top: 4px; }
.tile-correct { color: var(--success); }
.tile-wrong   { color: var(--danger); }
.tile-both    { color: var(--success); }

/* ---- History ---- */
.history-dashboard { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-card { background: var(--bg); border-radius: var(--radius); padding: 14px 18px; min-width: 140px; }
.dash-cat { font-weight: 700; font-size: .85rem; margin-bottom: 6px; }
.dash-stat { font-size: .82rem; color: var(--muted); }

.history-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.history-table th { background: #f1f5f9; padding: 10px 12px; text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 2px solid var(--border); }
.history-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.history-table tr:hover td { background: #f8fafc; }
.action-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.pct-good { color: var(--success); font-weight: 600; }
.pct-ok   { color: var(--warning); font-weight: 600; }
.pct-poor { color: var(--danger); font-weight: 600; }
.empty-state { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---- Progress ---- */
.progress-overview { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.progress-cat-card { background: var(--bg); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; border: 2px solid var(--border); }
.progress-empty { opacity: .6; }
.progress-cat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.progress-cat-name { font-weight: 700; font-size: 1rem; }
.progress-cat-attempts { font-size: .82rem; color: var(--muted); }
.progress-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.progress-stat { display: flex; flex-direction: column; align-items: center; min-width: 60px; }
.ps-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ps-value { font-size: 1.1rem; font-weight: 700; }
.progress-no-data { font-size: .88rem; color: var(--muted); }
.sparkline-wrap { margin: 8px 0 12px; }

/* ---- Footer ---- */
.footer { text-align: center; padding: 16px; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--card-bg); margin-top: auto; }

/* ---- Responsive ---- */
/* ---- Tablet ---- */
@media (max-width: 760px) {
  .navbar { padding: 0 14px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 6px 14px; padding-top: 8px; padding-bottom: 8px; }
  .nav-links { gap: 14px; flex-wrap: wrap; }
}

/* ---- Phone ---- */
@media (max-width: 600px) {
  .main-content { padding: 16px 10px; }
  .card { padding: 20px 14px; }
  .card-title { font-size: 1.3rem; }

  /* Navbar: brand left, links wrap below */
  .navbar { justify-content: center; text-align: center; }
  .nav-brand { font-size: 1.05rem; }
  .nav-logo { height: 30px; }
  .nav-links { width: 100%; justify-content: center; gap: 12px; font-size: .85rem; }

  /* Exam top bar */
  .exam-topbar { padding: 8px 12px; justify-content: center; }
  .step-dots { justify-content: center; gap: 4px; }
  .step-dot { width: 26px; height: 26px; font-size: .68rem; }
  .timer { font-size: 1.1rem; padding: 5px 12px; }

  /* Exam body padding */
  .stimulus-col, .question-col { padding: 16px; }
  .question-prompt { font-size: .95rem; }

  /* Options grid full width tap targets */
  .svg-tile svg { width: 64px; height: 64px; }
  .seq-cell svg { width: 56px; height: 56px; }
  .seq-placeholder { width: 50px; height: 50px; }

  /* Results / progress stats */
  .results-stats { gap: 10px; }
  .stat-box { padding: 12px 14px; min-width: 80px; flex: 1; }
  .stat-value { font-size: 1.4rem; }
  .results-actions .btn { flex: 1; min-width: 0; }

  /* History table: hide % col (shown in score), allow horizontal scroll */
  .history-table th:nth-child(4), .history-table td:nth-child(4) { display: none; }
  .action-cell { flex-direction: column; gap: 4px; }
  .action-cell .btn, .action-cell form { width: 100%; }
  .action-cell .btn { width: 100%; }

  /* Pie chart smaller on phones */
  .pie-stimulus { padding: 20px 8px; }
  .pie-stimulus svg { max-width: 230px; }

  /* Login logo */
  .login-logo img { height: 60px; }
  .login-wordmark { font-size: 1.3rem; }

  /* Footer */
  .footer { font-size: .72rem; }
}

/* ---- Small phone ---- */
@media (max-width: 380px) {
  .step-dot { width: 23px; height: 23px; font-size: .62rem; }
  .nav-links { gap: 9px; font-size: .8rem; }
}
