/**
 * 统一目录系统样式 - 暗黑风格 + 橙色高亮
 * 避免重复显示，统一视觉风格
 */

/* ========================================
   页面内目录样式 - 暗黑风格
   ======================================== */

.custom-toc {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border: 1px solid #4a5568;
    border-radius: 12px;
    padding: 24px;
    margin: 24px 0;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.custom-toc::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff6b35, #f7931e, #ff6b35);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: -200% 0; }
    50% { background-position: 200% 0; }
}

.custom-toc .toc-title {
    font-size: 18px;
    font-weight: 700;
    color: #f7fafc;
    margin: 0 0 18px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #ff6b35;
    display: flex;
    align-items: center;
    position: relative;
}

.custom-toc .toc-title::before {
    content: "📚";
    margin-right: 8px;
    font-size: 16px;
}

.custom-toc .toc-content {
    margin: 0;
    color: #e2e8f0;
}

/* 目录列表基础样式 - 暗黑风格 */
.toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc-list ul {
    margin: 6px 0 0 20px;
    padding: 0;
    list-style: none;
    border-left: 1px solid #4a5568;
    padding-left: 16px;
}

.toc-list li {
    margin: 10px 0;
    line-height: 1.5;
    position: relative;
}

/* 目录链接样式 - 橙色高亮 */
.toc-link {
    display: block;
    color: #cbd5e0;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    position: relative;
    font-weight: 500;
}

.toc-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    transition: width 0.3s ease;
}

.toc-link:hover {
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.1);
    text-decoration: none;
    border-left-color: #ff6b35;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}

.toc-link:hover::before {
    width: 100%;
}

.toc-link.active {
    color: #ff6b35;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.2), rgba(247, 147, 30, 0.1));
    font-weight: 700;
    border-left-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
    transform: translateX(6px);
}

.toc-link.active::before {
    width: 100%;
}

/* ========================================
   左侧固定目录样式 - 暗黑风格
   ======================================== */

.toc-left-sidebar {
    position: fixed;
    top: 200px;
    left: 50%;
    margin-left: -860px; /* 640px + 210px + 10px，右端距离文章区域10px */
    width: 210px;
    max-height: calc(100vh - 300px);
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #1a202c 100%);
    border: 1px solid #4a5568;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 107, 53, 0.1);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

/* 滚动后的定位状态 */
.toc-left-sidebar.scrolled {
    top: 100px;
    max-height: calc(100vh - 200px);
    transform: translateY(-10px);
}

/* 宽屏显示 */
@media (min-width: 1400px) {
    .toc-left-sidebar {
        opacity: 1;
        visibility: visible;
    }
}

/* 超宽屏优化 */
@media (min-width: 1600px) {
    .toc-left-sidebar {
        width: 225px;
        margin-left: -875px; /* 640px + 225px + 10px，右端距离文章区域10px */
    }
}

/* 收起状态 */
.toc-left-sidebar.collapsed {
    width: 50px;
    overflow: hidden;
    /* 收起时在内容区左侧，不覆盖内容 */
    margin-left: -700px; /* 640px + 50px + 10px间距，收起状态不变 */
}

.toc-left-sidebar.collapsed .toc-content,
.toc-left-sidebar.collapsed .reading-progress,
.toc-left-sidebar.collapsed .toc-progress {
    display: none;
}

.toc-left-sidebar.collapsed .toc-header {
    padding: 10px;
    justify-content: center;
    border-bottom: none;
    background: transparent;
    border-radius: 16px;
}

.toc-left-sidebar.collapsed .toc-header span {
    display: none;
}

.toc-left-sidebar.collapsed .toc-header::before {
    display: none;
}

/* 左侧目录头部 */
.toc-left-sidebar .toc-header {
    font-size: 16px;
    font-weight: 700;
    color: #f7fafc;
    padding: 24px;
    border-bottom: 2px solid #ff6b35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(247, 147, 30, 0.05));
    border-radius: 16px 16px 0 0;
    position: relative;
}

.toc-left-sidebar .toc-header::before {
    content: "📖";
    margin-right: 8px;
    font-size: 14px;
}

/* 左侧目录内容区 */
.toc-left-sidebar .toc-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    background: rgba(26, 32, 44, 0.5);
    position: relative;
}

/* 智能滚动指示器 */
.toc-left-sidebar .toc-content.auto-scrolling::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff6b35, #f7931e, #ff6b35);
    background-size: 200% 100%;
    animation: auto-scroll-indicator 1s ease-in-out;
    z-index: 10;
}

@keyframes auto-scroll-indicator {
    0% { 
        opacity: 0;
        background-position: -200% 0;
    }
    50% { 
        opacity: 1;
        background-position: 200% 0;
    }
    100% { 
        opacity: 0;
        background-position: 400% 0;
    }
}

.toc-left-sidebar .toc-content::-webkit-scrollbar {
    width: 6px;
}

.toc-left-sidebar .toc-content::-webkit-scrollbar-track {
    background: rgba(74, 85, 104, 0.3);
    border-radius: 3px;
}

.toc-left-sidebar .toc-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #ff6b35, #f7931e);
    border-radius: 3px;
}

.toc-left-sidebar .toc-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #f7931e, #ff6b35);
}

/* 左侧目录列表样式重置 */
.toc-left-sidebar .toc-content .toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc-left-sidebar .toc-content .toc-list ul {
    margin: 0 0 0 18px;
    padding: 0;
    list-style: none;
    border-left: 1px solid rgba(255, 107, 53, 0.3);
    padding-left: 12px;
}

.toc-left-sidebar .toc-content .toc-list li {
    margin: 0 0 8px 0;
    padding: 0;
    line-height: 1.4;
}

/* 左侧目录链接样式 */
.toc-left-sidebar .toc-content .toc-link {
    display: block;
    color: #cbd5e0;
    text-decoration: none;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
    line-height: 1.3;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.toc-left-sidebar .toc-content .toc-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 107, 53, 0.1), transparent);
    transition: left 0.5s ease;
}

.toc-left-sidebar .toc-content .toc-link:hover {
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.15);
    text-decoration: none;
    border-left-color: #ff6b35;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}

.toc-left-sidebar .toc-content .toc-link:hover::before {
    left: 100%;
}

.toc-left-sidebar .toc-content .toc-link.active {
    color: #ff6b35;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.25), rgba(247, 147, 30, 0.15));
    font-weight: 700;
    border-left-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateX(6px);
}

.toc-left-sidebar .toc-content .toc-link.active::before {
    left: 100%;
}

/* 切换按钮 */
.toc-left-sidebar .toc-toggle {
    background: rgba(255, 107, 53, 0.1);
    border: 1px solid rgba(255, 107, 53, 0.3);
    font-size: 14px;
    cursor: pointer;
    color: #ff6b35;
    padding: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
    flex-shrink: 0; /* 防止被压缩 */
}

.toc-left-sidebar .toc-toggle:hover {
    background: rgba(255, 107, 53, 0.2);
    border-color: #ff6b35;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

/* 收缩状态下的按钮样式 */
.toc-left-sidebar.collapsed .toc-toggle {
    width: 36px;
    height: 36px;
    margin: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.9), rgba(247, 147, 30, 0.8));
    border: 2px solid #ff6b35;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
    font-size: 16px;
}

.toc-left-sidebar.collapsed .toc-toggle:hover {
    background: linear-gradient(135deg, rgba(255, 107, 53, 1), rgba(247, 147, 30, 0.9));
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
}

/* 阅读进度区域 - 统一暗黑风格 */
.toc-left-sidebar .reading-progress {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 107, 53, 0.3);
    font-size: 12px;
    color: #cbd5e0;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(247, 147, 30, 0.05));
    border-radius: 0 0 16px 16px;
}

.toc-left-sidebar .progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(74, 85, 104, 0.5);
    border-radius: 3px;
    margin: 10px 0;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toc-left-sidebar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b35, #f7931e, #ff6b35);
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
    animation: progress-shimmer 2s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0%, 100% { background-position: -200% 0; }
    50% { background-position: 200% 0; }
}

.toc-left-sidebar .progress-text {
    text-align: center;
    font-size: 11px;
    color: #a0aec0;
    font-weight: 600;
}

/* 进度指示器 */
.toc-left-sidebar .toc-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    background: linear-gradient(180deg, #ff6b35, #f7931e);
    border-radius: 0 4px 4px 0;
    height: 0%;
    transition: height 0.3s ease;
    box-shadow: 0 0 10px rgba(255, 107, 53, 0.5);
}

/* 移动端隐藏左侧目录 */
@media (max-width: 1399px) {
    .toc-left-sidebar {
        display: none !important;
    }
}

/* 响应式优化 */
@media (min-width: 1400px) and (max-width: 1599px) {
    .toc-left-sidebar {
        width: 195px;
        margin-left: -845px; /* 640px + 195px + 10px，右端距离文章区域10px */
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .toc-link.active,
    .toc-left-sidebar .toc-content .toc-link.active {
        border: 2px solid #ff6b35;
        outline: 2px solid #fff;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .toc-link,
    .toc-left-sidebar .toc-content .toc-link,
    .toc-left-sidebar,
    .progress-fill {
        transition: none;
        animation: none;
    }
}