﻿/* ============================================
   TMUA 刷题小站 - 全局样式
   ============================================ */

:root {
  --primary: #1a56db;
  --primary-dark: #1342a0;
  --primary-light: #e8effd;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);

  /* Pearson VUE 考试颜色方案 */
  --exam-bg: #ffffff;
  --exam-text: #000000;
  --exam-highlight: #1a56db;
  --exam-border: #cccccc;
  --exam-flagged: #eab308;
  --exam-selected: #dbeafe;
  --exam-answered: #bbf7d0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   登录 / 注册 页面
   ============================================ */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #1a56db 50%, #2563eb 100%);
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-secondary:hover {
  background: var(--primary-light);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.auth-footer a:hover { text-decoration: underline; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* ============================================
   仪表盘
   ============================================ */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar h2 {
  font-size: 18px;
  color: var(--primary);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.btn-logout {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}

.btn-logout:hover {
  background: #f3f4f6;
  color: var(--danger);
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 32px 0 16px;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.paper-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.paper-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.paper-card .year {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.paper-card .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================
   考试模拟器 (Pearson VUE 风格)
   ============================================ */
.exam-page {
  background: var(--exam-bg);
  color: var(--exam-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.exam-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--exam-border);
  font-size: 13px;
  min-height: 40px;
}

.exam-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exam-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exam-toolbar button,
.exam-toolbar select {
  padding: 4px 10px;
  border: 1px solid var(--exam-border);
  border-radius: 4px;
  background: white;
  font-size: 13px;
  cursor: pointer;
}

.exam-toolbar button:hover {
  background: #e9ecef;
}

.exam-toolbar select {
  padding: 3px 6px;
}

.exam-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.exam-content {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
}

/* NDA 页面 */
.exam-nda {
  max-width: 720px;
  margin: 40px auto;
  text-align: center;
}

.exam-nda h2 {
  font-size: 22px;
  margin-bottom: 20px;
}

.exam-nda p {
  font-size: 14px;
  color: #444;
  margin-bottom: 20px;
  text-align: left;
  line-height: 1.7;
}

.exam-nda .btn {
  width: auto;
  padding: 12px 40px;
  font-size: 16px;
}

/* 题目区域 */
.question-area {
  max-width: 780px;
  margin: 0 auto;
}

.question-header {
  margin-bottom: 24px;
}

.question-number {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.question-text {
  font-size: 16px;
  line-height: 1.7;
}

.question-text .math {
  font-style: italic;
}

.diagram-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
  border-radius: 4px;
}

.option-table {
  border-collapse: collapse;
  margin: 12px auto;
  width: auto;
}
.option-table td,
.option-table th {
  border: 1px solid #999;
  padding: 6px 14px;
  text-align: center;
  vertical-align: middle;
}
.option-table td:first-child {
  font-weight: bold;
  text-align: center;
}

.diagram-placeholder {
  margin: 20px 0;
  padding: 40px;
  border: 2px dashed var(--exam-border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  background: #fafafa;
}

/* 选项 */
.options-list {
  list-style: none;
  margin-top: 24px;
}

.option-item {
  margin-bottom: 8px;
}

.option-item label {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--exam-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 15px;
}

.option-item label:hover {
  background: #f0f4ff;
  border-color: var(--primary);
}

.option-item input[type="radio"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.option-item input[type="radio"]:checked + .option-letter {
  /* 保留选项字母样式 */
}

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

.option-item .option-letter {
  font-weight: 700;
  margin-right: 8px;
  min-width: 20px;
}

/* 右侧导航 */
.exam-nav {
  width: 240px;
  border-left: 1px solid var(--exam-border);
  padding: 20px;
  overflow-y: auto;
  background: #fafafa;
  flex-shrink: 0;
}

.exam-nav h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.question-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--exam-border);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-btn:hover {
  background: #e9ecef;
}

.question-btn.active {
  border-color: var(--exam-highlight);
  background: var(--exam-highlight);
  color: white;
}

.question-btn.answered {
  background: var(--exam-answered);
  border-color: #86efac;
}

.question-btn.answered.active {
  background: var(--exam-highlight);
  color: white;
}

.question-btn.flagged {
  position: relative;
}

.question-btn.flagged::after {
  content: "🔖";
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
}

.nav-info {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.nav-info span {
  display: inline-block;
  margin-right: 8px;
}

.nav-info .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 2px;
  vertical-align: middle;
}

.dot-answered { background: var(--exam-answered); border: 1px solid #86efac; }
.dot-flagged { background: var(--exam-flagged); }
.dot-current { background: var(--exam-highlight); }

/* 底部导航 */
.exam-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-top: 1px solid var(--exam-border);
  background: #f8f9fa;
}

.exam-bottom-bar button {
  padding: 8px 24px;
  border: 1px solid var(--exam-border);
  border-radius: 4px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.exam-bottom-bar button:hover {
  background: #e9ecef;
}

.exam-bottom-bar button.btn-primary-exam {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.exam-bottom-bar button.btn-primary-exam:hover {
  background: var(--primary-dark);
}

.timer {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-warning { color: var(--danger); }

/* 考试结束页面 */
.exam-end {
  max-width: 600px;
  margin: 60px auto;
  text-align: center;
}

/* 成绩结果 */
.result-page {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 24px;
}

.result-header {
  text-align: center;
  margin-bottom: 32px;
}

.result-score {
  font-size: 64px;
  font-weight: 700;
  color: var(--primary);
}

.result-label {
  font-size: 18px;
  color: var(--text-secondary);
}

/* ============================================
   Loading spinner
   ============================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .exam-main {
    flex-direction: column-reverse;
  }
  .exam-nav {
    width: 100%;
    border-left: none;
    border-bottom: 1px solid var(--exam-border);
    padding: 12px 16px;
  }
  .question-grid {
    grid-template-columns: repeat(10, 1fr);
  }
  .exam-content {
    padding: 20px;
  }
  .paper-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* Random paper generator */
.generator-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  max-width: 480px;
}
.gen-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.gen-row label { min-width: 90px; font-size: 14px; }
.gen-select {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  outline: none;
}
.gen-select:focus { border-color: var(--primary); }