/* ==========================================================================
   User Guide / Docs Layout
   Sidebar navigation + content + TOC, adapted for Syfon's dark-first theme
   ========================================================================== */

:root {
    --sidebar-width: 280px;
    --header-height: 72px;
}

/* Documentation label above title */
.docs-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
    text-decoration: none;
    margin-bottom: 1rem;
}

.docs-label:hover {
    color: var(--color-primary-hover);
}

.docs-description {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    margin-bottom: 2rem;
}

/* ==========================================================================
   Docs Layout
   ========================================================================== */

.docs-layout {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.docs-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #0a1120;
    border-right: 1px solid var(--color-border);
    padding: 0 0 2rem;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-brand {
    padding: 1.5rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.sidebar-badge {
    display: inline-block;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-search {
    display: none;
    margin-top: 1rem;
}

.sidebar-search .pagefind-search-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.sidebar-search .pagefind-results {
    position: relative;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

@media (max-width: 900px) {
    .sidebar-search {
        display: block;
    }
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.docs-sidebar h3.sidebar-heading {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
    line-height: 1.4;
}

.sidebar-nav + .sidebar-heading {
    margin-top: 1.5rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin: 0;
}

.sidebar-nav a {
    display: block;
    padding: 0.5rem 1.5rem;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--color-bg-card);
    color: var(--color-primary);
}

.sidebar-nav a.active {
    background: var(--color-bg-card);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    font-weight: 600;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.docs-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    align-items: flex-start;
}

.docs-content {
    flex: 1;
    max-width: 800px;
    padding: 2rem 4rem 3rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.docs-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--color-text-primary);
}

.docs-content h2 {
    font-size: 1.75rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--color-text-primary);
}

.docs-content h3 {
    font-size: 1.35rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-primary);
}

.docs-content p {
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
}

.docs-content ul {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.docs-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    list-style-type: decimal;
}

.docs-content li {
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
    color: var(--color-text-secondary);
}

.docs-content a {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: rgba(45, 212, 191, 0.3);
    text-underline-offset: 2px;
}

.docs-content a:hover {
    color: var(--color-primary-hover);
    text-decoration-color: var(--color-primary);
}

/* Scroll offset for anchor links */
.docs-content h2[id],
.docs-content h3[id] {
    scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

/* Images */
.docs-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Code blocks */
.docs-content code {
    font-family: var(--font-family-mono);
    font-size: 0.9em;
    background: var(--color-bg-card);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    color: var(--color-primary);
}

.docs-content pre {
    background: var(--color-bg-darker);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.docs-content pre code {
    background: none;
    padding: 0;
    color: var(--color-text-primary);
}

/* Tables */
.docs-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

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

.docs-content th {
    background: var(--color-bg-card);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.docs-content tr:hover {
    background: var(--color-bg-card);
}

/* Blockquotes as callouts */
.docs-content blockquote {
    background: rgba(45, 212, 191, 0.08);
    border: 1px solid rgba(45, 212, 191, 0.2);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.docs-content blockquote p {
    margin-bottom: 0;
    font-size: 0.95rem;
}

.docs-content blockquote p:not(:last-child) {
    margin-bottom: 0.75rem;
}

/* ==========================================================================
   Table of Contents (right sidebar)
   ========================================================================== */

.docs-toc {
    width: 260px;
    padding: 2rem 1.5rem;
    position: fixed;
    top: var(--header-height);
    right: max(1.5rem, calc((100vw - 1650px) / 2));
    height: fit-content;
    max-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
}

.docs-toc .toc-nav {
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - var(--header-height) - 180px);
}

.docs-toc h4.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    margin-top: 0;
}

.toc-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-nav li {
    margin-bottom: 0.5rem;
}

.toc-nav a {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    padding: 0.25rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: -0.75rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.toc-nav a.active {
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    font-weight: 500;
}

.toc-nav li.toc-indent {
    margin-left: 0.75rem;
}

.toc-nav li.toc-indent a {
    font-size: 0.85rem;
}

/* ==========================================================================
   Pagefind Search
   ========================================================================== */

#search {
    position: relative;
    margin-bottom: 1.5rem;
    z-index: 101;
}

.pagefind-search-input {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.pagefind-search-input::placeholder {
    color: var(--color-text-muted);
}

.pagefind-search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.pagefind-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    margin-top: 0.5rem;
    z-index: 100;
    max-height: 500px;
    overflow-y: auto;
}

.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s ease;
    text-decoration: none;
}

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

.search-result-item:hover {
    background: var(--color-bg-elevated);
}

.search-result-title {
    display: block;
    font-weight: 500;
    color: var(--color-text-primary);
    font-size: 0.9rem;
}

.search-result-excerpt {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.search-result-excerpt mark {
    background: rgba(45, 212, 191, 0.2);
    color: var(--color-primary);
    padding: 0 0.15rem;
    border-radius: 2px;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ==========================================================================
   Page Navigation (prev/next)
   ========================================================================== */

.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.page-nav-link {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    max-width: 45%;
    transition: all 0.3s ease;
    background: var(--color-bg-card);
    text-decoration: none;
}

.page-nav-link:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.15);
}

.page-nav-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.page-nav-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.page-nav-link.next {
    text-align: right;
    margin-left: auto;
}

/* ==========================================================================
   Mobile Toggle
   ========================================================================== */

.docs-mobile-toggle {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    right: 1rem;
    width: 44px;
    height: 44px;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--color-text-inverse);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.3);
    z-index: 60;
    transition: transform 0.2s ease;
}

.docs-mobile-toggle:hover {
    transform: scale(1.05);
}

.docs-mobile-toggle svg {
    width: 20px;
    height: 20px;
}

/* Overlay for mobile sidebar */
.docs-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 45;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.docs-overlay.visible {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   Footer offset for docs pages
   ========================================================================== */

body.has-docs .footer {
    margin-left: var(--sidebar-width);
}

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

@media (max-width: 1300px) {
    .docs-toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .docs-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .docs-sidebar.open {
        transform: translateX(0);
    }

    .docs-main {
        margin-left: 0;
    }

    .docs-content {
        padding: 2rem;
    }

    .docs-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body.has-docs .footer {
        margin-left: 0;
    }
}

@media (max-width: 640px) {
    .docs-content {
        padding: 1.5rem;
    }

    .docs-content h1 {
        font-size: 2rem;
    }
}

/* ==========================================================================
   Light Mode Overrides
   ========================================================================== */

body.light-mode .docs-sidebar {
    background: #f8fafc;
    border-right-color: #e2e8f0;
}

body.light-mode .sidebar-brand {
    border-bottom-color: #e2e8f0;
}

body.light-mode .sidebar-nav a {
    color: #334155;
}

body.light-mode .sidebar-nav a:hover {
    background: #f1f5f9;
    color: var(--color-primary);
}

body.light-mode .sidebar-nav a.active {
    background: #ffffff;
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}

body.light-mode .docs-content p,
body.light-mode .docs-content li {
    color: #334155;
}

body.light-mode .docs-content code {
    background: #f1f5f9;
}

body.light-mode .docs-content pre {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body.light-mode .docs-content th {
    background: #f8fafc;
}

body.light-mode .docs-content tr:hover {
    background: #f8fafc;
}

body.light-mode .docs-content img {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.light-mode .page-nav-link {
    background: #ffffff;
    border-color: #e2e8f0;
}

body.light-mode .page-nav-link:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.1);
}

body.light-mode .pagefind-search-input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #020617;
}

body.light-mode .pagefind-results {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

body.light-mode .search-result-item:hover {
    background: #f8fafc;
}

body.light-mode .search-result-title {
    color: #020617;
}

body.light-mode .sidebar-search .pagefind-search-input {
    background: #ffffff;
    border-color: #e2e8f0;
}

body.light-mode .sidebar-search .pagefind-results {
    background: #ffffff;
    border-color: #e2e8f0;
}
