/* Smart TOC Plugin - Dark Theme */

#smart-toc-sidebar {
    position: fixed;
    right: 24px;
    top: 120px;
    width: 320px;
    max-height: calc(100vh - 160px);
    background: #0a0a0a;
    border: 2px solid #2d2d2d;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    z-index: 9999;
    overflow: hidden;
    transition: all 0.3s ease;
}

#smart-toc-sidebar:hover {
    border-color: #a855f7;
    box-shadow: 0 8px 32px rgba(168, 85, 247, 0.3);
}

.toc-header {
    background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #2d2d2d;
}

.toc-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.toc-close {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
}

.toc-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.toc-close svg {
    display: block;
}

.toc-nav {
    padding: 12px;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
    scrollbar-width: thin;
    scrollbar-color: #404040 #1a1a1a;
}

.toc-nav::-webkit-scrollbar {
    width: 6px;
}

.toc-nav::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 3px;
}

.toc-nav::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 3px;
}

.toc-nav::-webkit-scrollbar-thumb:hover {
    background: #a855f7;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0;
    padding: 0;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #b8b8b8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    margin-bottom: 4px;
}

.toc-link:hover {
    background: #1a1a1a;
    color: #ffffff;
    border-left-color: #666;
}

.toc-link.active {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(147, 51, 234, 0.15));
    color: #ffffff;
    font-weight: 600;
    border-left-color: #a855f7;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.2);
}

.toc-icon {
    flex-shrink: 0;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.5;
    transition: all 0.2s;
}

.toc-link.active .toc-icon {
    width: 8px;
    height: 8px;
    opacity: 1;
    background: #a855f7;
}

/* Indentation for heading levels */
.toc-link[data-level="2"] { padding-left: 12px; }
.toc-link[data-level="3"] { padding-left: 24px; font-size: 13px; }
.toc-link[data-level="4"] { padding-left: 36px; font-size: 13px; }
.toc-link[data-level="5"] { padding-left: 48px; font-size: 12px; }
.toc-link[data-level="6"] { padding-left: 60px; font-size: 12px; }

/* Mobile Floating Button */
#smart-toc-mobile-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #a855f7, #9333ea);
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.5);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s;
}

#smart-toc-mobile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.7);
}

#smart-toc-mobile-btn:active {
    transform: scale(0.95);
}

.toc-btn-icon {
    width: 24px;
    height: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.toc-btn-icon span {
    width: 20px;
    height: 2.5px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
    display: block;
}

/* Mobile Overlay - Lighter */
.toc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 9998;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile Drawer - Small Bottom Right Popup */
.toc-mobile-open #smart-toc-sidebar {
    position: fixed;
    right: 20px;
    bottom: 90px;
    top: auto;
    width: 280px;
    height: 320px;
    max-height: 50vh;
    border-radius: 12px;
    transform: scale(1);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from { 
        transform: scale(0.8);
        opacity: 0;
    }
    to { 
        transform: scale(1);
        opacity: 1;
    }
}

.toc-mobile-open .toc-close {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toc-mobile-open .toc-nav {
    max-height: calc(50vh - 80px);
}

.toc-mobile-open .toc-overlay {
    display: block;
}

/* Empty State */
.toc-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.toc-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.toc-empty-text {
    font-size: 14px;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 1280px) {
    #smart-toc-sidebar {
        width: 280px;
        right: 16px;
    }
}

@media (max-width: 1024px) {
    #smart-toc-sidebar {
        display: none;
    }
    
    #smart-toc-mobile-btn {
        display: block;
    }
    
    .toc-mobile-open #smart-toc-sidebar {
        display: block;
    }
}

@media (max-width: 640px) {
    .toc-mobile-open #smart-toc-sidebar {
        width: 260px;
        height: 300px;
        right: 16px;
        bottom: 80px;
    }
    
    #smart-toc-mobile-btn {
        width: 50px;
        height: 50px;
        bottom: 16px;
        right: 16px;
    }
    
    .toc-btn-icon {
        width: 20px;
        height: 16px;
    }
    
    .toc-btn-icon span {
        width: 18px;
        height: 2.5px;
    }
}