/* ── Lumenworks sidebar (channel-strip nav) ─────────────────────
   Primary navigation for desktop/tablet. Contains the 6 top-level
   tabs (.tab-bar kept for JS compatibility with switchTab), a live
   meter plate at the bottom, and collapses to a 56px icon rail
   between 1100px and 600px. On phones (<=600px) the sidebar hides
   entirely and mobile.css reverts .tab-bar to a fixed bottom strip.
   ──────────────────────────────────────────────────────────────── */

/* ── App shell: header on top, 2-column body below ── */

.app-body {
    display: grid;
    grid-template-columns: var(--sidebar-width, 248px) 1fr;
    gap: 0;
    align-items: stretch;
    min-height: calc(100vh - var(--transport-height, 64px));
}

.app-main {
    min-width: 0;        /* allow children to shrink instead of overflow */
    position: relative;
}

/* ── Sidebar container ── */

.sidebar {
    position: sticky;
    top: var(--transport-height, 64px);
    height: calc(100vh - var(--transport-height, 64px));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    border-right: var(--lux-hairline) solid var(--lux-line-bold, var(--border-color));
    background: linear-gradient(180deg, var(--lux-bg-1, var(--bg-secondary)) 0%, var(--lux-bg-0, var(--bg-color)) 100%);
    padding: 16px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: calc(var(--z-sticky) - 1);
}

.sidebar-section {
    padding: 0 12px;
}

.sidebar-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono, monospace);
    font-size: 0.55rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--lux-ink-mute, var(--text-secondary));
    padding: 0 8px 8px;
    border-bottom: 1px dashed var(--lux-line, var(--border-color));
    margin-bottom: 8px;
    font-weight: 500;
}
.sidebar-label::before { content: '['; color: var(--lux-ink-faint, var(--text-muted)); }
.sidebar-label::after { content: ']'; color: var(--lux-ink-faint, var(--text-muted)); margin-left: auto; }

/* ── Tab-bar (kept as vertical nav inside sidebar on desktop) ── */

.sidebar .tab-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
    width: 100%;
}

.sidebar .tab-btn {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 9px 10px;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: var(--lux-r-sm, 3px);
    font-family: var(--font-mono, monospace);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--lux-ink-dim, var(--text-secondary));
    cursor: pointer;
    position: relative;
    text-align: left;
    transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.sidebar .tab-btn:hover {
    color: var(--lux-ink, var(--text-color));
    background: var(--lux-bg-2, var(--bg-secondary));
    border-bottom-color: transparent;
}

.sidebar .tab-btn.active {
    color: var(--lux-ink, var(--text-color));
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--ch-signal, var(--primary-color)) 14%, transparent) 0%,
        transparent 80%);
    box-shadow: inset 2px 0 0 var(--ch-signal, var(--primary-color));
    border-bottom-color: transparent;
}

.sidebar .tab-btn.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: var(--ch-signal, var(--primary-color));
    box-shadow: var(--lux-signal-glow, 0 0 6px currentColor);
    border-radius: 2px;
}

.sidebar .tab-btn .icon {
    width: 16px;
    height: 16px;
    color: inherit;
    flex-shrink: 0;
}
.sidebar .tab-btn.active .icon {
    color: var(--ch-signal, var(--primary-color));
}

.sidebar .tab-btn > span[data-i18n] {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .tab-btn .tab-badge {
    background: var(--lux-bg-3, var(--border-color));
    color: var(--lux-ink-mute, var(--text-secondary));
    font-family: var(--font-mono, monospace);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    line-height: 1.4;
    text-align: center;
}
.sidebar .tab-btn.active .tab-badge {
    background: var(--ch-signal, var(--primary-color));
    color: var(--lux-bg-0, #000);
}

/* ── Sidebar footer: live CPU/FPS meter plate ── */

.sidebar-foot {
    margin-top: auto;
    padding: 14px 20px 8px;
    border-top: 1px dashed var(--lux-line, var(--border-color));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cpu-meter {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: var(--font-mono, monospace);
}

.cpu-meter-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.58rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--lux-ink-mute, var(--text-secondary));
}

.cpu-meter-row b {
    color: var(--lux-ink, var(--text-color));
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    font-size: 0.7rem;
    letter-spacing: 0;
}

.cpu-bar {
    height: 3px;
    background: var(--lux-bg-3, var(--border-color));
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.cpu-bar > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--ch-signal, var(--primary-color)), var(--ch-cyan, var(--info-color)));
    box-shadow: 0 0 6px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 50%, transparent);
    transition: width 0.4s ease;
    width: 0;
}

.cpu-bar-fps > i {
    background: linear-gradient(90deg, var(--ch-cyan, var(--info-color)), var(--ch-magenta, #ff4ade));
    box-shadow: 0 0 6px color-mix(in srgb, var(--ch-cyan, var(--info-color)) 50%, transparent);
}

.sidebar-version {
    font-family: var(--font-mono, monospace);
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--lux-ink-faint, var(--text-muted));
    text-align: center;
    padding-top: 6px;
    border-top: 1px dashed var(--lux-line, var(--border-color));
}

/* ── Responsive: icon rail at tablet-desktop, hidden at phone ── */

@media (max-width: 1100px) {
    :root { --sidebar-width: 56px; }

    .sidebar {
        padding: 14px 0 20px;
        gap: 16px;
    }
    .sidebar-section {
        padding: 0 6px;
    }
    .sidebar-label,
    .sidebar-version {
        display: none;
    }
    .sidebar-foot {
        padding: 10px 6px;
    }

    .sidebar .tab-btn {
        grid-template-columns: 1fr;
        padding: 10px 2px;
        justify-content: center;
        justify-items: center;
        gap: 3px;
    }
    /* Two-line caption with tight tracking — single-line ellipsis truncates
       longer labels like "Automations"/"Integrations" to "AUTOMA…" which
       isn't recoverable; two short lines are uglier per word but legible. */
    .sidebar .tab-btn > span[data-i18n] {
        font-size: 0.46rem;
        letter-spacing: 0.02em;
        line-height: 1.1;
        text-transform: uppercase;
        color: inherit;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: center;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .sidebar .tab-btn .icon {
        width: 20px;
        height: 20px;
    }
    .sidebar .tab-btn .tab-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        font-size: 0.55rem;
        min-width: 14px;
        padding: 0 4px;
    }

    .cpu-meter-row {
        font-size: 0.48rem;
        letter-spacing: 0.08em;
    }
    .cpu-meter-row b {
        font-size: 0.6rem;
    }
}

@media (max-width: 600px) {
    /* On phones, sidebar disappears and mobile.css reverts .tab-bar to
       a fixed bottom strip. The .app-body grid becomes a single column.  */
    :root { --sidebar-width: 0px; }

    .app-body {
        grid-template-columns: 1fr;
    }
    .sidebar {
        /* Hide sidebar chrome; .tab-bar inside still gets fixed-bottom
           styling from mobile.css regardless of its container. */
        position: static;
        height: auto;
        border-right: none;
        padding: 0;
        background: transparent;
        overflow: visible;
        display: contents;
    }
    .sidebar-foot,
    .sidebar-label {
        display: none !important;
    }
}
