/* 文档页面样式 */

.docs-container {
  max-width: 1400px;
  margin: 80px auto 40px;
  padding: 0;
  min-height: calc(100vh - 200px);
  display: flex;
  gap: 0;
  position: relative;
}

/* 手机端目录切换按钮 */
.toc-toggle {
  display: none;
  position: fixed;
  top: 70px;
  left: 20px;
  z-index: 999;
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}

.toc-toggle:hover {
  background: #f6f8fa;
}

.toc-toggle svg {
  display: block;
}

/* 左侧目录栏 */
.toc-sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 20px;
  background: #f6f8fa;
  border-right: 1px solid #e1e4e8;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e1e4e8;
}

.toc-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #24292e;
}

.toc-close {
  display: none;
  background: none;
  border: none;
  font-size: 28px;
  color: #586069;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
}

.toc-close:hover {
  color: #24292e;
}

/* 目录导航 */
.toc-nav {
  font-size: 14px;
}

.toc-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-nav > ul {
  padding-left: 0;
}

.toc-nav ul ul {
  padding-left: 16px;
}

.toc-nav li {
  margin: 4px 0;
}

.toc-nav a {
  display: block;
  padding: 6px 12px;
  color: #586069;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1.4;
}

.toc-nav a:hover {
  background: #e1e4e8;
  color: #24292e;
}

.toc-nav a.active {
  background: #0366d6;
  color: #fff;
  font-weight: 500;
}

/* 可折叠的目录项 */
.toc-item-collapsible {
  position: relative;
}

.toc-item-collapsible > a {
  padding-left: 28px;
}

.toc-toggle-icon {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 12px;
  height: 12px;
  cursor: pointer;
  transition: transform 0.2s;
  color: #586069;
}

.toc-toggle-icon::before {
  content: '▶';
  font-size: 10px;
}

.toc-item-collapsible.expanded > .toc-toggle-icon {
  transform: rotate(90deg);
}

.toc-item-collapsible > ul {
  display: none;
}

.toc-item-collapsible.expanded > ul {
  display: block;
}

/* 主内容区 */
.docs-content {
  flex: 1;
  min-width: 0;
  padding: 40px;
}

/* Markdown 内容样式 */
.markdown-body {
  box-sizing: border-box;
  min-width: 200px;
  max-width: 980px;
  margin: 0 auto;
  padding: 45px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .toc-toggle {
    background: #1a1a1a;
    border-color: #333;
    color: #e0e0e0;
  }
  
  .toc-toggle:hover {
    background: #2d2d2d;
  }
  
  .toc-sidebar {
    background: #1a1a1a;
    border-right-color: #333;
  }
  
  .toc-header {
    border-bottom-color: #333;
  }
  
  .toc-header h3 {
    color: #ffffff;
  }
  
  .toc-close {
    color: #b0b0b0;
  }
  
  .toc-close:hover {
    color: #ffffff;
  }
  
  .toc-nav a {
    color: #b0b0b0;
  }
  
  .toc-nav a:hover {
    background: #2d2d2d;
    color: #ffffff;
  }
  
  .toc-nav a.active {
    background: #0366d6;
    color: #fff;
  }
  
  .toc-toggle-icon {
    color: #b0b0b0;
  }
  
  .markdown-body {
    background: #1a1a1a;
    color: #e0e0e0;
  }
  
  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3,
  .markdown-body h4,
  .markdown-body h5,
  .markdown-body h6 {
    color: #ffffff;
    border-bottom-color: #333;
  }
  
  .markdown-body a {
    color: #58a6ff;
  }
  
  .markdown-body code {
    background-color: #2d2d2d;
    color: #e0e0e0;
  }
  
  .markdown-body pre {
    background-color: #2d2d2d;
  }
  
  .markdown-body blockquote {
    border-left-color: #555;
    color: #b0b0b0;
  }
  
  .markdown-body table tr {
    background-color: #1a1a1a;
    border-top-color: #333;
  }
  
  .markdown-body table tr:nth-child(2n) {
    background-color: #252525;
  }
  
  .markdown-body table th,
  .markdown-body table td {
    border-color: #333;
  }
}

/* 图片样式优化 */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin: 20px 0;
}

/* 标题锚点 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.markdown-body h1 {
  font-size: 2em;
  border-bottom: 1px solid #eaecef;
  padding-bottom: 0.3em;
}

.markdown-body h2 {
  font-size: 1.5em;
  border-bottom: 1px solid #eaecef;
  padding-bottom: 0.3em;
}

/* 代码块样式 */
.markdown-body pre {
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: #f6f8fa;
  border-radius: 6px;
}

.markdown-body code {
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 85%;
  background-color: rgba(175, 184, 193, 0.2);
  border-radius: 6px;
}

/* 响应式设计 - 平板 */
@media (max-width: 1024px) {
  .toc-sidebar {
    width: 240px;
  }
  
  .docs-content {
    padding: 30px 20px;
  }
}

/* 响应式设计 - 手机 */
@media (max-width: 768px) {
  .docs-container {
    margin-top: 60px;
    padding: 0;
    flex-direction: column;
  }
  
  .toc-toggle {
    display: block;
  }
  
  .toc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s;
    border-right: none;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }
  
  .toc-sidebar.show {
    transform: translateX(0);
  }
  
  .toc-close {
    display: block;
  }
  
  .docs-content {
    padding: 20px 10px;
  }
  
  .markdown-body {
    padding: 20px;
  }
}

/* 加载动画 */
.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.loading::after {
  content: '...';
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* 目录滚动条样式 */
.toc-sidebar::-webkit-scrollbar {
  width: 6px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: #d1d5da;
  border-radius: 3px;
}

.toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #959da5;
}

@media (prefers-color-scheme: dark) {
  .toc-sidebar::-webkit-scrollbar-thumb {
    background: #444;
  }
  
  .toc-sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
  }
}
