/* 目录容器样式 */
#toc-wrapper {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 300px;
    max-height: 80vh;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.33, 1, 0.68, 1);
    transform: translateX(0);
    opacity: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

#toc-wrapper.toc-collapsed {
    transform: translateX(calc(100% - 50px));
    opacity: 0.95;
}

#toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}

#toc-header span {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: 0.5px;
    flex-grow: 1;
}

#toc-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

#toc-controls button {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
    font-weight: 500;
}

#toc-controls button:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

#toc-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding: 0;
}

/* 目录列表容器 */
#toc-list-container {
    overflow-y: auto;
    padding: 15px;
    flex-grow: 1;
}

/* 目录列表样式 */
#toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

#toc-list ul {
    list-style: none;
    padding-left: 20px;
    margin: 0;
    display: none; /* 默认次级目录隐藏 */
}

#toc-list li {
    margin: 10px 0;
    position: relative;
    line-height: 1.5;
    transition: all 0.2s ease;
    border-left: 2px solid #e9ecef;
    padding-left: 15px;
}

#toc-list li:hover {
    border-left-color: #4dabf7;
}

#toc-list li.toc-has-children > a:after {
    content: '›';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(0);
    font-size: 16px;
    transition: transform 0.3s ease;
    color: #6c757d;
}

#toc-list li.toc-expanded > a:after {
    transform: translateY(-50%) rotate(90deg);
    color: #1a73e8;
}

#toc-list a {
    display: block;
    padding: 8px 30px 8px 12px;
    color: #495057;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
    font-size: 15px;
    background: transparent;
}

#toc-list a:hover {
    color: #1a73e8;
    background: #f1f8ff;
}

#toc-list .toc-level-1 > a {
    font-weight: 700;
    color: #212529;
    padding-left: 15px;
    background: #f8f9fa;
    border-left: 3px solid #1a73e8;
}

#toc-list .toc-level-2 > a {
    font-weight: 600;
    color: #343a40;
}

#toc-list .toc-level-3 > a {
    padding-left: 25px;
    font-size: 14.5px;
}

#toc-list .toc-level-4 > a {
    padding-left: 35px;
    font-size: 14px;
    color: #6c757d;
}

#toc-list .toc-level-5 > a,
#toc-list .toc-level-6 > a {
    padding-left: 45px;
    font-size: 13.5px;
    color: #868e96;
}

/* 当前活动项样式 */
#toc-list a.toc-active {
    color: #1a73e8;
    background: #e7f3ff;
    font-weight: 600;
}

#toc-list li.toc-active {
    border-left-color: #1a73e8;
}

/* 目录页脚 */
#toc-footer {
    padding: 12px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 13px;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#toc-progress {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

#toc-progress-bar {
    height: 100%;
    width: 0%;
    background: #1a73e8;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* 滚动条样式 */
#toc-list-container::-webkit-scrollbar {
    width: 8px;
}

#toc-list-container::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

#toc-list-container::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 4px;
}

#toc-list-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    #toc-wrapper {
        width: 280px;
        right: 15px;
    }
}

@media (max-width: 992px) {
    #toc-wrapper {
        position: static;
        width: 100%;
        max-height: none;
        margin: 0 auto 30px;
        transform: none !important;
        opacity: 1 !important;
        max-width: 700px;
    }
    
    #toc-controls {
        display: none;
    }
}

@media (max-width: 768px) {
    #toc-wrapper {
        border-radius: 8px;
        padding: 0;
    }
    
    #toc-header span {
        font-size: 17px;
    }
    
    #toc-list a {
        padding: 8px 25px 8px 10px;
    }
}