/* styles.css - 响应式改进版本 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* 移动端汉堡菜单按钮 */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: #2c3e50;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.mobile-toggle .bar {
    display: block;
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 5px 0;
    transition: 0.3s;
}

/* 左侧目录样式 */
.sidebar {
    width: 300px;
    background: linear-gradient(135deg, #2c3e50, #4a6491);
    color: white;
    padding: 25px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 0 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.sidebar p {
    font-size: 0.9rem;
    opacity: 0.8;
}

.toc {
    list-style: none;
}

.toc > li {
    margin-bottom: 5px;
}

.toc a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 12px 25px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    font-size: 0.95rem;
}

.toc a:hover, .toc a.active {
    background-color: rgba(255, 255, 255, 0.1);
    border-left: 3px solid #3498db;
    padding-left: 30px;
}

/* 子目录样式 */
.toc ul {
    list-style: none;
    margin-left: 15px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* 修复：增加max-height以支持更多页面 */
.toc li.has-children.expanded > ul {
    max-height: 15000px;
}

.toc ul a {
    padding: 10px 25px 10px 35px;
    font-size: 0.85em;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.toc ul a:hover, .toc ul a.active {
    padding-left: 40px;
    border-left: 2px solid #3498db;
}

.toggle-icon {
    float: right;
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.toc li.has-children.expanded > a .toggle-icon {
    transform: rotate(90deg);
}

/* 主内容区域 */
.content {
    flex: 1;
    margin-left: 300px;
    padding: 30px;
    max-width: 1200px;
    width: calc(100% - 300px);
    transition: margin-left 0.3s ease;
}

.page-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.page-header h1 {
    font-size: 2.2rem;
    color: #2c3e50;
    margin-bottom: 10px;
    line-height: 1.2;
}

.section {
    margin-bottom: 40px;
    padding: 25px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.section h2 {
    font-size: 1.6rem;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    line-height: 1.3;
}

.section h3 {
    font-size: 1.2rem;
    color: #34495e;
    margin: 25px 0 15px 0;
    line-height: 1.4;
}

.section p {
    margin-bottom: 15px;
    line-height: 1.7;
    font-size: 1rem;
}

.section ul, .section ol {
    margin: 15px 0 15px 25px;
}

.section li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* 代码块样式 */
pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

pre code {
    background: none;
    padding: 0;
}

/* 返回顶部按钮 */
.back-to-top {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.back-to-top:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* 移动端优化样式 */
@media (max-width: 768px) {
    /* 显示移动端汉堡菜单 */
    .mobile-toggle {
        display: block;
    }
    
    /* 移动端侧边栏样式 */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        z-index: 999;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* 移动端主内容区域 */
    .content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
        padding-top: 80px; /* 为汉堡菜单留出空间 */
    }
    
    /* 移动端标题优化 */
    .page-header h1 {
        font-size: 1.8rem;
    }
    
    .section h2 {
        font-size: 1.4rem;
    }
    
    .section h3 {
        font-size: 1.1rem;
    }
    
    /* 移动端内容优化 */
    .section {
        padding: 20px;
        margin-bottom: 25px;
    }
    
    .section p {
        font-size: 0.95rem;
    }
    
    /* 移动端代码块优化 */
    pre {
        padding: 15px;
        font-size: 0.8rem;
    }
    
    /* 移动端导航栏项目优化 */
    .toc a {
        padding: 15px 20px;
        font-size: 0.9rem;
    }
    
    .toc ul a {
        padding: 12px 20px 12px 30px;
        font-size: 0.8rem;
    }
    
    /* 移动端按钮优化 */
    .back-to-top {
        padding: 12px 24px;
        font-size: 0.9rem;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .content {
        margin-left: 280px;
        width: calc(100% - 280px);
        padding: 25px;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .section {
        padding: 20px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    .mobile-toggle {
        top: 15px;
        left: 15px;
        padding: 10px;
    }
    
    .content {
        padding: 15px;
        padding-top: 70px;
    }
    
    .page-header h1 {
        font-size: 1.6rem;
    }
    
    .section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .section h2 {
        font-size: 1.3rem;
    }
    
    .section p {
        font-size: 0.9rem;
    }
    
    pre {
        padding: 12px;
        font-size: 0.75rem;
    }
}

/* 打印样式优化 */
@media print {
    .sidebar,
    .mobile-toggle,
    .back-to-top {
        display: none;
    }
    
    .content {
        margin-left: 0;
        width: 100%;
        padding: 0;
    }
    
    .section {
        box-shadow: none;
        border: 1px solid #ddd;
        margin-bottom: 20px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sidebar {
        box-shadow: 3px 0 15px rgba(0, 0, 0, 0.15);
    }
    
    .section {
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.12);
    }
}