/* Documentation Table of Contents Styles */

/* TOC Container - Right Sidebar */
.docs-toc-container {
    position: fixed;
    right: 0;
    top: 120px;
    width: 280px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 1.5rem;
    background: rgba(30, 32, 36, 0.95);
    border-left: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 0.75rem 0 0 0.75rem;
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: transform 0.3s ease, right 0.3s ease;
}

.docs-toc-container.collapsed {
    right: -280px;
}

/* Custom scrollbar for TOC */
.docs-toc-container::-webkit-scrollbar {
    width: 6px;
}

.docs-toc-container::-webkit-scrollbar-track {
    background: rgba(30, 32, 36, 0.5);
    border-radius: 3px;
}

.docs-toc-container::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.5);
    border-radius: 3px;
}

.docs-toc-container::-webkit-scrollbar-thumb:hover {
    background: rgba(71, 85, 105, 0.7);
}


/* TOC Header */
.docs-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid rgba(16, 185, 129, 0.3);
    font-weight: 600;
    font-size: 0.875rem;
    color: #10b981;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.docs-toc-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.docs-toc-header i {
    font-size: 1rem;
}

/* Collapse Button */
.docs-toc-collapse-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.docs-toc-collapse-btn:hover {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

/* TOC Navigation */
.docs-toc-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* TOC Links - Base Style */
.docs-toc-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.4;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.docs-toc-link:hover {
    color: #e5e7eb;
    background: rgba(71, 85, 105, 0.1);
    border-left-color: rgba(16, 185, 129, 0.5);
}

.docs-toc-link.active {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
    font-weight: 500;
}

/* H1 Level - Main Heading */
.docs-toc-h1 {
    font-weight: 600;
    font-size: 0.9375rem;
    padding-left: 0.75rem;
    margin-bottom: 0.25rem;
    color: #e5e7eb;
}

.docs-toc-h1.active {
    color: #10b981;
}

/* H2 Level - Sections */
.docs-toc-h2 {
    padding-left: 1.25rem;
    font-size: 0.875rem;
}

/* H3 Level - Subsections */
.docs-toc-h3 {
    padding-left: 2rem;
    font-size: 0.8125rem;
    color: #64748b;
}

.docs-toc-h3:hover {
    color: #cbd5e1;
}

.docs-toc-h3.active {
    color: #10b981;
}

/* Adjust main content document to make room for TOC */
.manual-content-area {
    margin-right: 320px; /* Width of TOC + some margin */
    transition: margin-right 0.3s ease;
}

.manual-content-area.toc-collapsed {
    margin-right: 0;
}

.manual-document {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.manual-document.toc-collapsed {
    max-width: 1200px;
}

/* Expand button - shown when TOC is collapsed */
.docs-toc-expand-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(16, 185, 129, 0.9);
    color: white;
    border: none;
    padding: 0.75rem 0.5rem;
    border-radius: 0.5rem 0 0 0.5rem;
    cursor: pointer;
    z-index: 99;
    transition: all 0.2s ease;
    box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
}

.docs-toc-expand-btn.show {
    opacity: 1;
    visibility: visible;
}

.docs-toc-expand-btn:hover {
    background: rgba(16, 185, 129, 1);
    padding-right: 0.75rem;
}

.docs-toc-expand-btn i {
    font-size: 1.25rem;
}

/* Tablet and below - Hide TOC by default, show on toggle */
@media (max-width: 1280px) {
    .manual-content-area {
        margin-right: 0 !important;
    }

    .manual-document {
        max-width: 1200px !important;
    }

    .docs-toc-container {
        transform: translateX(100%);
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
        top: 80px;
        max-height: calc(100vh - 100px);
        width: 260px;
        right: 0 !important;
    }

    .docs-toc-container.mobile-open {
        transform: translateX(0);
    }

    .docs-toc-container.collapsed {
        right: 0 !important;
    }

    .docs-toc-collapse-btn,
    .docs-toc-expand-btn {
        display: none !important;
    }

    /* Add a toggle button for mobile */
    .docs-toc-toggle {
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(16, 185, 129, 0.9);
        color: white;
        border: none;
        padding: 0.75rem 0.5rem;
        border-radius: 0.5rem 0 0 0.5rem;
        cursor: pointer;
        z-index: 99;
        transition: all 0.2s ease;
        box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
    }

    .docs-toc-toggle:hover {
        background: rgba(16, 185, 129, 1);
        padding-right: 0.75rem;
    }

    .docs-toc-toggle i {
        font-size: 1.25rem;
    }
}

@media (max-width: 768px) {
    .docs-toc-container {
        width: 240px;
        top: 60px;
        max-height: calc(100vh - 80px);
    }

    .docs-toc-link {
        font-size: 0.8125rem;
    }

    .docs-toc-h1 {
        font-size: 0.875rem;
    }

    .docs-toc-h2 {
        font-size: 0.8125rem;
    }

    .docs-toc-h3 {
        font-size: 0.75rem;
    }
}

/* Animation for TOC appearance */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.docs-toc-container {
    animation: slideInRight 0.3s ease;
}

/* Backdrop for mobile */
.docs-toc-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
    backdrop-filter: blur(2px);
}

.docs-toc-backdrop.active {
    display: block;
}

@media (max-width: 1280px) {
    .docs-toc-backdrop.active {
        display: block;
    }
}
