/* 目录侧边栏样式 */
#toc-sidebar {
    position: fixed;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
    padding: 1rem;
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-height: 20rem;
    overflow-y: auto;
}

#toc-sidebar.opacity-100.visible {
    opacity: 1;
    visibility: visible;
}

#toc-sidebar .flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

#toc-sidebar h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
}

#toc-sidebar button {
    color: #9ca3af;
}

#toc-sidebar button:hover {
    color: #4b5563;
}

#toc-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc-sidebar .space-y-1 > * + * {
    margin-top: 0.25rem;
}

#toc-sidebar .pl-4 {
    padding-left: 1rem;
}

#toc-sidebar .toc-item a {
    display: flex;
    align-items: flex-start;
    color: #374151;
    font-size: 0.875rem;
    transition: color 0.2s;
    padding: 0.25rem 0;
}

#toc-sidebar .toc-item a:hover {
    color: #2563eb;
}

#toc-sidebar .toc-item .flex-1 {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 目录触发按钮 */
#toc-toggle {
    position: fixed;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.5rem;
    height: 2.5rem;
    background: #2563eb;
    color: white;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

#toc-toggle:hover {
    background: #1d4ed8;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* 移动端目录 */
.mobile-toc.md\\:hidden {
    margin-bottom: 1.5rem;
}

.mobile-toc details summary {
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.mobile-toc details summary i {
    margin-right: 0.5rem;
}

.mobile-toc .mt-3 {
    margin-top: 0.75rem;
}

/* 悬浮返回顶部按钮 */
#back-to-top-btn {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
    background: #2563eb;
    color: white;
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
}

#back-to-top-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
}

#back-to-top-btn:active {
    transform: translateY(0);
}

#back-to-top-btn.opacity-100.visible {
    opacity: 1;
    visibility: visible;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #toc-sidebar {
        left: 1rem;
        width: 14rem;
    }
    
    #toc-toggle {
        left: 0.5rem;
        width: 2rem;
        height: 2rem;
    }
    
    #back-to-top-btn {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 2rem;
        height: 2rem;
    }
}