/* 三栏布局样式 - 亚马逊跨境电商运营全攻略 */

/* 布局容器 */
.book-layout {
    display: flex;
    min-height: 100vh;
}

/* 左侧章节导航 */
.book-sidebar-left {
    width: 280px;
    min-width: 280px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.book-sidebar-left .sidebar-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.book-sidebar-left .sidebar-header h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.4;
}

.book-sidebar-left .sidebar-header a {
    color: white;
    text-decoration: none;
}

.book-sidebar-left .sidebar-header a:hover {
    text-decoration: underline;
}

.book-sidebar-left .sidebar-content {
    padding: 1rem 0;
}

/* 章节组 */
.chapter-group {
    margin-bottom: 0.5rem;
}

.chapter-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: background 0.2s;
}

.chapter-title:hover {
    background: #e2e8f0;
}

.chapter-title .chapter-number {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.chapter-title .chapter-icon {
    font-size: 1rem;
}

.chapter-title .expand-icon {
    margin-left: auto;
    font-size: 0.75rem;
    color: #94a3b8;
    transition: transform 0.2s;
}

.chapter-group.expanded .chapter-title .expand-icon {
    transform: rotate(90deg);
}

/* 章节链接 */
.chapter-sections {
    display: none;
    padding-left: 2.5rem;
}

.chapter-group.expanded .chapter-sections {
    display: block;
}

.section-link {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: #64748b;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.2s;
}

.section-link:hover {
    color: #4f46e5;
    background: #eef2ff;
    border-left-color: #4f46e5;
}

.section-link.active {
    color: #4f46e5;
    background: #eef2ff;
    border-left-color: #4f46e5;
    font-weight: 500;
}

/* 主内容区域 */
.book-main-content {
    flex: 1;
    margin-left: 280px;
    margin-right: 240px;
    min-width: 0;
}

/* 右侧目录 */
.book-sidebar-right {
    width: 240px;
    min-width: 240px;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    z-index: 100;
}

.book-sidebar-right .toc-header {
    padding: 1.5rem 1rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: white;
    border-bottom: 1px solid #f1f5f9;
}

.book-sidebar-right .toc-content {
    padding: 0.5rem 0;
}

.toc-link {
    display: block;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    color: #64748b;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    line-height: 1.4;
}

.toc-link:hover {
    color: #4f46e5;
    border-left-color: #c7d2fe;
}

.toc-link.active {
    color: #4f46e5;
    border-left-color: #4f46e5;
    font-weight: 500;
}

.toc-link.toc-h3 {
    padding-left: 1.5rem;
    font-size: 0.75rem;
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 200;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

.mobile-toc-btn {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1e293b;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 200;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

/* 遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* 响应式布局 */
@media screen and (max-width: 1200px) {
    .book-sidebar-right {
        display: none;
    }

    .book-main-content {
        margin-right: 0;
    }

    .mobile-toc-btn {
        display: flex;
    }

    .book-sidebar-right.mobile-open {
        display: block;
        width: 280px;
    }
}

@media screen and (max-width: 900px) {
    .book-sidebar-left {
        transform: translateX(-100%);
    }

    .book-sidebar-left.mobile-open {
        transform: translateX(0);
    }

    .book-main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }
}

/* 滚动条样式 */
.book-sidebar-left::-webkit-scrollbar,
.book-sidebar-right::-webkit-scrollbar {
    width: 4px;
}

.book-sidebar-left::-webkit-scrollbar-track,
.book-sidebar-right::-webkit-scrollbar-track {
    background: transparent;
}

.book-sidebar-left::-webkit-scrollbar-thumb,
.book-sidebar-right::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.book-sidebar-left::-webkit-scrollbar-thumb:hover,
.book-sidebar-right::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 章节颜色 */
.chapter-1 .chapter-number { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.chapter-2 .chapter-number { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.chapter-3 .chapter-number { background: linear-gradient(135deg, #22c55e, #16a34a); }
.chapter-4 .chapter-number { background: linear-gradient(135deg, #f97316, #ea580c); }
.chapter-5 .chapter-number { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.chapter-6 .chapter-number { background: linear-gradient(135deg, #ec4899, #db2777); }
.chapter-7 .chapter-number { background: linear-gradient(135deg, #ef4444, #dc2626); }
.chapter-8 .chapter-number { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.chapter-9 .chapter-number { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.chapter-10 .chapter-number { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.chapter-11 .chapter-number { background: linear-gradient(135deg, #d946ef, #c026d3); }

/* 返回目录按钮 */
.back-to-index {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 1rem;
    background: #f1f5f9;
    border-radius: 8px;
    color: #475569;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.back-to-index:hover {
    background: #e2e8f0;
    color: #1e293b;
}
