/* ========================================
   学法减分答题系统 - 移动端样式
   适配 320px - 768px 屏幕
   ======================================== */

:root {
  --primary: #4a90d9;
  --primary-dark: #357abd;
  --success: #52c41a;
  --danger: #ff4d4f;
  --warning: #faad14;
  --text: #333;
  --text-secondary: #666;
  --text-light: #999;
  --bg: #f5f6fa;
  --card-bg: #fff;
  --border: #e8e8e8;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

/* =====================
   通用组件
   ===================== */

.container {
  max-width: 750px;
  margin: 0 auto;
  padding: 0 15px;
}

/* 顶部导航 */
.header {
  background: var(--primary);
  color: #fff;
  padding: 12px 15px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(74,144,217,0.3);
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.header-back {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  padding: 5px;
}

.header-back::before {
  content: "‹";
  font-size: 24px;
  margin-right: 4px;
}

/* 卡片 */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  user-select: none;
  min-height: 44px;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 18px;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 13px;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-outline:active {
  background: var(--primary);
  color: #fff;
}

/* 输入框 */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color 0.2s;
  min-height: 44px;
}

.input:focus {
  border-color: var(--primary);
}

.input-search {
  padding-right: 44px;
}

.input::placeholder {
  color: var(--text-light);
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-judge {
  background: #e6f7ff;
  color: #1890ff;
}

.tag-single {
  background: #f6ffed;
  color: #52c41a;
}

.tag-multi {
  background: #fff7e6;
  color: #fa8c16;
}

.tag-correct {
  background: #f6ffed;
  color: #52c41a;
}

.tag-wrong {
  background: #fff2f0;
  color: #ff4d4f;
}

/* 加载 */
.loading {
  text-align: center;
  padding: 40px 0;
  color: var(--text-light);
}

.loading::after {
  content: "加载中...";
}

/* =====================
   首页
   ===================== */

.hero {
  padding: 30px 0;
  text-align: center;
}

.hero-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), #67b8f7);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(74,144,217,0.4);
}

.hero h1 {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 6px;
}

.hero p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* 统计卡片 */
.card-stats {
  text-align: center;
  padding: 12px;
}

.stat-number-lg {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label-sm {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

/* 底部版权卡片 */
.card-footer-info {
  text-align: center;
  padding: 20px;
}

.card-footer-info p {
  color: var(--text-secondary);
  font-size: 13px;
}

.card-footer-info strong {
  color: var(--primary);
}

/* OCR 加载遮罩 */
.ocr-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ocr-loading {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.ocr-loading p {
  margin-top: 16px;
  font-size: 15px;
  color: var(--text);
}

.ocr-progress {
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 16px auto 0;
  overflow: hidden;
}

.ocr-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #67b8f7);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.ocr-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================
   圈选裁剪遮罩
   ===================== */

.crop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.crop-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
}

.crop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1a1a1a;
  color: #fff;
  flex-shrink: 0;
}

.crop-btn-cancel,
.crop-btn-confirm {
  font-size: 16px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  user-select: none;
}

.crop-btn-cancel {
  color: #999;
}

.crop-btn-cancel:active {
  color: #fff;
}

.crop-btn-confirm {
  color: #4a90d9;
  font-weight: 600;
}

.crop-btn-confirm:active {
  color: #67b8f7;
}

.crop-title {
  font-size: 16px;
  font-weight: 500;
}

.crop-image-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #000;
  cursor: default;
}

.crop-image-wrapper img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* 预识别红色区域框 */
.crop-preview-area {
  position: absolute;
  border: 2px solid #ff4d4f;
  background: rgba(255, 77, 79, 0.08);
  cursor: pointer;
  z-index: 11;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  box-sizing: border-box;
  border-radius: 3px;
  min-width: 12px;
  min-height: 12px;
}

.crop-preview-area:hover,
.crop-preview-area:active {
  background: rgba(255, 77, 79, 0.25);
  border-color: #ff7875;
  transform: scale(1.03);
  z-index: 12;
}

.crop-area-num {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ff4d4f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* 手动拖拽选区 */
.crop-selection {
  position: absolute;
  border: 2px dashed #fff;
  background: rgba(74, 144, 217, 0.15);
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

.crop-selection::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border: 1px solid rgba(255,255,255,0.3);
  pointer-events: none;
}

.crop-selection::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crop-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  pointer-events: none;
  text-align: center;
  padding: 14px 22px;
  background: rgba(0,0,0,0.5);
  border-radius: 10px;
  max-width: 80%;
  line-height: 1.5;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 0 0 20px;
}

.menu-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: block;
}

.menu-card:active {
  transform: scale(0.96);
}

.menu-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.menu-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.menu-desc {
  font-size: 12px;
  color: var(--text-light);
}

/* =====================
   搜索页面
   ===================== */

.search-box {
  position: sticky;
  top: 48px;
  background: var(--bg);
  padding: 12px 15px;
  z-index: 99;
}

.search-result-count {
  padding: 8px 15px;
  font-size: 13px;
  color: var(--text-light);
}

.question-item {
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: block;
  color: var(--text);
}

.question-item:active {
  background: #f9f9f9;
}

.question-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.question-item-title {
  font-size: 15px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.question-item-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.highlight {
  color: var(--danger);
  font-weight: 600;
}

/* =====================
   题目详情
   ===================== */

.question-detail {
  padding: 16px;
}

.question-type {
  margin-bottom: 12px;
}

.question-text {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 16px;
}

.question-image {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 16px;
  background: #f9f9f9;
}

/* 选项列表 */
.option-list {
  list-style: none;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s;
  cursor: default;
}

.option-key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.option-value {
  flex: 1;
  font-size: 15px;
  line-height: 1.5;
  padding-top: 3px;
}

.option-item.correct {
  border-color: var(--success);
  background: #f6ffed;
}

.option-item.correct .option-key {
  background: var(--success);
  color: #fff;
}

.option-item.wrong {
  border-color: var(--danger);
  background: #fff2f0;
}

.option-item.wrong .option-key {
  background: var(--danger);
  color: #fff;
}

.option-item.selected {
  border-color: var(--primary);
  background: #e6f7ff;
}

.option-item.selected .option-key {
  background: var(--primary);
  color: #fff;
}

/* 解析 */
.explanation {
  margin-top: 16px;
  padding: 14px;
  background: #fffbe6;
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.explanation-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

/* =====================
   模拟考试
   ===================== */

.exam-header {
  background: var(--primary);
  color: #fff;
  padding: 8px 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.exam-header-left,
.exam-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.exam-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.exam-back-btn {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.exam-back-btn:active {
  background: rgba(255,255,255,0.2);
}

.exam-end-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.exam-end-btn:active {
  background: rgba(255,255,255,0.2);
}

.exam-score-label {
  font-size: 11px;
  opacity: 0.8;
  white-space: nowrap;
}

.exam-timer {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.exam-progress {
  font-size: 14px;
}

.exam-body {
  padding: 12px 15px;
}

.exam-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 15px;
  margin-bottom: 12px;
}

.exam-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.exam-nav-btn.answered.wrong {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.exam-nav-btn.current {
  border-color: var(--primary);
  font-weight: 700;
}

.exam-footer {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding: 12px 15px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  display: flex;
  gap: 12px;
}

.exam-footer .btn {
  flex: 1;
}

/* 答错弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 400px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-dialog .modal-header {
  font-size: 18px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 16px;
  padding: 0;
  border: none;
}

.modal-body {
  margin-bottom: 16px;
}

.modal-correct-label {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--success);
}

.modal-correct-label strong {
  font-size: 16px;
}

.modal-explanation {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
  background: #f9f9f9;
  padding: 12px;
  border-radius: 6px;
  margin-top: 8px;
}

/* 头部红色错误状态 */
.exam-header.exam-header-wrong {
  background: var(--danger) !important;
  transition: background 0.3s;
}

/* 多选题选项 */
.option-item.multi-select .option-key {
  border-radius: 4px;
}

.option-item.multi-select.selected .option-key::after {
  content: "✓";
}

/* =====================
   考试结果
   ===================== */

.result-hero {
  text-align: center;
  padding: 40px 20px;
}

.result-score {
  font-size: 56px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.result-label {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 30px;
}

.result-stat {
  text-align: center;
}

.result-stat-number {
  font-size: 28px;
  font-weight: 700;
}

.result-stat-number.correct {
  color: var(--success);
}

.result-stat-number.wrong {
  color: var(--danger);
}

.result-stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* =====================
   OCR页面
   ===================== */

.ocr-box {
  padding: 20px 15px;
  text-align: center;
}

.ocr-camera-btn {
  width: 120px;
  height: 120px;
  border-radius: 60px;
  background: linear-gradient(135deg, var(--primary), #67b8f7);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  font-size: 48px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(74,144,217,0.4);
  transition: all 0.2s;
  border: none;
}

.ocr-camera-btn:active {
  transform: scale(0.95);
}

.ocr-hint {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: 1.6;
}

.ocr-result {
  margin-top: 20px;
  text-align: left;
}

.ocr-result-text {
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
  word-break: break-all;
  min-height: 40px;
}

/* =====================
   动画
   ===================== */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.pulse {
  animation: pulse 2s ease infinite;
}

/* =====================
   404页面
   ===================== */

.not-found {
  text-align: center;
  padding: 60px 20px;
}

.not-found h2 {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 10px;
}

.not-found p {
  color: var(--text-light);
  margin-bottom: 20px;
}
