/* ============================================
   Global Sidebar - Collapsible Navigation
   ============================================ */

/* --- Sidebar Container --- */
.global-sidebar {
    width: 240px;
    min-width: 240px;
    height: 100vh;
    background: rgb(45, 50, 62);
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width 0.25s ease, min-width 0.25s ease;
    position: relative;
    z-index: 60;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12);
}

/* --- Collapsed State --- */
.global-sidebar.sidebar-collapsed {
    width: 60px;
    min-width: 60px;
}

/* --- Logo / Toolbar --- */
.global-sidebar .sidebar-toolbar {
    padding: 12px;
    cursor: pointer;
    background: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    min-height: 56px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
}

.global-sidebar .sidebar-logo {
    display: flex;
    align-items: center;
    overflow: hidden;
    width: 100%;
}

.global-sidebar .sidebar-logo-full {
    max-height: 40px;
    max-width: 180px;
    display: block;
}

.global-sidebar .sidebar-logo-icon {
    max-height: 32px;
    max-width: 32px;
    display: none;
    object-fit: contain;
}

.global-sidebar.sidebar-collapsed .sidebar-logo-full {
    display: none;
}

.global-sidebar.sidebar-collapsed .sidebar-logo-icon {
    display: block;
    margin: 0 auto;
}

.global-sidebar.sidebar-collapsed .sidebar-toolbar {
    padding: 12px 8px;
    justify-content: center;
}

/* --- Edge Toggle Button (pill on sidebar border) --- */
.global-sidebar .sidebar-edge-toggle {
    position: absolute;
    top: 52px;
    right: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgb(55, 61, 75);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 61;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.global-sidebar .sidebar-edge-toggle:hover {
    background: #039be5;
    color: #fff;
    border-color: #039be5;
    box-shadow: 0 2px 8px rgba(3, 155, 229, 0.3);
}

.global-sidebar .sidebar-edge-toggle .material-icons {
    font-size: 14px;
    line-height: 1;
}

/* --- Menu Scroll Wrapper --- */
.global-sidebar .sidebar-menu-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.global-sidebar .sidebar-menu-wrap::-webkit-scrollbar {
    width: 4px;
}

.global-sidebar .sidebar-menu-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* --- Back to Devices Button --- */
.global-sidebar .sidebar-back-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.global-sidebar .sidebar-back-section .sidebar-back-button {
    background: rgba(3, 155, 229, 0.1);
}

.global-sidebar .sidebar-back-section .sidebar-back-button:hover {
    background: #039be5 !important;
    color: #fff;
}

/* --- Side Menu --- */
.global-sidebar .side-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.global-sidebar .side-menu .subheader {
    padding: 10px 24px 5px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.3);
}

.global-sidebar.sidebar-collapsed .side-menu .subheader {
    text-align: center;
    padding: 10px 0 5px;
}

.global-sidebar.sidebar-collapsed .side-menu .subheader .menu-text {
    display: none;
}

/* --- Menu Items (expanded state - dark bg) --- */
.global-sidebar .side-menu .md-button {
    border-radius: 0;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-weight: 400;
    margin: 0 !important;
    max-height: 44px;
    overflow: hidden;
    padding: 0 10px 0 18px;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    width: 100%;
    text-transform: capitalize;
    position: relative;
    line-height: 44px;
}

.global-sidebar .side-menu .md-button.active,
.global-sidebar .side-menu a.md-button.active {
    color: #fff;
    background: #039be5;
}

.global-sidebar .side-menu .md-button:hover,
.global-sidebar .side-menu a.md-button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Active child link — full blue */
.global-sidebar .side-menu .md-button.active-menu {
    color: #fff;
    background: #039be5;
}

/* Child list area — subtle inset background */
.global-sidebar .side-menu .menu-toggle-list {
    background: rgba(0, 0, 0, 0.12);
}

/* Active child link inside toggle — accent bar + white text */
.global-sidebar .side-menu .menu-toggle-list .md-button.active-menu {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: inset 3px 0 0 #fff;
}

.global-sidebar .side-menu .menu-toggle-list .md-button.active-menu:hover {
    background: rgba(255, 255, 255, 0.14) !important;
}

.global-sidebar .side-menu .md-button span.inset {
    padding: 0;
}

.global-sidebar .side-menu .md-button span.inset .material-icons {
    font-size: 18px;
    width: auto;
    height: auto;
    line-height: 44px !important;
    position: absolute;
    top: 0;
    left: 18px;
}

.global-sidebar .side-menu .md-button span.menu-text {
    font-size: 13px;
    padding: 0 10px 0 0 !important;
    line-height: 44px;
    margin-left: 25px;
    transition: opacity 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-sidebar .side-menu a.md-button {
    padding: 0 18px;
    position: relative;
}

/* --- Toggle (dropdown) Items --- */
.global-sidebar .side-menu .md-button-toggle {
    position: relative;
}

.global-sidebar .toggle-icon {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease-in-out;
}

.global-sidebar .toggle-icon.toggled {
    transform: translateY(-50%) rotate(180deg);
}

.global-sidebar .menu-toggle-list {
    background: #282c37;
    overflow: hidden;
    position: relative;
    z-index: 1;
    transition: 0.75s cubic-bezier(0.35, 0, 0.25, 1);
    transition-property: max-height;
}

.global-sidebar .menu-toggle-list a.md-button,
.global-sidebar .menu-toggle-list .md-button {
    display: block;
    padding: 0 16px 0 48px;
    text-transform: none;
    font-weight: 400;
    font-size: 13px;
}

.global-sidebar .menu-toggle-list .md-button span.inset .material-icons {
    position: relative;
    left: auto;
    top: auto;
    line-height: 44px !important;
}

.global-sidebar .menu-toggle-list .md-button span.menu-text {
    font-weight: 400;
    font-size: 13px;
    white-space: nowrap;
}

/* --- Parent list items --- */
.global-sidebar .side-menu .parent-list-item {
    display: block;
    position: relative;
}

.global-sidebar .side-menu .parent-list-item menu-link {
    display: block;
}

.global-sidebar .side-menu .parent-list-item menu-toggle {
    display: block;
    position: relative;
}

.global-sidebar.sidebar-collapsed .side-menu .parent-list-item menu-toggle {
    overflow: visible;
}

/* --- Highlight icon when its popover is open --- */
.global-sidebar.sidebar-collapsed .parent-list-item.popout-active > menu-toggle > .md-button,
.global-sidebar.sidebar-collapsed .parent-list-item.popout-active > menu-link > .md-button {
    background: rgba(3, 155, 229, 0.15);
    color: rgba(255, 255, 255, 0.95);
}

/* ============================================
   Expanded State - Hide popout submenus
   ============================================ */

.global-sidebar .popout-submenu {
    display: none;
}

/* ============================================
   Collapsed State - Light theme, icons only
   ============================================ */

.global-sidebar.sidebar-collapsed .side-menu .md-button {
    padding: 0;
    text-align: center;
    justify-content: center;
    overflow: visible;
}

.global-sidebar.sidebar-collapsed .side-menu .md-button span.menu-text {
    display: none;
}

.global-sidebar.sidebar-collapsed .side-menu .md-button span.inset .material-icons {
    position: relative;
    left: auto;
    top: auto;
    display: block;
    margin: 0 auto;
    text-align: center;
    line-height: 44px !important;
}

.global-sidebar.sidebar-collapsed .toggle-icon {
    display: none;
}

/* Hide inline dropdown in collapsed state */
.global-sidebar.sidebar-collapsed .menu-toggle-list {
    display: none !important;
}

/* ============================================
   Collapsed State - Popout Submenus
   (hover to show, click to pin/unpin)
   ============================================ */

.global-sidebar.sidebar-collapsed .parent-list-item {
    position: relative;
}

/* Popout show/hide is controlled entirely by JS (moved to body + positioned) */

.popout-submenu {
    display: none;
    position: fixed;
    left: 60px; /* overridden by JS on mouseenter */
    min-width: 180px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 200;
    border-radius: 6px;
    padding: 4px 0;
}

.popout-submenu::-webkit-scrollbar {
    width: 4px;
}

.popout-submenu::-webkit-scrollbar-track {
    background: transparent;
}

.popout-submenu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.popout-submenu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Invisible bridge so mouse doesn't lose hover when moving from icon to popout */
.popout-submenu::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    width: 20px;
    height: 100%;
}

/* --- Header: label style, non-interactive --- */
.popout-submenu .popout-header {
    padding: 6px 12px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(0, 0, 0, 0.35);
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

/* --- Sub-items list with vertical line --- */
.popout-submenu ul {
    list-style: none;
    padding: 0;
    margin: 0 0 2px 12px;
    border-left: 2px solid rgba(0, 0, 0, 0.08);
}

.popout-submenu li {
    display: block;
}

/* --- Compact sub-item buttons --- */
.popout-submenu .md-button,
.popout-submenu a.md-button {
    padding: 0 12px 0 10px !important;
    text-align: left !important;
    white-space: nowrap;
    color: rgba(0, 0, 0, 0.7) !important;
    background: transparent !important;
    width: 100%;
    line-height: 28px;
    max-height: 28px;
    min-height: 28px;
    font-size: 12px;
    margin: 0 !important;
    border-radius: 0 !important;
    text-transform: none !important;
}

.popout-submenu .md-button span.menu-text,
.popout-submenu a.md-button span.menu-text {
    display: inline !important;
    margin-left: 0;
    color: rgba(0, 0, 0, 0.7);
    font-size: 12px;
}

/* --- Hover state --- */
.popout-submenu .md-button:hover,
.popout-submenu a.md-button:hover {
    color: #039be5 !important;
    background: rgba(3, 155, 229, 0.05) !important;
}

.popout-submenu .md-button:hover span.menu-text,
.popout-submenu a.md-button:hover span.menu-text {
    color: #039be5;
}

/* --- Active sub-navigation item --- */
.popout-submenu .md-button.active-menu,
.popout-submenu a.md-button.active-menu {
    color: #039be5 !important;
    background: rgba(3, 155, 229, 0.05) !important;
}

.popout-submenu .md-button.active-menu span.menu-text,
.popout-submenu a.md-button.active-menu span.menu-text {
    color: #039be5 !important;
    font-weight: 500;
}

/* Vertical line turns blue at the active item */
.popout-submenu li:has(> .md-button.active-menu) {
    border-left: 2px solid #039be5;
    margin-left: -2px;
}

/* ============================================
   Collapsed State - Tooltip for link items
   ============================================ */

/* Hidden by default */
.link-tooltip {
    display: none;
    position: fixed;
    left: 60px;
    background: #fff;
    color: rgba(0, 0, 0, 0.75);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

/* Tooltip show/hide is controlled entirely by JS (inline display style) */

/* Also show for sub-items inside popout (keep hidden) */
.popout-submenu .link-tooltip {
    display: none !important;
}

/* ============================================
   Disabled menu items
   ============================================ */

.global-sidebar .side-menu .md-button:disabled:hover,
.global-sidebar .side-menu a.md-button:disabled:hover {
    color: pink;
    background: navy;
}

.global-sidebar i.section-pseudo-element--blocked {
    margin: 0 10px;
    color: red;
}

/* ============================================
   Layout adjustment - main content
   ============================================ */

.nirad-app-layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.nirad-app-layout .nirad-main-content {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

/* --- Override fixed-position header banner padding for sidebar --- */
.nirad-app-layout .header-banner-holder {
    padding-left: 240px;
    transition: padding-left 0.25s ease;
}

.nirad-app-layout.sidebar-is-collapsed .header-banner-holder {
    padding-left: 60px;
}

/* ============================================
   Hamburger toggle button - hidden on large screens
   ============================================ */

.sidebar-mobile-toggle {
    display: none !important;
}

/* ============================================
   Responsive - overlay sidebar below 1280px
   ============================================ */

@media (max-width: 1279px) {
    .sidebar-mobile-toggle {
        display: inline-block !important;
    }

    .global-sidebar {
        position: fixed;
        left: -240px;
        transition: left 0.25s ease;
        width: 240px;
        min-width: 240px;
    }

    /* When mobile open: always show expanded (not collapsed) */
    .global-sidebar.sidebar-mobile-open {
        left: 0;
        width: 240px;
        min-width: 240px;
    }

    /* Override collapsed styling on mobile — still hide off-screen */
    .global-sidebar.sidebar-collapsed {
        left: -240px;
        width: 240px;
        min-width: 240px;
    }

    .global-sidebar.sidebar-collapsed.sidebar-mobile-open {
        left: 0;
    }

    /* Hide collapse text, show full menu */
    .global-sidebar.sidebar-mobile-open .side-menu .md-button span.menu-text {
        display: inline !important;
    }

    .global-sidebar.sidebar-mobile-open .sidebar-logo-full {
        display: block !important;
    }

    .global-sidebar.sidebar-mobile-open .sidebar-logo-icon {
        display: none !important;
    }

    .global-sidebar.sidebar-mobile-open .toggle-icon {
        display: block !important;
    }

    .global-sidebar.sidebar-mobile-open .side-menu .md-button {
        text-align: left !important;
        padding: 0 10px 0 18px !important;
    }

    .global-sidebar.sidebar-mobile-open .side-menu .md-button span.inset .material-icons {
        position: absolute !important;
        left: 18px !important;
        top: 0 !important;
        margin: 0 !important;
    }

    /* Hide edge toggle on mobile */
    .global-sidebar .sidebar-edge-toggle {
        display: none;
    }

    /* Header banner: no sidebar padding on mobile */
    .nirad-app-layout .header-banner-holder {
        padding-left: 0 !important;
    }

    /* Mobile overlay backdrop */
    .sidebar-mobile-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 59;
    }

    .sidebar-mobile-backdrop.active {
        display: block;
    }
}

/* ============================================
   Reports Sub-Group Labels (flat, no nesting)
   ============================================ */

.global-sidebar .menu-sub-group {
    padding: 0;
}

.global-sidebar .menu-sub-group-toggle {
    display: flex;
    align-items: center;
    padding: 8px 8px 8px 24px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    border-radius: 4px;
    margin: 2px 4px;
    overflow: hidden;
}

.global-sidebar .menu-sub-group-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.global-sidebar .menu-sub-group-icon {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.5);
    margin-right: 10px;
    flex-shrink: 0;
}

.global-sidebar .menu-sub-group-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-sidebar .menu-sub-group-arrow {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.35);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.global-sidebar .menu-sub-group-arrow.rotated {
    transform: rotate(180deg);
}

.global-sidebar .menu-sub-group-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.global-sidebar .menu-sub-group-list a.md-button,
.global-sidebar .menu-sub-group-list .md-button {
    padding-left: 56px;
}

/* Popout nested sub-header */
.popout-submenu .popout-sub-header {
    padding: 8px 12px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(0, 0, 0, 0.45);
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: 4px;
}

.popout-submenu .popout-sub-header:first-child {
    border-top: none;
    margin-top: 0;
}
