/* ===== 智能题库 - 全局样式 ===== */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fa; color: #1a2332; line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  color: #fff; padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header h1 { font-size: 1.25rem; font-weight: 600; }
.app-header .logo-icon { margin-right: 8px; }
.header-actions { display: flex; gap: 8px; }
.btn { cursor: pointer; border: none; border-radius: 6px; font-size: 0.875rem; padding: 8px 16px; transition: all 0.2s; display: inline-flex; align-items: center; gap: 4px; }
.btn-sm { padding: 4px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; font-weight: 500; }
.btn-primary { background: #1a73e8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1557b0; }
.btn-primary:disabled { background: #a0c4ff; cursor: not-allowed; }
.btn-outline { background: #fff; color: #1a73e8; border: 1px solid #1a73e8; }
.btn-outline:hover { background: #e8f0fe; }

/* ── Step Indicator ── */
.step-indicator {
  display: flex; align-items: center; justify-content: center;
  padding: 24px 32px; background: #fff; border-bottom: 1px solid #e8eaed;
}
.progress-step { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: default; }
.step-circle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.875rem;
  background: #e8eaed; color: #9aa0a6;
  transition: all 0.35s ease;
}

/* 已完成步骤 — 绿色实心 */
.progress-step.done .step-circle {
  background: #34a853; color: #fff;
  box-shadow: 0 0 0 3px rgba(52,168,83,0.15);
}
.progress-step.done .step-label {
  color: #34a853; font-weight: 600;
}

/* 当前激活步骤 — 蓝色高亮 + 放大 */
.progress-step.active .step-circle {
  background: #1a73e8; color: #fff;
  box-shadow: 0 2px 10px rgba(26,115,232,0.35);
  transform: scale(1.12);
}
.progress-step.active .step-label {
  color: #1a73e8; font-weight: 700;
}

/* 默认未到达步骤 — 灰色 */
.step-label {
  font-size: 0.8125rem; color: #9aa0a6; white-space: nowrap;
}

/* 连接线 */
.step-connector {
  width: 60px; height: 3px;
  background: #e8eaed;
  margin: 0 4px; margin-bottom: 22px;
  border-radius: 2px;
  transition: background 0.35s ease;
}
.step-connector.done { background: #34a853; }

/* ── Main Content ── */
#mainContent { max-width: 900px; margin: 0 auto; padding: 24px 16px 64px; }

/* ── Step Panels ── */
.step-panel { display: none; }
.step-panel.active { display: block; }
.panel-header { margin-bottom: 24px; }
.panel-header h2 { font-size: 1.35rem; font-weight: 600; color: #1a2332; }
.panel-desc { font-size: 0.875rem; color: #5f6368; margin-top: 4px; }
.panel-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }

/* ── Upload Area ── */
.upload-area { background: #fff; border-radius: 12px; border: 1px solid #e8eaed; overflow: hidden; }
.upload-tabs { display: flex; border-bottom: 1px solid #e8eaed; }
.tab-btn { flex: 1; padding: 14px; border: none; background: #f8f9fa; cursor: pointer; font-size: 0.9375rem; color: #5f6368; transition: all 0.2s; }
.tab-btn.active { background: #fff; color: #1a73e8; font-weight: 600; border-bottom: 2px solid #1a73e8; }
.tab-btn:hover { background: #e8f0fe; }
.upload-tab-content { display: none; padding: 24px; }
.upload-tab-content.active { display: block; }

.drop-zone {
  border: 2px dashed #dadce0; border-radius: 12px; padding: 48px 24px;
  text-align: center; cursor: pointer; transition: all 0.3s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: #1a73e8; background: #e8f0fe; }
.drop-icon { font-size: 3rem; margin-bottom: 12px; }
.drop-text { font-size: 1.1rem; color: #1a2332; margin-bottom: 8px; }
.drop-hint { font-size: 0.8125rem; color: #9aa0a6; margin-bottom: 16px; }
.file-preview { display: flex; align-items: center; gap: 12px; padding: 16px; background: #f0f7ff; border-radius: 8px; margin-top: 12px; }
.file-preview.hidden { display: none; }
.file-icon { font-size: 1.5rem; }
.file-name { flex: 1; font-weight: 500; word-break: break-all; }
.file-size { color: #5f6368; font-size: 0.8125rem; }

.text-input { width: 100%; min-height: 200px; padding: 16px; border: 1px solid #dadce0; border-radius: 8px; font-size: 0.9375rem; line-height: 1.7; resize: vertical; font-family: inherit; }
.text-input:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }
.text-char-count { text-align: right; font-size: 0.8125rem; color: #9aa0a6; margin-top: 6px; }

/* ── Loading ── */
.loading-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; color: #1a73e8; }
.loading-bar.hidden { display: none; }
.loading-spinner { width: 20px; height: 20px; border: 2px solid #e8eaed; border-top-color: #1a73e8; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-msg { background: #fce8e6; color: #c5221f; padding: 12px 16px; border-radius: 8px; margin-top: 12px; font-size: 0.875rem; }
.error-msg.hidden { display: none; }

/* ── Batch Toolbar ── */
.batch-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: #fff; border: 1px solid #e8eaed; border-radius: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.checkbox-inline { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 0.875rem; }
.batch-count { font-size: 0.875rem; font-weight: 500; color: #1a73e8; }
.toolbar-divider { color: #dadce0; }

/* ── Question List ── */
.question-list { display: flex; flex-direction: column; gap: 8px; }
.empty-state { text-align: center; padding: 48px 16px; color: #9aa0a6; font-size: 0.9375rem; }

/* ── Question Card ── */
.question-card {
  background: #fff; border: 1px solid #e8eaed; border-radius: 10px; padding: 16px;
  transition: all 0.2s; position: relative;
}
.question-card:hover { border-color: #c4c7c5; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.question-card.unchecked { opacity: 0.7; background: #fafafa; }
.question-card .card-header {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px;
}
.question-card .question-checkbox { margin-top: 2px; width: 18px; height: 18px; cursor: pointer; accent-color: #1a73e8; }
.question-card .question-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 500;
}
.question-badge.high { background: #e6f4ea; color: #137333; }
.question-badge.medium { background: #fef7e0; color: #b06000; }
.question-badge.low { background: #fce8e6; color: #c5221f; }
.question-card .question-type { font-size: 0.8125rem; color: #5f6368; margin-left: 8px; }
.question-card .question-content {
  font-size: 0.9375rem; line-height: 1.65; color: #1a2332;
  margin-left: 30px; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word;
}
.question-card .question-content.collapsed {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.question-card .card-actions { display: flex; gap: 8px; margin-left: 30px; flex-wrap: wrap; }
.question-card .card-actions .btn { font-size: 0.75rem; padding: 2px 10px; }
.question-card .question-position { font-size: 0.75rem; color: #9aa0a6; margin-left: 30px; margin-bottom: 4px; }

/* ── Status Bar ── */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #f8f9fa; border-radius: 8px; margin-top: 16px;
  font-size: 0.875rem; color: #5f6368;
}
.status-warning { color: #b06000; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4); z-index: 1000; display: flex;
  align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-content { background: #fff; border-radius: 12px; width: 90%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e8eaed; }
.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: #5f6368; padding: 4px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid #e8eaed; }

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 500; color: #5f6368; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #dadce0; border-radius: 6px; font-size: 0.9375rem; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .app-header { padding: 12px 16px; }
  .step-indicator { padding: 16px; }
  .step-connector { width: 24px; }
  .step-label { font-size: 0.6875rem; }
  .batch-toolbar { gap: 8px; }
  .panel-actions { flex-direction: column; }
  .panel-actions .btn { width: 100%; justify-content: center; }
}
/* ── KaTeX 公式样式控制 ── */
.katex { font-size: 1em !important; }
.katex-display { font-size: 1.05em !important; max-width: 100%; overflow-x: auto; }

/* ── 题目内容选项分行 ── */
.question-content { white-space: pre-wrap; }


/* ── 历史草稿列表 ── */
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff; border: 1px solid #e8eaed;
  border-radius: 8px; margin-bottom: 8px; gap: 12px;
}
.history-item:hover { border-color: #c4c7c5; }
.history-info { flex: 1; min-width: 0; }
.history-title { font-weight: 500; color: #1a2332; font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 0.8125rem; color: #9aa0a6; margin-top: 2px; }
.history-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.restore-select {
  padding: 4px 8px; border: 1px solid #dadce0; border-radius: 6px;
  font-size: 0.8125rem; background: #fff; color: #1a73e8;
  cursor: pointer; outline: none;
}
.restore-select:hover { background: #e8f0fe; border-color: #1a73e8; }
/* ── 入库结果页 (Step 4) ── */
.result-card { border-radius: 12px; padding: 24px; text-align: center; margin-bottom: 20px; border: 1px solid; }
.result-card.success { background: #e6f4ea; border-color: #34a853; }
.result-card.warning { background: #fef7e0; border-color: #f9ab00; }
.result-card.partial { background: #fff3e0; border-color: #ff9800; }
.result-card.error { background: #fce8e6; border-color: #ea4335; }
.result-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 6px; }
.result-subtitle { font-size: 0.875rem; color: #5f6368; }

.save-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.save-stat-item { background: #fff; border: 1px solid #e8eaed; border-radius: 10px; padding: 16px; text-align: center; }
.save-stat-label { font-size: 0.75rem; color: #9aa0a6; margin-bottom: 4px; }
.save-stat-value { font-size: 1.75rem; font-weight: 700; color: #1a2332; }
.stat-saved .save-stat-value { color: #34a853; }
.stat-dup .save-stat-value { color: #f9ab00; }
.stat-failed .save-stat-value { color: #ea4335; }

.result-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.result-table th { text-align: left; padding: 10px 12px; background: #f8f9fa; border-bottom: 2px solid #e8eaed; font-weight: 600; color: #5f6368; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.5px; }
.result-table td { padding: 10px 12px; border-bottom: 1px solid #e8eaed; vertical-align: middle; }
.result-table tbody tr:hover { background: #f8f9fa; }
.action-cell { text-align: center; }

.badge-db { display: inline-block; background: #e8f0fe; color: #1a73e8; padding: 1px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 500; margin-left: 6px; }

.fail-details { background: #fce8e6; border: 1px solid #ea4335; border-radius: 8px; padding: 16px; margin-top: 16px; }
.fail-item { padding: 4px 0; font-size: 0.875rem; color: #c5221f; }

.save-result-list { background: #fff; border: 1px solid #e8eaed; border-radius: 10px; padding: 16px; }

@media (max-width: 640px) {
  .save-stats-grid { grid-template-columns: repeat(2, 1fr); }
}/* ── 修复 P3：.question-card 样式（原 .question-card 未匹配实际渲染的 .question-card）── */

/* 卡片基础样式 */
.question-card {
  background: #fff; border: 1px solid #e8eaed; border-radius: 10px; padding: 16px;
  transition: all 0.2s; position: relative;
}
.question-card:hover { border-color: #c4c7c5; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.question-card.skipped { opacity: 0.7; background: #fafafa; }
.question-card.confirmed { border-left: 4px solid #34a853; }

/* 卡片头部 */
.question-card-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.question-card-header .question-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: #1a73e8; }
.question-card-header .question-id { font-weight: 600; color: #1a2332; font-size: 0.875rem; }
.question-card-header .question-type { font-size: 0.8125rem; color: #5f6368; }

/* 卡片内容区域 */
.question-card .question-content {
  font-size: 0.9375rem; line-height: 1.65; color: #1a2332;
  margin-bottom: 8px; white-space: pre-wrap; word-break: break-word;
  cursor: pointer; padding: 4px 0;
}
.question-card .question-content:not(.expanded),
.parse-detail-collapsed:not(.expanded) {
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.question-card .question-content.expanded {
  display: block; max-height: none;
}

/* 展开/收起按钮 */
.question-content-toggle {
  display: block; font-size: 0.75rem; color: #1a73e8;
  cursor: pointer; padding: 2px 0; margin-bottom: 6px;
  user-select: none;
}
.question-content-toggle:hover { color: #1557b0; text-decoration: underline; }

/* 卡片操作按钮区 */
.question-card .question-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.question-card .question-actions .btn { font-size: 0.75rem; padding: 2px 10px; }

/* 解析字段样式 */
.parse-fields { margin: 8px 0; }
.parse-field-row {
  display: flex; gap: 8px; padding: 4px 0; font-size: 0.875rem;
  border-bottom: 1px solid #f0f0f0;
}
.parse-field-label { font-weight: 500; color: #5f6368; min-width: 56px; flex-shrink: 0; }
.parse-field-value { color: #1a2332; flex: 1; }

/* 解析详情 Markdown 渲染（P2 表格） */
.parse-detail table { border-collapse: collapse; width: 100%; margin: 4px 0; font-size: 0.8125rem; }
.parse-detail th, .parse-detail td { border: 1px solid #dadce0; padding: 4px 8px; text-align: left; }
.parse-detail th { background: #f8f9fa; font-weight: 600; }

/* 可信度标签 */
.question-confidence {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 500;
}
.question-confidence.high { background: #e6f4ea; color: #137333; }
.question-confidence.medium { background: #fef7e0; color: #b06000; }
.question-confidence.low { background: #fce8e6; color: #c5221f; }

/* 解析状态标签 */
.parse-status-tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 500;
}
.parse-status-tag.confirmed { background: #e6f4ea; color: #137333; }
.parse-status-tag.modified { background: #e8f0fe; color: #1a73e8; }
.parse-status-tag.pending { background: #fef7e0; color: #b06000; }
.parse-status-tag.failed { background: #fce8e6; color: #c5221f; }

/* 学生答案区域 */
.question-user-answer { background: #fff8e1; padding: 6px 12px; border-radius: 6px; font-size: 0.8125rem; margin-bottom: 6px; }

/* 试卷标题栏 */
.source-title-bar { background: #f0f7ff; padding: 8px 12px; border-radius: 6px; font-size: 0.875rem; color: #1a73e8; margin-bottom: 12px; }

/* 难度标签 */
.difficulty-1 { color: #34a853; }
.difficulty-2 { color: #f9ab00; }
.difficulty-3 { color: #ea4335; }
.difficulty-4 { color: #c5221f; font-weight: 600; }
/* ── 解析区展开收起 ── */
.parse-detail-collapsed {
  max-height: 9em; overflow: hidden; position: relative;
  cursor: pointer; transition: max-height 0.2s;
}
.parse-detail-collapsed.expanded {
  max-height: none; overflow: visible;
}
.parse-detail-toggle {
  display: block; font-size: 0.75rem; color: #1a73e8;
  cursor: pointer; padding: 2px 0;
  user-select: none;
}
.parse-detail-toggle:hover { color: #1557b0; text-decoration: underline; }
/* ── 展开收起按钮（🔎）── */
.btn-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 10px; border: 1px solid #dadce0; border-radius: 14px;
  background: #fff; color: #1a73e8; font-size: 0.75rem;
  cursor: pointer; user-select: none; transition: all 0.15s;
  margin-top: 2px; margin-bottom: 2px;
}
.btn-toggle:hover { background: #e8f0fe; border-color: #1a73e8; }
.question-actions .btn-toggle { margin-left: 30px; }

/* 科目缺失警示条 */
.subject-warning-banner {
    background: #fff3e0;
    border: 1.5px solid #ff9800;
    border-left: 4px solid #e65100;
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #bf360c;
    line-height: 1.6;
    display: flex;
    align-items: center;
    gap: 8px;
}/* ── Sprint 2.5 Dashboard 样式 ── */
.dashboard-container { max-width: 960px; margin: 0 auto; padding: 20px; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.dashboard-section { margin-bottom: 32px; }

/* 状态卡片 */
.status-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; margin-bottom: 12px; transition: all 0.2s; }
.status-card:hover { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.status-card.running { border-left: 4px solid #2196F3; }
.status-card.actionable { border-left: 4px solid #FF9800; }
.status-card.done { border-left: 4px solid #4CAF50; }
.status-card.failed { border-left: 4px solid #f44336; }

/* 进度条 */
.progress-bar { height: 6px; background: #e0e0e0; border-radius: 3px; margin: 8px 0; overflow: hidden; }
.progress-fill { height: 100%; background: #2196F3; border-radius: 3px; transition: width 0.5s ease; }
.status-card.done .progress-fill { background: #4CAF50; }
.status-card.failed .progress-fill { background: #f44336; }

/* 状态标签 */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.6875rem; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.status-badge.status-ocr_running,
.status-badge.status-split_running,
.status-badge.status-parse_running { background: #e3f2fd; color: #1565c0; }
.status-badge.status-ocr_success,
.status-badge.status-split_success,
.status-badge.status-parse_success { background: #e8f5e9; color: #2e7d32; }
.status-badge.status-parse_partial { background: #fff3e0; color: #e65100; }
.status-badge.status-failed { background: #ffebee; color: #c62828; }
.status-badge.status-saved,
.status-badge.status-completed { background: #e8f5e9; color: #2e7d32; }

/* 空状态 */
.empty-state { text-align: center; padding: 48px 20px; color: #9e9e9e; font-size: 16px; }

/* 操作按钮组 */
.card-actions { display: flex; gap: 8px; margin-top: 8px; }
.card-actions button { padding: 4px 12px; border: 1px solid #d0d0d0; border-radius: 4px; cursor: pointer; font-size: 13px; background: #fff; transition: all 0.15s; }
.card-actions .btn-primary { background: #1976D2; color: #fff; border-color: #1976D2; }
.card-actions .btn-primary:hover { background: #1565c0; }
.card-actions .btn-danger { color: #d32f2f; border-color: #d32f2f; }
.card-actions .btn-danger:hover { background: #ffebee; }

/* 加载文本 */
.loading-text { text-align: center; padding: 24px 0; color: #9aa0a6; }

/* ── 提交通知条 ── */
.submit-notice {
  background: #e8f5e9;
  border-bottom: 2px solid #4caf50;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: #1b5e20;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.submit-notice[hidden] { display: none !important; }

/* ── 任务通知徽章 ── */
.task-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  color: #fff;
  font-size: 0.8125rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
  margin-right: 8px;
  white-space: nowrap;
}
.task-badge:hover {
  background: rgba(255, 255, 255, 0.25);
}
.task-badge .badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: #FF5252;
  border-radius: 9px;
  font-size: 0.75rem;
  font-weight: 600;
}
.task-badge.hidden {
  display: none !important;
}