/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --sidebar-bg: #1a1a2e;
    --sidebar-text: #eee;
    --main-bg: #f5f7fa;
    --card-bg: #fff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--main-bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ===== 布局容器 ===== */
.container {
    display: flex;
    min-height: 100vh;
}

/* ===== 左侧边栏 ===== */
.sidebar {
    width: 280px;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #16213e 100%);
    color: var(--sidebar-text);
    padding: 2rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

.sidebar-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.8;
    font-weight: 300;
}

/* 返回按钮 */
.nav-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    margin: 0 1rem 1rem 1rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    justify-content: center;
}

.nav-back:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.nav-back .icon {
    font-size: 1.3rem;
}

/* 搜索框 */
.search-box {
    padding: 0 1.5rem;
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* 导航菜单 */
.nav-menu {
    padding: 0 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.nav-item .icon {
    font-size: 1.3rem;
    margin-right: 0.75rem;
}

.nav-item span:last-child {
    font-weight: 500;
}

/* ===== 右侧内容区 ===== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem 3rem;
    max-width: 1200px;
}

.content-section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.content-section:hover {
    box-shadow: var(--shadow-hover);
}

.content-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.content-section h3 {
    font-size: 1.3rem;
    margin: 2rem 0 1rem;
    color: var(--text-primary);
}

.content-section h4 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--text-secondary);
}

.desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* ===== 代码块 ===== */
.code-block {
    margin: 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #282c34;
    color: #abb2bf;
    font-size: 0.85rem;
    font-weight: 500;
}

.copy-btn {
    padding: 0.4rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.copy-btn:active {
    transform: translateY(0);
}

.code-block pre {
    margin: 0;
    padding: 1.5rem;
    background: #282c34;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
}

/* ===== 函数表格 ===== */
.function-table {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.function-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.function-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.function-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.function-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.function-table tbody tr:hover {
    background: #f8fafc;
}

.function-table td {
    padding: 1rem;
    vertical-align: top;
}

.function-table code {
    background: #edf2f7;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #e53e3e;
}

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 滚动条样式 ===== */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }

    .content-section {
        padding: 1.5rem;
    }
}

/* ===== 平滑滚动 ===== */
html {
    scroll-behavior: smooth;
}

/* ===== 代码高亮优化 ===== */
.hljs {
    background: #282c34 !important;
    padding: 1.5rem;
}
