/* ============================================
   计算机原理学习工具 - 样式表
   设计风格：科技感深色主题，靛蓝主色调
   ============================================ */

/* CSS 变量定义 */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #334155;
  --border-light: #475569;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s ease;
}

/* 基础重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景装饰 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(34, 197, 94, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* 顶部导航栏 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.navbar-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 64px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.navbar-brand .logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}

.navbar-tabs {
  display: flex;
  gap: 4px;
  list-style: none;
}

.navbar-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: inherit;
}

.navbar-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.navbar-tab.active {
  background: var(--accent);
  color: white;
}

.navbar-tab .icon {
  font-size: 1rem;
}

/* 主容器 */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  position: relative;
  z-index: 1;
}

/* 视图切换 */
.view {
  display: none;
  animation: fadeIn 0.4s ease;
}

.view.active {
  display: block;
}

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

/* ============================================
   知识图谱视图
   ============================================ */

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

.map-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.map-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* 进度概览 */
.progress-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

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

.progress-card .stat {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.progress-card .label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.progress-card .bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-card .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* 章节卡片 */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent);
}

.chapter-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.chapter-card .chapter-num {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chapter-card .chapter-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 8px 0 12px;
}

.chapter-card .chapter-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.chapter-card .chapter-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chapter-card .chapter-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chapter-card .difficulty-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 12px;
}

.badge-easy { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-medium { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-hard { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ============================================
   知识点详情视图
   ============================================ */

.learn-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: calc(100vh - 120px);
}

/* 侧边栏目录 */
.sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
}

.sidebar h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section {
  margin-bottom: 16px;
}

.sidebar-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  padding: 4px 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  color: var(--text-secondary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--accent);
  color: white;
}

.sidebar-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-unlearned { background: var(--text-muted); }
.status-learning { background: var(--warning); }
.status-mastered { background: var(--success); }

/* 知识点内容区 */
.content-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  min-height: 600px;
}

.kp-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.kp-breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kp-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.kp-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.kp-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.kp-section {
  margin-bottom: 32px;
}

.kp-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
}

.kp-section-content {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.95rem;
}

.kp-section-content p {
  margin-bottom: 12px;
}

/* 重点标注 */
.key-points-list {
  list-style: none;
  padding: 0;
}

.key-points-list li {
  padding: 10px 16px;
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

/* 易错点 */
.mistakes-list {
  list-style: none;
  padding: 0;
}

.mistakes-list li {
  padding: 10px 16px;
  background: rgba(239, 68, 68, 0.08);
  border-left: 3px solid var(--danger);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

/* 例题 */
.example-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.example-card .question {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  white-space: pre-line;
}

.example-card .answer {
  color: var(--success);
  font-weight: 600;
  margin-bottom: 8px;
}

.example-card .explanation {
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  white-space: pre-line;
}

/* 参考链接 */
.references-list {
  list-style: none;
  padding: 0;
}

.references-list li {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.ref-type {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.ref-courseware { background: rgba(99, 102, 241, 0.2); color: var(--accent-light); }
.ref-book { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.ref-web { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

/* 知识点导航 */
.kp-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.kp-nav-btn {
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  font-family: inherit;
}

.kp-nav-btn:hover:not(:disabled) {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.kp-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 学习状态按钮 */
.status-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.status-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.status-btn.active {
  border-color: currentColor;
}

.status-btn.btn-mastered.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.status-btn.btn-learning.active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

/* ============================================
   闪卡视图
   ============================================ */

.flashcard-container {
  max-width: 700px;
  margin: 0 auto;
}

.flashcard-header {
  text-align: center;
  margin-bottom: 24px;
}

.flashcard-header h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.flashcard-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 闪卡筛选 */
.flashcard-filters {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  font-family: inherit;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--text-secondary);
}

.filter-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* 闪卡卡片 */
.flashcard-area {
  position: relative;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  margin-bottom: 24px;
}

.flashcard {
  width: 100%;
  max-width: 600px;
  min-height: 320px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
  cursor: pointer;
}

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

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.flashcard-front {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
}

.flashcard-back {
  background: linear-gradient(135deg, var(--accent-dark), var(--bg-secondary));
  transform: rotateY(180deg);
}

.flashcard-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.flashcard-content {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-line;
}

.flashcard-hint {
  position: absolute;
  bottom: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 闪卡控制 */
.flashcard-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.fc-btn {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fc-btn-flip {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.fc-btn-flip:hover {
  background: var(--accent);
}

.fc-btn-known {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}

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

.fc-btn-unknown {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
}

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

/* 闪卡进度 */
.flashcard-progress {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   刷题视图
   ============================================ */

.quiz-container {
  max-width: 800px;
  margin: 0 auto;
}

.quiz-header {
  text-align: center;
  margin-bottom: 24px;
}

.quiz-header h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.quiz-filters {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* 题目卡片 */
.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 20px;
}

.quiz-question {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.6;
  white-space: pre-line;
}

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

.quiz-option {
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  text-align: left;
  color: var(--text-secondary);
}

.quiz-option:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.quiz-option.correct {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

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

.quiz-option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.quiz-option.correct .quiz-option-letter {
  background: var(--success);
  color: white;
}

.quiz-option.wrong .quiz-option-letter {
  background: var(--danger);
  color: white;
}

/* 题目解析 */
.quiz-explanation {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  display: none;
}

.quiz-explanation.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

.quiz-explanation h4 {
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.quiz-explanation p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: pre-line;
}

/* 刷题控制 */
.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.quiz-btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: white;
}

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

.quiz-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 刷题结果 */
.quiz-result {
  text-align: center;
  padding: 40px;
}

.quiz-result-score {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.quiz-result-label {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* 错题本 */
.wrong-questions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wrong-question-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.wrong-question-item .wq-question {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.wrong-question-item .wq-answer {
  color: var(--success);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.wrong-question-item .wq-explanation {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   响应式设计
   ============================================ */

@media (max-width: 900px) {
  .learn-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: relative;
    top: 0;
    max-height: none;
    margin-bottom: 16px;
  }
}

@media (max-width: 600px) {
  .navbar-container {
    padding: 0 12px;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  .navbar-tab {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  
  .navbar-tab .icon {
    font-size: 0.9rem;
  }
  
  .navbar-tab .label {
    display: none;
  }
  
  .main-container {
    padding: 16px 12px;
  }
  
  .content-area {
    padding: 20px 16px;
  }
  
  .kp-title {
    font-size: 1.3rem;
  }
  
  .chapter-grid {
    grid-template-columns: 1fr;
  }
  
  .flashcard {
    min-height: 280px;
  }
  
  .flashcard-face {
    padding: 24px;
  }
  
  .flashcard-content {
    font-size: 1rem;
  }
  
  .quiz-card {
    padding: 20px 16px;
  }
  
  .quiz-option {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
  
  .flashcard-controls {
    flex-wrap: wrap;
  }
  
  .fc-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

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

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 加载动画 */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 12px;
}

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