/* ==========================================================================
   BullDB Premium CSS Design System
   ========================================================================== */

:root {
    /* Color Tokens (Dark Theme - Default) */
    --bg-base: #080a10;
    --bg-surface: #0e1220;
    --bg-surface-glass: rgba(14, 18, 32, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(59, 130, 246, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #a855f7;
    --accent: #00f5ff;
    
    --code-bg: #0b0d19;
    --code-text: #38bdf8;
    --code-keyword: #f43f5e;
    --code-string: #10b981;
    --code-comment: #64748b;

    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', source-code-pro, Menlo, Monaco, Consolas, monospace;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(16px);
}

/* Light Theme Variables */
html[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(37, 99, 235, 0.08);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.2);
    --secondary: #7c3aed;
    --accent: #06b6d4;
    
    --code-bg: #f1f5f9;
    --code-text: #0284c7;
    --code-keyword: #d97706;
    --code-string: #059669;
    --code-comment: #94a3b8;
    
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Resets & Base Layouts
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Page loader progress bar */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    width: 0%;
    z-index: 1000;
    transition: width 0.4s ease;
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background-color: var(--bg-surface-glass);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-premium);
}

.navbar-container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 0.75rem;
}

.brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px var(--primary));
}

.brand-name {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Search Box styling */
.search-container {
    position: relative;
    width: 320px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

#search-input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
}

#search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--border-glow);
    background-color: rgba(0, 0, 0, 0.4);
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-premium);
    display: none;
    z-index: 110;
}

.search-dropdown.active {
    display: block;
}

.search-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.search-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
}

.search-item-snippet {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Actions navigation dropdown */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.version-select-wrapper select {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1.5rem 0.5rem 1rem;
    border-radius: 8px;
    outline: none;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.85rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
}

.icon-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.icon-btn:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 10px var(--border-glow);
}

/* Sun/Moon icons toggle */
#theme-toggle .sun-icon {
    display: none;
}
html[data-theme="light"] #theme-toggle .sun-icon {
    display: block;
}
html[data-theme="light"] #theme-toggle .moon-icon {
    display: none;
}

/* ==========================================================================
   Main Layout & Sidebar
   ========================================================================= */

.main-layout {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    max-width: 1440px;
    margin: 72px auto 0;
    min-height: calc(100vh - 72px);
    position: relative;
}

/* Sidebar styling */
.sidebar {
    border-right: 1px solid var(--border-color);
    height: calc(100vh - 72px);
    position: sticky;
    top: 72px;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    background-color: rgba(8, 10, 16, 0.5);
}

.menu-section {
    margin-bottom: 2rem;
}

.menu-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.menu-list {
    list-style: none;
}

.menu-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition-smooth);
}

.menu-link:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.menu-link.active {
    color: var(--primary);
    background-color: var(--primary-glow);
    font-weight: 600;
}

/* Outline TOC table of contents right sidebar */
.right-toc {
    border-left: 1px solid var(--border-color);
    height: calc(100vh - 72px);
    position: sticky;
    top: 72px;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    font-size: 0.85rem;
}

.toc-title {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toc-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-smooth);
    display: block;
    line-height: 1.4;
}

.toc-link:hover {
    color: var(--primary);
}

.toc-link.h3 {
    padding-left: 1rem;
    font-size: 0.8rem;
}

/* ==========================================================================
   Content Area & Hero section
   ========================================================================== */

.content-area {
    padding: 2.5rem 3rem;
    overflow-y: auto;
}

.content-wrapper {
    max-width: 820px;
    margin: 0 auto;
}

/* Hero Section style */
.hero-section {
    position: relative;
    padding: 3rem 2rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(14, 18, 32, 0.6) 0%, rgba(8, 10, 16, 0.8) 100%);
    overflow: hidden;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-premium);
}

.hero-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    right: -50%;
    bottom: -50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, rgba(168, 85, 247, 0.08) 50%, transparent 100%);
    z-index: 0;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.hero-content h1 {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

/* ==========================================================================
   Markdown Typography & Body
   ========================================================================== */

.markdown-body {
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
}

.markdown-body h1 {
    font-size: 2.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

.markdown-body h2 {
    font-size: 1.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
}

.markdown-body h3 {
    font-size: 1.35rem;
}

.markdown-body p {
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
}

.markdown-body blockquote {
    padding: 0.75rem 1.25rem;
    margin: 1.5rem 0;
    border-left: 4px solid var(--primary);
    background-color: rgba(59, 130, 246, 0.05);
    border-radius: 0 8px 8px 0;
    color: var(--text-primary);
}

.markdown-body blockquote p {
    margin-bottom: 0;
    color: var(--text-primary);
}

/* Code & Pre */
.markdown-body pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    position: relative;
    box-shadow: var(--shadow-premium);
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--code-text);
    background-color: rgba(59, 130, 246, 0.08);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    color: var(--text-primary);
    display: block;
}

/* Lists and Tables */
.markdown-body ul, 
.markdown-body ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.markdown-body th,
.markdown-body td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.markdown-body th {
    background-color: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

/* Tables in light mode */
html[data-theme="light"] .markdown-body th {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Custom code rendering highlights (light-first best-effort styling via CSS selectors) */
.token-comment { color: var(--code-comment); }
.token-string { color: var(--code-string); }
.token-keyword { color: var(--code-keyword); font-weight: 600; }

/* ==========================================================================
   Loading Animation & Footer Nav
   ========================================================================== */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 0;
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 10px var(--primary-glow);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Doc footer navigation prev/next links */
.doc-footer {
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.footer-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 3rem;
}

.footer-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.footer-nav-link:hover {
    border-color: var(--primary);
    background-color: rgba(59, 130, 246, 0.02);
}

.footer-nav-link.next {
    align-items: flex-end;
}

.nav-desc {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

.footer-copyright {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Responsive / Mobile styling
   ========================================================================== */

.mobile-only {
    display: none;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 250px 1fr;
    }
    .right-toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        top: 72px;
        bottom: 0;
        width: 280px;
        z-index: 90;
        background-color: var(--bg-surface);
        box-shadow: var(--shadow-premium);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .content-area {
        padding: 1.5rem 1.5rem;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .search-container {
        display: none; /* hidden on small mobiles in header, can be rendered in sidebar */
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .footer-nav {
        flex-direction: column;
    }
}
