/* docs-style.css */
:root {
    /* Sidebar width */
    --sidebar-width: clamp(200px, 20vw, 300px);
    /* Never smaller than 200px, aims for 20% of viewport width, never larger than 300px */
    
    /* Maximum content width */
    --content-max-width: 1400px;
    /* Fixed maximum width for the main content */
    
    /* Base font size for regular text */
    --font-size-base: clamp(14px, 1.2vw, 16px);
    /* Never smaller than 14px, aims for 1.2% of viewport width, never larger than 16px */
    
    /* Font size for code blocks */
    --font-size-code: clamp(13px, 1.1vw, 15px);
    /* Never smaller than 14px, aims for 1.1% of viewport width, never larger than 16px */
    
    /* Heading font sizes */
    --font-size-h1: clamp(1.8rem, 3vw, 2.5rem);
    /* Never smaller than 1.8rem, aims for 3% of viewport width, never larger than 2.5rem */
    
    --font-size-h2: clamp(1.3rem, 2.5vw, 2rem);
    /* Never smaller than 1.3rem, aims for 2.5% of viewport width, never larger than 2rem */
    
    --font-size-h3: clamp(1rem, 2vw, 1.5rem);
    /* Never smaller than 1rem, aims for 2% of viewport width, never larger than 1.5rem */
    
    /* Base spacing unit */
    --spacing-base: clamp(1rem, 2vw, 1.5rem);
    /* Never smaller than 1rem, aims for 2% of viewport width, never larger than 1.5rem */
}

/* Container layout adjustments */
.docs-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: clamp(20px, 4vw, 40px);
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--spacing-base);
    box-sizing: border-box;
}

/* Reset any inherited margins */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
}

.docs-sidebar {
    position: sticky;
    top: 20px;
    z-index: 100;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

/* Documentation-specific styles */
.docs-nav {
    background: var(--card-bg);
    border-radius: 8px;
    padding: var(--spacing-base);
    margin-top: 10px;  /* Add space between home link and nav */
    width: var(--sidebar-width);
    overflow-y: auto;
    /* flex-grow: 1;      Allow nav to fill remaining space */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.docs-nav::-webkit-scrollbar {
    width: 6px;
}

.docs-nav::-webkit-scrollbar-track {
    background: transparent;
}

.docs-nav::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.docs-nav ul {
    list-style: none;
    padding: 0;
}

.docs-nav li {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.docs-nav a {
    color: var(--text);
    text-decoration: none;
    display: block;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background 0.3s ease;
    line-height: 1.4;
}

.docs-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.docs-nav a.active {
    background: var(--primary);
    color: white;
}

.docs-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: clamp(20px, 4vw, 40px);
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--spacing-base);
    box-sizing: border-box;
}

.docs-content {
    background: var(--card-bg);
    border-radius: 8px;
    padding: var(--spacing-base);
    font-size: var(--font-size-base);
    line-height: 1.7;
    max-width: 100%;
    overflow-x: auto;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.docs-content section {
    margin-bottom: calc(var(--spacing-base) * 2);
    scroll-margin-top: 2rem;
}

.docs-content h2 {
    font-size: var(--font-size-h2);
    margin-bottom: var(--spacing-base);
}

.docs-content h3 {
    font-size: var(--font-size-h3);
    margin: calc(var(--spacing-base) * 1.5) 0 var(--spacing-base);
}

.docs-content p {
    margin-bottom: var(--spacing-base);
}

.docs-content ul {
    margin: 0 0 var(--spacing-base) 20px;
}

.docs-content li {
    margin-bottom: calc(var(--spacing-base) * 0.5);
}

/* Table Styles */
.function-table {
    display: inline-block;  /* Change from block to inline-block */
    margin: var(--spacing-base) 0;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    min-width: min-content;  /* Ensure minimum width based on content */
}

/* Use wrapper for overflow handling */
.function-table-wrapper {
    overflow-x: auto;
    margin: 0;
    padding: 0;
}

.function-table table {
    border-collapse: collapse;
    margin: 0;  /* Remove any default margins */
}

/* Scrollable container for mobile */
.function-table-wrapper {
    overflow-x: auto;
    margin: 0;
    padding: 0;
    width: 100%;
}

.function-table th,
.function-table td {
    padding: calc(var(--spacing-base) * 0.75);
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: var(--font-size-code);
}

.function-table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    white-space: nowrap;
}

.function-table td {
    min-width: 120px;
}

/* Last row shouldn't have a border */
.function-table tr:last-child td {
    border-bottom: none;
}

/* Code Blocks */
.code-block {
    margin: var(--spacing-base) 0;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    background: #2d2d2d;
}

.code-block pre {
    margin: 0;
    padding: var(--spacing-base);
    overflow-x: auto;
    width: 100%;
}

.code-block code {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: var(--font-size-code);
    line-height: 1.5;
    tab-size: 2;
}

.code-block code,
.code-block pre code,
pre[class*="language-"],
code[class*="language-"] {
    font-family: 'SF Mono', Monaco, Consolas, monospace !important;
    font-size: var(--font-size-code) !important;
    line-height: 1.5;
    tab-size: 2;
}

.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: none;
    font-size: 20px;
    z-index: 99;
    transition: opacity 0.3s;
    opacity: 0.7;
}

.back-to-top:hover {
    opacity: 1;
}

.back-to-top.visible {
    display: block;
}

/* Home Link */
.home-link {
    display: inline-block;
    /* margin-bottom: var(--spacing-base); */
    margin-bottom: 0;
    width: var(--sidebar-width);
    color: var(--text);
    text-decoration: none;
    padding: 8px 16px;
    background: var(--card-bg);
    border-radius: 4px;
    transition: background 0.3s ease, transform 0.2s ease;
    font-size: var(--font-size-base);
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-4px);
}

@media (min-width: 2000px) {
    :root {
        --content-max-width: 1800px;
    }
}

/* Responsive Design Breakpoints - ordered from largest to smallest */
@media (min-width: 2000px) {
    :root {
        --content-max-width: 1800px;
    }
}

/* Tablet and smaller desktops */
@media (max-width: 1024px) {
    .docs-container {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        position: fixed;  /* Change to fixed for mobile menu */
        left: -100%;
        top: 0;
        width: min(80vw, 300px);
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        background: var(--card-bg);
        padding: var(--spacing-base);
    }

    .docs-nav {
        margin-top: 10px;
        padding: 0;
        width: 100%;  /* Take full width of sidebar */
    }

    .docs-sidebar.active {
        left: 0;
    }

    .docs-nav.active {
        left: 0;
    }

    /* Menu toggle button */
    .menu-toggle {
        display: block !important; /* Force display on all smaller screens */
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1001;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        font-size: 24px;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }

    /* Add overlay for menu background */
    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .menu-overlay.active {
        display: block;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .docs-container {
        padding: calc(var(--spacing-base) * 0.75);
    }
    /* Table styles */
    .function-table {
        width: 100%;  /* Full width on mobile */
        display: block;  /* Switch to block on mobile */
    }
    
    .function-table table {
        min-width: 600px;  /* Minimum width for scrolling */
    }
    
    .function-table-wrapper {
        overflow-x: auto;
    }

    .function-table th,
    .function-table td {
        padding: calc(var(--spacing-base) * 0.5);
    }

    /* Home link adjustments */
    .home-link {
        padding: 6px 12px;
        font-size: calc(var(--font-size-base) * 0.9);
    }

    /* Adjust content spacing */
    .docs-content {
        padding: calc(var(--spacing-base) * 0.75);
    }

    /* Make menu slightly wider on very small screens */
    .docs-nav {
        width: min(60vw, 300px);
    }

    /* Adjust menu toggle position */
    .menu-toggle {
        bottom: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    :root {
        --spacing-base: clamp(0.75rem, 1.5vw, 1rem);
        --font-size-base: clamp(14px, 1vw, 16px);
        --font-size-code: clamp(13px, 0.9vw, 15px);
    }
    .docs-container {
        padding: var(--spacing-base);
    }
    
    .docs-content {
        padding: var(--spacing-base);
    }

    .function-table th,
    .function-table td {
        padding: calc(var(--spacing-base) * 0.4);
    }
}

/* High DPI Screen Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .docs-content {
        font-smooth: always;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Print Styles */
@media print {
    .docs-nav,
    .menu-toggle,
    .back-to-top {
        display: none;
    }

    .docs-container {
        display: block;
    }

    .docs-content {
        max-width: none;
        padding: 0;
    }
}