/* --- Docs Global Resets --- */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; 
}

.docs-body {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

/* --- Thinner Docs Header --- */
.docs-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(5, 6, 8, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-color);
    height: 60px;
    display: flex;
    align-items: center;
}

.docs-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
}

.docs-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.docs-mobile-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.5rem;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.docs-mobile-toggle:hover {
    background: rgba(255,255,255,0.05);
}

.docs-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #fff;
}

.docs-logo img { height: 24px; }

/* AJAX Search Bar */
.docs-search-wrapper {
    position: relative;
    width: 400px;
}

.docs-search-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

#docs-ajax-search {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 8px 16px 8px 40px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#docs-ajax-search:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 123, 255, 0.05);
    box-shadow: 0 0 10px var(--primary-glow);
}

.btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }

/* --- Docs Layout Grid --- */
.docs-layout {
    flex: 1; 
    display: grid;
    /* Increased left sidebar width from 280px to 320px */
    grid-template-columns: 320px 1fr;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

.docs-layout.has-toc {
    /* Increased left sidebar width from 280px to 320px */
    grid-template-columns: 320px 1fr 250px; 
}

/* --- Sidebar Containers (Stretches to Footer) --- */
.docs-sidebar {
    background: rgba(10, 12, 16, 0.3);
    border-right: 1px solid var(--border-color);
}

.docs-toc {
    background: rgba(10, 12, 16, 0.3);
    border-left: 1px solid var(--border-color);
}

/* --- Sidebar Inner Content (Sticky & Scrollable) --- */
.docs-nav, .docs-toc-inner {
    position: sticky;
    top: 60px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 2rem 1.5rem;
}

.docs-nav::-webkit-scrollbar, .docs-toc-inner::-webkit-scrollbar { width: 4px; }
.docs-nav::-webkit-scrollbar-track, .docs-toc-inner::-webkit-scrollbar-track { background: transparent; }
.docs-nav::-webkit-scrollbar-thumb, .docs-toc-inner::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* --- Right Sidebar TOC Styles --- */
.docs-toc-inner h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 0;
    margin-bottom: 1rem;
}

.docs-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.docs-toc-list a {
    color: #cbd5e1;
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
    display: block;
}

.docs-toc-list a:hover {
    color: var(--primary);
}

.docs-toc-list .toc-h3 {
    padding-left: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================================================================
   MODERN SIDEBAR NAVIGATION (ELECTRIC MINIMALISM)
   ========================================================================= */

/* --- 1. Top-Level Categories (e.g., OBJECTS, PLUGINS) --- */
.nav-group { 
    margin-bottom: 1.5rem; 
}

.nav-group-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02); /* Permanent subtle grey background */
    border: 1px solid rgba(255, 255, 255, 0.02); /* Faint border for crisp edges */
    border-radius: 6px;
    padding: 8px 12px; /* Pushed text inward away from the background edges */
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5); 
    transition: all 0.2s ease;
}

.nav-group-toggle h4 {
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px; 
    margin: 0;
}

.nav-group-toggle .chevron {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

/* Brighter background and pure white text on hover */
.nav-group-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

/* Keep text white when open */
.nav-group:not(.is-closed) > .nav-group-toggle {
    color: #fff;
}

/* --- 2. Sub-Categories (e.g., Basic, Developer) --- */
.nav-sub-group {
    margin: 4px 0; 
}

.nav-sub-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02); /* Permanent subtle grey background */
    border: 1px solid rgba(255, 255, 255, 0.02);
    padding: 6px 12px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.55);
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    border-radius: 6px;
    transition: all 0.2s ease;
}

/* Brighter background and pure white text on hover */
.nav-sub-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-sub-group:not(.is-closed) > .nav-sub-toggle {
    color: #fff;
    font-weight: 500;
}

/* --- 3. The Tree Structure (Indentations & Lines) --- */
.nav-group-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 2500px;
    opacity: 1;
    list-style: none;
    
    /* The core of the tree look */
    margin: 6px 0 6px 8px; /* Indent from parent */
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.08); /* A very faint, single guide line */
}

/* --- 4. Standard Article Links --- */
.nav-group-list a {
    position: relative;
    display: block;
    padding: 6px 12px;
    color: rgba(255, 255, 255, 0.55);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent; /* Keeps layout stable for active state border */
}

.nav-group-list a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.03);
}

/* --- 5. The "Electric" Active State --- */
.nav-group-list a.active {
    color: var(--primary);
    background: rgba(0, 123, 255, 0.08); /* Soft blue fill */
    border: 1px solid rgba(0, 123, 255, 0.2); /* Subtle outer border */
    /* This creates a sharp blue left line AND a soft electric glow */
    box-shadow: inset 3px 0 0 var(--primary), 0 0 12px rgba(0, 123, 255, 0.15); 
    font-weight: 500;
}

/* --- 6. Open/Closed States Logic --- */
.nav-group.is-closed .chevron,
.nav-sub-group.is-closed .chevron {
    transform: rotate(-90deg);
}

.nav-group.is-closed .nav-group-list,
.nav-sub-group.is-closed .nav-group-list {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    margin-top: 0;
    margin-bottom: 0;
}

/* --- Article Content --- */
.docs-content {
    /* Reduced L/R padding from 4rem to 2.5rem to make room for wider sidebar */
    padding: 3rem 2.5rem 6rem;
    max-width: 950px;
}

.doc-article h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.doc-article h2 { font-size: 1.8rem; margin-top: 2.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.doc-article h3 { font-size: 1.3rem; margin-top: 2rem; }
.doc-lead { font-size: 1.1rem; color: var(--text-muted); font-weight: 300; line-height: 1.7; }
.doc-divider { border: 0; height: 1px; background: var(--border-color); margin: 2rem 0; }

/* --- Alert Boxes --- */
.doc-alert {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    border-left: 4px solid transparent;
    background: var(--bg-surface);
}

.doc-alert .alert-icon { font-size: 1.5rem; margin-top: 2px; }
.doc-alert p { margin: 0; font-size: 0.9rem; color: #cbd5e1; }
.doc-alert strong { display: block; margin-bottom: 4px; font-size: 1rem; color: #fff; }

.alert-info { border-left-color: var(--primary); background: rgba(0, 123, 255, 0.05); }
.alert-info .alert-icon { color: var(--primary); }

.alert-warning { border-left-color: var(--gold); background: rgba(245, 176, 65, 0.05); }
.alert-warning .alert-icon { color: var(--gold); }

/* --- Code Blocks --- */
.doc-code-block {
    background: #0d1116;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5rem 0;
    text-align: left !important;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.code-lang { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }

.copy-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.copy-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.doc-code-block pre { margin: 0; padding: 1.25rem; overflow-x: auto; }
.doc-code-block code { font-family: monospace; font-size: 0.9rem; color: #e2e8f0; }

/* --- Dropdown Search --- */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2000;
    overflow: hidden;
}

.search-dropdown a {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: #fff;
    text-decoration: none;
    transition: background 0.2s;
}

.search-dropdown a:last-child { border-bottom: none; }
.search-dropdown a:hover { background: rgba(0, 123, 255, 0.1); }
.search-dropdown .res-title { font-weight: 500; font-size: 0.95rem; display: block; margin-bottom: 2px; }
.search-dropdown .res-desc { font-size: 0.8rem; color: var(--text-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-dropdown-empty { padding: 15px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* --- Docs Slim Footer --- */
.docs-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
    background: rgba(5, 6, 8, 0.85);
}

.docs-footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.docs-footer a { 
    color: var(--text-muted); 
    transition: color 0.2s; 
    margin-left: 20px;
}

.docs-footer a:hover { color: #fff; }

/* =========================================================================
   MOBILE RESPONSIVE & OFF-CANVAS MENU LOGIC
   ========================================================================= */
.docs-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 800;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.docs-mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    .docs-mobile-toggle { display: block; }
    .docs-search-wrapper { display: none; }
    
    .docs-layout, .docs-layout.has-toc { grid-template-columns: 1fr; }
    .docs-toc { display: none; }
    
    .docs-sidebar {
        position: fixed;
        top: 60px;
        left: -320px;
        width: 300px;
        height: calc(100vh - 60px);
        background: #0d1117;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 900;
    }
    .docs-sidebar.active { left: 0; }
}

@media (max-width: 768px) {
    .docs-header-container { padding: 0 1rem; }
    .docs-content { padding: 2rem 1.5rem; }
    
    .doc-article h1, .doc-article h2, .doc-article h3, .doc-article p, .doc-header-block { text-align: center; }
    .inline-badge { margin-left: auto; margin-right: auto; }
    .doc-article ul { text-align: left; display: inline-block; }
    
    .doc-alert { flex-direction: column; align-items: center; text-align: center; }
    .doc-alert p { text-align: center; }

    .docs-footer-container { 
        flex-direction: column; 
        gap: 15px; 
        text-align: center; 
        padding: 0 1rem;
    }
    .docs-footer a { margin: 0 10px; }
}

/* --- Fix for Jodit YouTube Embed Overflows --- */
jodit[data-jodit_iframe_wrapper="1"] {
    width: 100% !important;
    height: 100% !important;
}