/**
 * Sidebar CSS
 * Contains styles for the sidebar, navigation links, and sidebar components
 */

/* Sidebar vars - referencing layout.css variables */
:root {
    /* Using the same variable names for consistency, but keep sidebar-specific vars here too */
    --sidebar-background: var(--menu-bg, #212529);
    --sidebar-text-color: rgba(255, 255, 255, 0.7);
    --sidebar-link-hover: rgba(255, 255, 255, 0.1);
    --sidebar-divider: rgba(255, 255, 255, 0.1);
}

/* Sidebar basic structure */
.app-sidebar {
    position: fixed;
    width: var(--sidebar-width, 280px); /* Using variable with fallback */
    height: 100vh;
    background-color: var(--sidebar-bg, #fff);
    z-index: 1051; /* Increased z-index to be higher than header (1010) */
    transition: transform 0.3s ease;
    top: 0;
    left: 0;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

/* Sidebar toggle functionality */
html[data-toggled="close"] .app-sidebar {
    transform: translateX(-280px) !important;
    transition: transform 0.3s ease;
}

html[data-toggled="open"] .app-sidebar {
    transform: translateX(0) !important;
    transition: transform 0.3s ease;
}

/* Sidebar header with logo */
.main-sidebar-header {
    background-color: var(--sidebar-background);
    border-right: 1px solid var(--sidebar-divider);
    height: var(--header-height, 60px);
    min-height: var(--header-height, 60px);
    max-height: var(--header-height, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Extremely high z-index to ensure it's on top of everything */
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width, 240px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    transform: none !important; /* Force no transform to override any inline styles */
    overflow: visible !important;
}

/* Style any logo class in the sidebar header */
.main-sidebar-header a,
.main-sidebar-header .header-logo,
.main-sidebar-header .sidebar-logo {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10000 !important; /* Even higher z-index for logo */
    position: relative !important;
    overflow: visible !important;
}

.main-sidebar-header img,
.main-sidebar-header .header-logo img,
.main-sidebar-header .sidebar-logo img {
    opacity: 1 !important;
    visibility: visible !important;
    height: 32px !important;
    width: auto !important;
    object-fit: contain !important;
    max-width: none !important;
    z-index: 10001 !important;
    position: relative !important;
}

/* Sidebar logo styles */
.sidebar-logo {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10000; /* Even higher z-index for logo */
}

.sidebar-logo img {
    opacity: 1 !important;
    visibility: visible !important;
    height: 32px;
    width: auto;
    object-fit: contain;
    max-width: none;
    z-index: 10000; /* Even higher z-index for logo image */
}

/* Sidebar navigation */
.main-menu {
    padding: 0; /* Remove extra padding */
    margin: 0;
    height: calc(100% - 60px); /* Adjust for header */
    overflow-y: auto;
    overflow-x: hidden;
}

.main-sidebar {
    padding-top: var(--header-height);
    height: 100%;
    transition: transform 0.3s ease;
    margin-top: 0; /* Ensure no extra margin at top */
    display: flex;
    flex-direction: column;
}

/* Sidebar menu positioning */
.menu-content {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

/* Fix spacing between menu sections */
.menu-label {
    color: var(--sidebar-text-color);
    opacity: 0.7;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 20px 5px; /* Reduced bottom padding */
    margin-top: 5px; /* Reduced top margin */
}

.slide {
    margin-bottom: 2px; /* Reduced margin */
}

.side-menu__item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--sidebar-text-color);
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 5px;
    margin: 0 10px;
}

.side-menu__item:hover {
    background-color: var(--sidebar-link-hover);
    color: #fff;
}

.side-menu__item.active {
    background-color: rgba(var(--primary-rgb, 13, 110, 253), 0.2);
    color: var(--primary-color, #0d6efd);
}

.side-menu__icon {
    margin-right: 10px;
    font-size: 1.25rem;
}

.side-menu__label {
    flex: 1;
}

/* Light mode sidebar */
[data-theme-mode="light"] .app-sidebar,
[data-theme-mode="light"] .main-sidebar-header,
.light-mode .app-sidebar,
.light-mode .main-sidebar-header {
    background-color: #f8f9fa;
    color: #343a40;
    border-right-color: rgba(0, 0, 0, 0.1);
}

[data-theme-mode="light"] .side-menu__item,
.light-mode .side-menu__item {
    color: rgba(0, 0, 0, 0.7);
}

[data-theme-mode="light"] .side-menu__item:hover,
.light-mode .side-menu__item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000;
}

[data-theme-mode="light"] .side-menu__item.active,
.light-mode .side-menu__item.active {
    background-color: rgba(var(--primary-rgb, 13, 110, 253), 0.1);
    color: var(--primary-color, #0d6efd);
}

[data-theme-mode="light"] .menu-label,
.light-mode .menu-label {
    color: rgba(0, 0, 0, 0.5);
}

/* Improve sidebar contrast in dark mode */
[data-theme-mode="dark"] .side-menu__item,
.dark-mode .side-menu__item {
    color: rgba(255, 255, 255, 0.8);
}

[data-theme-mode="dark"] .side-menu__item:hover, 
.dark-mode .side-menu__item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

[data-theme-mode="dark"] .side-menu__item.active,
.dark-mode .side-menu__item.active {
    background-color: rgba(var(--primary-rgb, 13, 110, 253), 0.3);
    color: #fff;
}

/* Mobile sidebar */
@media (max-width: 992px) {
    .app-sidebar, 
    .main-sidebar, 
    .main-sidebar-header {
        z-index: 1050;
    }
    
    /* Add overlay when sidebar is open on mobile */
    [data-toggled="open"]::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
} 