/* Documentation Page Styles */
/* Uses global CSS variables from style.css */

/* Lock page scroll on docs pages, only sidebar and content scroll */
body.docs-page {
    height: 100vh;
    overflow: hidden;
}

body.docs-page main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ===== Layout Container ===== */
.docs-container {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* ===== Sidebar Navigation ===== */
.docs-sidebar {
    --docs-sidebar-width: 280px;
    width: var(--docs-sidebar-width);
    min-width: var(--docs-sidebar-width);
    flex-shrink: 0;
    background: var(--background, #ffffff);
    border-right: 1px solid var(--color-gray-200, #e5e7eb);
    padding: 2rem 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.3s ease;
    height: 100%;
    margin-left: max(var(--space-6, 1.5rem), calc((100vw - var(--max-width-container)) / 2 + var(--space-6, 1.5rem)));
}

.docs-sidebar-title {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-color, #1f2937);
    margin: 0;
}

.docs-sidebar-close {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--color-gray-600, #4b5563);
    transition: color 0.2s ease;
}

.docs-sidebar-close:hover {
    color: var(--color-primary, #23967f);
}

.docs-nav {
    padding: 1rem 0;
}

.docs-category {
    margin-bottom: 1.5rem;
}

.docs-category-title {
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--color-gray-600, #4b5563);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 1.5rem;
    margin: 0 0 0.5rem 0;
}

.docs-article-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-article-item {
    margin: 0;
}

.docs-article-link {
    display: block;
    padding: 0.5rem 1.5rem;
    color: var(--text-color, #1f2937);
    text-decoration: none;
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.docs-article-link:hover {
    background-color: var(--color-gray-50, #f9fafb);
    color: var(--color-primary, #23967f);
}

.docs-article-link.active {
    background-color: var(--color-gray-50, #f9fafb);
    color: var(--color-primary, #23967f);
    border-left-color: var(--color-primary, #23967f);
    font-weight: var(--font-weight-medium, 500);
}

/* ===== Main Content Area ===== */
.docs-content {
    flex: 1;
    padding: 2rem 0;
    min-width: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    padding-right: max(3rem, calc((100vw - var(--max-width-container)) / 2 + 3rem));
}

/* Constrain article width to match container max-width */
.docs-article {
    max-width: calc(var(--max-width-container) - var(--docs-sidebar-width) - var(--space-6, 1.5rem) * 2 - 3rem * 2);
    padding-left: 3rem;
    margin: 0;
}

/* Mobile Header (hidden on desktop) */
.docs-mobile-header {
    display: none;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
}

.docs-menu-toggle {
    background: none;
    border: 1px solid var(--color-gray-300, #d1d5db);
    border-radius: var(--radius-md, 0.375rem);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-color, #1f2937);
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-tap-highlight-color: rgba(35, 150, 127, 0.1);
    touch-action: manipulation;
    -webkit-appearance: button;
    appearance: button;
}

.docs-menu-toggle svg {
    pointer-events: none;
    width: 24px;
    height: 24px;
}

.docs-menu-toggle:hover {
    background-color: var(--color-gray-50, #f9fafb);
    border-color: var(--color-primary, #23967f);
    color: var(--color-primary, #23967f);
}

.docs-mobile-title {
    font-size: 1.125rem;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-color, #1f2937);
    user-select: none;
    -webkit-user-select: none;
}

/* Loading State */
.docs-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-light, #6b7280);
}

.docs-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-gray-200, #e5e7eb);
    border-top-color: var(--color-primary, #23967f);
    border-radius: 50%;
    animation: docs-spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes docs-spin {
    to {
        transform: rotate(360deg);
    }
}

.docs-loading p {
    margin: 0;
    font-size: 1rem;
}

/* Error State */
.docs-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.docs-error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.docs-error h2 {
    font-size: 1.5rem;
    color: var(--text-color, #1f2937);
    margin: 0 0 0.5rem 0;
}

.docs-error-message {
    color: var(--text-light, #6b7280);
    margin: 0 0 1.5rem 0;
}

.docs-error-retry {
    background-color: var(--color-primary, #23967f);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: var(--font-weight-medium, 500);
    border-radius: var(--radius-md, 0.375rem);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.docs-error-retry:hover {
    background-color: var(--color-primary-hover, #1b7362);
}

/* Article Content Styling */
.docs-article {
    color: var(--text-color, #1f2937);
    line-height: 1.7;
}

.docs-article h1 {
    font-size: 2.25rem;
    font-weight: var(--font-weight-semibold, 600);
    margin: 0 0 1.5rem 0;
    line-height: 1.2;
    color: var(--text-color, #1f2937);
}

.docs-article h2 {
    font-size: 1.75rem;
    font-weight: var(--font-weight-semibold, 600);
    margin: 2.5rem 0 1rem 0;
    line-height: 1.3;
    color: var(--text-color, #1f2937);
    padding-top: 1rem;
    border-top: 1px solid var(--color-gray-200, #e5e7eb);
}

.docs-article h2:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.docs-article h3 {
    font-size: 1.375rem;
    font-weight: var(--font-weight-semibold, 600);
    margin: 2rem 0 0.75rem 0;
    line-height: 1.4;
    color: var(--text-color, #1f2937);
}

.docs-article p {
    margin: 0 0 1.25rem 0;
    font-size: 1rem;
    line-height: 1.7;
}

.docs-article ul,
.docs-article ol {
    margin: 0 0 1.25rem 0;
    padding-left: 1.75rem;
}

.docs-article li {
    margin: 0.5rem 0;
    line-height: 1.7;
}

.docs-article a {
    color: var(--color-primary, #23967f);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.docs-article a:hover {
    border-bottom-color: var(--color-primary, #23967f);
}

.docs-article pre {
    background-color: var(--color-gray-50, #f9fafb);
    border: 1px solid var(--color-gray-200, #e5e7eb);
    border-radius: var(--radius-md, 0.375rem);
    padding: 1rem;
    overflow-x: auto;
    margin: 0 0 1.25rem 0;
}

.docs-article code {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.875rem;
    background-color: var(--color-gray-100, #f3f4f6);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

/* Tables within documentation articles */
.docs-article table {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    border-collapse: collapse;
    margin: 1rem 0;
    overflow: hidden;
    border-radius: 0.375rem;
    border: 1px solid var(--color-gray-200, #e5e7eb);
    background: var(--card-bg, #fff);
    overflow-x: auto;
    /* allow horizontal scrolling on small screens */
}

.docs-article thead th {
    background: var(--color-gray-50, #fafafa);
    font-weight: 600;
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
}

.docs-article tbody td,
.docs-article tbody th {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
    vertical-align: top;
    font-size: 0.95rem;
}

/* Make the first column slightly bolder/ narrower for label/value tables */
.docs-article td:first-child,
.docs-article th:first-child {
    width: 30%;
}

.docs-article tbody tr:last-child td {
    border-bottom: none;
}

/* Ensure code/pre inside table cells don't have extra backgrounds */
.docs-article table td code,
.docs-article table td pre {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

@media (max-width: 640px) {

    .docs-article thead th,
    .docs-article tbody td {
        padding: 0.65rem 0.75rem;
        font-size: 0.95rem;
    }

    .docs-article td:first-child,
    .docs-article th:first-child {
        width: 40%;
    }
}

.docs-article pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.docs-article strong {
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-color, #1f2937);
}

/* Table Styles */
.docs-article table {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background-color: white;
    border: 1px solid var(--color-gray-200, #e5e7eb);
    border-radius: var(--radius-md, 0.375rem);
    overflow: hidden;
}

.docs-article thead {
    background-color: var(--color-gray-50, #f9fafb);
}

.docs-article th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: var(--font-weight-semibold, 600);
    font-size: 0.9375rem;
    color: var(--text-color, #1f2937);
    border-bottom: 2px solid var(--color-gray-200, #e5e7eb);
}

.docs-article td {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    color: var(--color-gray-700, #374151);
    border-bottom: 1px solid var(--color-gray-200, #e5e7eb);
}

.docs-article tbody tr:last-child td {
    border-bottom: none;
}

.docs-article tbody tr:hover {
    background-color: var(--color-gray-50, #f9fafb);
}

/* Make tables scroll horizontally inside article to avoid page scroll */
.docs-article table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}

/* Overlay for mobile sidebar */
.docs-overlay {
    display: none;
    position: fixed;
    top: 72px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    -webkit-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.docs-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Responsive Design ===== */

/* Desktop */
@media (min-width: 1024px) {
    .docs-sidebar {
        --docs-sidebar-width: 280px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1023px) {
    .docs-content {
        padding: 3rem;
    }

    .docs-sidebar {
        --docs-sidebar-width: 260px;
    }
}

/* Mobile */
@media (max-width: 1023px) {
    body.docs-page {
        height: auto;
        overflow: visible;
    }

    /* body.docs-page main {
        padding-top: calc(var(--header-height) + 40px);
    } */

    .docs-container {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
        min-height: calc(100vh - 72px - 200px);
    }

    .docs-content {
        overflow-y: visible;
        height: auto;
    }

    .docs-sidebar {
        position: fixed;
        top: 72px;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: -webkit-calc(100vh - 72px);
        height: calc(100vh - 72px);
        z-index: 999;
        margin-left: 0 !important;
        -webkit-transform: translateX(-100%);
        -ms-transform: translateX(-100%);
        transform: translateX(-100%);
        -webkit-transition: -webkit-transform 0.3s ease;
        transition: -webkit-transform 0.3s ease;
        transition: transform 0.3s ease;
        transition: transform 0.3s ease, -webkit-transform 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .docs-sidebar.active {
        -webkit-transform: translateX(0);
        -ms-transform: translateX(0);
        transform: translateX(0);
    }

    .docs-sidebar-close {
        display: block;
    }

    .docs-mobile-header {
        display: flex;
    }

    /* Menu toggle icon rotation */
    .docs-menu-toggle svg {
        transition: transform 0.2s ease;
        transform-origin: center;
    }

    .docs-menu-toggle.active svg {
        transform: rotate(90deg);
    }

    /* Add spacing at top of nav in mobile sidebar */
    .docs-nav {
        padding-top: 2rem;
    }

    .docs-content {
        padding: 1.5rem 1rem !important;
        padding-right: 1rem !important;
    }

    .docs-article {
        max-width: 100% !important;
        padding-left: 0 !important;
    }

    .docs-overlay {
        display: block;
    }

    .docs-article h1 {
        font-size: 1.875rem;
    }

    .docs-article h2 {
        font-size: 1.5rem;
    }

    .docs-article h3 {
        font-size: 1.25rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .docs-content {
        padding: 1rem 0.75rem;
    }

    .docs-article h1 {
        font-size: 1.625rem;
    }

    .docs-article h2 {
        font-size: 1.375rem;
    }

    .docs-article pre {
        font-size: 0.8125rem;
        padding: 0.75rem;
    }
}

/* Utility class for JavaScript-controlled visibility */
/* Must be at the end to override display properties */
.hidden {
    display: none !important;
}