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

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

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --success: #34a853;
    --success-light: #e6f4ea;
    --danger: #ea4335;
    --danger-light: #fce8e6;
    --warning: #f9ab00;
    --warning-light: #fef7e0;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f4;
    --gray-200: #e8eaed;
    --gray-300: #dadce0;
    --gray-500: #9aa0a6;
    --gray-700: #5f6368;
    --gray-900: #202124;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    min-height: 100vh;
}

#app { max-width: 900px; margin: 0 auto; padding: 20px 16px 40px; }

/* ===== 通用组件 ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 28px; border: none; border-radius: 8px;
    font-size: 15px; font-weight: 500; cursor: pointer;
    transition: all 0.2s; text-decoration: none; color: #fff;
}
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #d33b2e; box-shadow: var(--shadow-md); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #2d9349; box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; border: 2px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-large { padding: 14px 36px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 8px 20px; font-size: 14px; }

/* ===== 登录/注册页 ===== */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 80vh; padding: 20px;
}
.auth-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 40px; max-width: 400px; width: 100%;
}
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary), #4285f4);
    border-radius: 16px; display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #fff; box-shadow: var(--shadow-md);
}
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-subtitle { font-size: 14px; color: var(--gray-500); text-align: center; margin-bottom: 28px; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--gray-700); }
.form-input {
    width: 100%; padding: 12px 14px; border: 2px solid var(--gray-200);
    border-radius: 8px; font-size: 15px; outline: none; transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--gray-500); }
.auth-switch a { color: var(--primary); cursor: pointer; text-decoration: none; }
.auth-error {
    background: var(--danger-light); color: var(--danger); padding: 10px 14px;
    border-radius: 8px; font-size: 14px; margin-bottom: 16px; display: none;
}
.auth-error.show { display: block; }

/* ===== 首页/仪表盘 ===== */
.home-page { text-align: center; padding: 40px 0; }
.home-logo {
    width: 72px; height: 72px; margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary), #4285f4);
    border-radius: 18px; display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: #fff; box-shadow: var(--shadow-lg);
}
.home-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.home-subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 32px; }
.home-stats {
    display: flex; gap: 16px; justify-content: center; margin-bottom: 36px; flex-wrap: wrap;
}
.stat-card {
    background: #fff; border-radius: var(--radius); padding: 20px 32px;
    box-shadow: var(--shadow-sm); text-align: center; min-width: 120px;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* 模式卡片 */
.mode-card {
    background: #fff; border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow-sm); margin-bottom: 12px; text-align: left;
    cursor: pointer; transition: all 0.2s; border: 2px solid transparent;
}
.mode-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.mode-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.mode-icon {
    width: 40px; height: 40px; border-radius: 10px; display: flex;
    align-items: center; justify-content: center; font-size: 20px; color: #fff; flex-shrink: 0;
}
.mode-icon.exam { background: linear-gradient(135deg, var(--primary), #4285f4); }
.mode-icon.practice { background: linear-gradient(135deg, var(--success), #4caf50); }
.mode-icon.wrong { background: linear-gradient(135deg, var(--danger), #f4583e); }
.mode-icon.bank { background: linear-gradient(135deg, #7c4dff, #9c27b0); }
.mode-icon.history { background: linear-gradient(135deg, #ff7043, #ff5722); }
.mode-title { font-size: 17px; font-weight: 600; }
.mode-desc { font-size: 14px; color: var(--gray-500); margin-left: 52px; line-height: 1.6; }
.mode-badge {
    display: inline-block; margin-left: 52px; margin-top: 6px;
    padding: 3px 10px; border-radius: 20px; font-size: 12px;
    background: var(--primary-light); color: var(--primary);
}

/* 顶部用户栏 */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; margin-bottom: 16px;
}
.top-bar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--gray-700); }
.top-bar-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff; display: flex;
    align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
}

/* ===== 考试/练习页面 ===== */
.exam-header {
    position: sticky; top: 0; z-index: 100; background: #fff;
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 14px 18px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.exam-header-left { display: flex; align-items: center; gap: 16px; }
.exam-header-right { display: flex; align-items: center; gap: 10px; }
.exam-progress { font-size: 14px; color: var(--gray-700); }
.exam-progress .current { font-weight: 700; color: var(--primary); font-size: 16px; }
.timer {
    display: flex; align-items: center; gap: 8px; padding: 8px 16px;
    border-radius: 24px; font-size: 16px; font-weight: 600;
    font-variant-numeric: tabular-nums; background: var(--gray-100);
}
.timer.warning { background: var(--warning-light); color: #e37400; }
.timer.danger { background: var(--danger-light); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.exam-mode-tag { padding: 4px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.tag-exam { background: var(--primary-light); color: var(--primary); }
.tag-practice { background: var(--success-light); color: var(--success); }
.tag-wrong { background: var(--danger-light); color: var(--danger); }

/* ===== 题目卡片 ===== */
.question-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 24px; margin-bottom: 16px;
}
.question-type-tag {
    display: inline-block; padding: 3px 12px; border-radius: 6px;
    font-size: 12px; font-weight: 600; margin-bottom: 12px;
}
.type-single { background: #e3f2fd; color: #1565c0; }
.type-multi { background: #f3e5f5; color: #7b1fa2; }
.type-judge { background: #e8f5e9; color: #2e7d32; }
.question-text { font-size: 17px; line-height: 1.7; margin-bottom: 24px; font-weight: 500; }
.question-text .q-num { color: var(--primary); font-weight: 700; margin-right: 8px; }

/* ===== 选项 ===== */
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-item {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
    border: 2px solid var(--gray-200); border-radius: 10px;
    cursor: pointer; transition: all 0.15s;
}
.option-item:hover { border-color: var(--primary); background: var(--primary-light); }
.option-item.selected { border-color: var(--primary); background: var(--primary-light); }
.option-item.correct { border-color: var(--success); background: var(--success-light); }
.option-item.wrong { border-color: var(--danger); background: var(--danger-light); }
.option-label {
    width: 32px; height: 32px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
    flex-shrink: 0; border: 2px solid var(--gray-300); color: var(--gray-700);
    transition: all 0.15s;
}
.option-item.selected .option-label { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-item.correct .option-label { background: var(--success); border-color: var(--success); color: #fff; }
.option-item.wrong .option-label { background: var(--danger); border-color: var(--danger); color: #fff; }
.option-text { font-size: 15px; line-height: 1.6; padding-top: 5px; flex: 1; }
.option-icon { margin-left: auto; font-size: 20px; padding-top: 4px; }

/* ===== 答案解析 ===== */
.answer-analysis { margin-top: 18px; padding: 14px; border-radius: 10px; display: none; }
.answer-analysis.show { display: block; }
.aa-correct { background: var(--success-light); border-left: 4px solid var(--success); }
.aa-wrong { background: var(--danger-light); border-left: 4px solid var(--danger); }
.aa-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.aa-correct .aa-title { color: var(--success); }
.aa-wrong .aa-title { color: var(--danger); }
.aa-body { font-size: 14px; color: var(--gray-700); line-height: 1.6; }

/* ===== 导航 ===== */
.exam-nav { display: flex; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.exam-nav-center { display: flex; gap: 8px; }

/* ===== 答题卡 ===== */
.answer-sheet {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 24px; margin-bottom: 16px;
}
.answer-sheet-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.answer-sheet-section { margin-bottom: 20px; }
.answer-sheet-section:last-child { margin-bottom: 0; }
.answer-sheet-section-title { font-size: 13px; color: var(--gray-500); margin-bottom: 10px; }
.answer-sheet-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; }
.as-item {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
    border: 2px solid var(--gray-200); background: var(--gray-50); transition: all 0.15s;
}
.as-item:hover { border-color: var(--primary); }
.as-item.answered { background: var(--primary); color: #fff; border-color: var(--primary); }
.as-item.current { border-color: var(--primary); border-width: 3px; }

/* ===== 结果页 ===== */
.result-page { text-align: center; padding: 40px 0; }
.result-score-circle {
    width: 160px; height: 160px; margin: 0 auto 24px; border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 6px solid; position: relative;
}
.score-pass { border-color: var(--success); }
.score-fail { border-color: var(--danger); }
.score-num { font-size: 48px; font-weight: 700; line-height: 1; }
.score-label { font-size: 14px; color: var(--gray-500); margin-top: 4px; }
.result-status { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.result-status.pass { color: var(--success); }
.result-status.fail { color: var(--danger); }
.result-summary {
    display: flex; gap: 20px; justify-content: center; margin: 24px 0; flex-wrap: wrap;
}
.result-summary-item {
    background: #fff; border-radius: var(--radius); padding: 16px 24px;
    box-shadow: var(--shadow-sm); text-align: center; min-width: 100px;
}
.result-summary-num { font-size: 24px; font-weight: 700; }
.result-summary-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.result-type-breakdown {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 24px; margin-bottom: 16px;
}
.type-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}
.type-row:last-child { border-bottom: none; }
.type-row-label { font-size: 14px; font-weight: 600; width: 80px; }
.type-row-bar {
    flex: 1; height: 24px; border-radius: 6px; background: var(--gray-100);
    overflow: hidden; display: flex;
}
.type-row-bar-correct, .type-row-bar-wrong {
    height: 100%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; font-weight: 600;
}
.type-row-bar-correct { background: var(--success); }
.type-row-bar-wrong { background: var(--danger); }
.type-row-score { font-size: 14px; font-weight: 600; width: 60px; text-align: right; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* ===== 做题情况详情 ===== */
.review-section {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    overflow: hidden; margin-bottom: 16px;
}
.review-tabs { display: flex; border-bottom: 2px solid var(--gray-100); }
.review-tab {
    padding: 14px 24px; font-size: 14px; font-weight: 600; cursor: pointer;
    border-bottom: 3px solid transparent; color: var(--gray-500); transition: all 0.15s;
}
.review-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.review-tab .tab-count {
    margin-left: 4px; padding: 2px 8px; border-radius: 12px; font-size: 12px; background: var(--gray-100);
}
.review-tab.active .tab-count { background: var(--primary-light); }
.review-list { max-height: 600px; overflow-y: auto; }
.review-item { padding: 20px 24px; border-bottom: 1px solid var(--gray-100); }
.review-item:last-child { border-bottom: none; }
.review-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.review-item-status { font-size: 14px; font-weight: 600; padding: 3px 10px; border-radius: 6px; }
.review-status-correct { background: var(--success-light); color: var(--success); }
.review-status-wrong { background: var(--danger-light); color: var(--danger); }
.review-item-q { font-size: 15px; line-height: 1.6; margin-bottom: 12px; }
.review-answer-row { font-size: 14px; line-height: 1.8; color: var(--gray-700); }
.review-answer-row .label { font-weight: 600; }
.review-answer-row .correct-ans { color: var(--success); font-weight: 600; }
.review-answer-row .wrong-ans { color: var(--danger); font-weight: 600; }

/* ===== 题库管理页 ===== */
.bank-list-page { padding: 20px 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.bank-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 20px; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: space-between;
}
.bank-info { flex: 1; }
.bank-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.bank-meta { display: flex; gap: 16px; font-size: 13px; color: var(--gray-500); }
.bank-meta-item { display: flex; align-items: center; gap: 4px; }
.bank-actions { display: flex; gap: 8px; }

/* ===== 导入题库页 ===== */
.import-page { padding: 20px 0; max-width: 600px; margin: 0 auto; }
.upload-area {
    border: 3px dashed var(--gray-300); border-radius: var(--radius);
    padding: 40px 20px; text-align: center; cursor: pointer;
    transition: all 0.2s; background: var(--gray-50);
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary); background: var(--primary-light);
}
.upload-icon { font-size: 48px; margin-bottom: 12px; color: var(--gray-500); }
.upload-text { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.upload-sub { font-size: 14px; color: var(--gray-500); }
.upload-formats { margin-top: 12px; font-size: 13px; color: var(--gray-500); }

/* 导入预览 */
.import-preview {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 24px; margin-top: 20px;
}
.preview-stats { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.preview-stat {
    background: var(--gray-50); border-radius: 8px; padding: 12px 20px; text-align: center; min-width: 80px;
}
.preview-stat-num { font-size: 22px; font-weight: 700; }
.preview-stat-label { font-size: 12px; color: var(--gray-500); }
.preview-questions {
    max-height: 300px; overflow-y: auto; border: 1px solid var(--gray-200);
    border-radius: 8px; padding: 12px;
}
.preview-q { padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.preview-q:last-child { border-bottom: none; }
.preview-q-type { font-size: 12px; padding: 2px 8px; border-radius: 4px; margin-right: 8px; }

/* ===== 练习配置 ===== */
.config-page { max-width: 560px; margin: 0 auto; padding: 20px 0; }
.config-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 28px; margin-bottom: 16px;
}
.config-section-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.type-selector { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.type-selector-item {
    padding: 14px 24px; border: 2px solid var(--gray-200); border-radius: 10px;
    cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.15s; background: var(--gray-50);
}
.type-selector-item:hover { border-color: var(--primary); }
.type-selector-item.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.config-row { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.config-row label { font-size: 14px; font-weight: 500; min-width: 100px; }
.config-row input, .config-row select {
    padding: 8px 12px; border: 2px solid var(--gray-200); border-radius: 8px;
    font-size: 14px; outline: none; cursor: pointer; flex: 1;
}
.config-row input:focus, .config-row select:focus { border-color: var(--primary); }

/* ===== 历史记录 ===== */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
}
.history-left { flex: 1; }
.history-bank { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.history-date { font-size: 13px; color: var(--gray-500); }
.history-score {
    font-size: 28px; font-weight: 700; min-width: 60px; text-align: right;
}
.history-score.pass { color: var(--success); }
.history-score.fail { color: var(--danger); }
.history-detail { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 16px; margin-bottom: 8px; }
.empty-state-sub { font-size: 14px; }

/* ===== 弹窗 ===== */
.overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 200; display: none;
    align-items: center; justify-content: center;
}
.overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 28px; max-width: 400px; width: 90%;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.modal-body { font-size: 14px; color: var(--gray-700); line-height: 1.6; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ===== Toast ===== */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background: var(--gray-900); color: #fff; padding: 12px 24px;
    border-radius: 24px; font-size: 14px; z-index: 300;
    display: none; box-shadow: var(--shadow-lg);
}
.toast.show { display: block; animation: toastIn 0.3s ease; }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== 加载 ===== */
.loading { text-align: center; padding: 40px; color: var(--gray-500); font-size: 16px; }

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    .home-title { font-size: 20px; }
    .question-text { font-size: 15px; }
    .answer-sheet-grid { grid-template-columns: repeat(8, 1fr); }
    .result-summary { gap: 10px; }
    .result-summary-item { padding: 12px 16px; min-width: 80px; }
    .exam-header { padding: 12px 14px; }
    .question-card { padding: 20px; }
    .auth-card { padding: 28px 20px; }
}

/* ===== 用户管理 ===== */
.user-table-wrap { overflow-x: auto; margin-top: 8px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td { padding: 10px 12px; border-bottom: 1px solid #eef1f5; text-align: left; white-space: nowrap; }
.user-table th { background: #f8fafc; color: var(--gray-500); font-weight: 600; font-size: 12px; }
.user-table tr:hover td { background: #fafbfd; }
.user-table .user-ops { white-space: nowrap; }
.role-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef2ff; color: #4f46e5; }
.status-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.status-tag.ok { background: #ecfdf5; color: #059669; }
.status-tag.off { background: #fef2f2; color: #dc2626; }
.alert-success { background: #ecfdf5; color: #059669; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.alert-warn { background: #fffbeb; color: #b45309; padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.8; }
