/* ============================================================
   学生在线考试系统 样式
   ============================================================ */
:root {
    --primary: #2f6bff;
    --primary-dark: #1e50d6;
    --primary-soft: #eaf0ff;
    --success: #16a34a;
    --success-soft: #e8f7ee;
    --warning: #f59e0b;
    --danger: #e5484d;
    --danger-soft: #ffecec;
    --text: #16213a;
    --text-muted: #6b7691;
    --border: #e3e9f4;
    --bg: #f4f7fd;
    --card: #ffffff;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(23, 43, 87, 0.08);
}

* { box-sizing: border-box; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ---------- 顶栏 ---------- */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    background: linear-gradient(135deg, #2f6bff, #6f9bff);
    color: #fff;
    font-size: 12px;
    letter-spacing: 1px;
    padding: 5px 9px;
    border-radius: 8px;
    font-weight: 800;
}

.brand-text { font-size: 16px; }

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

.nav a {
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 9px;
    font-weight: 500;
}

.nav a:hover {
    background: var(--primary-soft);
    color: var(--primary);
    text-decoration: none;
}

.nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.top-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
}

.user-name { color: var(--text); font-weight: 600; }
.link-muted { color: var(--text-muted); }

/* ---------- 布局 ---------- */
.main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 24px 48px;
    display: block;
}

.footer {
    text-align: center;
    color: #9aa4ba;
    font-size: 12px;
    padding: 24px 16px 32px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-head h1 {
    font-size: 22px;
    margin: 0 0 4px;
}

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.card + .card { margin-top: 18px; }

.card h2 {
    font-size: 17px;
    margin: 0 0 14px;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    background: #eef2fa;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.btn:hover { filter: brightness(0.97); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 30px; font-size: 16px; border-radius: 12px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 表单 ---------- */
.label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.input, .select, .textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}

.textarea { resize: vertical; min-height: 90px; }

.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- 提示 ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error { background: var(--danger-soft); color: #b42318; border: 1px solid #ffd1d1; }
.alert-info { background: var(--primary-soft); color: #1e50d6; border: 1px solid #d4e1ff; }
.alert-success { background: var(--success-soft); color: #147a3a; border: 1px solid #c8efd7; }
.alert-warning { background: #fff7e6; color: #a35d00; border: 1px solid #ffe2b8; }

/* ---------- 登录页 ---------- */
.page-auth .topbar { box-shadow: 0 1px 0 var(--border); }
.page-auth .main {
    min-height: calc(100vh - 150px);
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(800px 400px at 15% 10%, #dfe9ff 0%, transparent 60%),
        radial-gradient(700px 360px at 90% 85%, #e8e2ff 0%, transparent 55%);
    max-width: none;
    padding: 40px 20px;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    padding: 36px 34px 30px;
}

.auth-badge {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.auth-card h1 { font-size: 25px; margin: 0 0 6px; }
.auth-card .sub { color: var(--text-muted); margin: 0 0 24px; font-size: 13px; }
.auth-card .btn { margin-top: 20px; }

.auth-foot {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- 考试须知 ---------- */
.notice-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 18px 0 24px;
}

.notice-item {
    background: #f8faff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.notice-item strong {
    display: block;
    font-size: 21px;
    color: var(--primary);
    margin-bottom: 2px;
}

.notice-item span { font-size: 12px; color: var(--text-muted); }

.rule-list { padding-left: 20px; margin: 0 0 24px; color: #44506b; }
.rule-list li { margin-bottom: 8px; }
.rule-list b { color: var(--danger); }

.student-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-soft);
    color: #1e50d6;
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 600;
    font-size: 13px;
}

/* ---------- 答题页 ---------- */
.page-exam-paper {
    background: #eef2fa;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

.page-exam-paper .topbar,
.page-exam-paper .footer { display: none; }

.page-exam-paper .main {
    max-width: none;
    padding: 0;
}

.exam-top {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 64px;
    background: #0f1b33;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 26px;
}

.exam-top-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.exam-top-left .tag {
    background: rgba(255, 255, 255, 0.12);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.exam-timer {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 16px;
    border-radius: 10px;
}

.timer-label { font-size: 12px; color: #b9c5dd; }

#timerText {
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.exam-timer.urgent { background: rgba(229, 72, 77, 0.22); }
.exam-timer.urgent #timerText { color: #ffb4b4; }

.exam-top-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.violation-note { font-size: 12px; color: #b9c5dd; }

.exam-layout {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 22px;
    align-items: start;
}

.quiz-panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 30px;
    min-height: 520px;
    display: flex;
    flex-direction: column;
}

.q-card { display: none; }
.q-card.active { display: block; }

.q-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.q-no { font-weight: 700; color: var(--text-muted); font-size: 13px; }
.q-score { margin-left: auto; font-size: 12px; color: var(--text-muted); }

.q-title {
    font-size: 19px;
    line-height: 1.7;
    margin: 0 0 22px;
    font-weight: 600;
}

.options { display: flex; flex-direction: column; gap: 12px; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}

.option:hover { border-color: #b9ccff; background: #f9fbff; }

.option input { position: absolute; opacity: 0; pointer-events: none; }

.option-letter {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 8px;
    background: #f0f4fc;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.option-text { flex: 1; padding-top: 2px; word-break: break-word; }

.option:has(input:checked),
.option.is-selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 1px var(--primary) inset;
}

.option:has(input:checked) .option-letter,
.option.is-selected .option-letter {
    background: var(--primary);
    color: #fff;
}

.q-nav {
    margin-top: auto;
    padding-top: 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.q-progress {
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* 答题卡 */
.sheet-panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    position: sticky;
    top: 88px;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.sheet-head h3 { margin: 0; font-size: 15px; }
.sheet-count { font-size: 12px; color: var(--text-muted); }

.sheet-section { margin-bottom: 16px; }
.sheet-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.sheet-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 7px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.12s;
}

.sheet-btn:hover { border-color: var(--primary); color: var(--primary); }

.sheet-btn.answered {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.sheet-btn.current {
    outline: 2px solid #0f1b33;
    outline-offset: 1px;
}

.sheet-legend {
    display: flex;
    gap: 14px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px dashed var(--border);
    padding-top: 12px;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    border: 1px solid var(--border);
    margin-right: 4px;
    vertical-align: -1px;
}

.legend-dot.done { background: var(--primary); border-color: var(--primary); }

.exam-tip {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px 28px;
    text-align: center;
    font-size: 12px;
    color: #8a94ab;
}

/* 提示浮层 */
.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    background: #0f1b33;
    color: #fff;
    padding: 11px 22px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 200;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.leave-mask {
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 34, 0.72);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.leave-mask[hidden],
.toast[hidden] { display: none; }

.leave-box {
    background: #fff;
    border-radius: 18px;
    padding: 30px 34px;
    max-width: 430px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.leave-box h2 { margin: 0 0 10px; font-size: 20px; color: var(--danger); }
.leave-box p { margin: 0 0 22px; color: var(--text-muted); }

/* ---------- 成绩页 ---------- */
.result-hero {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.score-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2f6bff, #6f9bff);
    color: #fff;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 12px 28px rgba(47, 107, 255, 0.32);
}

.score-circle strong { font-size: 44px; line-height: 130px; }
.score-circle span { font-size: 14px; opacity: 0.85; }
.score-circle.pass { background: linear-gradient(135deg, #16a34a, #34c76a); box-shadow: 0 12px 28px rgba(22, 163, 74, 0.3); }
.score-circle.fail { background: linear-gradient(135deg, #e5484d, #ff7b7f); box-shadow: 0 12px 28px rgba(229, 72, 77, 0.3); }

.result-info h1 { margin: 0 0 4px; font-size: 24px; }
.result-info p { margin: 0 0 14px; color: var(--text-muted); }

.result-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
}

.result-meta span {
    background: #f4f7fd;
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 999px;
    color: #44506b;
}

.review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 26px 0 14px;
}

.review-head h2 { margin: 0; font-size: 18px; }

.review-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    background: #fff;
    overflow: hidden;
}

.review-item summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.review-item summary::-webkit-details-marker { display: none; }

.review-no {
    flex: 0 0 30px;
    height: 30px;
    border-radius: 8px;
    background: #f0f4fc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
}

.review-title { flex: 1; font-weight: 500; }

.review-result { font-weight: 800; font-size: 16px; }
.review-item.ok .review-result { color: var(--success); }
.review-item.wrong .review-result { color: var(--danger); }

.review-body {
    border-top: 1px dashed var(--border);
    padding: 16px 18px 20px;
    background: #fbfcff;
}

.review-options { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }

.review-option {
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
}

.review-option b {
    flex: 0 0 20px;
    color: var(--text-muted);
}

.review-option.is-correct {
    background: var(--success-soft);
    border-color: #bce8cc;
    color: #147a3a;
}

.review-option.is-wrong {
    background: var(--danger-soft);
    border-color: #ffcccc;
    color: #b42318;
}

.review-answer { font-size: 13px; color: #44506b; }
.review-answer b { color: var(--text); }
.review-explanation {
    margin-top: 10px;
    font-size: 13px;
    color: #6b7691;
    background: #f4f7fd;
    padding: 10px 12px;
    border-radius: 8px;
}

/* ---------- 后台 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 6px 20px rgba(23, 43, 87, 0.05);
}

.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; line-height: 1.2; }
.stat-card .stat-value small { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; }

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th, .table td {
    text-align: left;
    padding: 12px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    background: #f9fbff;
    white-space: nowrap;
}

.table tbody tr:hover { background: #fafcff; }

.table .cell-main { font-weight: 500; max-width: 440px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f4fc;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-single { background: #eaf0ff; color: #2358d8; }
.badge-multi { background: #fff2e0; color: #a35d00; }
.badge-subject { background: #eef7f1; color: #147a3a; }
.badge-ok { background: var(--success-soft); color: #147a3a; }
.badge-warn { background: var(--danger-soft); color: #b42318; }

.score-strong { font-weight: 800; font-size: 15px; }
.score-good { color: var(--success); }
.score-bad { color: var(--danger); }

.answer-key { font-weight: 700; color: var(--primary); letter-spacing: 1px; }

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted);
    background: #fff;
}

.pagination a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

.empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}

.split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    align-items: start;
}

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--text-muted); }
.kv b { font-weight: 600; }

.subject-table td:last-child, .subject-table th:last-child { text-align: right; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
    .exam-layout { grid-template-columns: 1fr; }
    .sheet-panel { position: static; order: 2; }
    .quiz-panel { min-height: 420px; padding: 22px 20px; }
    .sheet-grid { grid-template-columns: repeat(10, 1fr); }
    .notice-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .topbar-inner { padding: 0 14px; gap: 12px; height: auto; min-height: 58px; flex-wrap: wrap; }
    .brand-text { display: none; }
    .nav { order: 3; width: 100%; overflow-x: auto; padding-bottom: 8px; }
    .main { padding: 18px 14px 36px; }
    .card { padding: 18px; }
    .exam-top { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
    .exam-timer { margin-left: 0; }
    .exam-top-right { margin-left: auto; }
    .exam-layout { padding: 14px; }
    .sheet-grid { grid-template-columns: repeat(8, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .result-hero { gap: 18px; }
    .score-circle { width: 100px; height: 100px; }
    .score-circle strong { font-size: 34px; line-height: 100px; }
    .notice-grid, .stat-grid { grid-template-columns: 1fr 1fr; }
    .toolbar .input, .toolbar .select { min-width: 0; flex: 1; }
}
