/* ─── 基础样式 ───────────────────────────────────────────── */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --secondary: #6b7280;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --elementary: #22c55e;
  --middle: #3b82f6;
  --high: #8b5cf6;
  
  --bg: #f9fafb;
  --card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
}

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

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ─── 按钮 ───────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

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

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

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

.btn-secondary:hover {
  background: #4b5563;
}

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

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

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

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

/* ─── 首页 ──────────────────────────────────────────────── */
.landing .hero {
  text-align: center;
  padding: 60px 20px;
}

.hero h1 {
  font-size: 48px;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 18px;
  color: var(--text-light);
  margin-bottom: 30px;
}

.level-badges {
  margin-bottom: 30px;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: white;
  margin: 0 5px;
}

.badge.elementary { background: var(--elementary); }
.badge.middle { background: var(--middle); }
.badge.high { background: var(--high); }

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

.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.feature .icon {
  font-size: 32px;
}

.cta-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

/* ─── 认证页面 ──────────────────────────────────────────── */
.auth-card {
  max-width: 400px;
  margin: 60px auto;
  background: var(--card);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 30px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.error-msg, .success-msg {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
}

.error-msg {
  background: #fef2f2;
  color: var(--danger);
}

.success-msg {
  background: #f0fdf4;
  color: var(--success);
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  color: var(--text-light);
}

.auth-footer a {
  color: var(--primary);
}

/* ─── Dashboard ─────────────────────────────────────────── */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}

.dashboard-header h1 {
  font-size: 24px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.stats-section, .level-section, .history-section {
  margin-bottom: 40px;
}

.stats-section h2, .level-section h2, .history-section h2 {
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--card);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--primary);
}

.stat-label {
  color: var(--text-light);
  margin-top: 5px;
}

.level-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.level-card {
  background: var(--card);
  padding: 30px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

.level-card:hover {
  transform: translateY(-4px);
}

.level-card.elementary { border-top: 4px solid var(--elementary); }
.level-card.middle { border-top: 4px solid var(--middle); }
.level-card.high { border-top: 4px solid var(--high); }

.level-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.level-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.level-count {
  color: var(--text-light);
  margin-bottom: 15px;
}

.level-progress {
  margin-bottom: 20px;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

.progress-text {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
}

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

.history-list {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}

.history-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  gap: 15px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item .word {
  font-weight: 600;
  min-width: 100px;
}

.history-item .level-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.level-badge.elementary { background: #dcfce7; color: var(--elementary); }
.level-badge.middle { background: #dbeafe; color: var(--middle); }
.level-badge.high { background: #ede9fe; color: var(--high); }

.history-item .mode {
  color: var(--text-light);
  font-size: 12px;
}

.history-item .result {
  margin-left: auto;
  font-size: 12px;
}

.history-item.passed .result { color: var(--success); }
.history-item.failed .result { color: var(--danger); }

.history-item .time {
  color: var(--text-light);
  font-size: 11px;
  min-width: 80px;
  text-align: right;
}

/* ─── 学习页面 ──────────────────────────────────────────── */
.learn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  margin-bottom: 20px;
}

.back-btn {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.progress-info {
  display: flex;
  gap: 20px;
  color: var(--text-light);
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 40px;
}

.mode-card {
  background: var(--card);
  padding: 40px 20px;
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.mode-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.mode-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.mode-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

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

/* 闪卡 */
.flashcard-container {
  display: flex;
  justify-content: center;
  margin: 40px 0;
}

.flashcard {
  width: 350px;
  height: 450px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: var(--card);
  border-radius: 16px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.flashcard-back {
  transform: rotateY(180deg);
}

.flashcard .word {
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 10px;
}

.flashcard .phonetic {
  color: var(--text-light);
  margin-bottom: 20px;
}

.flashcard .word-small {
  font-size: 20px;
  margin-bottom: 5px;
}

.flashcard .pos {
  color: var(--text-light);
  margin-bottom: 10px;
}

.flashcard .meaning {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 20px;
}

.flashcard .example {
  color: var(--text-light);
  font-style: italic;
  text-align: center;
}

.flashcard .hint {
  color: var(--text-light);
  font-size: 12px;
  margin-top: 20px;
}

.speak-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 20px;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* 选择题 */
.choice-container {
  max-width: 500px;
  margin: 0 auto;
}

.question-card {
  background: var(--card);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 30px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.question-card .word {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 10px;
}

.question-card .phonetic {
  color: var(--text-light);
  margin-bottom: 15px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  background: var(--card);
  border: 2px solid var(--border);
  padding: 15px 20px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

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

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

/* 拼写 */
.spelling-container {
  max-width: 500px;
  margin: 0 auto;
}

.hint-card {
  background: var(--card);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 30px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hint-card .pos {
  color: var(--text-light);
  margin-bottom: 10px;
}

.hint-card .meaning {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}

.hint-card .example {
  color: var(--text-light);
  font-style: italic;
}

.input-area {
  display: flex;
  gap: 10px;
}

.input-area input {
  flex: 1;
  padding: 15px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 18px;
}

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

.feedback {
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
  text-align: center;
  font-weight: 500;
}

.feedback.success {
  background: #dcfce7;
  color: var(--success);
}

.feedback.error {
  background: #fef2f2;
  color: var(--danger);
}

/* 完成页面 */
.complete-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.complete-card {
  background: var(--card);
  padding: 60px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.complete-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.complete-stats {
  margin: 30px 0;
}

.complete-stats p {
  margin: 10px 0;
  font-size: 18px;
}

.complete-stats span {
  font-weight: bold;
  color: var(--primary);
}

.complete-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
}

/* ─── 管理后台 ──────────────────────────────────────────── */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}

.admin-section {
  background: var(--card);
  padding: 30px;
  border-radius: 16px;
  margin-bottom: 30px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.admin-section h2 {
  margin-bottom: 20px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
}

.import-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  cursor: pointer;
}

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

.import-hint {
  color: var(--text-light);
  margin-bottom: 10px;
}

#importVocab {
  width: 100%;
  min-height: 200px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  margin-bottom: 15px;
}

#importVocab:focus {
  outline: none;
  border-color: var(--primary);
}

.import-content input[type="file"] {
  margin-bottom: 15px;
}

.import-result {
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
}

.import-result.success {
  background: #dcfce7;
  color: var(--success);
}

.import-result.error {
  background: #fef2f2;
  color: var(--danger);
}

.import-result.info {
  background: #eff6ff;
  color: var(--primary);
}

.filter-bar {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

.filter-bar select, .filter-bar input {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.filter-bar input {
  flex: 1;
}

.words-table-container {
  overflow-x: auto;
}

.words-table {
  width: 100%;
  border-collapse: collapse;
}

.words-table th, .words-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.words-table th {
  background: var(--bg);
  font-weight: 600;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.page-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
}

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

/* ─── 通用 ──────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.empty {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.error {
  color: var(--danger);
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .hero h1 {
    font-size: 32px;
  }

  .features {
    gap: 20px;
  }

  .level-cards {
    grid-template-columns: 1fr;
  }

  .flashcard {
    width: 100%;
    max-width: 350px;
  }

  .history-item {
    flex-wrap: wrap;
  }
}

/* ─── 弹窗 Modal ────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card);
  padding: 30px;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.success-msg {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
  text-align: center;
  background: #dcfce7;
  color: var(--success);
}
