/* ========================================
   QuantKit Docs - Documentation Styles
   Sidebar + Content Layout
   ======================================== */

/* ---- Layout ---- */
.docs-layout {
    display: flex;
    max-width: 1100px;
    margin: 0 auto;
    min-height: calc(100vh - var(--navbar-height));
    padding-top: var(--navbar-height);
}

/* ---- Sidebar ---- */
.docs-sidebar {
    position: sticky;
    top: var(--navbar-height);
    width: 240px;
    min-width: 240px;
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    border-right: 1px solid var(--color-border);
    padding: 24px 0;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.docs-sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.docs-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

/* Sidebar product header */
.docs-sidebar-product {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 28px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    pointer-events: none;
}

.docs-sidebar-product img {
    width: 24px;
    height: 24px;
}

.docs-sidebar-product-name {
    font-family: var(--font-display);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.docs-sidebar-product-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
}

.docs-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.docs-sidebar-section {
    padding: 0 16px;
    margin-bottom: 8px;
}

.docs-sidebar-heading {
    font-family: var(--font-display);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 12px;
    margin: 0;
}

.docs-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transition: all var(--transition-fast);
    line-height: 1.4;
}

.docs-sidebar-link:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

.docs-sidebar-link.active {
    color: var(--color-accent);
    background: rgba(var(--color-accent-rgb), 0.08);
}

.docs-sidebar-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}

.docs-sidebar-link.active svg {
    opacity: 1;
}

/* Sub-links (in-page anchors) */
.docs-sidebar-sublinks {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 38px;
}

.docs-sidebar-sublink {
    display: block;
    padding: 4px 12px;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    text-decoration: none;
    border-left: 1px solid var(--color-border);
    transition: all var(--transition-fast);
}

.docs-sidebar-sublink:hover {
    color: var(--color-text-secondary);
    border-left-color: var(--color-text-muted);
}

.docs-sidebar-sublink.active {
    color: var(--color-accent);
    border-left-color: var(--color-accent);
}

/* ---- Content Area ---- */
.docs-content-wrapper {
    flex: 1;
    min-width: 0;
}

.docs-content {
    width: 100%;
    max-width: 780px;
    padding: 48px 56px 80px;
}

.docs-content h1 {
    font-family: var(--font-display);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin: 0 0 8px;
    padding-top: 48px;
    line-height: var(--line-height-tight);
}

.docs-content h1:not(:first-of-type) {
    margin-top: 64px;
    border-top: 1px solid var(--color-border);
}

.docs-content h1:first-of-type {
    padding-top: 0;
}

.docs-content .docs-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-text-muted);
    margin: 0 0 40px;
    line-height: var(--line-height-normal);
}

.docs-content h2 {
    font-family: var(--font-display);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin: 48px 0 16px;
    padding-left: 12px;
    border-left: 3px solid var(--color-accent);
    line-height: var(--line-height-tight);
}

.docs-content h2:first-of-type {
    margin-top: 0;
}

.docs-content h3 {
    font-family: var(--font-display);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin: 36px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.docs-content h4 {
    font-family: var(--font-display);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    margin: 24px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.docs-content p {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    line-height: var(--line-height-relaxed);
    margin: 0 0 16px;
}

.docs-content ul,
.docs-content ol {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    margin: 0 0 16px;
    padding-left: 24px;
}

.docs-content li {
    margin-bottom: 8px;
}

.docs-content li strong {
    color: var(--color-text);
}

.docs-content a {
    color: var(--color-accent);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.docs-content a:hover {
    opacity: 0.8;
}

/* ---- Docs Components ---- */

/* Info/Warning/Tip callouts */
.docs-callout {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin: 24px 0;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
}

.docs-callout p {
    margin: 0;
    font-size: inherit;
}

.docs-callout-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.docs-callout.info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.docs-callout.info .docs-callout-title {
    color: #60a5fa;
}

.docs-callout.warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.docs-callout.warning .docs-callout-title {
    color: #fbbf24;
}

.docs-callout.tip {
    background: rgba(var(--color-accent-rgb), 0.06);
    border: 1px solid rgba(var(--color-accent-rgb), 0.15);
}

.docs-callout.tip .docs-callout-title {
    color: var(--color-accent);
}

/* Inline icon button — standard for all icon illustrations in docs */
.docs-inline-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2em;
    width: 2em;
    vertical-align: middle;
    margin: 0 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.docs-inline-icon-btn img {
    height: 1.25em;
    width: 1.25em;
    filter: invert(75%) sepia(72%) saturate(1225%) hue-rotate(107deg) brightness(104%) contrast(105%);
}

/* Inline text button — mimics app UI buttons (e.g. Connect, SPX dropdown) */
.docs-inline-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 2em;
    vertical-align: middle;
    margin: 0 5px;
    padding: 0 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-family: var(--font-sans);
    font-size: 0.8em;
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    white-space: nowrap;
    line-height: 1;
}

.docs-inline-text-btn .btn-arrow {
    font-size: 0.7em;
    opacity: 0.6;
}

/* History bar buttons — dark compact controls */
.docs-history-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    vertical-align: middle;
    margin: 0 2px;
    padding: 0 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    font-family: var(--font-sans);
    font-size: 0.78em;
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    white-space: nowrap;
    line-height: 1;
    gap: 4px;
}

.docs-history-btn .play-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent var(--color-text);
}

.docs-history-btn .live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

/* Inline text button color variant for timestamp */
.docs-inline-text-btn.timestamp {
    color: #ef4444;
}

/* Inline panel toggle — colored square button mimicking app panel toggles */
.docs-inline-panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    vertical-align: middle;
    margin: 0 1px;
    padding: 0;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.75em;
    font-weight: var(--font-weight-bold);
    color: #000;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* Gradient stops: green → yellow → orange → red across 11 buttons */
.docs-inline-panel-btn.c1  { background: #22c55e; }
.docs-inline-panel-btn.c2  { background: #4cb94e; }
.docs-inline-panel-btn.c3  { background: #6fad3f; }
.docs-inline-panel-btn.c4  { background: #8fa131; }
.docs-inline-panel-btn.c5  { background: #ad9424; }
.docs-inline-panel-btn.c6  { background: #c9861a; }
.docs-inline-panel-btn.c7  { background: #e07612; }
.docs-inline-panel-btn.c8  { background: #ee640e; }
.docs-inline-panel-btn.c9  { background: #f04f10; }
.docs-inline-panel-btn.c10 { background: #ef3b13; }
.docs-inline-panel-btn.c11 { background: #ef4444; }

/* Area color dot — used in UI overview table */
.docs-area-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
}

.docs-area-dot.green  { background: #00FF11; }
.docs-area-dot.blue   { background: #00BBFF; }
.docs-area-dot.red    { background: #FF5900; }

/* Theme color palette swatches */
.docs-palette {
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
}

.docs-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Panel accordion — expandable panel showcase */
.docs-panel-accordion {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 16px 0 24px;
}

.docs-panel-category {
    font-family: var(--font-display);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 12px 0 4px;
}

.docs-panel-category:first-child {
    margin-top: 0;
}

.docs-panel-row {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-elevated);
    overflow: hidden;
    transition: border-color 0.2s;
}

.docs-panel-row:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.docs-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
}

.docs-panel-header .panel-name {
    flex: 1;
    font-family: var(--font-display);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
}

.docs-panel-header .panel-chevron {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.docs-panel-row.active .panel-chevron {
    transform: rotate(90deg);
}

.docs-panel-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.docs-panel-detail-inner {
    padding: 0 16px 16px;
}

.docs-panel-detail-inner img {
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    margin: 0 auto 10px;
}

.docs-panel-detail-inner p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Screenshot / image container */
.docs-image {
    margin: 24px 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.docs-image img {
    width: 100%;
    height: auto;
    display: block;
}

.docs-image-caption {
    padding: 10px 16px;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}

/* Steps list */
.docs-steps {
    counter-reset: step;
    list-style: none;
    padding-left: 0;
    margin: 16px 0 24px;
}

.docs-steps li {
    counter-increment: step;
    position: relative;
    padding-left: 40px;
    margin-bottom: 16px;
}

.docs-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 1px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(var(--color-accent-rgb), 0.12);
    color: var(--color-accent);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Keyboard shortcut / code inline */
.docs-kbd {
    display: inline-block;
    padding: 2px 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8em;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
}

/* Inline code */
.docs-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    color: var(--color-accent);
}

/* Table */
.docs-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 24px;
    font-size: var(--font-size-sm);
}

.docs-table th,
.docs-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.docs-table th {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    background: var(--color-bg-elevated);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.docs-table td {
    color: var(--color-text-secondary);
}

.docs-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Icon column — narrow & centered */
.docs-table th.col-icon,
.docs-table td.col-icon {
    width: 60px;
    text-align: center;
}

/* Center all cells in the same column as col-icon (2nd column) */
.docs-table th.col-icon ~ td,
.docs-table:has(th.col-icon) td:nth-child(2) {
    text-align: center;
}

/* Page navigation (prev/next) */
.docs-page-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--color-border);
}

.docs-page-nav a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition-base);
    min-width: 180px;
}

.docs-page-nav a:hover {
    border-color: rgba(var(--color-accent-rgb), 0.3);
    background: rgba(var(--color-accent-rgb), 0.04);
    opacity: 1;
}

.docs-page-nav-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.docs-page-nav-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-accent);
}

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

/* Version badge */
.docs-version {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(var(--color-accent-rgb), 0.08);
    border: 1px solid rgba(var(--color-accent-rgb), 0.15);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    color: var(--color-accent);
    font-weight: var(--font-weight-medium);
    margin-bottom: 16px;
}

/* ---- Mobile Sidebar Toggle ---- */
.docs-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    cursor: pointer;
    z-index: 60;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .docs-content {
        padding: 40px 32px 80px;
    }
}

@media (max-width: 768px) {
    .docs-sidebar {
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        width: 280px;
        min-width: 280px;
        z-index: 1500;
        background: var(--color-bg);
    }

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

    .docs-content {
        padding: 32px 20px 80px;
    }

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

    .docs-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1400;
    }

    .docs-overlay.open {
        display: block;
    }

    .docs-content h1 {
        font-size: var(--font-size-2xl);
    }

    .docs-content h2 {
        font-size: var(--font-size-xl);
    }

    .docs-page-nav {
        flex-direction: column;
    }

    .docs-page-nav .next {
        text-align: left;
    }
}
