/* ===== 变量与基础样式 ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

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

.hidden { display: none !important; }

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

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

.auth-modal {
  width: 400px;
  padding: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 16px;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all 0.2s;
}

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

.auth-switch {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin: 0 28px 20px;
  padding: 4px;
}

.switch-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.switch-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

#authForm {
  padding: 0 28px 28px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.error-msg {
  background: #fef2f2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

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

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

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

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

/* ===== 应用布局 ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(6, 182, 212, 0.1));
  color: var(--primary);
}

.nav-icon {
  font-size: 18px;
}

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 0 32px 32px;
}

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px 4px 14px;
  width: 320px;
  box-shadow: var(--shadow-sm);
}

.search-box input {
  flex: 1;
  border: none;
  padding: 10px;
  font-size: 14px;
  background: transparent;
  outline: none;
  font-family: inherit;
}

.search-box button {
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  font-size: 16px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-stats {
  display: flex;
  gap: 12px;
}

.stat-item {
  background: var(--surface);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  padding: 6px 12px 6px 6px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.user-info:hover {
  background: var(--surface-hover);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 140px;
  animation: slideDown 0.15s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-menu a {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  border-radius: 6px;
}

.user-menu a:hover {
  background: var(--surface-hover);
}

.user-menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

/* ===== 视图容器 ===== */
.view-container {
  min-height: calc(100vh - 100px);
}

/* ===== 首页 Hero ===== */
.hero {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 32px;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 60%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  max-width: 600px;
}

.hero p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 24px;
  max-width: 500px;
}

.hero-stats {
  display: flex;
  gap: 32px;
}

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

.hero-stat span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.25s;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.card-body {
  padding: 20px;
}

/* ===== 课程卡片 ===== */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title h2 {
  font-size: 22px;
  font-weight: 700;
}

.section-title a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.course-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s;
  border: 1px solid var(--border);
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.course-cover {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: white;
  position: relative;
}

.course-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.course-info {
  padding: 18px;
}

.course-info h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.course-info p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.course-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== 进度条 ===== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ===== 单词卡片 ===== */
.word-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.word-text {
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.word-phonetic {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-family: 'Courier New', monospace;
}

.word-meaning {
  font-size: 22px;
  margin-bottom: 16px;
  font-weight: 600;
}

.word-example {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: left;
  font-size: 14px;
  margin-bottom: 24px;
}

.word-example .en {
  font-weight: 500;
  margin-bottom: 4px;
}

.word-example .cn {
  color: var(--text-secondary);
}

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

/* ===== 选项按钮 ===== */
.options-grid {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

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

.option-btn:hover {
  border-color: var(--primary-light);
  background: rgba(99, 102, 241, 0.05);
}

.option-btn.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.option-btn.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ===== 进度视图 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
}

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

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

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

/* ===== 图表 ===== */
.chart-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 200px;
  padding: 0 12px;
}

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

.bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(180deg, var(--primary), var(--secondary));
  border-radius: 6px 6px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}

.bar-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== 成就 ===== */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.achievement-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.achievement-card.unlocked {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface), #fffbeb);
}

.achievement-card.locked {
  opacity: 0.5;
  filter: grayscale(1);
}

.achievement-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.achievement-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

/* ===== 社区 ===== */
.community-post {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.post-meta {
  flex: 1;
}

.post-author {
  font-weight: 600;
  font-size: 14px;
}

.post-time {
  font-size: 12px;
  color: var(--text-muted);
}

.post-content {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.post-actions {
  display: flex;
  gap: 20px;
}

.post-action {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.post-action:hover {
  color: var(--primary);
  background: var(--surface-hover);
}

.new-post-form {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}

.new-post-form textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.new-post-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== Lesson Player ===== */
.lesson-player {
  max-width: 800px;
  margin: 0 auto;
}

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

.lesson-header h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.lesson-header .lesson-type {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.fill-blank {
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.fill-blank .blank {
  display: inline-block;
  min-width: 120px;
  border-bottom: 3px solid var(--primary);
  margin: 0 4px;
  padding: 4px 12px;
  color: var(--primary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  z-index: 2000;
  animation: toastIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 学习模式选择器 ===== */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.mode-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

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

.mode-card.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.mode-card .icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.mode-card .name {
  font-weight: 600;
  margin-bottom: 4px;
}

.mode-card .desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== 轮播 ===== */
.carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px;
  scroll-behavior: smooth;
}

.carousel::-webkit-scrollbar {
  height: 6px;
}

.carousel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.carousel-item {
  min-width: 200px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.carousel-item:hover {
  transform: translateY(-2px);
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
  }
  .hero h1 {
    font-size: 28px;
  }
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state .empty-text {
  font-size: 16px;
}
