:root {
    --sidebar-width: 280px;
    --right-sidebar-width: 240px;
    --top-nav-height: 60px;
    --bottom-bar-height: 50px;
    --primary-color: #4e73df;
    --sidebar-bg: #f8f9fa;
    --sidebar-active-bg: #e9ecef;
    --sidebar-hover-bg: #e9ecef;
    --border-color: #dee2e6;
}

[data-bs-theme="dark"] {
    --sidebar-bg: #212529;
    --sidebar-active-bg: #2c3034;
    --sidebar-hover-bg: #2c3034;
    --border-color: #373b3e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
}
/* 修改后的样式 */
.navbar .navbar-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 主容器 */
.main-container {
    display: flex;
    height: calc(100vh - var(--top-nav-height) - var(--bottom-bar-height));
    overflow: hidden;
}

/* 左侧边栏 */
.left-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.left-sidebar::-webkit-scrollbar {
    width: 6px;
}

.left-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.left-sidebar::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-bg);
    border-radius: 3px;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--bs-body-color);
}

/* 树形菜单 */
.tree-menu {
    list-style: none;
    padding: 0;
}

.tree-menu ul {
    list-style: none;
    padding-left: 0;
}

.tree-item {
    position: relative;
}
.tree-item a{text-decoration: none; color: var(--bs-body-color);}
.arrow i{ transition: transform .2s; display: inline-block;}
.tree-item > a[aria-expanded="true"] .arrow i{ transform: rotate(90deg); }
.tree-item-content {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    
}

.tree-item-content:hover {
    background: var(--sidebar-hover-bg);
}

.tree-item-content.active {
    background: var(--sidebar-active-bg);
    color: var(--primary-color);
    font-weight: 500;
}


.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    font-size: 0.8rem;
}

.tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.tree-icon {
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

.tree-label {
    /* flex: 1; */
    font-size: 0.9rem;
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.tree-children.collapsed {
    max-height: 0;
}

/* 中间内容区 */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
}

.content-area::-webkit-scrollbar {
    width: 8px;
}

.content-area::-webkit-scrollbar-track {
    background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-bg);
    border-radius: 4px;
}

.content-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.content-header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.content-meta {
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
}

.content-body h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.content-body h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.content-body p {
    line-height: 1.8;
    margin-bottom: 1rem;
}

.content-body ul, .content-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.content-body li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.content-body code {
    background: var(--bs-tertiary-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
    color: var(--bs-code-color);
}

.content-body pre {
    background: var(--bs-tertiary-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.content-body pre code {
    background: none;
    padding: 0;
}

.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.content-body th, .content-body td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.content-body th {
    background: var(--bs-tertiary-bg);
    font-weight: 600;
}

.content-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--bs-secondary-color);
}

.content-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

/* 代码块复制按钮 */
.code-block {
    position: relative;
}

.code-block .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.code-block:hover .copy-btn {
    opacity: 1;
}

/* 右侧边栏 */
.right-sidebar {
    width: var(--right-sidebar-width);
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 1rem;
}

.right-sidebar::-webkit-scrollbar {
    width: 6px;
}

.right-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-bg);
    border-radius: 3px;
}

.right-sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toc-list {
    list-style: none;
    padding: 0;
}

.toc-list li {
    margin-bottom: 0.25rem;
}

.toc-list a {
    display: block;
    padding: 0.35rem 0.5rem;
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: all 0.2s;
    border-left: 2px solid transparent;
}

.toc-list a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--primary-color);
}

.toc-list a.active {
    background: var(--sidebar-active-bg);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

.toc-list .toc-h2 {
    padding-left: 0.5rem;
}

.toc-list .toc-h3 {
    padding-left: 1.5rem;
    font-size: 0.8rem;
}

/* 底部工具栏 */
.bottom-bar {
    height: var(--bottom-bar-height);
    background: var(--bs-body-bg);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.bottom-bar-left, .bottom-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bottom-bar button {
    background: none;
    border: none;
    color: var(--bs-body-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.bottom-bar button:hover {
    background: var(--bs-tertiary-bg);
}

.bottom-bar .copyright {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--bs-body-color);
    cursor: pointer;
    padding: 0.5rem;
}

/* 遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--top-nav-height);
    left: 0;
    right: 0;
    bottom: var(--bottom-bar-height);
    background: rgba(0, 0, 0, 0.5);
    z-index: 1020;
}

.sidebar-overlay.show {
    display: block;
}

/* 上一篇/下一篇导航 */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.page-nav a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--bs-body-color);
    padding: 1rem;
    border-radius: 8px;
    transition: background 0.2s;
    max-width: 45%;
}

.page-nav a:hover {
    background: var(--bs-tertiary-bg);
}

.page-nav a.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.page-nav .nav-label {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    margin-bottom: 0.25rem;
}

.page-nav .nav-title {
    font-weight: 500;
    color: var(--primary-color);
}

.page-nav .next {
    text-align: right;
    align-items: flex-end;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .right-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .top-navbar .search-box {
        display: none;
    }

    .top-navbar .nav-links {
        display: none;
    }

    .left-sidebar {
        position: fixed;
        top: var(--top-nav-height);
        left: 0;
        bottom: var(--bottom-bar-height);
        z-index: 1040;
        transform: translateX(-100%);
    }

    .left-sidebar.show {
        transform: translateX(0);
    }

    .content-area {
        padding: 1rem;
    }

    .content-header h1 {
        font-size: 1.5rem;
    }
}

/* 打印样式 */
@media print {
    .top-navbar,
    .left-sidebar,
    .right-sidebar,
    .bottom-bar,
    .mobile-menu-btn {
        display: none !important;
    }

    .main-container {
        margin-top: 0;
        height: auto;
    }

    .content-area {
        overflow: visible;
    }
}