/* =========================
   Docs Layout
========================= */

.doc-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.doc-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
}

/* =========================
   Left Sidebar
========================= */

.doc-sidebar {
  flex: 0 0 220px;
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  background: #f8f9fb;
  border: 1px solid #e6e8ee;
  border-radius: 12px;
  padding: 1rem 0.85rem;
  box-sizing: border-box;
  text-align: left;
  position: sticky;
  top: 2rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.doc-sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1rem;
}

/* =========================
   Navigation
========================= */

.doc-nav,
.doc-nav ul {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-nav-item,
.doc-sidebar li {
  display: block;
  margin: 0;
}

.doc-nav-toggle,
.doc-nav-link,
.doc-link,
.doc-sidebar a {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  text-decoration: none;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.2s ease, color 0.2s ease;
}

.doc-nav-toggle {
  position: relative;
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: #4b5563;
}

.doc-nav-toggle:hover {
  background: #eef2f7;
  color: #111827;
}

.doc-nav-toggle::after {
  content: "▸";
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.2s ease;
  font-size: 0.8rem;
}

.doc-nav-toggle.open::after {
  transform: translateY(-50%) rotate(90deg);
}

.doc-nav-link,
.doc-link,
.doc-sidebar a {
  padding: 0.55rem 0.8rem;
  font-size: 0.94rem;
  line-height: 1.5;
  color: #374151;
}

.doc-nav-link:hover,
.doc-link:hover,
.doc-sidebar a:hover {
  background: #eef2f7;
  color: #111827;
}

.doc-nav-link.active,
.doc-link.active,
.doc-sidebar a.active {
  background: #e8f1ff;
  color: #155eef;
  font-weight: 600;
}

.doc-subnav,
.has-children > .doc-nav-level {
  display: none;
  margin-top: 0.2rem;
  margin-left: 0.8rem;
  padding-left: 0.8rem;
  border-left: 1px solid #e5e7eb;
}

.doc-subnav.open,
.has-children.open > .doc-nav-level {
  display: block;
}

.has-children.open > .doc-nav-toggle .doc-nav-arrow {
  transform: rotate(90deg);
}

.doc-nav-arrow {
  display: inline-block;
  width: 1rem;
  margin-right: 0.4rem;
  transition: transform 0.2s ease;
}

.doc-nav-level-0 > .doc-nav-item > .doc-nav-toggle,
.doc-nav-level-0 > .doc-nav-item > .doc-nav-link,
.level-0 > .doc-nav-toggle {
  font-size: 0.95rem;
  font-weight: 700;
  color: #374151;
}

.doc-nav-level-1 .doc-nav-toggle,
.doc-nav-level-1 .doc-nav-link,
.level-1 > .doc-nav-toggle {
  font-size: 0.93rem;
  font-weight: 600;
  color: #4b5563;
}

.doc-nav-level-2 .doc-nav-toggle,
.doc-nav-level-2 .doc-nav-link,
.level-2 > .doc-link {
  font-size: 0.92rem;
  color: #374151;
}

/* =========================
   Main Content
========================= */

.doc-main {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.doc-content {
  width: 100%;
  min-height: calc(100vh - 260px);
  background: #ffffff;
  border: 1px solid #e6e8ee;
  border-radius: 12px;
  padding: 2rem 2rem;
  box-sizing: border-box;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

/* =========================
   Markdown Body
========================= */

.markdown-body {
  color: #2d3748;
  line-height: 1.8;
  font-size: 16px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: #1f2937;
  margin-top: 1.8em;
  margin-bottom: 0.8em;
  font-weight: 700;
}

.markdown-body h1 {
  font-size: 2rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.4rem;
}

.markdown-body h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid #edf0f3;
  padding-bottom: 0.3rem;
}

.markdown-body p {
  margin: 1em 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 1em 0 1em 1.5em;
}

.markdown-body code {
  background: #f3f4f6;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  font-family: "Courier New", monospace;
  font-size: 0.95em;
}

.markdown-body pre {
  background: #111827;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-body blockquote {
  border-left: 4px solid #cbd5e1;
  padding-left: 1rem;
  color: #4b5563;
  margin: 1rem 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #e5e7eb;
  padding: 0.75rem;
  text-align: left;
}

.markdown-body th {
  background: #f8fafc;
}

/* =========================
   Toolbar / PDF
========================= */

.doc-toolbar {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.doc-toolbar .button.small {
  min-width: 140px;
  text-align: center;
}


.pdf-frame {
  width: 100%;
  height: calc(100vh - 360px);
  min-height: 900px;
  border: none;
  display: block;
  background: #fff;
  border-radius: 8px;
}

/* =========================
   Right TOC
========================= */

.doc-toc {
  flex: 0 0 240px;
  width: 240px;
  min-width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 2rem;
  align-self: start;
}

.doc-toc-inner {
  padding: 0.75rem 0.5rem;
  border-left: 1px solid #e5e7eb;
  box-sizing: border-box;
}

.doc-toc-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #374151;
}

#doc-toc-list,
#toc-root {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.15rem 0;
  min-width: 0;
}

.toc-item {
  display: block;
  margin: 0.08rem 0;
}

.toc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 2rem;
}

.toc-link {
  flex: 1;
  min-width: 0;
  display: block;
  text-decoration: none;
  line-height: 1.45;
  padding: 0.22rem 0.35rem;
  color: #334155;
  border-radius: 6px;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.toc-link:hover {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
}

.toc-link.active {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  font-weight: 700;
  position: relative;
}

.toc-toggle {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  margin-right: 0.1rem;
  border: none;
  background: transparent;
  color: #374151;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-size: 0.82rem;
  transition: transform 0.2s ease, color 0.2s ease;
}

.toc-toggle:hover {
  color: #2563eb;
}

.toc-collapsible.open > .toc-row .toc-toggle {
  transform: rotate(0deg);
}

.toc-collapsible:not(.open) > .toc-row .toc-toggle {
  transform: rotate(-90deg);
}

.toc-children {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.25s ease;
}

.toc-collapsible:not(.open) > .toc-children {
  max-height: 0;
}

/* TOC 层级 */

.toc-level-1 > .toc-link,
.toc-level-1 > .toc-row > .toc-link {
  font-size: 0.96rem;
  font-weight: 800;
  color: #2563eb;
  padding-left: 0.7rem;
  margin-top: 0.4rem;
  position: relative;
}

.toc-level-1 > .toc-link::before,
.toc-level-1 > .toc-row > .toc-link::before {
  content: "";
  position: absolute;
  left: 0.12rem;
  top: 0.22rem;
  bottom: 0.22rem;
  width: 3px;
  border-radius: 999px;
  background: #2563eb;
}

.toc-level-2 > .toc-link,
.toc-level-2 > .toc-row > .toc-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  padding-left: 1.35rem;
}

.toc-level-3 > .toc-link,
.toc-level-3 > .toc-row > .toc-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: #475569;
  padding-left: 2.15rem;
}

.toc-level-4 > .toc-link,
.toc-level-4 > .toc-row > .toc-link {
  font-size: 0.78rem;
  font-weight: 400;
  color: #64748b;
  padding-left: 2.85rem;
}

.toc-level-2 > .toc-link.active::before,
.toc-level-2 > .toc-row > .toc-link.active::before,
.toc-level-3 > .toc-link.active::before,
.toc-level-3 > .toc-row > .toc-link.active::before,
.toc-level-4 > .toc-link.active::before,
.toc-level-4 > .toc-row > .toc-link.active::before {
  content: "";
  position: absolute;
  left: 0.08rem;
  top: 0.24rem;
  bottom: 0.24rem;
  width: 3px;
  border-radius: 999px;
  background: #2563eb;
}

/* =========================
   Responsive
========================= */

@media (max-width: 980px) {
  .doc-layout {
    flex-direction: column;
  }

  .doc-sidebar,
  .doc-main,
  .doc-toc {
    width: 100%;
    min-width: unset;
    max-width: none;
    position: static;
  }

  .doc-sidebar {
    max-height: unset;
    overflow: visible;
  }

  .doc-content {
    padding: 1.5rem;
  }

  .pdf-frame {
    min-height: 600px;
  }
}
/* 文档侧边栏：恢复正常字号和大小写 */
#doc-nav .doc-nav-toggle,
#doc-nav .doc-link {
  font-size: 0.95rem !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  line-height: 1.6 !important;
  font-family: inherit !important;
}

/* 组标题按钮 */
#doc-nav .doc-nav-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent !important;
  border: none !important;
  padding: 0.55rem 0.75rem !important;
  color: #2f3b52 !important;
  cursor: pointer;
  text-align: left !important;
  box-shadow: none !important;
}

/* 文档链接按钮 */
#doc-nav .doc-link {
  width: 100%;
  display: block;
  background: transparent !important;
  border: none !important;
  padding: 0.45rem 0.75rem !important;
  color: #4a5568 !important;
  cursor: pointer;
  text-align: left !important;
  border-radius: 10px;
  box-shadow: none !important;
}

/* hover */
#doc-nav .doc-link:hover,
#doc-nav .doc-nav-toggle:hover {
  background: rgba(80, 120, 200, 0.08) !important;
  color: #1f3f75 !important;
}

/* 当前激活项 */
#doc-nav .doc-link.active {
  background: #e8f0ff !important;
  color: #1f4ea3 !important;
  font-weight: 600 !important;
}

/* 子目录缩进更自然 */
#doc-nav .doc-subnav {
  margin-left: 0.75rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(120, 130, 150, 0.15);
}

/* 每个节点之间的间距 */
#doc-nav .doc-nav-item {
  margin-bottom: 0.2rem;
}
