/* 主题变量 - 黑白优化版 */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-hover: #f0f0f0;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e5e5e5;
    --shadow: rgba(0, 0, 0, 0.05);
    --accent: #1a1a1a;
    --accent-hover: #333333;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition-base: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-hover: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --text-tertiary: #666666;
    --border-color: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
    --accent: #ffffff;
    --accent-hover: #e5e5e5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

/* 顶部导航 */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 100;
    transition: all 0.3s;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.8;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-actions a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-actions a:hover {
    color: var(--text-primary);
}

.search-input {
    width: 300px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.search-input:focus {
    border-color: var(--accent);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    color: var(--text-secondary);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 主容器 */
.main-container {
    display: flex;
    justify-content: center;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
    padding: 0 40px;
}

/* 侧边栏 */
.sidebar {
    width: 240px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: 20px 16px;
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding: 0 6px;
}

.category-list {
    list-style: none;
}

.category-item {
    margin-bottom: 2px;
}

.category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.category-link:hover,
.category-link.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-count {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* 内容区域 */
.content-area {
    flex: 1;
    margin-left: 240px;
    padding: 30px 30px;
    max-width: 900px;
}

/* 右侧栏 */
.right-sidebar {
    width: 220px;
    margin-left: 30px;
    padding: 0 16px 0 8px;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
    align-self: flex-start;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

/* 鼠标悬停时显示滚动条 */
.right-sidebar:hover {
    scrollbar-color: var(--border-color) transparent;
}

/* Webkit 浏览器滚动条样式 */
.right-sidebar::-webkit-scrollbar {
    width: 6px;
}

.right-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

/* 鼠标悬停时显示滚动条 */
.right-sidebar:hover::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

.right-sidebar:hover::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* 文档列表 */
.doc-list {
    list-style: none;
}

.doc-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s;
}

.doc-item:hover {
    transform: translateX(4px);
}

.doc-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.doc-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.3s;
}

.doc-title a:hover {
    color: var(--text-secondary);
}

.doc-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.doc-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.doc-excerpt {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
}

/* 右侧栏 - 已移到上面 */

.toc-section {
    background: transparent;
    border-radius: 0;
    padding: 0;
    border: none;
}

.toc-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: block;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.toc-title::before {
    content: '';
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 0;
}

.toc-item.toc-h1,
.toc-item.toc-h2 {
    margin-left: 0;
}

.toc-item.toc-h3 {
    margin-left: 0;
}

.toc-item.toc-h4 {
    margin-left: 0;
}

.toc-link {
    display: block;
    padding: 6px 0 6px 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
    border-radius: 0;
    line-height: 1.5;
    border-left: 2px solid transparent;
}

.toc-link:hover {
    color: var(--text-primary);
    background: transparent;
    border-left-color: var(--text-tertiary);
}

.toc-link.active {
    color: var(--text-primary);
    background: transparent;
    font-weight: 500;
    border-left-color: var(--accent);
}

.toc-empty {
    color: var(--text-tertiary);
    font-size: 12px;
    padding: 16px 0;
}

/* 文档详情页 */
.doc-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.doc-header-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.doc-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
}

/* 响应式 */
@media (max-width: 1400px) {
    .right-sidebar {
        display: none;
    }
    
    .content-area {
        margin-right: 20px;
        max-width: 1200px;
    }
}

@media (max-width: 1024px) {
    .content-area {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .content-area {
        margin-left: 0;
        padding: 20px;
    }
    
    .top-nav {
        padding: 0 20px;
    }
    
    .search-input {
        width: 200px;
    }
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    right: 40px;
    bottom: 40px;
    width: 48px;
    height: 48px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 99;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    stroke: var(--bg-primary);
    transition: stroke 0.3s;
}

@media (max-width: 768px) {
    .back-to-top {
        right: 20px;
        bottom: 20px;
        width: 44px;
        height: 44px;
    }
}

/* 页脚 */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 30px 20px;
    margin-top: 60px;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content .copyright {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.footer-content .copyright .footer-item {
    display: inline-block;
    margin: 0 6px;
}

.footer-content .copyright .footer-item:first-child {
    margin-left: 0;
}

.footer-content .copyright .footer-item:last-child {
    margin-right: 0;
}

.footer-content .copyright a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-content .copyright a:hover {
    color: var(--text-primary);
}


/* 友情链接 */
.friendlinks {
    margin-bottom: 24px;
}

.friendlinks h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: center;
}

.friendlinks-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
}

.friendlinks-list a {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.friendlinks-list a:hover {
    color: var(--accent);
}
