/* docs-shell.css — Enterprise docs layout for magic.threadsync.io
   3-column grid: sidebar | content | TOC rail
   Loaded on all docs pages (not homepage) */

/* ===== DOCS LAYOUT GRID ===== */
.docs-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 200px;
    grid-template-areas: "sidebar content toc";
    max-width: 1440px;
    margin: 0 auto;
    min-height: 0; /* let page shell handle min-height */
}

.docs-layout > main {
    grid-area: content;
    min-width: 0; /* prevent code blocks from blowing out grid */
}

/* ===== SIDEBAR ===== */
.docs-sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 24px 0 24px 16px;
    border-right: 1px solid var(--border, #1e1e28);
    font-size: 0.875rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border, #1e1e28) transparent;
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border, #1e1e28); border-radius: 2px; }

.docs-nav-group {
    margin-bottom: 20px;
}

.docs-nav-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim, #52525b);
    padding: 0 12px 6px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
}
.docs-nav-heading::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--text-dim, #52525b);
    border-bottom: 1.5px solid var(--text-dim, #52525b);
    transform: rotate(45deg);
    transition: transform 0.15s;
    flex-shrink: 0;
}
.docs-nav-group.collapsed .docs-nav-heading::before {
    transform: rotate(-45deg);
}
.docs-nav-group.collapsed .docs-nav-list {
    display: none;
}

.docs-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.docs-nav-list a {
    display: block;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-muted, #71717a);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    line-height: 1.4;
}
.docs-nav-list a:hover {
    color: var(--text, #e4e4e7);
    background: rgba(255, 255, 255, 0.04);
}
.docs-nav-list a.docs-nav-active {
    color: var(--accent, #6366f1);
    background: var(--accent-glow, rgba(99, 102, 241, 0.1));
    font-weight: 600;
}

/* Sidebar mobile toggle (visible only on mobile) */
.docs-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 201;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent, #6366f1);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.docs-sidebar-toggle:hover {
    background: var(--accent-muted, #4f46e5);
}

/* Sidebar backdrop (mobile overlay) */
.docs-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 199;
}

/* ===== TOC RAIL (right side) ===== */
.docs-toc-rail {
    grid-area: toc;
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 24px 16px 24px 0;
    font-size: 0.8rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border, #1e1e28) transparent;
}

.docs-toc-rail::-webkit-scrollbar { width: 4px; }
.docs-toc-rail::-webkit-scrollbar-thumb { background: var(--border, #1e1e28); border-radius: 2px; }

.docs-toc-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim, #52525b);
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border, #1e1e28);
}

.docs-toc-rail ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.docs-toc-rail li {
    margin: 0;
}
.docs-toc-rail li.docs-toc-h3 {
    padding-left: 12px;
}
.docs-toc-rail a {
    display: block;
    padding: 4px 8px;
    color: var(--text-dim, #52525b);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    line-height: 1.4;
}
.docs-toc-rail a:hover {
    color: var(--text-muted, #71717a);
}
.docs-toc-rail a.active {
    color: var(--accent, #6366f1);
    border-left-color: var(--accent, #6366f1);
}

/* ===== SEARCH PALETTE (Cmd/Ctrl+K) ===== */
.docs-search-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 300;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
}
.docs-search-backdrop.open {
    display: flex;
}

.docs-search-modal {
    width: 560px;
    max-width: 90vw;
    max-height: 60vh;
    background: var(--bg-elevated, #0e0e12);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.docs-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #1e1e28);
}
.docs-search-input-wrap svg {
    flex-shrink: 0;
    color: var(--text-dim, #52525b);
}
.docs-search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text, #e4e4e7);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}
.docs-search-input::placeholder {
    color: var(--text-dim, #52525b);
}
.docs-search-kbd {
    font-size: 0.7rem;
    color: var(--text-dim, #52525b);
    background: var(--bg-card, #121218);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: inherit;
}

.docs-search-results {
    overflow-y: auto;
    max-height: calc(60vh - 60px);
    padding: 8px;
}
.docs-search-results:empty::after {
    content: 'No results found.';
    display: block;
    padding: 24px 16px;
    text-align: center;
    color: var(--text-dim, #52525b);
    font-size: 0.875rem;
}

.docs-search-result {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.1s;
}
.docs-search-result:hover,
.docs-search-result.selected {
    background: rgba(255, 255, 255, 0.05);
}
.docs-search-result-title {
    font-weight: 600;
    color: var(--text, #e4e4e7);
    font-size: 0.875rem;
}
.docs-search-result-category {
    font-size: 0.75rem;
    color: var(--text-dim, #52525b);
}
.docs-search-result-heading {
    font-size: 0.8rem;
    color: var(--accent, #6366f1);
}

/* Keyboard hint in header nav */
.docs-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #1e1e28);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim, #52525b);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    white-space: nowrap;
}
.docs-search-trigger:hover {
    border-color: var(--border-light, #2a2a38);
    color: var(--text-muted, #71717a);
}

/* ===== CODE COPY BUTTON ===== */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    background: var(--bg-hover, #18181f);
    color: var(--text-dim, #52525b);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    z-index: 2;
    line-height: 1;
}
pre:hover .code-copy-btn,
.code-block:hover .code-copy-btn,
.code-body:hover .code-copy-btn {
    opacity: 1;
}
.code-copy-btn:hover {
    color: var(--text, #e4e4e7);
    background: var(--bg-card, #121218);
}

/* Copy button inside .code-header (flex layout) */
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.code-header .code-copy-btn {
    position: static;
    opacity: 0;
}
.code-block:hover .code-header .code-copy-btn {
    opacity: 1;
}

/* Language label for bare pre blocks */
.code-lang-label {
    position: absolute;
    top: 6px;
    left: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim, #52525b);
    pointer-events: none;
    z-index: 1;
}

/* ===== ERROR CATALOG TOOLBAR ===== */
.error-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-card, #121218);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 10px;
}

.error-toolbar input[type="search"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg, #08080a);
    color: var(--text, #e4e4e7);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.error-toolbar input[type="search"]:focus {
    border-color: var(--accent, #6366f1);
}
.error-toolbar input[type="search"]::placeholder {
    color: var(--text-dim, #52525b);
}

.error-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.error-filters button {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 600;
    background: var(--bg, #08080a);
    color: var(--text-muted, #71717a);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    min-height: auto;
}
.error-filters button:hover {
    border-color: var(--border-light, #2a2a38);
    color: var(--text, #e4e4e7);
}
.error-filters button.active {
    background: var(--accent-glow, rgba(99, 102, 241, 0.15));
    border-color: var(--accent, #6366f1);
    color: var(--accent, #6366f1);
}

/* Error entry highlight for deep links */
.error-entry.highlight {
    animation: error-highlight 2s ease-out;
}
@keyframes error-highlight {
    0% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* Copy JSON button on error entries */
.error-copy-json {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    background: var(--bg-hover, #18181f);
    color: var(--text-dim, #52525b);
    border: 1px solid var(--border, #1e1e28);
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    margin-top: 8px;
    min-height: auto;
}
.error-copy-json:hover {
    color: var(--text, #e4e4e7);
    background: var(--bg-card, #121218);
}

/* ===== HEADING ANCHOR LINKS ===== */
.heading-anchor {
    position: absolute;
    left: -1.5em;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim, #52525b);
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    padding: 0 4px;
}
h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus {
    opacity: 1;
}
.heading-anchor:hover {
    color: var(--accent, #6366f1);
}

/* ===== CALLOUT COMPONENTS ===== */
.callout {
    border-radius: 8px;
    padding: 14px 16px;
    margin: 16px 0;
    font-size: 0.9rem;
    line-height: 1.6;
    border-left: 3px solid;
}
.callout-title {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Note (blue-ish) */
.callout-note,
.note {
    background: rgba(99, 102, 241, 0.06);
    border-left-color: var(--accent, #6366f1);
    color: var(--text, #e4e4e7);
}
.callout-note .callout-title { color: var(--accent, #6366f1); }

/* Warning (amber) */
.callout-warning {
    background: rgba(245, 158, 11, 0.06);
    border-left-color: #f59e0b;
    color: var(--text, #e4e4e7);
}
.callout-warning .callout-title { color: #f59e0b; }

/* Security (red) */
.callout-security {
    background: rgba(239, 68, 68, 0.06);
    border-left-color: #ef4444;
    color: var(--text, #e4e4e7);
}
.callout-security .callout-title { color: #ef4444; }

/* Enterprise (emerald) */
.callout-enterprise {
    background: rgba(16, 185, 129, 0.06);
    border-left-color: #10b981;
    color: var(--text, #e4e4e7);
}
.callout-enterprise .callout-title { color: #10b981; }

/* Success */
.callout-success,
.success-box {
    background: rgba(16, 185, 129, 0.06);
    border-left-color: #10b981;
    color: var(--text, #e4e4e7);
}
.callout-success .callout-title { color: #10b981; }

/* ===== RESPONSIVE ===== */

/* Tablet: hide TOC, keep sidebar */
@media (max-width: 1200px) {
    .docs-layout {
        grid-template-columns: 240px minmax(0, 1fr);
        grid-template-areas: "sidebar content";
    }
    .docs-toc-rail {
        display: none;
    }
}

/* Mobile: sidebar becomes drawer */
@media (max-width: 900px) {
    .docs-layout {
        grid-template-columns: 1fr;
        grid-template-areas: "content";
    }

    .docs-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        height: 100dvh;
        z-index: 200;
        background: var(--bg, #08080a);
        border-right: 1px solid var(--border, #1e1e28);
        transition: left 0.25s ease;
        padding-top: 80px;
    }
    .docs-sidebar.open {
        left: 0;
    }

    .docs-sidebar-toggle {
        display: flex;
    }

    .docs-sidebar-backdrop.open {
        display: block;
    }

    .docs-toc-rail {
        display: none;
    }
}
