
/* 定义CSS变量，方便全局统一管理色彩和字体 */
:root {
  --primary-color: #0d47a1; /* 深蓝色，主色调 */
  --secondary-color: #6a1b9a; /* 紫色，辅助色调 */
  --accent-color-1: #ff9800; /* 亮橙色，点缀色 */
  --accent-color-2: #00e5ff; /* 青绿色，另一个点缀色 */
  --background-color: #2c3e50; /* 非白色背景，保证整体色彩丰富 */
  --text-color: #ecf0f1; /* 浅色文字，适应深色背景 */
  --card-background: #34495e; /* 卡片背景色 */
  --shadow-color: rgba(0, 0, 0, 0.2); /* 阴影颜色 */
  --font-family: 'Roboto', sans-serif; /* 统一字体 */
}

/* 全局样式设置 */
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* 固定顶部导航栏 */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 4px var(--shadow-color);
}

/* 导航栏内的链接样式 */
.navbar a {
  color: #fff;
  text-decoration: none;
  margin-right: 20px;
  font-size: 16px;
  transition: color 0.3s ease;
}

.navbar a:hover {
  color: var(--accent-color-1);
}

/* 侧边栏样式 */
.sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  width: 250px;
  height: calc(100% - 60px);
  background-color: var(--secondary-color);
  padding: 20px;
  transition: width 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 60px;
}

/* 侧边栏内的链接样式 */
.sidebar a {
  display: block;
  color: #fff;
  text-decoration: none;
  margin-bottom: 15px;
  font-size: 16px;
  transition: color 0.3s ease;
}

.sidebar a:hover {
  color: var(--accent-color-2);
}

/* 主容器，内容区域 */
.main-content {
  margin-left: 250px;
  padding: 80px 20px 20px 20px;
  transition: margin-left 0.3s ease;
}

/* 当侧边栏收缩时，主内容区域的样式 */
.sidebar.collapsed + .main-content {
  margin-left: 60px;
}

/* 页面显著位置的提示 */
.banner {
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 8px;
  margin-bottom: 40px;
  box-shadow: 0 4px 6px var(--shadow-color);
}

.banner h1 {
  margin: 0;
  font-size: 24px;
  color: #fff;
}

/* 章节导航样式 */
.chapter-nav {
  position: fixed;
  top: 80px;
  right: 20px;
  background-color: var(--card-background);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 6px var(--shadow-color);
}

.chapter-nav a {
  display: block;
  color: #ecf0f1;
  text-decoration: none;
  margin-bottom: 10px;
  font-size: 14px;
  transition: color 0.3s ease;
}

.chapter-nav a:hover {
  color: var(--accent-color-1);
}

/* 文章内容区域 */
.article {
  max-width: 800px;
  margin: 0 auto;
}

.article h2, .article h3, .article h4 {
  color: var(--accent-color-1);
}

.article pre {
  background-color: #1c2833;
  padding: 15px;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.article code {
  color: var(--accent-color-2);
  font-family: 'Courier New', Courier, monospace;
}

/* 卡片式设计 */
.card-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.card {
  background-color: var(--card-background);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 6px var(--shadow-color);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 12px var(--shadow-color);
}

/* 图片样式 */
.card img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition: transform 0.3s ease;
}

.card img:hover {
  transform: scale(1.05);
}

/* 按钮样式 */
.button {
  background: var(--primary-color);
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
  font-size: 16px;
}

.button:hover {
  background: linear-gradient(45deg, var(--primary-color), var(--accent-color-1));
  transform: scale(1.05);
}

/* 响应式布局 */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .navbar a {
    display: none;
  }

  .chapter-nav {
    display: none;
  }

  .main-content {
    margin-left: 60px;
  }
}

/* 折叠区域样式 */
.collapsible {
  background-color: var(--card-background);
  color: #fff;
  cursor: pointer;
  padding: 10px 15px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 16px;
  transition: background 0.3s ease;
  border-radius: 4px;
  margin-bottom: 10px;
}

.collapsible:hover {
  background: var(--secondary-color);
}

.content {
  padding: 0 15px;
  display: none;
  background-color: var(--background-color);
  overflow: hidden;
  border-radius: 4px;
}

.content p {
  margin: 10px 0;
}

/* 定义动画效果 */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 1s ease-in-out;
}

/* 代码块示例样式 */
.code-example {
  background-color: #1c2833;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
}

.code-example code {
  color: var(--accent-color-2);
  font-family: 'Courier New', Courier, monospace;
}

