/* SQL学习平台 - 全局样式 (统一风格适配版) */

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

/* ========== 仅新增：统一CSS变量体系 ========== */
:root {
  --primary-color: #3b82f6;      /* 主色调：蓝色 */
  --secondary-color: #60a5fa;    /* 次要色调 */
  --background-color: #f3f4f6;   /* 背景色 */
  --card-background: #ffffff;    /* 卡片背景 */
  --text-color: #1f2937;         /* 主文本色 */
  --sidebar-background: #ffffff; /* 侧边栏背景 */
  --border-color: #e5e7eb;       /* 边框色 */
  --hover-color: rgba(59, 130, 246, 0.1); /* 悬浮色 */
  --active-color: rgba(59, 130, 246, 0.15); /* 激活色 */
  --muted-color: #6b7280;        /* 弱化文本色 */
  --header-height: 64px;         /* 新增：header高度 */
  --sidebar-width: 260px;        /* 新增：侧边栏宽度 */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background-color); /* 替换：使用变量 */
  color: var(--text-color);                 /* 替换：使用变量 */
  line-height: 1.4;
}

/* 顶部导航栏 */
.header {
  /* 替换：渐变配色统一 */
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 1rem 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: fixed; /* 改为固定定位 */
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height); /* 使用变量 */
  z-index: 1000; /* 提高层级 */
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: bold;
  text-decoration: none;
  color: white;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color); /* 替换：使用变量 */
  font-weight: bold;
  font-size: 0.9rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
  text-decoration: none;
  display: inline-block;
  font-size: 0.9rem;
}

.header-btn:hover {
  background: rgba(255,255,255,0.3);
}

.mobile-menu-btn {
  display: none;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.5rem;
}

/* 主容器 */
.container {
  display: flex;
  min-height: 100vh;
  padding-top: var(--header-height); /* 为header留出空间 */
}

/* 侧边栏 (核心调整：适配统一风格) */
.sidebar {
  width: var(--sidebar-width); /* 使用变量 */
  background: var(--sidebar-background); /* 替换：使用变量 */
  border-right: 1px solid var(--border-color); /* 替换：使用变量 */
  padding: 1.5rem 0;
  overflow-y: auto;
  /* 新增：固定定位 */
  position: fixed;
  left: 0;
  top: var(--header-height); /* 在header下方 */
  height: calc(100vh - var(--header-height)); /* 计算剩余高度 */
  z-index: 900; /* 低于header但高于内容 */
  /* 新增：侧边栏阴影 */
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.nav-item {
  padding: 0.75rem 1.5rem;
  margin: 0.25rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-color); /* 替换：使用变量 */
  text-decoration: none;
}

.nav-item:hover {
  background: var(--hover-color); /* 替换：使用变量 */
}

.nav-item.active {
  background: var(--active-color); /* 替换：使用变量 */
  color: var(--primary-color);     /* 替换：使用变量 */
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit; /* Match icon color to menu text */
  flex-shrink: 0; /* Prevent icon from shrinking */
}

.nav-children {
  margin-left: 2.5rem;
}

.nav-child {
  padding: 0.5rem 1rem;
  margin: 0.25rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  color: var(--muted-color); /* 替换：使用变量 */
  font-size: 0.9rem;
  text-decoration: none;
  display: block;
}

.nav-child:hover {
  background: var(--hover-color); /* 替换：使用变量 */
  color: var(--primary-color);    /* 替换：使用变量 */
}

.nav-child.active {
  background: var(--active-color); /* 替换：使用变量 */
  color: var(--primary-color);     /* 替换：使用变量 */
  font-weight: 600;
}

/* 主内容区 */
.main-content {
  flex: 1;
  padding: 0.8rem;
  overflow-y: auto; /* 允许垂直滚动 */
  background-color: var(--background-color); /* 替换：使用变量 */
  /* 新增：左侧留出侧边栏空间 */
  margin-left: var(--sidebar-width);
  /* 新增：高度计算 */
  min-height: calc(100vh - var(--header-height));
  max-height: calc(100vh - var(--header-height));
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* 页面标题 */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 1rem;
}

.page-desc {
  font-size: 1.0rem;
  color: var(--muted-color); /* 替换：使用变量 */
  line-height: 1.6;
}

/* 欢迎区域 */
.welcome-section {
  margin-bottom: 1.5rem;
}

.welcome-title {
  font-size: 2.0rem;
  font-weight: bold;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 0.8rem;
}

.welcome-desc {
  font-size: 1.125rem;
  color: var(--muted-color); /* 替换：使用变量 */
  line-height: 1.6;
}

/* 卡片样式 (核心调整：统一卡片风格) */
.card {
  background: var(--card-background); /* 替换：使用变量 */
  border-radius: 0.5rem; /* 统一圆角 */
  padding: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* 统一阴影 */
  margin-bottom: 0.5rem;
  transition: all 0.3s;
  border: none; /* 移除默认边框 */
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* 统一hover阴影 */
}

.card-title {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 0.5rem;
}

.card-subtitle {
  color: var(--muted-color); /* 替换：使用变量 */
  margin-bottom: 1.5rem;
}

.card-desc {
  color: var(--muted-color); /* 替换：使用变量 */
  line-height: 1.6;
}

/* 特色功能卡片 (适配统一风格) */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.feature-card {
  background: var(--card-background); /* 替换：使用变量 */
  border-radius: 0.5rem; /* 统一圆角 */
  padding: 0.8rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  border: 1px solid transparent; /* 保留原有边框逻辑 */
  transition: all 0.3s;
}

.feature-card:hover {
  border-color: var(--primary-color); /* 替换：使用变量 */
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.2); /* 适配主色调 */
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.icon-star {
  background: var(--hover-color); /* 替换：使用变量 */
  color: var(--primary-color);    /* 替换：使用变量 */
}

.icon-clock {
  background: rgba(32, 201, 151, 0.1);
  color: #20C997;
}

.icon-users {
  background: rgba(255, 193, 7, 0.1);
  color: #FFC107;
}

.feature-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 0.5rem;
}

.feature-desc {
  color: var(--muted-color); /* 替换：使用变量 */
  line-height: 1.6;
}

/* 学习路径 */
.learning-path {
  margin-top: 1.5rem;
}

.section-title {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 1rem;
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1rem;
}

.path-card {
  background: var(--card-background); /* 替换：使用变量 */
  border-radius: 0.5rem; /* 统一圆角 */
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: none; /* 移除默认边框 */
}

.path-card.basic {
  background: linear-gradient(135deg, #e3f2fd 0%, var(--card-background) 100%); /* 适配变量 */
}

.path-card.advanced {
  background: linear-gradient(135deg, #f3e5f5 0%, var(--card-background) 100%); /* 适配变量 */
}

.path-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.path-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--primary-color); /* 替换：使用变量 */
  color: white;
}

.path-icon.advanced {
  background: #9C27B0;
}

.path-info h3 {
  font-size: 1.3rem;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 0.15rem;
}

.path-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #20C997;
  color: white;
}

.path-badge.medium {
  background: #FFC107;
}

.path-desc {
  color: var(--muted-color); /* 替换：使用变量 */
  margin-bottom: 1rem;
  line-height: 1.4;
}

.path-topics {
  margin-bottom: 1.5rem;
}

.path-topics h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color); /* 替换：使用变量 */
  margin-bottom: 0.75rem;
}

.topic-list {
  display: grid;
  gap: 0.5rem;
}

.topic-item {
  padding: 0.6rem 0.8rem;
  background: var(--hover-color); /* 替换：使用变量 */
  border-radius: 8px;
  transition: all 0.3s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.topic-item:hover {
  background: var(--active-color); /* 替换：使用变量 */
}

.topic-name {
  color: var(--primary-color); /* 替换：使用变量 */
  font-weight: 600;
}

.topic-desc {
  font-size: 0.875rem;
  color: var(--muted-color); /* 替换：使用变量 */
  margin-left: 0.5rem;
}

/* 按钮样式 (适配统一风格) */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary-color); /* 替换：使用变量 */
  color: white;
}

.btn-primary:hover {
  background: var(--secondary-color); /* 替换：使用变量 */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); /* 适配主色调 */
}

.btn-secondary {
  background: var(--muted-color); /* 替换：使用变量 */
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-full {
  width: 100%;
}

/* 代码块 (微调) */
.code-block {
  background: #f5f5f5;
  border-radius: 4px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--text-color); /* 替换：使用变量 */
  overflow-x: auto;
  line-height: 1.3;
  margin: 1rem 0;
}

.code-block code {
  display: block;
}

/* 提示框 (保留原有样式，仅替换文本色变量) */
.alert {
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.alert-warning {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
}

.alert-info {
  background: #d1ecf1;
  border-left: 4px solid #17a2b8;
}

.alert-success {
  background: #d4edda;
  border-left: 4px solid #28a745;
}

.alert-icon {
  font-size: 1.0rem;
  flex-shrink: 0;
}

.alert-content {
  line-height: 1.0;
  color: #856404;
}

.alert-info .alert-content {
  color: #0c5460;
}

.alert-success .alert-content {
  color: #155724;
}

/* 练习卡片 (适配变量) */
.practice-card {
  background: linear-gradient(135deg, #e8f5e9 0%, var(--card-background) 100%);
  border-left: 4px solid #20C997;
  border-radius: 0.5rem; /* 统一圆角 */
  padding: 2rem;
  margin-top: 2rem;
}

.practice-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.practice-icon {
  font-size: 1.5rem;
}

.practice-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color); /* 替换：使用变量 */
}

.practice-list {
  list-style: none;
  counter-reset: practice-counter;
}

.practice-item {
  counter-increment: practice-counter;
  padding: 0.75rem 0;
  display: flex;
  gap: 1rem;
  color: var(--text-color); /* 替换：使用变量 */
  line-height: 1.6;
}

.practice-item::before {
  content: counter(practice-counter) ".";
  font-weight: bold;
  color: #20C997;
  flex-shrink: 0;
}

/* 标签 (适配变量) */
.badge {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 12px;
  text-align: center;
}

.badge-success {
  background: #20C997;
  color: white;
}

.badge-warning {
  background: #FFC107;
  color: white;
}

.badge-danger {
  background: #dc3545;
  color: white;
}

.badge-primary {
  background: var(--primary-color); /* 替换：使用变量 */
  color: white;
}

/* 表格 (适配变量) */
.table-container {
  overflow-x: auto;
  margin: 1rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-background); /* 替换：使用变量 */
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color); /* 替换：使用变量 */
}

th {
  background: var(--background-color); /* 替换：使用变量 */
  font-weight: 600;
  color: var(--text-color); /* 替换：使用变量 */
}

tr:hover {
  background: var(--hover-color); /* 替换：使用变量 */
}

/* 输入框 (适配变量) */
.input-group {
  margin-bottom: 1rem;
}

.input-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-color); /* 替换：使用变量 */
}

.input-field {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color); /* 替换：使用变量 */
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary-color); /* 替换：使用变量 */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* 适配主色调 */
}

textarea.input-field {
  min-height: 200px;
  resize: vertical;
  font-family: 'Courier New', monospace;
}

/* 网格布局 (保留原有) */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* 移动端适配 (保留原有，仅替换变量) */
@media (max-width: 768px) {
  /* 移动端恢复为原来的布局 */
  .sidebar {
    display: none;
    position: static;
    width: 100%;
    height: auto;
    box-shadow: none;
    margin-top: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .welcome-title,
  .page-title {
    font-size: 1.25rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .main-content {
    padding: 1rem;
    margin-left: 0;
    min-height: auto;
    max-height: none;
  }

  .card,
  .feature-card,
  .path-card {
    padding: 1.5rem;
  }

  .path-grid {
    grid-template-columns: 1fr;
  }

  .header-right span {
    display: none;
  }
  
  /* 移动端显示侧边栏时的样式 */
  .sidebar.show {
    display: block;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - var(--header-height));
    z-index: 1001;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
  }
  
  .sidebar.show + .main-content {
    margin-left: 0;
  }
}

/* 工具类 (保留原有) */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--muted-color); /* 替换：使用变量 */
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* 关键词标签区域整体样式 (保留原有) */
.tags-section {
  padding: 1rem 1.5rem;
}

/* 标签标题样式 (适配变量) */
.tags-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted-color); /* 替换：使用变量 */
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tags-section .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tags-section .tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--background-color); /* 替换：使用变量 */
  color: var(--text-color); /* 替换：使用变量 */
  border-radius: 0.25rem;
  transition: all 0.3s ease;
  white-space: nowrap;
}

/* 标签hover效果 (适配变量) */
.tags-section .tag:hover {
  background-color: var(--hover-color); /* 替换：使用变量 */
  color: var(--primary-color); /* 替换：使用变量 */
}

/* 强制换行符 (保留原有) */
.tag-break {
  flex-basis: 100%;
  height: 0;
  overflow: hidden;
}

/* 自定义SQL数据类型表格样式 (适配变量) */
.sql-type-table {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 0.85rem;
  line-height: 1.2;
  border: 1px solid var(--border-color); /* 替换：使用变量 */
}

/* 表头样式 (适配变量) */
.sql-type-table thead th {
  padding: 0.5rem 0.75rem;
  background: var(--background-color); /* 替换：使用变量 */
  font-weight: 600;
  color: var(--text-color); /* 替换：使用变量 */
  border: 1px solid var(--border-color); /* 替换：使用变量 */
  text-align: center;
}

/* 表体单元格样式 (适配变量) */
.sql-type-table tbody td {
  padding: 0.4rem 0.6rem;
  text-align: center;
  border: 1px solid var(--border-color); /* 替换：使用变量 */
  color: var(--text-color); /* 替换：使用变量 */
}

/* 保留hover效果 (适配变量) */
.sql-type-table tbody tr:hover {
  background: var(--hover-color); /* 替换：使用变量 */
}

/* 表格容器适配 (保留原有) */
.table-container {
  overflow-x: auto;
  margin: 0.8rem 0;
  padding: 0;
}

/* 简单修复：为所有锚点目标添加固定偏移 */
:target {
  scroll-margin-top: 80px; /* 根据实际导航栏高度调整 */
}

/* 兼容性回退 */
:target::before {
  display: block;
  content: " ";
  margin-top: -80px;
  height: 80px;
  visibility: hidden;
  pointer-events: none;
}