/* --- VARIABLES --- */
:root {
    --bg-body: #ffffff;
    --bg-subtle: #f9fafb;
    --bg-sidebar: #ffffff;
    --border-color: #e5e7eb;
    
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    
    --accent: #0071e3;
    --accent-hover: #005bb5;
    
    /* Scrollbar Colors */
    --sb-track: transparent;
    --sb-thumb: #d1d5db;
    --sb-thumb-hover: #9ca3af;
    
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --header-height: 60px;
    --sidebar-width: 260px;
    --toc-width: 220px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0d0d0d;
        --bg-subtle: #161616;
        --bg-sidebar: #0d0d0d;
        --border-color: #27272a;
        
        --text-primary: #ededed;
        --text-secondary: #a1a1aa;
        --text-tertiary: #52525b;
        
        --accent: #3b82f6;
        --accent-hover: #60a5fa;

        /* Dark Scrollbar */
        --sb-thumb: #3f3f46;
        --sb-thumb-hover: #52525b;
    }
    .doc-logo img { filter: invert(1); }
}

/* --- SCROLLBARS (New) --- */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--sb-thumb) var(--sb-track);
}
/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--sb-track);
}
::-webkit-scrollbar-thumb {
    background-color: var(--sb-thumb);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--sb-thumb-hover);
}

/* --- RESET & BASE --- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; transition: 0.15s; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* --- BUTTONS --- */
.btn-primary {
    background-color: var(--accent);
    color: #ffffff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary:active { transform: scale(0.98); }

.btn-icon {
    background: transparent; border: none;
    color: var(--text-tertiary); font-size: 20px;
    padding: 8px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* --- HEADER --- */
.doc-header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
}
@media (prefers-color-scheme: dark) { .doc-header { background: rgba(13, 13, 13, 0.9); } }

.doc-header-left { display: flex; align-items: center; gap: 12px; }

.mobile-menu-btn {
    display: none;
    background: none; border: none;
    font-size: 24px; color: var(--text-primary);
    padding: 4px;
}

.doc-logo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.doc-logo img { height: 24px; width: auto; }
.badge { 
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    font-size: 11px; padding: 2px 6px; border-radius: 4px; color: var(--text-secondary);
}

.doc-header-center { flex: 1; display: flex; justify-content: center; padding: 0 20px; }

.search-trigger {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    width: 100%; max-width: 400px;
    display: flex; align-items: center; gap: 10px;
    color: var(--text-tertiary); font-size: 13px; cursor: pointer;
}
.search-trigger kbd { margin-left: auto; border: 1px solid var(--border-color); border-radius: 4px; padding: 1px 4px; font-size: 10px; }

.doc-header-right { display: flex; align-items: center; gap: 16px; font-size: 14px; font-weight: 500; }
.nav-link { color: var(--text-secondary); white-space: nowrap;}
.nav-link:hover { color: var(--text-primary); }
.mobile-icon-btn { display: none; background: none; border: none; font-size: 20px; color: var(--text-primary); padding: 4px; }

/* --- SIDEBAR --- */
.doc-sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    position: fixed; top: var(--header-height); bottom: 0; left: 0;
    overflow-y: auto;
    padding: 24px 16px 24px 24px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 150;
}
.sidebar-header-mobile { display: none; }
.mobile-only-group { display: none; }

.nav-group { margin-bottom: 32px; }
.nav-group h4 {
    font-size: 12px; font-weight: 600; color: var(--text-primary);
    text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 12px 0;
}
.nav-item { display: block; padding: 6px 0; font-size: 14px; color: var(--text-secondary); }
.nav-item:hover { color: var(--text-primary); }
.nav-item.active { color: var(--accent); font-weight: 500; }

.mobile-sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 140;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
    backdrop-filter: blur(2px);
}
.mobile-sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

/* --- MAIN CONTENT --- */
.doc-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.content-view {
    padding: 48px 48px;
    max-width: 1000px;
    margin: 0 auto;
}
.content-view.hidden { display: none; }

/* Landing */
.landing-hero { text-align: center; margin-bottom: 48px; padding-top: 20px; }
.landing-hero h1 { font-size: 42px; font-weight: 700; letter-spacing: -1px; margin-bottom: 12px; }
.landing-hero p { font-size: 18px; color: var(--text-secondary); max-width: 600px; margin: 0 auto; line-height: 1.6; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.feature-card {
    border: 1px solid var(--border-color); border-radius: 12px; padding: 24px;
    background: var(--bg-body);
}
.icon-box {
    width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 16px;
}
.blue { background: rgba(0, 113, 227, 0.1); color: var(--accent); }
.purple { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
.gold { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

/* Article */
.article-container { display: flex; gap: 40px; position: relative; }
.doc-article { flex: 1; min-width: 0; }

.breadcrumbs { font-size: 13px; color: var(--text-tertiary); display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.crumb-link { cursor: pointer; color: var(--text-secondary); }

/* Main Title Styling */
#article-title { 
    font-size: 36px; 
    font-weight: 700; 
    margin-top: 0; 
    line-height: 1.2; 
    color: var(--text-primary); 
    margin-bottom: 24px;
}

/* Markdown Styling */
.markdown-body { color: var(--text-secondary); font-size: 16px; line-height: 1.7; overflow-wrap: break-word;}

/* If an H1 slips through in markdown, style it like an H2 to prevent visual clash, or we remove it via JS */
.markdown-body h1 { font-size: 26px; font-weight: 600; color: var(--text-primary); margin-top: 32px; }

.markdown-body h2 { font-size: 22px; color: var(--text-primary); font-weight: 600; margin-top: 40px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.markdown-body h3 { font-size: 18px; color: var(--text-primary); font-weight: 600; margin-top: 32px; margin-bottom: 12px; }
.markdown-body p { margin-bottom: 20px; }
.markdown-body code {
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    padding: 2px 4px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; color: var(--text-primary);
}
.markdown-body pre {
    background: #1e1e1e; color: #e5e5e5;
    padding: 16px; border-radius: 8px; overflow-x: auto; margin-bottom: 24px;
}
.markdown-body img { max-width: 100%; border-radius: 8px; height: auto; }

/* TOC Sidebar - HIDDEN by default, shown only on large screens */
.toc-sidebar { width: var(--toc-width); display: none; flex-shrink: 0; }
@media (min-width: 1200px) { .toc-sidebar { display: block; } }

.toc-sticky { position: sticky; top: 100px; border-left: 1px solid var(--border-color); padding-left: 20px; max-height: 80vh; overflow-y: auto;}
.toc-title { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-primary); display: block; margin-bottom: 12px; }
#toc-list { list-style: none; padding: 0; margin: 0; }
#toc-list li a { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.4; }
#toc-list li a:hover { color: var(--accent); }

/* Search Overlay */
.search-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 200; backdrop-filter: blur(2px);
    display: flex; justify-content: center; padding-top: 80px;
}
.search-overlay.hidden { display: none; }

.search-modal {
    background: var(--bg-body); width: 100%; max-width: 600px;
    border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    overflow: hidden; height: fit-content; max-height: 80vh; display: flex; flex-direction: column;
    margin: 0 16px;
}

.search-input-wrapper { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border-color); }
.search-input-wrapper input { flex: 1; border: none; background: transparent; font-size: 16px; outline: none; color: var(--text-primary); margin: 0 12px; }
.search-results { overflow-y: auto; padding: 8px; min-height: 100px; }
.result-item { padding: 12px 16px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.result-item:hover { background: var(--bg-subtle); }
.result-title { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.result-snippet { font-size: 12px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.empty-placeholder { padding: 20px; text-align: center; color: var(--text-tertiary); font-size: 14px; }

/* 404 */
.error-container { text-align: center; padding-top: 60px; }
.error-container h2 { font-size: 48px; margin: 0; }

/* --- RESPONSIVE MEDIA QUERIES --- */

@media (max-width: 900px) {
    .mobile-menu-btn { display: block; }
    .doc-header-center { display: none; }
    .mobile-icon-btn { display: block; }
    .desktop-only { display: none; }
    
    .doc-sidebar {
        top: 0; width: 280px;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }
    .doc-sidebar.open { transform: translateX(0); }
    
    .sidebar-header-mobile {
        display: flex; justify-content: space-between; align-items: center;
        margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color);
        font-weight: 600; color: var(--text-primary);
    }
    .mobile-only-group { display: block; margin-top: 32px; border-top: 1px solid var(--border-color); padding-top: 24px; }

    .doc-main { margin-left: 0; }
    .content-view { padding: 32px 20px; }
    
    .landing-hero h1 { font-size: 32px; }
    #article-title { font-size: 28px; }
    .markdown-body pre { padding: 12px; font-size: 13px; }
}

@media (max-width: 400px) {
    .doc-header { padding: 0 12px; }
    .content-view { padding: 24px 16px; }
    .landing-hero h1 { font-size: 28px; }
    .doc-logo span { display: none; }
    .doc-logo img { height: 28px; }
    .card-grid { grid-template-columns: 1fr; }

}

        @media (max-width: 720px) {
                .toc-sidebar {
        display: none !important;
                }
        }