/* ============================================================
   在线考试系统 - 主样式表
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f0f2f5;
}

a { color: #1890ff; text-decoration: none; }
a:hover { color: #40a9ff; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* --- Header --- */
.site-header {
    background: #001529;
    color: #fff;
    padding: 0 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container {
    display: flex;
    align-items: center;
    height: 56px;
    gap: 24px;
}
.site-logo {
    color: #fff !important;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}
.site-nav a {
    color: rgba(255,255,255,.65);
    font-size: 13px;
    transition: color .2s;
}
.site-nav a:hover { color: #fff; }
.nav-user { color: rgba(255,255,255,.85); margin-left: auto; font-size: 13px; }
.btn-logout {
    color: rgba(255,255,255,.65) !important;
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 3px;
    font-size: 12px;
}
.btn-logout:hover { color: #fff !important; border-color: #fff; }

/* --- Admin Layout --- */
.admin-layout { display: flex; gap: 24px; min-height: calc(100vh - 100px); }
.admin-sidebar {
    width: 200px;
    min-width: 200px;
    background: #fff;
    border-radius: 6px;
    padding: 16px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.admin-sidebar a {
    display: block;
    padding: 10px 24px;
    color: #555;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.admin-sidebar a:hover { background: #f5f5f5; color: #1890ff; }
.admin-sidebar a.active {
    color: #1890ff;
    background: #e6f7ff;
    border-left-color: #1890ff;
    font-weight: 600;
}
.admin-content { flex: 1; min-width: 0; }

/* --- Main Content --- */
.site-main { padding: 24px 0; }
.site-footer {
    text-align: center;
    padding: 20px 0;
    color: #999;
    font-size: 12px;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}
.card-header h2 { font-size: 18px; font-weight: 600; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead { background: #fafafa; }
th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #e8e8e8;
    white-space: nowrap;
}
td {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
tr:hover td { background: #fafafa; }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    transition: all .2s;
    background: #fff;
    color: #333;
}
.btn:hover { border-color: #1890ff; color: #1890ff; }
.btn-primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; color: #fff; }
.btn-danger { background: #ff4d4f; border-color: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; border-color: #ff7875; color: #fff; }
.btn-success { background: #52c41a; border-color: #52c41a; color: #fff; }
.btn-success:hover { background: #73d13d; border-color: #73d13d; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn + .btn { margin-left: 8px; }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}
.form-control {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color .2s;
    background: #fff;
}
.form-control:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24,144,255,.2);
}
.form-control[readonly] { background: #f5f5f5; }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-text { font-size: 12px; color: #999; margin-top: 4px; }
.form-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* --- Alerts --- */
.alert {
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
.alert-danger { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; }
.alert-info { background: #e6f7ff; border: 1px solid #91d5ff; color: #096dd9; }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}
.badge-primary { background: #e6f7ff; color: #1890ff; }
.badge-success { background: #f6ffed; color: #52c41a; }
.badge-warning { background: #fffbe6; color: #faad14; }
.badge-danger { background: #fff2f0; color: #ff4d4f; }
.badge-secondary { background: #f5f5f5; color: #999; }

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}
.pagination a, .pagination .page-current {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
}
.pagination a:hover { border-color: #1890ff; color: #1890ff; }
.pagination .page-current {
    background: #1890ff;
    border-color: #1890ff;
    color: #fff;
}

/* --- Stats --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    text-align: center;
}
.stat-card .stat-number {
    font-size: 36px;
    font-weight: 700;
    color: #1890ff;
    line-height: 1.2;
}
.stat-card .stat-label { color: #999; font-size: 13px; margin-top: 4px; }

/* --- Login Page --- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f0f2f5; }
.login-box {
    width: 400px;
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.login-box h1 { text-align: center; font-size: 24px; margin-bottom: 8px; color: #001529; }
.login-box .login-subtitle { text-align: center; color: #999; margin-bottom: 32px; font-size: 13px; }
.login-box .btn { width: 100%; padding: 10px; font-size: 15px; }

/* --- Exam Taking --- */
.exam-header {
    background: #001529;
    color: #fff;
    padding: 12px 24px;
    position: sticky;
    top: 56px;
    z-index: 90;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.exam-timer {
    font-size: 28px;
    font-family: "SF Mono", "Consolas", "Menlo", monospace;
    font-weight: 700;
}
.exam-timer.timer-warning { color: #faad14; }
.exam-timer.timer-danger { color: #ff4d4f; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

.exam-body {
    max-width: 900px;
    margin: 24px auto;
    padding: 0 20px;
}
.question-card {
    background: #fff;
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.question-num {
    display: inline-block;
    background: #1890ff;
    color: #fff;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    margin-right: 8px;
}
.question-type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 11px;
    background: #f0f0f0;
    color: #666;
    margin-right: 8px;
}
.question-score { color: #999; font-size: 12px; float: right; }
.question-content { margin: 12px 0; font-size: 15px; line-height: 1.8; }

/* Options */
.option-list { list-style: none; margin-top: 12px; }
.option-item {
    padding: 10px 16px;
    margin-bottom: 6px;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.option-item:hover { border-color: #1890ff; background: #f0f7ff; }
.option-item.selected { border-color: #1890ff; background: #e6f7ff; }
.option-item input[type="radio"],
.option-item input[type="checkbox"] { margin: 0; }
.option-key {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 50%;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    flex-shrink: 0;
}
.option-text { flex: 1; }

/* Exam actions */
.exam-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 24px 0 40px;
}
.exam-actions .btn { padding: 12px 40px; font-size: 16px; }

/* --- Result Page --- */
.result-header {
    text-align: center;
    margin-bottom: 24px;
}
.result-score {
    font-size: 72px;
    font-weight: 700;
    line-height: 1;
}
.result-score.pass { color: #52c41a; }
.result-score.fail { color: #ff4d4f; }
.result-meta { color: #999; margin-top: 8px; }

.answer-review-item {
    background: #fff;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.answer-review-item.correct { border-left: 4px solid #52c41a; }
.answer-review-item.wrong { border-left: 4px solid #ff4d4f; }
.answer-review-item.pending { border-left: 4px solid #faad14; }

/* --- Question Form --- */
.options-editor { margin-top: 12px; }
.option-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.option-row .option-key-label {
    width: 32px;
    text-align: center;
    font-weight: 600;
    color: #1890ff;
}
.option-row .form-control { flex: 1; }

/* --- Grading --- */
.grading-answer-box {
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 8px;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.8;
}
.grading-ref-box {
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* --- Batch Import --- */
.batch-textarea {
    width: 100%;
    min-height: 200px;
    font-family: "SF Mono", "Consolas", "Menlo", monospace;
    font-size: 13px;
    padding: 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    resize: vertical;
    line-height: 1.8;
}
.batch-preview { margin-top: 16px; }

/* --- Misc --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #999; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mr-8 { margin-right: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.keyword-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    background: #e6f7ff;
    color: #1890ff;
    border-radius: 3px;
    font-size: 12px;
}
.confirm-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.confirm-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.confirm-dialog p { margin: 16px 0 24px; font-size: 15px; }
