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

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 顶部导航栏 */
header {
    background-color: #333;
    color: #fff;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.search-box {
    margin-top: 10px;
}

.search-box input {
    width: 200px;
    padding: 8px;
    border: none;
    border-radius: 4px 0 0 4px;
}

.search-box button {
    padding: 8px 12px;
    background-color: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.search-box button:hover {
    background-color: #45a049;
}

/* 主内容区 */
.main-content {
    display: flex;
    margin-top: 20px;
    min-height: calc(100vh - 120px);
}

/* 侧边栏导航 */
.sidebar {
    width: 250px;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-right: 20px;
    position: sticky;
    top: 100px;
    height: fit-content;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.sidebar ul {
    list-style: none;
}

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

.sidebar li.section-title {
    font-weight: bold;
    margin-top: 15px;
    color: #4CAF50;
    font-size: 16px;
}

.sidebar a {
    color: #333;
    text-decoration: none;
    display: block;
    padding: 5px 0;
    transition: all 0.3s ease;
}

.sidebar a:hover {
    color: #4CAF50;
    padding-left: 10px;
}

/* 主要内容 */
.content {
    flex: 1;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.content section {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.content h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 2px solid #4CAF50;
}

.content h3 {
    font-size: 18px;
    margin: 20px 0 10px;
    color: #555;
}

.content p {
    margin-bottom: 15px;
    line-height: 1.8;
}

.content ul, .content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.content li {
    margin-bottom: 5px;
}

/* 代码块 */
pre {
    background-color: #2d2d2d;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 20px;
    border-left: 4px solid #4CAF50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: #f8f8f2;
    line-height: 1.5;
}

/* 代码语法高亮 */
code .tag {
    color: #66d9ef;
}

code .attribute {
    color: #a6e22e;
}

code .value {
    color: #e6db74;
}

code .comment {
    color: #75715e;
}

code .doctype {
    color: #ae81ff;
}

/* 表格 */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.content table th, .content table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.content table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.content table tr:hover {
    background-color: #f5f5f5;
}

/* 返回顶部按钮 */
#back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 20px;
    cursor: pointer;
    display: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

#back-to-top:hover {
    background-color: #45a049;
    transform: translateY(-5px);
}

/* 移动导航菜单切换按钮 */
.mobile-menu-toggle {
    display: none;
    background-color: #4CAF50;
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        margin-right: 0;
        margin-bottom: 20px;
        position: relative;
        top: 0;
        display: none;
    }
    
    .sidebar.active {
        display: block;
        animation: slideDown 0.3s ease;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .mobile-menu-toggle {
        display: block;
        width: 100%;
        text-align: center;
    }
    
    .search-box input {
        width: 150px;
    }
    
    /* 优化代码块在小屏幕上的显示 */
    pre {
        padding: 10px;
        font-size: 12px;
    }
    
    code {
        font-size: 12px;
    }
    
    /* 优化表格在小屏幕上的显示 */
    .content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 20px;
    }
    
    .content {
        padding: 15px;
    }
    
    .content h2 {
        font-size: 20px;
    }
    
    .content h3 {
        font-size: 16px;
    }
    
    /* 进一步优化小屏幕上的显示 */
    .container {
        padding: 0 10px;
    }
    
    .search-box {
        margin-top: 10px;
    }
    
    .search-box input {
        width: 120px;
    }
    
    .search-box button {
        padding: 8px 10px;
    }
    
    /* 优化实践任务卡片在小屏幕上的显示 */
    .practice-card {
        padding: 15px;
    }
    
    .practice-steps ol {
        margin-left: 15px;
    }
    
    .practice-steps li {
        margin-bottom: 8px;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .content {
        flex: 1;
    }
}

/* 搜索结果 */
.search-results {
    margin-top: 20px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.search-results h3 {
    margin-bottom: 10px;
}

.search-results ul {
    margin-left: 0;
}

.search-results li {
    margin-bottom: 10px;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;
}

.search-results a {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
}

.search-results a:hover {
    text-decoration: underline;
}