/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    margin: 0;
    padding: 0;
}

.container {
    min-height: 100vh;
    background-color: #fff;
}

header {
    padding: 20px 30px;
    margin-left: 280px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 28px;
    color: #fff;
    font-weight: 600;
}

main {
    display: flex;
    gap: 0;
    min-height: 100vh;
}

/* 目录菜单样式 - 参考 Tigshop */
.toc {
    width: 280px;
    flex-shrink: 0;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
    z-index: 50;
    display: block;
    visibility: visible;
    opacity: 1;
}

/* 目录切换按钮 - 默认隐藏 */
.toc-toggle {
    display: none;
}

.toc nav {
    padding: 20px 0;
    font-size: 14px;
}

.toc ul {
    list-style: none;
    padding-left: 0;
}

/* 一级菜单 */
.toc > nav > ul > li {
    margin-bottom: 8px;
}

.toc > nav > ul > li > a {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    padding: 10px 20px;
    border-left: 3px solid transparent;
}

.toc > nav > ul > li > a:hover {
    background-color: #f3f4f6;
    border-left-color: #667eea;
    color: #667eea;
}

/* 二级菜单 */
.toc ul ul {
    padding-left: 0;
    margin-top: 4px;
    margin-bottom: 8px;
}

.toc ul ul li {
    margin-bottom: 2px;
}

.toc ul ul a {
    padding: 8px 20px 8px 35px;
    font-size: 14px;
    color: #4b5563;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.toc ul ul a:hover {
    background-color: #f9fafb;
    border-left-color: #a78bfa;
    color: #667eea;
}

/* 三级菜单 */
.toc ul ul ul a {
    padding-left: 50px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
}

.toc ul ul ul a:hover {
    background-color: #fafafa;
    color: #764ba2;
}

/* 通用链接样式 */
.toc a {
    color: #4b5563;
    text-decoration: none;
    display: block;
    transition: all 0.2s ease;
    position: relative;
}

.toc a:hover {
    color: #667eea;
}

/* 激活状态 */
.toc a.active {
    background-color: #ede9fe;
    border-left-color: #667eea !important;
    color: #667eea;
    font-weight: 600;
}

/* 自定义滚动条 */
.toc::-webkit-scrollbar {
    width: 6px;
}

.toc::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.toc::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.toc::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 内容区域 */
.content {
    flex: 1;
    min-width: 0;
    margin-left: 280px;
    padding: 40px 50px;
    background-color: #fff;
    overflow-x: hidden;
}

.content h1 {
    font-size: 32px;
    margin: 0 0 30px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
    color: #1f2937;
    font-weight: 700;
}

.content h2 {
    font-size: 26px;
    margin: 40px 0 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
    color: #374151;
    font-weight: 600;
}

.content h3 {
    font-size: 22px;
    margin: 30px 0 15px;
    color: #4b5563;
    font-weight: 600;
}

.content h4 {
    font-size: 18px;
    margin: 25px 0 12px;
    color: #6b7280;
    font-weight: 600;
}

.content p {
    margin-bottom: 16px;
    line-height: 1.8;
    color: #4b5563;
}

.content ul, .content ol {
    margin: 15px 0;
    padding-left: 30px;
    line-height: 1.8;
}

.content li {
    margin-bottom: 10px;
    color: #4b5563;
}

.content img {
    max-width: 100%;
    height: auto;
    margin: 25px 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.content img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background-color: #f3f4f6;
    color: #e83e8c;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.content pre {
    background-color: #1f2937;
    color: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 25px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.content pre code {
    background: none;
    color: #f9fafb;
    padding: 0;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow: hidden;
}

.content th, .content td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.content th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.content tr:hover {
    background-color: #f9fafb;
}

.content tr:last-child td {
    border-bottom: none;
}

.content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.content a:hover {
    color: #764ba2;
    border-bottom-color: #764ba2;
}

footer {
    padding: 30px;
    margin-left: 280px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    text-align: center;
    color: #fff;
    font-size: 14px;
}

footer p {
    margin: 0;
    opacity: 0.9;
}

/* 响应式设计 */
@media (min-width: 769px) {
    /* 确保桌面端菜单始终可见 */
    .toc {
        transform: none !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: fixed !important;
        left: 0 !important;
    }

    .toc-toggle {
        display: none !important;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .toc {
        width: 240px;
    }

    .content {
        margin-left: 240px;
        padding: 30px 35px;
    }

    header {
        margin-left: 240px;
    }

    footer {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    .toc {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }

    .toc.show {
        transform: translateX(0);
    }

    .toc-toggle {
        display: block !important;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1001;
        padding: 10px 16px;
        background: rgba(102, 126, 234, 0.9);
        color: #fff;
        cursor: pointer;
        font-weight: 600;
        font-size: 14px;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        border: none;
        backdrop-filter: blur(10px);
    }

    .toc-toggle:hover {
        background: rgba(102, 126, 234, 1);
    }

    .toc nav {
        padding-top: 60px;
    }

    /* 遮罩层 - 使用独立元素而不是伪元素 */
    body::after {
        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, visibility 0.3s ease;
        z-index: 999;
        pointer-events: none;
    }

    body.menu-open::after {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .container {
        padding: 0;
    }

    header {
        margin-left: 0;
        padding: 15px 20px;
        padding-top: 60px;
    }

    header h1 {
        font-size: 22px;
    }

    .content {
        margin-left: 0;
        padding: 20px;
        padding-top: 60px;
    }

    .content h1 {
        font-size: 26px;
    }

    .content h2 {
        font-size: 22px;
    }

    .content h3 {
        font-size: 19px;
    }

    .content h4 {
        font-size: 16px;
    }

    footer {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .content {
        padding: 15px;
    }

    .content h1 {
        font-size: 24px;
    }

    .content h2 {
        font-size: 20px;
    }
}
