/* ==========================================================================
   CherryAI — MODERN SIDEBAR NAVIGATION
   Grouped IA, collapsible, responsive icon rail, smooth transitions
   ========================================================================== */

.sidebar-nav {
    padding: 8px 10px 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ---- Overview / Top-Level Nav Item ---- */
/* PR #116c: tightened density (10→8px padding), refined typography
   (lighter weight 500 default; 600 only on active), and active state
   uses a 2px left accent bar + soft tint instead of full background pill. */
.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 1px;
    transition: background-color 0.12s ease, color 0.12s ease;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.06);
    color: white;
    font-weight: 600;
}

.nav-item.active::after {
    /* 2px left accent bar — Linear / Stripe pattern. */
    content: '';
    position: absolute;
    left: -8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: #6366f1;
    border-radius: 1px;
}

.nav-item-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--info, #3b82f6), var(--info, #1d4ed8));
    flex-shrink: 0;
    font-size: 13px;
    color: white;
}

.nav-item-overview .nav-item-icon {
    background: linear-gradient(135deg, var(--info, #3b82f6), var(--info, #1d4ed8));
}

.nav-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Section Labels ---- */
/* PR #116c: 11px (was 10px) — slightly more legible while staying tight.
   Lower opacity (0.28) for a softer "ambient" feel. */
.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.28);
    padding: 14px 12px 6px;
}

/* ---- Persona switcher (Nav-N1.5, session 60) ---- */
/* "Working as: [role]" — slims the sidebar to a persona (§9 role map).
   View-personalization only; the active persona is resolved server-side
   from the nav_persona cookie so the menu renders pre-filtered (no FOUC). */
.nav-persona-switcher {
    padding: 10px 12px 8px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.nav-persona-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.32);
    margin-bottom: 5px;
}

.nav-persona-select-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-persona-icon {
    position: absolute;
    left: 9px;
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
}

.nav-persona-arrow {
    position: absolute;
    right: 9px;
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
}

.nav-persona-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 7px 26px 7px 28px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.nav-persona-select:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.18);
}

.nav-persona-select:focus-visible {
    outline: 2px solid var(--accent, #cf3339);
    outline-offset: 1px;
}

/* Native option list renders on a light surface in most browsers — keep it
   readable regardless of the dark rail. */
.nav-persona-select option {
    color: #1a1a1a;
    background: #ffffff;
}

/* Collapsed icon-rail: drop the label, keep a compact icon-only control. */
.sidebar.collapsed .nav-persona-label {
    display: none !important;
}
.sidebar.collapsed .nav-persona-switcher {
    padding: 8px 6px;
}
.sidebar.collapsed .nav-persona-select {
    padding: 7px 4px;
    text-indent: -9999px;
}
.sidebar.collapsed .nav-persona-arrow {
    display: none;
}
.sidebar.collapsed .nav-persona-icon {
    left: 50%;
    transform: translateX(-50%);
}

/* ---- Menu Group (Accordion) ---- */
/* PR #116c: smaller icon (28px), tighter padding (6px vertical),
   no background on expanded (the chevron + child indent is enough). */
.menu-group {
    margin-bottom: 1px;
}

.menu-group-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.12s ease;
    user-select: none;
    position: relative;
    gap: 10px;
}

.menu-group-header:hover {
    background: rgba(255,255,255,0.04);
}

.menu-group.expanded > .menu-group-header {
    background: transparent;
}

.menu-group-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    font-size: 13px;
    color: white;
    transition: transform 0.2s ease;
}

/* Color-coded group icons */
.menu-group[data-section="work"] .menu-group-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.menu-group[data-section="assets"] .menu-group-icon { background: linear-gradient(135deg, var(--success, #10b981), var(--success, #059669)); }
.menu-group[data-section="materials"] .menu-group-icon { background: linear-gradient(135deg, var(--warning, #f59e0b), var(--warning, #d97706)); }
.menu-group[data-section="finance"] .menu-group-icon { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.menu-group[data-section="admin"] .menu-group-icon { background: linear-gradient(135deg, var(--text-muted, #64748b), var(--text-secondary, #475569)); }
.menu-group[data-section="reports"] .menu-group-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.menu-group[data-section="setup"] .menu-group-icon { background: linear-gradient(135deg, #84cc16, #65a30d); }

.menu-group-title {
    font-size: 13px;
    font-weight: 600;
    color: white;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-group-arrow {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(255,255,255,0.4);
    font-size: 12px;
}

.menu-group.expanded .menu-group-arrow {
    transform: rotate(180deg);
    color: rgba(255,255,255,0.7);
}

/* ---- Menu Items (Collapsible Children) ---- */
.menu-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease,
                padding 0.2s ease;
    opacity: 0;
    padding-left: 0;
}

.menu-group.expanded .menu-items {
    /* Nav-A: groups now carry sub-nav (parents + indented children), so the
       expanded height must accommodate a tall group without clipping. */
    max-height: 3000px;
    opacity: 1;
    padding-left: 44px;
    padding-top: 2px;
    padding-bottom: 4px;
}

/* ── Nav-A (session 48) — one level of sub-nav under a parent item ───────────
   A parent item (.menu-item--parent) is a normal navigable link; its children
   render in an indented .menu-subitems list directly beneath it. Children are
   lighter and icon-less so the hierarchy reads at a glance. */
.menu-item--parent {
    font-weight: 600;
}

.menu-subitems {
    display: flex;
    flex-direction: column;
    margin: 1px 0 4px 0;
    padding-left: 14px;
    border-left: 1px solid rgba(255,255,255,0.08);
    margin-left: 7px;
}

.menu-subitem {
    padding: 5px 10px;
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.48);
}

.menu-subitem:hover {
    background: rgba(255,255,255,0.04);
    color: white;
}

.menu-subitem.active {
    background: rgba(255,255,255,0.06);
    color: white;
    font-weight: 600;
}

.menu-subitem-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PR #116c: child menu items — minimal, no dot indicators (too busy),
   2px left accent bar for active state to match parent nav-item. */
.menu-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    margin-bottom: 1px;
    transition: background-color 0.12s ease, color 0.12s ease;
    position: relative;
    gap: 10px;
}

.menu-item:hover {
    background: rgba(255,255,255,0.04);
    color: white;
}

.menu-item.active {
    background: rgba(255,255,255,0.06);
    color: white;
    font-weight: 600;
}

.menu-item.active::after {
    content: '';
    position: absolute;
    left: -8px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: #6366f1;
    border-radius: 1px;
}

.menu-item-icon {
    width: 16px;
    text-align: center;
    opacity: 0.6;
    flex-shrink: 0;
    font-size: 13px;
}

.menu-item:hover .menu-item-icon,
.menu-item.active .menu-item-icon {
    opacity: 1;
}

/* ---- Recent Nav ---- */
.recent-nav-section {
    margin-top: 4px;
}

.recent-item {
    opacity: 0.8;
}

/* ---- Sidebar Brand ---- */
.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 16px 12px;
    gap: 10px;
    position: relative;
}

.sidebar-brand-info {
    flex: 1;
    min-width: 0;
}

.sidebar-brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: 15px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
}

.sidebar-brand-module {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
}

.sidebar-collapse-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(8px);
    color: rgba(255,255,255,0.5);
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.sidebar-collapse-btn .collapse-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.2);
    color: white;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
    transform: scale(1.08);
}

.sidebar-collapse-btn:active {
    transform: scale(0.95);
}

.sidebar.collapsed .sidebar-collapse-btn .collapse-arrow {
    transform: rotate(180deg);
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
    padding: 8px 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--success, #10b981), var(--success, #059669));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
}

/* ---- Sidebar Overlay (Mobile) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Collapsed Sidebar (Icon Rail) ----
 * PR #116a fix: when collapsed, also override the --sidebar-width CSS
 * variable that .main-content reads for its margin-left. Without this,
 * the sidebar shrinks but the main content stays offset by 280px,
 * leaving a dead zone between rail and content.
 *
 * The :has() selector lifts the variable to the :root scope when ANY
 * descendant .sidebar has .collapsed. Browsers without :has() support
 * (Firefox <121 etc.) fall through to the inline body-class fallback
 * applied by sidebar-nav.js below as defense-in-depth.
 */
:root:has(.sidebar.collapsed) {
    --sidebar-width: 64px;
}
body.sidebar-is-collapsed {
    --sidebar-width: 64px;
}

.sidebar.collapsed {
    width: 64px;
    min-width: 64px;
    /* PR #116a fix: let tooltips escape past the rail's right edge.
       overflow-y: auto from .sidebar would clip the ::after pseudo-element. */
    overflow: visible;
    /* PR #116a-followup: smooth width transition for hover-peek. */
    transition: width 180ms ease-out, min-width 180ms ease-out, box-shadow 180ms ease-out;
}

/* ------------------------------------------------------------
   Collapsed rail brand fit (Cowork E2E audit fix).
   The ABS wordmark <img> renders ~114px wide but the collapsed
   rail is only 64px with overflow:visible, so on Control Center
   pages the logo bled over the page header ("Receiving"/"Production"
   title collided with the logo). Stack the brand, hide the EAM /
   "Powered by" text, and contain the wordmark inside the rail.
   ------------------------------------------------------------ */
.sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    gap: 10px;
    padding: 14px 6px;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-brand-logo-wrap {
    width: 100%;
    justify-content: center;
    gap: 0;
    flex: 0 0 auto;
}
.sidebar.collapsed .sidebar-brand-logo-wrap img {
    height: 26px !important;
    width: 44px !important;
    object-fit: contain;
    object-position: center;
}
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-brand-module,
.sidebar.collapsed .sidebar-brand-logo-wrap > div {
    display: none !important;
}
.sidebar.collapsed .sidebar-collapse-btn {
    margin: 0 auto;
}

/* ============================================================
   PR #116b: Sidebar footer utility controls
   Search/Cmd-K trigger + Theme toggle + Help link.
   Migrated here from the killed .main-header topbar.
   ============================================================ */
.sidebar-utility-row {
    display: flex;
    gap: 6px;
    padding: 8px 12px 4px 12px;
    align-items: center;
}

.sidebar-utility-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-utility-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.16);
    color: white;
}

.sidebar-utility-btn:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.6);
    outline-offset: 2px;
}

.sidebar-utility-btn .sidebar-utility-label {
    flex: 1 1 auto;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-utility-btn .sidebar-utility-kbd {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    padding: 1px 6px;
    border-radius: 4px;
}

.sidebar-utility-btn.icon-only {
    flex: 0 0 auto;
    padding: 8px;
    justify-content: center;
}

.sidebar-utility-btn.icon-only .sidebar-utility-label,
.sidebar-utility-btn.icon-only .sidebar-utility-kbd {
    display: none;
}

/* Collapsed rail: stack utility buttons vertically, icons only. */
.sidebar.collapsed .sidebar-utility-row {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 6px 4px 6px;
    gap: 4px;
}

.sidebar.collapsed .sidebar-utility-btn {
    padding: 8px;
    justify-content: center;
    flex: 0 0 auto;
}

.sidebar.collapsed .sidebar-utility-btn .sidebar-utility-label,
.sidebar.collapsed .sidebar-utility-btn .sidebar-utility-kbd {
    display: none;
}

/* During hover-peek, restore the expanded look. */
.sidebar.collapsed.peek-open .sidebar-utility-row {
    flex-direction: row;
    padding: 8px 12px 4px 12px;
    gap: 6px;
}

.sidebar.collapsed.peek-open .sidebar-utility-btn:first-child {
    flex: 1 1 auto;
    justify-content: flex-start;
}

.sidebar.collapsed.peek-open .sidebar-utility-btn:first-child .sidebar-utility-label,
.sidebar.collapsed.peek-open .sidebar-utility-btn:first-child .sidebar-utility-kbd {
    display: inline;
}

/* Collapsed-rail tooltip support for utility buttons. */
.sidebar.collapsed .sidebar-utility-btn[data-tooltip] {
    position: relative;
}

.sidebar.collapsed .sidebar-utility-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background: var(--surface-secondary, #1e293b);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
}

.sidebar.collapsed .sidebar-utility-btn:hover[data-tooltip]::after {
    opacity: 1;
    visibility: visible;
}

.sidebar.collapsed.peek-open .sidebar-utility-btn[data-tooltip]::after {
    display: none !important;
}

/* ---- Sidebar user dropdown (migrated user menu from killed topbar) ---- */
.sidebar-user-dropdown {
    position: relative;
}

.sidebar-user-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sidebar-user-trigger:hover {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.08);
}

.sidebar-user-trigger .sidebar-user-caret {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.55;
}

.sidebar.collapsed .sidebar-user-trigger {
    padding: 8px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-user-trigger .sidebar-user-details,
.sidebar.collapsed .sidebar-user-trigger .sidebar-user-caret {
    display: none;
}

.sidebar.collapsed.peek-open .sidebar-user-trigger {
    padding: 10px 12px;
    justify-content: flex-start;
}

.sidebar.collapsed.peek-open .sidebar-user-trigger .sidebar-user-details,
.sidebar.collapsed.peek-open .sidebar-user-trigger .sidebar-user-caret {
    display: revert;
}

.sidebar-user-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 12px;
    right: 12px;
    background: var(--surface-elevated, #0f172a);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    padding: 8px;
    z-index: 1100;
    min-width: 220px;
}

.sidebar.collapsed:not(.peek-open) .sidebar-user-popover {
    left: calc(100% + 8px);
    right: auto;
    bottom: 0;
}

.sidebar-user-popover-header {
    padding: 8px 12px 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 6px;
}

.sidebar-user-popover-header strong {
    display: block;
    color: white;
    font-size: 13px;
}

.sidebar-user-popover-header span {
    display: block;
    color: rgba(255,255,255,0.55);
    font-size: 11px;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-user-popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.12s ease;
}

.sidebar-user-popover-item:hover {
    background: rgba(255,255,255,0.06);
    color: white;
}

.sidebar-user-popover-item i {
    width: 16px;
    opacity: 0.75;
}

/* ---- Floating mobile menu button ---- */
.mobile-menu-btn-floating {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 950;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: none; /* desktop hides; mobile media query shows */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.mobile-menu-btn-floating:hover {
    background: rgba(30, 41, 59, 0.95);
}

@media (max-width: 1024px) {
    .mobile-menu-btn-floating {
        display: flex;
    }
}

/* ---- Suppress legacy main-header rules at the source ---- */
.main-header {
    display: none !important;
}

/* ---- Hover-peek overlay (Linear/Notion/Stripe pattern) ----
 * When the user hovers the collapsed rail, expand the sidebar to its
 * full width AS AN OVERLAY — the content pane does NOT reflow. The
 * sidebar becomes position: fixed with a high z-index, shadowing over
 * the content. Mouse-leave (with grace) returns it to the icon rail.
 *
 * The pinned-collapsed state is preserved across page loads via
 * localStorage; hover-peek is a transient overlay only.
 *
 * Width-during-peek matches expanded width so labels, submenus, section
 * headers all render exactly as the user remembers them.
 */
.sidebar.collapsed.peek-open {
    width: var(--sidebar-expanded-width, 280px);
    min-width: var(--sidebar-expanded-width, 280px);
    /* Lift above content with a soft shadow so the overlay reads. */
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    /* Critically: don't push --sidebar-width back to 280 — content stays
       at its 64px-margin layout. The peek floats on top. */
}

/* Restore everything that .sidebar.collapsed hides, while peeking. */
.sidebar.collapsed.peek-open .sidebar-brand-info,
.sidebar.collapsed.peek-open .nav-item-label,
.sidebar.collapsed.peek-open .menu-group-title,
.sidebar.collapsed.peek-open .menu-group-arrow,
.sidebar.collapsed.peek-open .nav-section-label,
.sidebar.collapsed.peek-open .sidebar-user-details,
.sidebar.collapsed.peek-open .org-selector-label,
.sidebar.collapsed.peek-open .org-selector-arrow,
.sidebar.collapsed.peek-open .recent-nav-section,
.sidebar.collapsed.peek-open .menu-items {
    display: revert !important;
    max-height: none !important;
    opacity: 1 !important;
}

/* Re-show org-selector during peek. */
.sidebar.collapsed.peek-open .org-selector-wrapper {
    display: revert;
}

/* Hide the icon-only tooltip flyouts during peek (the labels are visible
   now — tooltip would be redundant clutter). */
.sidebar.collapsed.peek-open .menu-group-header[data-tooltip]::after,
.sidebar.collapsed.peek-open .nav-item[data-tooltip]::after {
    display: none !important;
}

/* Brand area: when peeking, restore the brand label even though
   .sidebar.collapsed .sidebar-brand sets justify-content:center. */
.sidebar.collapsed.peek-open .sidebar-brand {
    justify-content: flex-start;
    padding: 24px;
}

/* Menu-group header spacing during peek matches the expanded state. */
.sidebar.collapsed.peek-open .menu-group-header {
    padding: 10px 16px;
    justify-content: flex-start;
}

/* Re-expand any group that has an active child during peek, so the
   user sees where they are inside the IA. */
.sidebar.collapsed.peek-open .menu-group.expanded .menu-items {
    display: block !important;
}

.sidebar.collapsed .sidebar-brand-info,
.sidebar.collapsed .nav-item-label,
.sidebar.collapsed .menu-group-title,
.sidebar.collapsed .menu-group-arrow,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-user-details,
.sidebar.collapsed .org-selector-label,
.sidebar.collapsed .org-selector-arrow,
.sidebar.collapsed .recent-nav-section,
.sidebar.collapsed .menu-items {
    display: none !important;
    max-height: 0 !important;
    opacity: 0 !important;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 16px 8px;
}

.sidebar.collapsed .sidebar-collapse-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.sidebar.collapsed .sidebar-collapse-btn i,
.sidebar.collapsed .sidebar-collapse-btn .collapse-arrow {
    transform: rotate(180deg);
}

.sidebar.collapsed .menu-group-header {
    justify-content: center;
    padding: 8px;
}

.sidebar.collapsed .menu-group-icon {
    margin: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 8px;
}

.sidebar.collapsed .nav-item-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-nav {
    padding: 8px 6px;
}

.sidebar.collapsed .sidebar-footer {
    padding: 8px 6px;
}

.sidebar.collapsed .sidebar-user-info {
    justify-content: center;
    padding: 8px;
}

.sidebar.collapsed .org-selector-wrapper {
    display: none;
}

/* Tooltip on collapsed hover */
.sidebar.collapsed .menu-group-header[data-tooltip] {
    position: relative;
}

.sidebar.collapsed .menu-group-header[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background: var(--surface-secondary, #1e293b);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
}

.sidebar.collapsed .menu-group-header:hover[data-tooltip]::after {
    opacity: 1;
    visibility: visible;
}

/* PR #116a fix: use data-tooltip (human label) not data-nav-route (URL)
   so the tooltip shows "Dashboard" instead of "/" etc. Apply position:relative
   so the absolute ::after anchors correctly. */
.sidebar.collapsed .nav-item[data-tooltip] {
    position: relative;
}

.sidebar.collapsed .nav-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background: var(--surface-secondary, #1e293b);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
}

.sidebar.collapsed .nav-item:hover[data-tooltip]::after {
    opacity: 1;
    visibility: visible;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .cherryai-sidebar {
        width: 64px !important;
        min-width: 64px !important;
    }
    .cherryai-sidebar .sidebar-brand-info,
    .cherryai-sidebar .nav-item-label,
    .cherryai-sidebar .menu-group-title,
    .cherryai-sidebar .menu-group-arrow,
    .cherryai-sidebar .nav-section-label,
    .cherryai-sidebar .sidebar-user-details,
    .cherryai-sidebar .org-selector-label,
    .cherryai-sidebar .org-selector-arrow,
    .cherryai-sidebar .recent-nav-section,
    .cherryai-sidebar .menu-items {
        display: none !important;
        max-height: 0 !important;
        opacity: 0 !important;
    }
    .cherryai-sidebar .menu-group-header {
        justify-content: center;
        padding: 8px;
    }
    .cherryai-sidebar .nav-item {
        justify-content: center;
        padding: 10px 8px;
    }
    .cherryai-sidebar .sidebar-nav {
        padding: 8px 6px;
    }
    .cherryai-sidebar .sidebar-brand {
        justify-content: center;
        padding: 16px 8px;
    }
    .cherryai-sidebar .sidebar-footer {
        padding: 8px 6px;
    }
    .cherryai-sidebar .sidebar-user-info {
        justify-content: center;
        padding: 8px;
    }
    .cherryai-sidebar .org-selector-wrapper {
        display: none;
    }
    .cherryai-sidebar .sidebar-collapse-btn {
        display: none;
    }
}

@media (max-width: 768px) {
    .cherryai-sidebar {
        position: fixed !important;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px !important;
        min-width: 260px !important;
        z-index: 999;
        transition: left 0.25s ease;
    }
    .cherryai-sidebar.mobile-open {
        left: 0;
    }
    .cherryai-sidebar.mobile-open .sidebar-brand-info,
    .cherryai-sidebar.mobile-open .nav-item-label,
    .cherryai-sidebar.mobile-open .menu-group-title,
    .cherryai-sidebar.mobile-open .menu-group-arrow,
    .cherryai-sidebar.mobile-open .nav-section-label,
    .cherryai-sidebar.mobile-open .sidebar-user-details,
    .cherryai-sidebar.mobile-open .org-selector-label,
    .cherryai-sidebar.mobile-open .org-selector-arrow {
        display: block !important;
        opacity: 1 !important;
    }
    .cherryai-sidebar.mobile-open .menu-items {
        display: block !important;
    }
    .cherryai-sidebar.mobile-open .menu-group.expanded .menu-items {
        max-height: 500px !important;
        opacity: 1 !important;
    }
    .cherryai-sidebar.mobile-open .menu-group-header {
        justify-content: flex-start;
        padding: 8px 12px;
    }
    .cherryai-sidebar.mobile-open .nav-item {
        justify-content: flex-start;
        padding: 10px 12px;
    }
    .cherryai-sidebar.mobile-open .sidebar-brand {
        justify-content: flex-start;
        padding: 16px 12px;
    }
    .cherryai-sidebar.mobile-open .sidebar-collapse-btn {
        display: flex;
    }
    .main-content {
        margin-left: 0 !important;
    }
}

/* ---- Process Flow Indicators (legacy support) ---- */
.menu-item[data-step]::after {
    content: attr(data-step);
    position: absolute;
    right: 8px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ---- Quick Action (legacy compat) ---- */
.quick-action {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.quick-action:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.quick-action.active {
    background: rgba(255,255,255,0.12);
    color: white;
}

.quick-action-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin-right: 12px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--info, #3b82f6), var(--info, #1d4ed8));
}

.quick-action-icon svg {
    width: 18px;
    height: 18px;
    color: white;
}

.quick-action-text {
    font-size: 13px;
    font-weight: 600;
    color: inherit;
}

/* ---- Divider ---- */
.menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 12px;
}

/* ---- Badge ---- */
.menu-item-badge {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
}

.menu-item-badge.alert {
    background: linear-gradient(135deg, var(--danger, #ef4444), var(--danger, #dc2626));
    color: white;
}

/* ---- Menu Group Subtitle (legacy compat) ---- */
.menu-group-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Menu Group Content (legacy compat) ---- */
.menu-group-content {
    flex: 1;
    min-width: 0;
}

/* ---- Sidebar Footer (legacy) ---- */
.sidebar-footer .quick-action {
    margin-bottom: 0;
}

.sidebar-footer .quick-action-icon {
    background: linear-gradient(135deg, var(--text-muted, #64748b), var(--text-secondary, #475569));
}

/* ---- Sign In Button ---- */
.nav-item-signin {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    margin: 4px 0;
    color: #93c5fd;
    font-weight: 600;
}
.nav-item-signin:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
    color: #bfdbfe;
}
