/**
 * Unified Navigation Styles
 * Shared across all pages
 */

/* Import org-switcher component styles for multi-org support */
@import url('components/org-switcher.css?v=20260610-221515265-i3l06s');

/* Disable transitions during initial state application */
.sidebar.no-transition,
.sidebar.no-transition * {
    transition: none;
}

/* Dark mode sidebar colors (default) */
:root {
    --sidebar-text: rgba(255, 255, 255, 0.75);
    --sidebar-text-strong: rgba(255, 255, 255, 0.95);
    --sidebar-text-muted: rgba(255, 255, 255, 0.5);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.12);
    --sidebar-active-bg: rgba(59, 130, 246, 0.35);
    --sidebar-divider: rgba(255, 255, 255, 0.12);
    --sidebar-user-bg: rgba(0, 0, 0, 0.25);
}

/* Light mode sidebar colors - OS preference */
@media (prefers-color-scheme: light) {
    :root {
        --sidebar-text: #1e293b;
        --sidebar-text-strong: #0f172a;
        --sidebar-text-muted: #475569;
        --sidebar-hover-bg: rgba(15, 23, 42, 0.1);
        --sidebar-active-bg: rgba(59, 130, 246, 0.18);
        --sidebar-divider: rgba(15, 23, 42, 0.12);
        --sidebar-user-bg: rgba(15, 23, 42, 0.06);
    }
}

/* Manual Light Mode Override via data-theme attribute */
[data-theme="light"] {
    --sidebar-text: #1e293b;
    --sidebar-text-strong: #0f172a;
    --sidebar-text-muted: #475569;
    --sidebar-hover-bg: rgba(15, 23, 42, 0.1);
    --sidebar-active-bg: rgba(59, 130, 246, 0.18);
    --sidebar-divider: rgba(15, 23, 42, 0.12);
    --sidebar-user-bg: rgba(15, 23, 42, 0.06);
}

/* Manual Dark Mode Override via data-theme attribute */
[data-theme="dark"] {
    --sidebar-text: rgba(255, 255, 255, 0.87);
    --sidebar-text-strong: rgba(255, 255, 255, 0.95);
    --sidebar-text-muted: rgba(255, 255, 255, 0.6);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.12);
    --sidebar-active-bg: rgba(59, 130, 246, 0.35);
    --sidebar-divider: rgba(255, 255, 255, 0.15);
    --sidebar-user-bg: rgba(0, 0, 0, 0.25);
}

/* Comprehensive transition lock during navigation */
body.no-transition,
body.no-transition *,
.no-transition,
.no-transition * {
    transition: none !important;
    animation: none !important;
}

.sidebar.is-loading {
    opacity: 0.8;
    pointer-events: none;
    cursor: progress;
}

/* Sidebar Container */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 60px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    transition: width 0.3s ease;
    z-index: 500; /* Lowered from 1000 to prevent modal conflicts */
    overflow: hidden;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.sidebar.expanded {
    width: var(--sidebar-width-expanded, 300px);
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--sidebar-divider);
    min-height: 70px;
}

/* Center toggle button when sidebar is collapsed */
.sidebar:not(.expanded) .sidebar-header {
    justify-content: center;
    padding: 20px 5px;
}

/* Ensure toggle button fits in collapsed sidebar */
.sidebar:not(.expanded) .sidebar-toggle {
    margin: 0 auto;
}

.sidebar-header h2 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    opacity: 0;
    white-space: nowrap;
}

.sidebar.expanded .sidebar-header h2 {
    opacity: 1;
}

/* Hide h2 completely when sidebar is collapsed so it doesn't take space */
.sidebar:not(.expanded) .sidebar-header h2 {
    display: none;
}

.sidebar-toggle {
    background: var(--sidebar-hover-bg);
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    color: var(--text-primary);
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar.expanded .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar Search Button (Command Palette trigger) */
.sidebar-search-btn {
    background: var(--sidebar-hover-bg);
    border: 1px solid var(--sidebar-divider);
    border-radius: var(--border-radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-right: 8px;
}

.sidebar-search-btn:hover {
    background: var(--sidebar-active-bg);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.sidebar-search-btn svg {
    flex-shrink: 0;
}

.sidebar-search-shortcut {
    font-family: monospace;
    font-size: 0.65rem;
    padding: 2px 4px;
    background: var(--bg-secondary);
    border-radius: 3px;
    color: var(--text-muted);
}

/* Hide search button when sidebar is collapsed */
.sidebar:not(.expanded) .sidebar-search-btn {
    display: none;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 15px 10px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

/* Section Labels — plain text dividers between groups, mirroring the
   global manage popover's section headings. No module color, no left
   accent border, no AI sparkle — the popover doesn't have any of those
   and the sidebar should look the same. */
.menu-section-label,
.sidebar-section-label {
    color: var(--sidebar-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 10px 12px 4px;
    margin-top: 4px;
    border-top: 1px solid var(--sidebar-divider);
    opacity: 0;
    transition: color 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    user-select: none;
}

.sidebar-menu > .menu-section-label:first-of-type,
.sidebar-menu > .sidebar-section-label:first-of-type {
    border-top: none;
    margin-top: 0;
}

/* Module-driven section coloring removed — the global manage popover
   shows section headings as plain muted text and the sidebar mirrors
   that. Module identity is conveyed via the home-page module cards and
   the per-page module color, not via the nav. */

/* AI sparkle marker disabled — popover doesn't have it, sidebar shouldn't either. */
.sidebar-section-label.has-ai-enhanced > span::after {
    display: none;
}

.menu-section-label > span,
.sidebar-section-label > span {
    flex: 1;
}

/* Hide section labels when sidebar is collapsed */
.sidebar:not(.expanded) .menu-section-label,
.sidebar:not(.expanded) .sidebar-section-label {
    display: none;
}

.sidebar.expanded .menu-section-label,
.sidebar.expanded .sidebar-section-label {
    opacity: 1;
}

/* ============================================================
   Parent-category headers
   One tier above section labels; groups 30+ sections into 6
   collapsible buckets. Each category carries a color stripe
   set via --nav-category-light / --nav-category-dark inline
   style (from NAV_VISIBILITY_DATA.categories[].color).
   ============================================================ */
.menu-category-label,
.sidebar-category-label {
    color: var(--sidebar-text);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 14px 12px 8px;
    margin-top: 8px;
    border-top: 1px solid var(--sidebar-divider);
    border-left: 3px solid var(--nav-category-light, var(--sidebar-text-muted));
    opacity: 0;
    transition: color 0.2s ease, background-color 0.15s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    outline: none;
}
[data-theme="dark"] .menu-category-label,
[data-theme="dark"] .sidebar-category-label {
    border-left-color: var(--nav-category-dark, var(--sidebar-text-muted));
}

.sidebar-menu > .menu-category-label:first-of-type,
.sidebar-menu > .sidebar-category-label:first-of-type {
    border-top: none;
    margin-top: 0;
}

.sidebar.expanded .menu-category-label,
.sidebar.expanded .sidebar-category-label {
    opacity: 1;
}

.sidebar:not(.expanded) .menu-category-label,
.sidebar:not(.expanded) .sidebar-category-label {
    display: none;
}

.menu-category-label:hover,
.sidebar-category-label:hover,
.menu-category-label:focus-visible,
.sidebar-category-label:focus-visible {
    background-color: var(--sidebar-hover, rgba(255, 255, 255, 0.05));
}

.menu-category-label .category-label-text,
.sidebar-category-label .category-label-text {
    flex: 1;
}

.menu-category-label .category-chevron,
.sidebar-category-label .category-chevron {
    flex-shrink: 0;
    transition: transform 0.18s ease;
    transform: rotate(0deg);
}

.menu-category-label.collapsed .category-chevron,
.sidebar-category-label.collapsed .category-chevron {
    transform: rotate(-90deg);
}

/* Three-level visual hierarchy when categories are present:
   - Category label: flush left, color stripe (most prominent)
   - Section label: indented ~20px (medium)
   - Item link:     indented ~32px (least)
   Child items (nav-child) keep their existing deeper indent.   */
.sidebar-menu .menu-section-label[data-category-parent],
.sidebar-menu .sidebar-section-label[data-category-parent] {
    padding-left: 20px;
}
.sidebar.expanded .sidebar-menu li[data-category-parent] > .sidebar-link {
    padding-left: 32px;
}
.sidebar.expanded .sidebar-menu li[data-category-parent].nav-child > .sidebar-link,
.sidebar.expanded .sidebar-menu li[data-category-parent].sidebar-nav-child > .sidebar-link {
    padding-left: 48px;
}

/* Global manage (+) button — sits in the sidebar header next to "Menu"
   and opens the popover that controls visibility of every nav item the
   user can access, grouped by section. Replaces the per-section "+"
   buttons that used to live on every section header. Sized to match
   .sidebar-toggle so the two buttons line up visually in the header. */
.nav-global-manage-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-hover-bg);
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 8px;
    cursor: pointer;
    color: var(--text-primary);
    margin-left: auto;
    margin-right: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.nav-global-manage-btn:hover {
    background: var(--accent-primary, #2563eb);
    color: #fff;
}

/* "+" → "−" visual flip when manage mode is active.
   The button SVG contains both the vertical (M12 5v14, .manage-btn-vline)
   and horizontal (M5 12h14) strokes. Hiding the vertical leaves a minus. */
.nav-global-manage-btn.manage-active .manage-btn-vline {
    display: none;
}

.nav-global-manage-btn.manage-active {
    background: var(--accent-primary, #2563eb);
    color: #fff;
}

/* Hide the global manage button when the sidebar is collapsed — there's
   no header space for it. */
.sidebar:not(.expanded) .nav-global-manage-btn {
    display: none;
}

/* In-nav manage-mode toggle. Each `.nav-manage-toggle` sits at the right
   edge of an item's <li>. Hidden by default; revealed when the body has
   the `nav-manage-mode` class so the existing nav layout stays clean. */
.nav-manage-toggle {
    display: none;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
    margin-right: 12px;
    cursor: pointer;
}
body.nav-manage-mode .nav-manage-toggle {
    display: inline-flex;
}

/* The <a class="sidebar-link"> inside a row is width:100% by default,
   which would push the toggle off-screen. Make the row a flex container
   in manage mode so the link and toggle share the row. */
body.nav-manage-mode .sidebar-menu > li,
body.nav-manage-mode .sidebar-menu .nav-child {
    display: flex;
    align-items: center;
    margin-bottom: 0;
}
body.nav-manage-mode .sidebar-menu .sidebar-link {
    flex: 1;
    width: auto;
}

/* Dim items that are currently hidden so the user can see, at a glance,
   which items are off. The toggle's own state still tells the truth. */
body.nav-manage-mode .sidebar-menu li[data-hidden="true"] .sidebar-link {
    opacity: 0.45;
}

/* In manage mode, mute the active highlight so the toggle takes focus. */
body.nav-manage-mode .sidebar-menu .sidebar-link.active {
    background: transparent;
}

/* Suppress hover tooltips in manage mode — every label is fully visible
   and the tooltip would obscure the toggle. */
body.nav-manage-mode .sidebar-menu [data-tooltip]::after,
body.nav-manage-mode .sidebar-menu [data-tooltip]::before {
    display: none !important;
}

/* Mobile / narrow-viewport tweaks for manage-mode rows. The toggle is
   32×18 plus 12px right margin; on very small screens we trim that and
   let the link text truncate so the toggle never wraps below the row. */
@media (max-width: 640px) {
    .nav-manage-toggle {
        margin-right: 8px;
    }
    body.nav-manage-mode .sidebar-menu .sidebar-link {
        min-width: 0;
        overflow: hidden;
    }
    body.nav-manage-mode .sidebar-menu .sidebar-link-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }
}

/* Toggle-switch primitives — used by the in-nav .nav-manage-toggle.
   The visible track + thumb plus the hidden checkbox; checked state is
   driven by the native :checked sibling selector. */
.nav-manage-cb {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.nav-manage-switch-track {
    position: relative;
    width: 32px;
    height: 18px;
    background: var(--sidebar-divider);
    border-radius: 9px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.nav-manage-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s;
}
.nav-manage-cb:checked + .nav-manage-switch-track {
    background: var(--accent-primary, #2563eb);
}
.nav-manage-cb:checked + .nav-manage-switch-track .nav-manage-switch-thumb {
    transform: translateX(14px);
}

/* Menu Divider */
.menu-divider,
.sidebar-divider {
    height: 1px;
    background: var(--sidebar-divider);
    margin: 10px 15px;
}

/* Hide dividers when sidebar is collapsed */
.sidebar:not(.expanded) .menu-divider,
.sidebar:not(.expanded) .sidebar-divider {
    display: none;
}

/* Sidebar Links — compact 6px/0.82rem rows to keep the menu dense. */
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease, color 0.2s ease;
    gap: 8px;
    white-space: nowrap;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.82rem;
}

/* Center icons when sidebar is collapsed */
.sidebar:not(.expanded) .sidebar-link {
    justify-content: center;
    padding: 12px 0;
    margin: 2px 5px;
    width: auto;
}

.sidebar:not(.expanded) .sidebar-menu {
    padding: 15px 5px;
}

/* Fix active state when collapsed */
.sidebar:not(.expanded) .sidebar-link.active {
    background: var(--sidebar-active-bg);
    border-radius: var(--border-radius-sm);
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-strong);
    transform: translateX(2px);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--accent-primary);
    font-weight: 600;
    border-left: 3px solid var(--accent-primary);
    padding-left: 12px;
}

/* Non-clickable parent items that toggle children */
.sidebar-link-parent {
    cursor: pointer;
    user-select: none;
}

.sidebar-link svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

/* Module-colored icon wrapper */
.nav-icon-wrap {
    display: inline-flex;
    flex-shrink: 0;
}

.nav-icon-wrap svg {
    color: inherit;
}

/* Beta badge to the left of the icon */
.nav-beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 14px;
    padding: 0 4px;
    font-size: 0.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-radius: 3px;
    background: var(--accent-primary, #6366f1);
    color: #fff;
    flex-shrink: 0;
    margin-right: 4px;
}

/* When sidebar is collapsed, hide beta badge */
.sidebar:not(.expanded) .nav-beta-badge {
    display: none;
}

/* (NEW) badge — same dimensions as beta badge, distinct color
   so a feature recently promoted to GA/EA is visually different
   from one still in beta. */
.nav-new-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 14px;
    padding: 0 4px;
    font-size: 0.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-radius: 3px;
    background: var(--color-success, #10b981);
    color: #fff;
    flex-shrink: 0;
    margin-right: 4px;
}

.sidebar:not(.expanded) .nav-new-badge {
    display: none;
}

/* Child rows put NEW immediately before the label text */
.sidebar-link-child .nav-new-badge {
    margin-right: 6px;
}

.sidebar-link-text {
    opacity: 0;
    font-weight: 500;
}

.sidebar.expanded .sidebar-link-text {
    opacity: 1;
}

/* Hide link text completely when sidebar is collapsed */
.sidebar:not(.expanded) .sidebar-link-text {
    display: none;
}

/* Child Navigation Items — indented to match the popover's child-row
   indent (28px). No bullet dot, no module color — popover children are
   plain text and the sidebar mirrors that. */
.nav-child,
.sidebar-nav-child {
    margin-left: 0;
}

/* Hide child items when sidebar is collapsed */
.sidebar:not(.expanded) .nav-child,
.sidebar:not(.expanded) .sidebar-nav-child {
    display: none;
}

.sidebar-link-child {
    padding: 6px 12px 6px 28px;
    font-size: 0.82rem;
    color: var(--sidebar-text);
}

[data-theme="dark"] .sidebar-link-child {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .sidebar-link-child:hover {
    color: #fff;
}

/* Item Toggle Button (for parent items with children) */
.sidebar-menu li {
    position: relative;
}

.item-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-text-muted);
    border-radius: 4px;
    transition: transform 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    opacity: 0;
}

.sidebar.expanded .item-toggle {
    opacity: 1;
}

/* Hide item toggles when sidebar is collapsed */
.sidebar:not(.expanded) .item-toggle {
    display: none;
}

.item-toggle:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-strong);
}

.item-toggle svg {
    transition: transform 0.2s ease;
}

.item-toggle.collapsed svg {
    transform: rotate(-90deg);
}

/* Dashboard Shortcut Buttons */
.shortcut-add-btn,
.shortcut-remove-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--sidebar-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav-child {
    position: relative;
}

.sidebar-nav-child:hover .shortcut-add-btn,
li:hover > .shortcut-remove-btn {
    opacity: 1;
}

.shortcut-add-btn:hover {
    background: var(--sidebar-hover-bg);
    color: #22c55e; /* Green for add */
}

.shortcut-remove-btn:hover {
    background: var(--sidebar-hover-bg);
    color: #ef4444; /* Red for remove */
}

.shortcut-add-btn:focus,
.shortcut-remove-btn:focus {
    opacity: 1;
    outline: 2px solid var(--sidebar-active-bg);
    outline-offset: 1px;
}

.shortcut-add-btn svg,
.shortcut-remove-btn svg {
    width: 12px;
    height: 12px;
}

/* Custom shortcut item styling */
.custom-shortcut-item {
    position: relative;
}

.custom-shortcut-item .sidebar-link {
    padding-right: 32px; /* Make room for remove button */
}

/* Hide buttons when sidebar is collapsed */
.sidebar:not(.expanded) .shortcut-add-btn,
.sidebar:not(.expanded) .shortcut-remove-btn {
    display: none;
}

/* Pinned dashboard child styling */
.pinned-dashboard-child .sidebar-link {
    padding-right: 32px; /* Make room for remove button */
}

.pinned-dashboard-child .pinned-icon {
    flex-shrink: 0;
    margin-right: 8px;
    color: var(--sidebar-text-muted);
    opacity: 0.7;
}

.pinned-dashboard-child:hover .pinned-icon {
    color: var(--sidebar-accent-color, #f59e0b);
    opacity: 1;
}

.pinned-dashboard-child .sidebar-link-child {
    display: flex;
    align-items: center;
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-hover-bg);
    border-radius: 2px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-hover-bg);
}

/* Main Content Offset - handled by base.css using CSS variables */

/* Mobile Menu Toggle Button - Fixed position, visible only on mobile */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 600; /* Above sidebar (500) but below modals */
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm, 8px);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    box-shadow: var(--shadow-md, 0 4px 8px rgba(0, 0, 0, 0.25));
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.mobile-menu-toggle:focus {
    outline: none;
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(59, 130, 246, 0.2));
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* Mobile Overlay - darkens background when sidebar is open */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 400; /* Below sidebar */
    opacity: 0;
}

.mobile-menu-overlay.active {
    opacity: 1;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
    }

    /* Show overlay on mobile */
    .mobile-menu-overlay {
        display: block;
        pointer-events: none;
    }

    .mobile-menu-overlay.active {
        pointer-events: auto;
    }

    .sidebar {
        width: 0;
        transform: translateX(-100%);
    }

    .sidebar.expanded {
        width: 100%;
        max-width: 100vw;
        transform: translateX(0);
    }

    /* Mobile full-screen sidebar enhancements */
    .sidebar.expanded .sidebar-header {
        justify-content: space-between;
        padding: 1.25rem 1rem;
    }

    /* Show close button in sidebar header on mobile */
    .sidebar.expanded .sidebar-toggle {
        display: flex;
        order: 2;
    }

    /* Ensure title is visible */
    .sidebar.expanded .sidebar-header h2 {
        opacity: 1;
        font-size: 1.25rem;
    }

    /* Better scrolling for menu */
    .sidebar.expanded .sidebar-menu {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body {
        margin-left: 0;
    }

    body.sidebar-expanded {
        margin-left: 0;
    }

    /* Hide mobile toggle when sidebar is expanded */
    body.sidebar-expanded .mobile-menu-toggle {
        opacity: 0;
        pointer-events: none;
    }

    .sidebar.expanded ~ .main-content {
        opacity: 0.5;
    }
}

/* Assessment Module Colors - Removed for visual consistency
   All nav items now use consistent hover/active styling
   Original colors were: custom-primary, cis-primary */

/* Phase 3: Scope indicator for linked account users */
.sidebar-scope-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    margin: 0 10px 10px 10px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    color: var(--sidebar-text);
}

.scope-indicator-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    color: var(--color-primary, #3b82f6);
}

.scope-indicator-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
}

.scope-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text-muted);
    font-weight: 600;
}

.scope-linked-account-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--sidebar-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed state for scope indicator */
.sidebar:not(.expanded) .sidebar-scope-indicator {
    flex-direction: column;
    padding: 8px 5px;
    margin: 0 5px 10px 5px;
    text-align: center;
}

.sidebar:not(.expanded) .scope-indicator-text {
    display: none;
}

.sidebar:not(.expanded) .scope-indicator-icon {
    width: 24px;
    height: 24px;
}

/* Sidebar Org Switcher for Multi-Org Users */
.sidebar-org-switcher {
    padding: 10px 15px;
    border-bottom: 1px solid var(--sidebar-divider);
    margin-bottom: 5px;
}

.sidebar-org-switcher .org-switcher {
    width: 100%;
}

.sidebar-org-switcher .org-switcher-button {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--sidebar-divider);
    color: var(--sidebar-text);
    justify-content: space-between;
}

.sidebar-org-switcher .org-switcher-button:hover {
    background: var(--sidebar-hover-bg);
    border-color: var(--primary-color);
}

.sidebar-org-switcher .org-switcher-dropdown {
    background: var(--bg-secondary);
    border-color: var(--sidebar-divider);
    position: fixed;
    left: auto;
    top: auto;
    margin-left: 5px;
    z-index: 10000;
}

.sidebar-org-switcher .org-switcher-header {
    color: var(--sidebar-text-muted);
    border-color: var(--sidebar-divider);
}

.sidebar-org-switcher .org-switcher-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-org-switcher .org-switcher-item.current {
    background: rgba(59, 130, 246, 0.2);
}

.sidebar-org-switcher .org-name {
    color: var(--sidebar-text);
}

.sidebar-org-switcher .org-role {
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text-muted);
}

.sidebar-org-switcher .org-switcher-footer {
    border-color: var(--sidebar-divider);
}

/* Collapsed sidebar - hide org switcher text */
.sidebar:not(.expanded) .sidebar-org-switcher {
    padding: 10px 5px;
}

.sidebar:not(.expanded) .sidebar-org-switcher .org-current-name {
    display: none;
}

.sidebar:not(.expanded) .sidebar-org-switcher .org-switcher-button {
    justify-content: center;
    padding: 8px;
}

.sidebar:not(.expanded) .sidebar-org-switcher .org-switcher-icon {
    margin: 0;
}

/* Sidebar org info display (simple display, no switching) */
.sidebar-org-info {
    padding: 8px 15px;
    border-bottom: 1px solid var(--sidebar-divider);
    margin-bottom: 5px;
}

.sidebar-org-info .org-display {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--sidebar-text);
    font-size: 0.875rem;
}

.sidebar-org-info .org-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-org-info .org-display-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar:not(.expanded) .sidebar-org-info .org-display-name {
    display: none;
}

.sidebar:not(.expanded) .sidebar-org-info {
    padding: 8px 5px;
    text-align: center;
}

/* User Info Section at Bottom */
.sidebar-user-info {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: var(--sidebar-user-bg);
    border-top: 1px solid var(--sidebar-divider);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 60px;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-user-info:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar-user-info:focus-visible {
    outline: 2px solid var(--accent-color, #3b82f6);
    outline-offset: -2px;
}

/* Chevron icon — visible on hover when sidebar is expanded */
.user-settings-icon {
    flex-shrink: 0;
    opacity: 0;
    color: var(--sidebar-text);
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
}

.sidebar.expanded .sidebar-user-info:hover .user-settings-icon {
    opacity: 0.7;
}

/* Hide chevron when sidebar is collapsed */
.sidebar:not(.expanded) .user-settings-icon {
    display: none;
}

.user-avatar {
    position: relative;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    color: var(--sidebar-text-strong);
}

.user-avatar > svg {
    width: 16px;
    height: 16px;
}

/* Gear badge on avatar - hints at settings */
.user-avatar-gear {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    color: var(--sidebar-text);
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.3s ease-out;
}

.user-avatar-gear svg {
    width: 10px;
    height: 10px;
}

.sidebar-user-info:hover .user-avatar-gear {
    opacity: 1;
    transform: rotate(90deg);
}

.user-details {
    flex: 1;
    min-width: 0;
    opacity: 0;
}

.sidebar.expanded .user-details {
    opacity: 1;
}

.user-email {
    display: block;
    font-size: 0.75rem;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hide user details when sidebar is collapsed */
.sidebar:not(.expanded) .user-details {
    display: none;
}

/* Center avatar when sidebar is collapsed */
.sidebar:not(.expanded) .sidebar-user-info {
    justify-content: center;
    padding: 15px 5px;
}

/* Adjust menu padding to account for user info section */
.sidebar-menu {
    padding-bottom: 110px;
}

/* ========================================
   Cross-Dashboard Navigation Styles
   ======================================== */

/* Company jump dropdown in organization dashboard */
.cross-nav-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cross-nav-dropdown label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.cross-nav-dropdown .form-select {
    min-width: 200px;
}

/* Enterprise back link on linked account dashboards */
.cross-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: all 0.15s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.cross-nav-link:hover {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.cross-nav-link:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.cross-nav-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Breadcrumb navigation for remediation detail */
.cross-nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.cross-nav-breadcrumb .breadcrumb-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-xs);
    transition: all 0.15s ease;
}

.cross-nav-breadcrumb .breadcrumb-link:hover {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.cross-nav-breadcrumb .breadcrumb-link:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.cross-nav-breadcrumb .breadcrumb-separator {
    color: var(--text-muted);
    user-select: none;
}

.cross-nav-breadcrumb .breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
    padding: 0.25rem 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cross-nav-dropdown {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .cross-nav-dropdown .form-select {
        width: 100%;
        min-width: 0;
    }

    .cross-nav-breadcrumb {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .cross-nav-link {
        font-size: 0.8125rem;
        padding: 0.375rem 0.5rem;
    }
}

/* ========================================
   Pinnable Dashboard Navigation Styles
   ======================================== */

/* Dashboard nav item with inline controls */
.nav-item--dashboard .dashboard-nav-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
}

.nav-item--dashboard .dashboard-nav-content:hover {
    background: var(--sidebar-hover-bg);
}

.nav-item--dashboard .sidebar-link {
    flex: 1;
    min-width: 100px;
    padding: 8px;
}

.nav-item--dashboard .sidebar-link:hover {
    background: transparent;
    transform: none;
}

.dashboard-selectors {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* Inline dropdown component */
.nav-dropdown-inline {
    position: relative;
}

.nav-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px 6px;
    font-size: var(--text-2xs, 0.625rem);
    font-family: inherit;
    background: var(--sidebar-hover-bg);
    border: 1px solid var(--sidebar-divider);
    border-radius: 4px;
    cursor: pointer;
    color: var(--sidebar-text);
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.nav-dropdown-trigger:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-primary);
}

.nav-dropdown-trigger:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.nav-dropdown-value {
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-dropdown-chevron {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.nav-dropdown-trigger[aria-expanded="true"] .nav-dropdown-chevron {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 140px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--sidebar-divider);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    margin-top: 2px;
}

.nav-dropdown-trigger[aria-expanded="true"] + .nav-dropdown-menu,
.nav-dropdown-menu.show {
    display: block;
}

.nav-dropdown-item {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--sidebar-text);
    transition: background-color 0.1s ease;
}

.nav-dropdown-item:hover {
    background: var(--sidebar-hover-bg);
}

.nav-dropdown-item.selected {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
}

.nav-dropdown-item:first-child {
    border-radius: 5px 5px 0 0;
}

.nav-dropdown-item:last-child {
    border-radius: 0 0 5px 5px;
}

.nav-dropdown-item:only-child {
    border-radius: 5px;
}

/* Dropdown separator for "Latest" option */
.nav-dropdown-separator {
    height: 1px;
    background: var(--sidebar-divider);
    margin: 4px 0;
}

/* Pin/Unpin buttons */
.dashboard-pin-btn,
.dashboard-unpin-btn,
.nav-unpin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--sidebar-text-muted);
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.dashboard-pin-btn:hover {
    background: var(--sidebar-hover-bg);
    color: var(--accent-primary);
}

.dashboard-pin-btn:focus,
.dashboard-unpin-btn:focus,
.nav-unpin-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.dashboard-pin-btn svg,
.dashboard-unpin-btn svg,
.nav-unpin-btn svg {
    width: 14px;
    height: 14px;
}

/* Pinned state - filled pin */
.dashboard-unpin-btn,
.nav-unpin-btn {
    color: var(--accent-primary);
    opacity: 0;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

/* Show unpin button on hover */
.nav-item--pinned:hover .nav-unpin-btn {
    opacity: 1;
}

.dashboard-unpin-btn:hover,
.nav-unpin-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Pinned item styling */
.nav-item--pinned {
    position: relative;
}

.nav-item--pinned .sidebar-link {
    padding-right: 32px; /* Make room for X button */
}

/* Hide inline controls when sidebar is collapsed */
.sidebar:not(.expanded) .dashboard-selectors,
.sidebar:not(.expanded) .dashboard-pin-btn,
.sidebar:not(.expanded) .dashboard-unpin-btn,
.sidebar:not(.expanded) .nav-unpin-btn {
    display: none;
}

.sidebar:not(.expanded) .nav-item--dashboard .dashboard-nav-content {
    padding: 0;
}

.sidebar:not(.expanded) .nav-item--dashboard .sidebar-link {
    padding: 12px 0;
    justify-content: center;
}

.sidebar:not(.expanded) .nav-item--pinned::before {
    display: none;
}

/* Empty state for no datasets */
.nav-dropdown-empty {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--sidebar-text-muted);
    font-style: italic;
}

/* Loading state for dropdown */
.nav-dropdown-loading {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--sidebar-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-dropdown-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--sidebar-divider);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: dropdown-spin 0.6s linear infinite;
}

@keyframes dropdown-spin {
    to { transform: rotate(360deg); }
}

/* Dashboard group header with selector */
.dashboard-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px 6px;
}

.dashboard-group-header .menu-section-label {
    padding: 0;
    margin: 0;
}

/* ===========================================
   Collapsed Sidebar Tooltips
   Shows item labels on hover when menu is minimized
   =========================================== */

/* JavaScript-powered tooltip element */
.nav-collapsed-tooltip {
    position: fixed;
    padding: 8px 14px;
    background: var(--bg-secondary);
    color: var(--sidebar-text-strong);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 10000;
    transform: translateY(-50%);
}

/* Arrow pointing to the icon */
.nav-collapsed-tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--bg-secondary);
}

/* Show tooltip when visible */
.nav-collapsed-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .nav-dropdown-menu {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        max-width: 90vw;
        max-height: 60vh;
    }

    .nav-dropdown-item {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* ========================================
   CONSOLIDATED NAVIGATION 2.0
   Dashboard Consolidation - Saved Views & Posture Nav
   ======================================== */

/* Nav items with children - parent indicator */
.nav-item-with-children {
    position: relative;
}

.nav-item-with-children.collapsed .nav-child {
    display: none;
}

/* Program View Children (CIS/CSF/Custom) */
.nav-child[data-parent-item="posture"],
.nav-child[data-parent-item="reports"] {
    position: relative;
}

/* Active state for child items with query params */
.sidebar-link-child.active {
    color: var(--accent-primary) !important;
    font-weight: 600;
}

.sidebar-link-child.active::before {
    background: var(--module-color, var(--accent-primary)) !important;
}

/* Responsive adjustments for saved views */
/* ========================================
   Navigation Badge System
   Badge indicators for nav items (e.g., unacknowledged alerts count)
   ======================================== */

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: auto;
    background: #dc2626;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
    flex-shrink: 0;
}

/* Slightly different appearance for urgent counts */
.nav-badge[data-urgent="true"] {
    background: #dc2626;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 4px rgba(220, 38, 38, 0);
    }
}

/* Hide badge when sidebar is collapsed */
.sidebar:not(.expanded) .nav-badge {
    display: none;
}

/* Show badge as dot when sidebar is collapsed (optional visual indicator) */
.sidebar:not(.expanded) .sidebar-link[data-has-badge="true"]::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #dc2626;
    border-radius: 50%;
}

/* Position adjustment for items with badges */
.sidebar-link:has(.nav-badge) {
    padding-right: 8px;
}

/* Dark mode adjustments */
[data-theme="dark"] .nav-badge {
    background: #ef4444;
}

/* Light mode adjustments */
[data-theme="light"] .nav-badge {
    background: #dc2626;
}

/* ========================================
   Navigation Sidebar Filter / Search
   Inline filter input above menu items
   ======================================== */

.sidebar-nav-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--sidebar-divider);
}

.nav-filter-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--sidebar-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-filter-input {
    flex: 1;
    background: transparent;
    border: 1px solid var(--sidebar-divider);
    border-radius: 4px;
    padding: 5px 8px;
    color: var(--sidebar-text-strong);
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    min-width: 0;
}

.nav-filter-input::placeholder {
    color: var(--sidebar-text-muted);
    opacity: 0.7;
}

.nav-filter-input:focus {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

.nav-filter-clear {
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--sidebar-text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-filter-clear.visible {
    display: flex;
}

.nav-filter-clear:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-strong);
}

/* Items hidden by the filter */
.nav-filter-hidden {
    display: none !important;
}

/* "No results" message */
.nav-filter-no-results {
    padding: 20px 15px;
    text-align: center;
    color: var(--sidebar-text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

/* Collapsed sidebar: hide input and clear button, show only icon */
.sidebar:not(.expanded) .nav-filter-input,
.sidebar:not(.expanded) .nav-filter-clear {
    display: none !important;
}

.sidebar:not(.expanded) .sidebar-nav-filter {
    justify-content: center;
    padding: 8px 5px;
    cursor: pointer;
}

/* Mobile: larger touch targets */
@media (max-width: 768px) {
    .nav-filter-input {
        padding: 8px 10px;
        font-size: 0.875rem;
    }

    .nav-filter-clear {
        width: 28px;
        height: 28px;
    }
}
