/* ====== 基础重置 ====== */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4f6df5;
  --primary-dark: #3b54d4;
  --primary-light: #e8edff;
  --danger: #e53e3e;
  --danger-light: #fff0f0;
  --success: #38a169;
  --success-light: #f0fff4;
  --warn: #dd6b20;
  --text: #1a202c;
  --text-2: #4a5568;
  --text-3: #a0aec0;
  --bg: #f7f8fc;
  --border: #e2e8f0;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.1);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

/* ====== 视图切换 ====== */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }

/* ====== 卡片 ====== */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 480px; }
.center-card { text-align: center; }

h1 { font-size: 26px; margin-bottom: 8px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.subtitle { color: var(--text-3); margin-bottom: 24px; }
.hint { color: var(--text-3); font-size: 13px; margin: 4px 0; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; color: var(--text-2); }
.req { color: var(--danger); }
input, textarea, select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit; transition: border-color .2s, box-shadow .2s;
  background: var(--white); color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s; text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 32px; font-size: 16px; width: 100%; margin-top: 8px; }
.btn-row { display: flex; gap: 10px; align-items: center; }

/* ====== 消息 ====== */
.error-msg { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 12px; }
.success-msg { color: var(--success); font-size: 14px; margin-top: 12px; }

/* ====== 学生信息确认 ====== */
.student-info-box { background: var(--bg); border-radius: 8px; padding: 20px; margin: 16px 0; }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-3); font-weight: 500; }
.info-row .value { font-weight: 600; }

/* ====== 答题页 ====== */
.quiz-header { width: 100%; max-width: 760px; padding: 20px 0; }
.quiz-progress { text-align: center; }
#progress-text { font-weight: 600; color: var(--text-2); }
.progress-bar { width: 100%; height: 6px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; width: 0; }

/* ====== 固定倒计时条 ====== */
.timer-bar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  background: var(--white); border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  padding: 10px 24px; align-items: center; justify-content: space-between;
  height: 56px;
}
.timer-left { display: flex; align-items: center; gap: 10px; }
.timer-label { font-size: 13px; color: var(--text-3); }
.timer-display { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.timer-display.timer-warning { color: var(--danger); animation: blink 1s ease-in-out infinite; }
.timer-right { font-size: 13px; color: var(--text-3); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* 为倒计时留出空间 */
#quiz-view { padding-top: 76px; }
#quiz-view .quiz-container, #quiz-view .quiz-footer { padding-top: 0; }

/* ====== 提交核对页状态标签 ====== */
.status-tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.status-tag.submitted { background: var(--success-light); color: var(--success); }
.status-tag.pending { background: var(--danger-light); color: var(--danger); }
.submission-summary { display: flex; gap: 20px; align-items: center; margin-bottom: 16px; }
.submission-summary .summary-card { background: var(--bg); border-radius: 8px; padding: 16px 24px; text-align: center; }
.submission-summary .summary-card .num { font-size: 32px; font-weight: 800; color: var(--primary); }
.submission-summary .summary-card .lbl { font-size: 13px; color: var(--text-3); margin-top: 2px; }
/* ====== 提交核对分组显示 ====== */
.sub-group { margin-bottom: 20px; }
.sub-group-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; padding: 10px 16px; border-radius: 8px; }
.sub-group-title.sub-group-ok { background: var(--success-light); color: var(--success); }
.sub-group-title.sub-group-pending { background: var(--danger-light); color: var(--danger); }
.quiz-container { width: 100%; max-width: 760px; }
.quiz-footer { width: 100%; max-width: 760px; text-align: center; padding: 24px 0 40px; }

.quiz-item { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; margin-bottom: 20px; }
.quiz-item .q-num { font-size: 14px; color: var(--text-3); margin-bottom: 8px; }
.quiz-item .q-content { font-size: 17px; font-weight: 600; line-height: 1.7; margin-bottom: 16px; white-space: pre-wrap; word-break: break-word; }
.quiz-item .q-image { max-width: 100%; border-radius: 8px; margin-bottom: 16px; }
.quiz-option .opt-text { white-space: pre-wrap; word-break: break-word; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 2px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: all .15s; background: var(--white);
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-light); font-weight: 600; }
.quiz-option .opt-label { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.quiz-option.selected .opt-label { background: var(--primary); color: #fff; }
.quiz-option .opt-text { flex: 1; }
.opt-image { display: block; max-width: 200px; max-height: 150px; margin: 4px 0 0 36px; border-radius: 6px; border: 1px solid var(--border); }
.quiz-option.disabled { cursor: default; }
.quiz-option.correct { border-color: var(--success); background: var(--success-light); }
.quiz-option.correct .opt-label { background: var(--success); color: #fff; }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger-light); }
.quiz-option.wrong .opt-label { background: var(--danger); color: #fff; }

/* ====== 成绩页 ====== */
.result-card { max-width: 420px; }
.score-display { margin: 24px 0; }
.score-number { font-size: 56px; font-weight: 800; color: var(--primary); line-height: 1; }
.score-label { color: var(--text-3); font-size: 16px; margin-top: 4px; }
.result-summary { display: flex; gap: 20px; justify-content: center; margin-bottom: 24px; font-size: 14px; color: var(--text-2); }
.result-summary strong { font-size: 18px; }

/* ====== 管理后台布局 ====== */
#admin-main, #admin-login { min-height: 100vh; }
.admin-layout { display: flex; width: 100%; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { padding: 20px; font-size: 17px; font-weight: 700; border-bottom: 1px solid var(--border); }
.nav-list { list-style: none; padding: 10px 0; }
.nav-item { padding: 12px 20px; cursor: pointer; font-size: 15px; color: var(--text-2); transition: all .15s; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.content { flex: 1; padding: 30px; overflow-y: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

/* ====== 数据表格 ====== */
.table-wrap { background: var(--white); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.data-table th { background: var(--bg); padding: 12px 16px; text-align: left; font-weight: 600; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.table-actions { display: flex; gap: 8px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* 序号列与总人数 */
.seq-col { text-align: center; color: var(--text-3); font-variant-numeric: tabular-nums; }
.total-badge { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 8px; }

/* 批量导入 Excel 预览表格（紧凑、列对齐） */
.import-preview-wrap { max-height: 300px; overflow: auto; }
.import-preview-wrap .data-table { min-width: 560px; }
.import-preview-table th, .import-preview-table td { padding: 8px 12px; white-space: nowrap; }
.import-preview-table td { font-size: 13px; }

/* ====== 题目列表 ====== */
.question-list { display: flex; flex-direction: column; gap: 12px; }
.question-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; gap: 16px; }
.question-card .q-index { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.question-card .q-body { flex: 1; }
.question-card .q-title { font-weight: 600; margin-bottom: 8px; font-size: 15px; }
.question-card .q-thumb { max-width: 120px; border-radius: 6px; margin-bottom: 8px; }
.question-card .q-opts { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text-2); }
.question-card .q-opt { padding: 3px 10px; border-radius: 4px; background: var(--bg); }
.question-card .q-opt.correct-opt { background: var(--success-light); color: var(--success); font-weight: 600; }
.question-card .q-meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.question-card .q-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ====== 弹窗 ====== */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.4); z-index: 1000; align-items: flex-start; justify-content: center; padding-top: 5vh; overflow-y: auto; }
.modal.active { display: flex; }
.modal-content { background: var(--white); border-radius: 12px; width: 90%; max-width: 600px; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 800px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-3); padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }

/* ====== 图片预览 ====== */
.image-preview { max-width: 200px; border-radius: 6px; margin-top: 8px; }

/* ====== 样例文本 ====== */
.sample-text { background: var(--bg); padding: 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); margin: 8px 0; white-space: pre; font-family: monospace; }

/* ====== 答题详情 ====== */
.detail-item { background: var(--bg); border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.detail-item .di-q { font-weight: 600; margin-bottom: 8px; }
.detail-item .di-img { max-width: 200px; border-radius: 4px; margin-bottom: 8px; }
.detail-item .di-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.detail-item .di-opt { padding: 4px 10px; border-radius: 4px; font-size: 13px; background: var(--white); border: 1px solid var(--border); }
.detail-item .di-opt.is-correct { border-color: var(--success); background: var(--success-light); color: var(--success); }
.detail-item .di-opt.is-selected { border-color: var(--primary); background: var(--primary-light); }
.detail-item .di-opt.is-wrong { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }
.detail-item .di-result { font-size: 14px; font-weight: 600; }
.detail-item .di-result.ok { color: var(--success); }
.detail-item .di-result.fail { color: var(--danger); }

/* ====== 筛选下拉 ====== */
.filter-select {
  width: auto; min-width: 180px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: var(--white); color: var(--text); cursor: pointer;
}

/* ====== 搜索框 ====== */
.search-input {
  width: 200px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: var(--white); color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--primary); }

/* ====== 考试列表 ====== */
.exam-list { display: flex; flex-direction: column; gap: 12px; }
.exam-card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; display: flex; justify-content: space-between; align-items: center;
}
.exam-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.exam-info { flex: 1; }
.exam-name { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.exam-meta { display: flex; gap: 16px; font-size: 13px; color: var(--text-3); }
.exam-actions { display: flex; gap: 8px; flex-shrink: 0; }
.exam-tag { font-size: 12px; padding: 2px 8px; border-radius: 4px; background: var(--primary-light); color: var(--primary); font-weight: 500; }

/* ====== 答题页防复制/防搜题（学生端）======
   禁止选中题目文字、禁止拖拽/保存题目图片 */
.quiz-container, .quiz-container * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.quiz-container img {
  -webkit-user-drag: none;
  -moz-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* ====== 响应式 ====== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo { font-size: 12px; padding: 14px 8px; text-align: center; }
  .nav-item { font-size: 12px; padding: 10px 8px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .card { padding: 24px; }
  .filter-select { min-width: 120px; }
}
