/* ==========================================================
   DEV 文档页样式：侧边栏 + 内容卡片 + 目录(TOC)
   ========================================================== */

.doc-layout {
  display: flex;
  gap: 28px;
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 32px) 24px 90px;
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.doc-sidebar {
  flex: 0 0 230px;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  align-self: flex-start;
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  box-shadow: 0 20px 40px -28px rgba(0, 0, 0, 0.12), inset 0 0 18px rgba(255, 255, 255, 0.3);
}
.doc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.doc-sidebar-home {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(66, 185, 131, 0.1);
  margin-bottom: 14px;
  transition: background 0.15s;
}
.doc-sidebar-home:hover {
  background: rgba(66, 185, 131, 0.18);
}

.doc-sidebar-group-title {
  font-size: 11px;
  font-weight: 700;
  color: #a0aab5;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 12px 4px;
}

.doc-sidebar-app,
.doc-sidebar-link {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: #57606a;
  margin: 1px 0;
  transition: background 0.15s, color 0.15s;
}
.doc-sidebar-app:hover,
.doc-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #34495e;
}
.doc-sidebar-app.active,
.doc-sidebar-link.active {
  background: #42b983;
  color: #fff;
  font-weight: 600;
}

.doc-sidebar-group-children {
  padding-left: 12px;
}

/* ---------- 内容卡片 ---------- */
.doc-content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 860px;
}

.doc-body {
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 32px;
  box-shadow: 0 30px 50px -30px rgba(0, 0, 0, 0.1), inset 0 0 24px rgba(255, 255, 255, 0.35);
  padding: 40px 46px;
  color: var(--text);
  word-break: break-word;
}

/* ==========================================================
   Markdown 排版（核心）
   ========================================================== */
.doc-body > *:first-child {
  margin-top: 0;
}
.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4 {
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.35;
  /* 锚点定位时避开顶部固定导航 */
  scroll-margin-top: 84px;
}
.doc-body h1 {
  font-size: 1.85rem;
  margin: 0 0 0.6em;
  padding-bottom: 0.35em;
  border-bottom: 2px solid var(--primary-bg);
}
.doc-body h2 {
  font-size: 1.4rem;
  margin: 1.6em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.doc-body h3 {
  font-size: 1.15rem;
  margin: 1.4em 0 0.5em;
}
.doc-body h4 {
  font-size: 1rem;
  margin: 1.2em 0 0.4em;
  color: var(--primary-dark);
}

.doc-body p {
  margin: 0.85em 0;
  line-height: 1.75;
}
.doc-body a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.doc-body a:hover {
  border-bottom-color: var(--primary);
}

.doc-body ul,
.doc-body ol {
  margin: 0.85em 0;
  padding-left: 1.7em;
}
.doc-body li {
  margin: 0.35em 0;
  line-height: 1.7;
}
.doc-body li::marker {
  color: var(--primary);
}

/* 表格 */
.doc-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.1em 0;
  display: block;
  overflow-x: auto;
  font-size: 14px;
}
.doc-body th,
.doc-body td {
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 9px 16px;
  text-align: left;
}
.doc-body th {
  background: #f5f7f6;
  font-weight: 600;
  white-space: nowrap;
}
.doc-body tr:nth-child(even) td {
  background: rgba(66, 185, 131, 0.025);
}

/* 引用块 */
.doc-body blockquote {
  border-left: 4px solid var(--primary);
  background: var(--primary-bg);
  padding: 12px 20px;
  margin: 1em 0;
  color: #57606a;
  border-radius: 0 10px 10px 0;
}
.doc-body blockquote p {
  margin: 0.4em 0;
}

/* 代码 */
.doc-body code {
  background: rgba(66, 185, 131, 0.1);
  color: #c7254e;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: "Fira Mono", Consolas, "Courier New", monospace;
  font-size: 0.89em;
}
.doc-body pre {
  background: #f6f8fa;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 1em 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}
.doc-body pre code {
  background: transparent !important; /* 用容器底色，让 hljs 的 token 颜色生效 */
  padding: 0;
  font-size: 0.86em;
  line-height: 1.6;
}

/* 图片 */
.doc-body img {
  max-width: 100%;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* 代码块复制按钮 */
.doc-body .codehilite,
.doc-body pre {
  position: relative;
}
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  color: #57606a;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 5;
}
.doc-body pre:hover .code-copy-btn {
  opacity: 1;
}
.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  color: #42b983;
}

.doc-body hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin: 2em 0;
}

/* ---------- 右侧目录 TOC ---------- */
.doc-toc {
  flex: 0 0 200px;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  align-self: flex-start;
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  box-shadow: 0 20px 40px -28px rgba(0, 0, 0, 0.12);
  font-size: 13px;
}
.doc-toc::-webkit-scrollbar {
  width: 4px;
}
.doc-toc-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.doc-toc .toc,
.doc-toc .toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.doc-toc .toc ul ul {
  padding-left: 14px;
}
.doc-toc .toc a {
  display: block;
  color: var(--text-light);
  padding: 3px 0;
  line-height: 1.5;
  border: none;
  transition: color 0.15s;
}
.doc-toc .toc a:hover {
  color: var(--primary);
}
.doc-toc .toc > ul > li > a {
  font-weight: 500;
  color: var(--text);
}

/* ---------- 目录列表（无 README 的目录页） ---------- */
.dir-listing {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dir-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(66, 185, 131, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: var(--text);
  transition: background 0.15s, transform 0.15s;
}
.dir-item:hover {
  background: rgba(66, 185, 131, 0.12);
  transform: translateX(2px);
}
.dir-icon { font-size: 16px; }
.dir-name { font-weight: 500; }
.dir-arrow { margin-left: auto; color: var(--primary); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .doc-toc {
    display: none;
  }
}
@media (max-width: 768px) {
  .doc-layout {
    flex-direction: column;
    gap: 16px;
    padding-top: calc(var(--nav-h) + 16px);
  }
  .doc-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .doc-body {
    padding: 24px 20px;
  }
}
