/* Sidebar styles - shared across portal pages */
:root {
    --sidebar-bg: #000000;
}

.sidebar {
    --sidebar-bg: #000000;
    background-color: var(--sidebar-bg);
    color: #ffffff;
    height: 100vh;
    width: 250px;
    transition: width 0.3s;
    overflow: hidden !important; /* Prevent layout shift when Utilities/Libraries expand */
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    contain: layout; /* Isolate sidebar from main content layout changes */
}

/* No bullets anywhere in sidebar */
.sidebar ul,
.sidebar .nav,
.sidebar li {
    list-style: none;
}

.sidebar > ul.nav {
    padding-left: 0;
    margin-left: 0;
}

/* Top: logo and user-info fixed */
.sidebar .logo-container,
.sidebar .user-info {
    flex-shrink: 0;
}

/* User info block - clean, consistent */
.sidebar .user-info {
    padding: 10px 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.9em;
}

.sidebar .user-info .nav-item {
    padding: 2px 0;
    color: #ffffff;
}

.sidebar .user-info .username {
    color: #4ade80;
}

.sidebar .user-info .permissions {
    color: #fbbf24;
    font-size: 0.85em;
}

.logo-container {
    padding: 10px;
    overflow: hidden;
    background-color: var(--sidebar-bg) !important;
}

.sidebar .logo {
    width: 150px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    filter: invert(1);
    mix-blend-mode: screen; /* Black parts of inverted logo blend with sidebar background */
}

/* Middle: nav takes fixed space - does NOT grow when submenus expand (prevents layout shift) */
.sidebar > .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

/* All submenus hidden by default; openSubmenuForCurrentPage shows only the matching one */
.sidebar .submenu,
#librarySubmenu,
#utilitiesSubmenu,
#reportsSubmenu,
#adminSubmenu,
#viewerSubmenu {
    display: none;
    max-height: 40vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

/* Consistent submenu styling - no bullets, uniform indent */
.sidebar .submenu {
    list-style: none;
    padding-left: 16px;
    margin-bottom: 0;
    margin-top: 4px;
}

.sidebar .submenu .nav-item {
    padding: 4px 0;
}

/* Admin submenu: tighter spacing between dropdown items */
.sidebar #adminSubmenu .nav-item {
    padding: 0;
}
.sidebar #adminSubmenu .nav-item .nav-link {
    padding: 4px 0;
    line-height: 1.2;
    font-size: 0.82em;
}

/* Libraries submenu: same spacing and smaller font */
.sidebar #librarySubmenu .nav-item {
    padding: 0;
}
.sidebar #librarySubmenu .nav-item .nav-link {
    padding: 4px 0;
    line-height: 1.2;
    font-size: 0.82em;
}

/* Nested submenu (e.g. Viewer under Utilities) - same style, extra indent */
.sidebar .submenu .submenu {
    padding-left: 16px;
    margin-top: 4px;
    margin-bottom: 4px;
}

/* Active page link - subtle highlight */
.sidebar .nav-link.active {
    color: #add8e6 !important;
    font-weight: 500;
}

/* Bottom: fixed - logo area matches sidebar, well above bottom edge */
.sidebar .mt-auto {
    flex-shrink: 0;
    background-color: var(--sidebar-bg) !important;
    padding-bottom: 28px !important;
    padding-top: 12px !important;
}

.sidebar .cirrius-logo-wrap {
    background-color: var(--sidebar-bg); /* #2d2d2d - match sidebar */
    display: inline-block;
}

.sidebar .cirrius-logo {
    width: 234px; /* 20% wider than 195px; transparent bg matches sidebar */
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    /* No filter: new logo (cirrius2.png) is dark-mode ready with blue cloud, white/red text */
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.hidden {
    width: 0;
    overflow: visible !important; /* Toggle button must stay visible when collapsed */
}

.sidebar.hidden .user-info,
.sidebar.hidden .logo-container,
.sidebar.hidden .nav,
.sidebar.hidden .mt-auto {
    display: none;
}

.sidebar .nav-link:active,
.sidebar .nav-link:focus {
    color: #ffffff !important;
    background-color: transparent !important;
}

.sidebar .nav-link {
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.sidebar .nav-link:hover {
    color: #add8e6;
}

.main-bg.sidebar-hidden {
    margin-left: 0;
}

/* Toggle button - collapse/expand sidebar (shared so viewer pages have it) */
.btn-toggle {
    position: fixed;
    left: 218px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    background-color: var(--sidebar-bg);
    border: none;
    padding: 10px 8px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: left 0.3s ease, background-color 0.3s ease;
}

.sidebar.hidden ~ * .btn-toggle,
.sidebar.hidden .btn-toggle {
    left: 5px;
}

.btn-toggle:hover {
    background-color: #404040;
}

.btn-toggle .arrow {
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3), 2px 2px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    display: inline-block;
}

.btn-toggle .arrow::before {
    content: '<';
}

.sidebar.hidden .btn-toggle .arrow::before {
    content: '>';
}
