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

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

.container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 300px;
    background-color: #2c3e50;
    color: white;
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    transition: transform 0.3s ease-in-out;
    z-index: 100;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    padding-left: 50px;
}

.sidebar-nav {
    padding: 20px 0;
}

.sidebar-item {
    margin-bottom: 5px;
}

.sidebar-link {
    display: block;
    padding: 10px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background-color 0.3s;
}

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

.sidebar-children {
    margin-left: 20px;
}

.level-1 .sidebar-link { padding-left: 20px; }
.level-2 .sidebar-link { padding-left: 40px; }
.level-3 .sidebar-link { padding-left: 60px; }

.main-content {
    flex: 1;
    width: 100%;
    padding-left: 310px;
    padding-right: 10px;
    padding-top: 40px;
    padding-bottom: 40px;
    transition: padding-left 0.3s ease-in-out;
}

.sidebar.hidden ~ .main-content {
    padding-left: 0;
}

.content-wrapper {
    width: 100%;
    margin: 0 auto;
    display: flex;
    gap: 20px;
}

.content {
    flex: 1;
    min-width: 0;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.content img {
    max-width: 100%;
}

.toc {
    flex: 0 0 250px; /* grow=0, shrink=0, basis=250px */
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 20px;
    transition: all 0.3s ease-in-out;
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.toc-header h3 {
    margin: 0;
    color: #2c3e50;
    flex: 1;
}

.toc-toggle {
    background: rgba(44, 62, 80, 0.1);
    color: #2c3e50;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 28px;
    height: 28px;
}

.toc-toggle:hover {
    background: rgba(44, 62, 80, 0.2);
}

.toc-toggle:active {
    transform: scale(0.95);
}

.toc-toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.toc-content {
    transition: opacity 0.3s ease-in-out;
}

.toc.hidden {
    width: 50px;
    padding: 20px 10px;
    flex: 0 0 50px;  /* 宽度变成 50px */
}

.toc.hidden .toc-content {
    display: none;
}

.toc.hidden .toc-header {
    margin-bottom: 0;
    justify-content: center;
}

.toc.hidden .toc-header h3 {
    display: none;
}

.toc.hidden .toc-toggle {
    width: 32px;
    height: 32px;
    font-size: 24px;
}

.toc.hidden .toc-toggle-icon {
    transform: rotate(45deg);
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 5px;
}

.toc-link {
    display: block;
    padding: 5px 0;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.toc-link:hover {
    color: #2c3e50;
}

.level-1 .toc-link { padding-left: 0; }
.level-2 .toc-link { padding-left: 15px; }
.level-3 .toc-link { padding-left: 30px; }

/* Markdown 内容样式 */
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.content h1 { font-size: 2rem; }
.content h2 { font-size: 1.5rem; }
.content h3 { font-size: 1.25rem; }

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

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

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

.content code {
    background-color: #f1f2f6;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
}

.content pre {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 20px;
}

.content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.content blockquote {
    border-left: 4px solid #3498db;
    padding-left: 20px;
    margin: 20px 0;
    color: #666;
    font-style: italic;
}

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

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

.content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* 侧边栏切换按钮 */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(44, 62, 80, 0.9);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle:hover {
    background: rgba(44, 62, 80, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* 响应式设计 - 中等屏幕：TOC显示在内容上方 */
@media (max-width: 1024px) {
    .content-wrapper {
        flex-direction: column;
    }
    
    .content {
        order: 2;
    }
    
    .toc {
        width: 100%;
        position: static;
        order: 1;
        margin-bottom: 20px;
    }
}

/* 响应式设计 - 小屏幕 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .toc.hidden {
        width: 50px;
        position: fixed;
        right: 20px;
        top: 20px;
        z-index: 999;
        padding: 10px;
    }
    
    .toc.hidden .toc-toggle {
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
    
    .sidebar-toggle {
        display: block;
    }
}