/* =========================================================
   Civil Service Reviewer — Stylesheet
   Lightweight, mobile-first. No frameworks.
   ========================================================= */

:root {
    --primary:        #0038a8;  /* Philippine blue */
    --primary-dark:   #002766;
    --primary-soft:   #eef3ff;
    --accent:         #ce1126;  /* Philippine red */
    --gold:           #fcd116;

    --bg:             #f5f7fb;
    --surface:        #ffffff;
    --text:           #1a1a2e;
    --text-muted:     #6b7280;
    --border:         #e5e7eb;

    --correct:        #10b981;
    --correct-bg:     #d1fae5;
    --correct-text:   #065f46;
    --incorrect:      #ef4444;
    --incorrect-bg:   #fee2e2;
    --incorrect-text: #991b1b;
    --warn:           #d97706;

    --radius:         10px;
    --radius-sm:      6px;
    --shadow:         0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg:      0 8px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout ---------- */
.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}
.container-narrow {
    max-width: 460px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ---------- Site nav ---------- */
.site-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.nav-inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    background: var(--primary);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.brand-text { font-size: 1rem; }

.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
    margin-left: 8px;
}
.nav-links a {
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
}
.nav-links a:hover {
    color: var(--text);
    background: var(--primary-soft);
    text-decoration: none;
}
.nav-links a.active {
    color: var(--primary);
    background: var(--primary-soft);
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.user-name {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Hero / dashboard greeting ---------- */
.hero {
    text-align: center;
    padding: 36px 0 28px;
}
.hero h1 {
    margin: 0;
    font-size: 2rem;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
}
.subtitle { color: var(--text-muted); margin: 6px 0 4px; }
.meta     { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.dashboard-hello {
    padding: 22px 0 12px;
}
.dashboard-hello h1 {
    margin: 0 0 4px;
    font-size: 1.65rem;
    color: var(--primary-dark);
    letter-spacing: -0.01em;
}
.dashboard-hello p { margin: 0; }

/* ---------- Stats grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.stat-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 12px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.1;
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Card ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card h2 {
    margin: 0 0 16px;
    font-size: 1.2rem;
    color: var(--text);
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.link-arrow {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 500;
}

/* ---------- Auth pages ---------- */
.auth-card {
    margin-top: 24px;
}
.auth-title {
    margin: 0 0 4px;
    font-size: 1.5rem;
    color: var(--primary-dark);
    text-align: center;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 20px;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.auth-alt {
    text-align: center;
    margin: 16px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.field-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}
.field input {
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    transition: border-color 0.15s ease;
}
.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ---------- Banners ---------- */
.banner {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.95rem;
}
.banner ul { padding-left: 18px; margin: 4px 0 0; }
.banner-error {
    background: var(--incorrect-bg);
    color: var(--incorrect-text);
    border: 1px solid #fca5a5;
}
.banner-success {
    background: var(--correct-bg);
    color: var(--correct-text);
    border: 1px solid #6ee7b7;
}

/* ---------- Categories ---------- */
.categories {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.category-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--surface);
}
.category-option:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.category-option input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
.category-option.selected,
.category-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.category-label {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.category-name {
    font-weight: 500;
    color: var(--text);
}
.category-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s ease;
    font-family: inherit;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
}
.btn-block { width: 100%; }
.btn-sm    { padding: 7px 14px; font-size: 0.88rem; }
.inline-form { display: inline-block; }

/* ---------- Quiz ---------- */
.quiz-header { margin-bottom: 20px; margin-top: 8px; }
.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
    flex-wrap: wrap;
}
.category-tag {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.progress-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.35s ease;
}

.topic-label {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 8px;
    font-weight: 700;
}
.question-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0 0 20px;
    color: var(--text);
    font-weight: 500;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}
.choice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--surface);
}
.choice:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.choice input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
.choice.selected,
.choice:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.choice-key {
    font-weight: 700;
    color: var(--primary);
    min-width: 18px;
    flex-shrink: 0;
}
.choice-text { flex: 1; }

.quiz-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

/* ---------- Result ---------- */
.result-summary { text-align: center; }
.result-summary h1 {
    margin: 8px 0;
    color: var(--primary-dark);
    font-size: 1.5rem;
}
.score-big {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    margin: 8px 0 0;
    letter-spacing: -0.02em;
}
.score-of {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
}
.score-percent {
    font-size: 1.3rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 500;
}
.verdict {
    font-size: 1.05rem;
    margin: 12px 0 12px;
    font-weight: 600;
}
.verdict-good { color: var(--correct); }
.verdict-okay { color: var(--warn); }
.verdict-low  { color: var(--incorrect); }

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}
.result-actions-bottom { margin-top: 24px; }

/* ---------- Review ---------- */
.review-section h2 {
    margin: 28px 0 14px;
    color: var(--primary-dark);
    font-size: 1.25rem;
}
.review-item   { border-left: 4px solid var(--border); }
.review-correct   { border-left-color: var(--correct);   }
.review-incorrect { border-left-color: var(--incorrect); }
.review-skipped   { border-left-color: var(--warn);      }

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.q-number {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.result-badge { font-weight: 600; font-size: 0.9rem; }
.review-correct   .result-badge { color: var(--correct);   }
.review-incorrect .result-badge { color: var(--incorrect); }
.review-skipped   .result-badge { color: var(--warn);      }

.review-choices {
    list-style: none;
    padding: 0;
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.review-choices li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #f9fafb;
    font-size: 0.95rem;
}
.review-choices li.choice-correct {
    background: var(--correct-bg);
    color: var(--correct-text);
}
.review-choices li.choice-correct .choice-key { color: var(--correct-text); }
.review-choices li.choice-wrong {
    background: var(--incorrect-bg);
    color: var(--incorrect-text);
}
.review-choices li.choice-wrong .choice-key { color: var(--incorrect-text); }

.review-choices .marker {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.explanation {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    margin-top: 12px;
    line-height: 1.55;
}
.explanation strong { color: var(--primary-dark); }

/* ---------- Attempt list (history / recent) ---------- */
.attempt-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.attempt-row + .attempt-row {
    border-top: 1px solid var(--border);
}
.attempt-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 4px;
    color: inherit;
    text-decoration: none;
    transition: background 0.15s ease;
}
.attempt-link:hover {
    background: var(--primary-soft);
    text-decoration: none;
}
.attempt-list-full .attempt-link { padding: 16px 6px; }
.attempt-main { min-width: 0; }
.attempt-category {
    font-weight: 600;
    color: var(--text);
}
.attempt-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 2px;
}
.attempt-score {
    text-align: right;
    white-space: nowrap;
}
.score-num {
    font-weight: 700;
    color: var(--text);
    font-size: 1.05rem;
}
.score-pct {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 2px;
    font-weight: 600;
}
.score-pct.pct-good { color: var(--correct); }
.score-pct.pct-okay { color: var(--warn);    }
.score-pct.pct-low  { color: var(--incorrect); }

/* ---------- Leaderboard ---------- */
.leaderboard {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lb-row {
    display: grid;
    grid-template-columns: 40px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #f9fafb;
}
.lb-row.lb-me {
    background: var(--primary-soft);
    border: 1.5px solid var(--primary);
}
.lb-rank {
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    font-size: 1.05rem;
}
.lb-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lb-you {
    display: inline-block;
    margin-left: 8px;
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.lb-attempts { font-size: 0.8rem; }
.lb-score { text-align: right; }

/* ---------- Footer / misc ---------- */
.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 32px;
}

.muted    { color: var(--text-muted); }
.small    { font-size: 0.88rem; }
.mb-12    { margin-bottom: 12px; }
.mt-8     { margin-top: 8px; }
.m-0      { margin: 0; }
code      { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }

.empty-state {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ---------- Install page ---------- */
.config-summary {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    color: var(--text);
    font-size: 0.95rem;
}
.config-summary li { padding: 4px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .container         { padding: 16px 14px 40px; }
    .container-narrow  { padding: 16px 14px 40px; }
    .card              { padding: 18px; }
    .nav-inner         { padding: 10px 14px; gap: 10px; }
    .nav-links         { order: 3; flex-basis: 100%; margin-left: 0; }
    .nav-user          { margin-left: auto; }
    .brand-text        { display: none; }
    .hero              { padding: 24px 0 20px; }
    .hero h1           { font-size: 1.55rem; }
    .score-big         { font-size: 2.5rem; }
    .question-text     { font-size: 1.05rem; }
    .quiz-actions      { flex-direction: column-reverse; }
    .quiz-actions .btn { width: 100%; }
    .review-choices li { flex-wrap: wrap; }
    .review-choices .marker { margin-left: 28px; }
    .lb-row {
        grid-template-columns: 36px 1fr auto;
        row-gap: 4px;
    }
    .lb-attempts { grid-column: 2; }
    .lb-score    { grid-column: 3; grid-row: 1; }
}
