/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 布局 */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    overflow-y: auto;
}

#sidebar h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #34495e;
    padding-bottom: 10px;
}

#sidebar ul {
    list-style: none;
}

#sidebar > ul > li {
    margin-bottom: 15px;
}

#sidebar ul ul {
    margin-left: 20px;
    margin-top: 5px;
}

#sidebar a {
    color: #ecf0f1;
    text-decoration: none;
    display: block;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

#sidebar a:hover {
    background-color: #34495e;
}

#content {
    margin-left: 280px;
    min-height: 100vh;
    background-color: white;
}

header {
    background-color: #3498db;
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
}

/* 章节和内容 */
.chapter {
    padding: 40px;
    max-width: 1000px;
    margin: 0 auto;
}

.chapter h2 {
    color: #2c3e50;
    font-size: 2em;
    margin-bottom: 30px;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

.section {
    margin-bottom: 40px;
}

.section h3 {
    color: #34495e;
    font-size: 1.6em;
    margin-bottom: 20px;
}

.section h4 {
    color: #34495e;
    font-size: 1.3em;
    margin-top: 20px;
    margin-bottom: 15px;
}

.section h5 {
    color: #34495e;
    font-size: 1.1em;
    margin-top: 15px;
    margin-bottom: 10px;
}

.section h6 {
    color: #34495e;
    font-size: 1em;
    margin-top: 10px;
    margin-bottom: 8px;
    font-style: italic;
}

/* 代码块 */
pre {
    background-color: #f8f8f8;
    border: 1px solid #e1e1e1;
    border-radius: 4px;
    padding: 15px;
    overflow-x: auto;
    margin: 15px 0;
    white-space: pre !important;
}

pre code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    white-space: pre !important;
    display: block !important;
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

/* 内联代码 */
p code, li code {
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    color: #d14;
}

/* 示例框 */
.example {
    background-color: #e8f4f8;
    border-left: 4px solid #3498db;
    padding: 20px;
    margin: 20px 0;
    border-radius: 4px;
}

.example h5 {
    color: #2980b9;
    margin-bottom: 10px;
}

/* 习题框 */
.exercise {
    background-color: #fff9e6;
    border-left: 4px solid #f39c12;
    padding: 20px;
    margin: 20px 0;
    border-radius: 4px;
}

.exercise h5 {
    color: #d68910;
    margin-bottom: 10px;
}

/* 答案切换按钮 */
.toggle-answer {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.toggle-answer:hover {
    background-color: #2980b9;
}

/* 答案区域 */
.answer {
    background-color: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    padding: 15px;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.answer.hidden {
    display: none;
}

/* 安装指南 */
.installation-guide {
    background-color: #f8f8f8;
    padding: 20px;
    border-radius: 4px;
    margin: 20px 0;
}

.installation-guide h5 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1em;
}

/* 列表样式 */
.section ul, .section ol {
    margin-left: 30px;
    margin-bottom: 15px;
}

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

/* 段落 */
.section p {
    margin-bottom: 15px;
    text-align: justify;
}

/* 页脚 */
footer {
    background-color: #34495e;
    color: #ecf0f1;
    text-align: center;
    padding: 20px;
    margin-top: 50px;
}

/* 移动端菜单切换按钮 */
.menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background-color: #2c3e50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    #sidebar {
        width: 280px;
        height: 100vh;
        position: fixed;
        left: -280px;
        top: 0;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 5px rgba(0,0,0,0.3);
    }
    
    #sidebar.active {
        left: 0;
    }
    
    /* 移动端遮罩层 */
    #sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        z-index: -1;
    }
    
    #sidebar.active::before {
        opacity: 1;
        visibility: visible;
    }
    
    #sidebar h2 {
        font-size: 1.2em;
    }
    
    #sidebar a {
        font-size: 0.9em;
        padding: 3px 8px;
    }
    
    #content {
        margin-left: 0;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    header p {
        font-size: 1em;
    }
    
    .chapter {
        padding: 20px 15px;
    }
    
    .chapter h2 {
        font-size: 1.6em;
    }
    
    .section h3 {
        font-size: 1.3em;
    }
    
    .section h4 {
        font-size: 1.1em;
    }
    
    /* 代码块移动端优化 */
    pre {
        font-size: 0.8em;
        padding: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 练习框移动端优化 */
    .exercise, .example {
        padding: 15px;
        margin: 15px 0;
    }
    
    /* 按钮移动端优化 */
    .toggle-answer {
        font-size: 0.85em;
        padding: 6px 12px;
        touch-action: manipulation;
    }
    
    /* 表格响应式 */
    table {
        font-size: 0.85em;
    }
}

/* 小屏幕优化 (手机竖屏) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }
    
    header p {
        font-size: 0.9em;
    }
    
    .chapter {
        padding: 15px 10px;
    }
    
    .chapter h2 {
        font-size: 1.4em;
    }
    
    .section h3 {
        font-size: 1.2em;
    }
    
    .section h4 {
        font-size: 1.05em;
    }
    
    .section h5 {
        font-size: 1em;
    }
    
    .section h6 {
        font-size: 0.95em;
    }
    
    pre {
        font-size: 0.75em;
        padding: 8px;
    }
    
    .exercise, .example {
        padding: 12px;
        margin: 10px 0;
    }
    
    .toggle-answer {
        font-size: 0.8em;
        padding: 5px 10px;
    }
    
    /* 侧边栏在小屏幕上占更少宽度 */
    #sidebar {
        width: 250px;
        left: -250px;
    }
}

/* 打印样式 */
@media print {
    #sidebar {
        display: none;
    }
    
    #content {
        margin-left: 0;
    }
    
    .toggle-answer {
        display: none;
    }
    
    .answer {
        display: block !important;
    }
}

/* 修复 Prism.js 代码格式问题 */
.token {
    white-space: pre !important;
}

pre[class*="language-"] {
    white-space: pre !important;
    word-wrap: normal !important;
    overflow-x: auto !important;
}

code[class*="language-"] {
    white-space: pre !important;
    display: block !important;
}

/* 确保代码块正确显示 */
pre code.language-coq {
    background: none;
    padding: 0;
}

/* 防止 Prism 样式被覆盖 */
.prism-highlighted {
    background: transparent !important;
}