/* Note: Main CSS variables are now defined in css/settings.css 
   This file only contains sidebar-specific variables */
:root {
    --paragraph-font-size: 0.90rem;
    --sidebar-bg-light: linear-gradient(195deg, #007ec7, #02204e);
    --sidebar-bg-dark: linear-gradient(195deg, #10131a 80%, rgba(38, 99, 235, 0.55) 100%);
    --sidebar-text-light: #fff;
    --sidebar-text-dark: #e5e7eb;
    --sidebar-icon-light: #fff;
    --sidebar-icon-dark: #60a5fa;
}

.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg-light);
    color: var(--sidebar-text-light);
    padding: 20px 0;
    box-sizing: border-box;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s, background 0.3s, color 0.3s;
}

.sidebar .logo {
    padding: 0 20px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    color: var(--sidebar-text-light);
}

.sidebar .logo i {
    color: var(--sidebar-icon-light);
    font-size: 24px;
    margin-right: 10px;
}

.sidebar .logo span {
    font-size: var(--heading-4-subheading-font-size);
    font-weight: var(--heading-4-subheading-font-weight);
    color: var(--sidebar-text-light);
}

.sidebar .nav-menu {
    padding: 0;
    margin: 0;
}

.nav-section {
    margin: 0;
    padding: 0;
}

.nav-section h3 {
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--text-light);
    margin: 0;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    box-sizing: border-box;
    padding: 0 0 0 24px; /* Only left padding for icon/text alignment */
    color: var(--sidebar-text-light);
    text-decoration: none;
    background: none;
    border: none;
    transition: background 0.2s, color 0.2s;
    font-size: var(--paragraph-font-size);
    font-weight: var(--paragraph-font-weight);
    margin: 0;
    text-transform: uppercase;
}

.nav-item,
.nav-item:visited {
    background: none;
    color: var(--sidebar-text-light);
    
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255,255,255,0.08);
    color: var(--primary-color);
}

.nav-item i {
    margin-right: 10px;
    width: 20px;
    color: var(--sidebar-icon-light);
    align-items: center;
}

/* Adjust main content area */
.content-wrapper {
    margin-left: 250px;
    padding: 20px;
    transition: margin-left 0.3s;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Hamburger menu button styles */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 1101;
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.0);
    border: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    padding: 0;
}
.sidebar-toggle span {
    display: block;
    width: 28px;
    height: 4px;
    margin: 4px 0;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s;
}

/* Sidebar overlay styles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.3);
    z-index: 1200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    /* Add blur effect to everything behind overlay */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Responsive styles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 60px; /* height of the topbar */
        width: 250px;
        height: calc(100vh - 60px);
        z-index: 1201;
        background: var(--primary-dark);
        transform: translateX(-100%);
        transition: transform 0.3s;
        box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
        position: fixed;
        top: 10px;
        left: 18px;
        z-index: 1300;
    }
    .main-content {
        margin-left: 0;
        width: 100vw;
        height: 100vh;
        overflow-y: auto;
    }
    body.sidebar-open .main-content,
    body.sidebar-open .content-wrapper {
        filter: none;
        pointer-events: auto;
        user-select: auto;
        transition: filter 0.3s;
    }
    .sidebar-overlay {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100vw;
        height: calc(100vh - 60px);
        z-index: 1200;
        display: block;
    }
    .content-wrapper {
        margin-left: 0;
    }
    .main-content {
        margin-left: 0;
        width: 100vw;
        height: 100vh;
    }
    /* Remove forced expansion of all submenus on mobile */
    /* .sidebar .submenu {
        max-height: 1000px !important;
        opacity: 1 !important;
        padding-top: 8px;
        padding-bottom: 8px;
        margin-bottom: 8px;
        overflow: visible;
    } */
}

@media (max-width: 768px) {
  .dashboard-container.sidebar-active .sidebar {
    transform: translateX(0);
    z-index: 1201;
  }
  .dashboard-container.sidebar-active .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  /* Remove or reduce blur/brightness on main content when sidebar is open */
  .dashboard-container.sidebar-active .main-content,
  .dashboard-container.sidebar-active .content-wrapper {
    /* Subtle effect or none */
    filter: none;
    pointer-events: auto;
    user-select: auto;
    transition: filter 0.3s;
  }
}

/* Sidebar submenu expand/collapse - with smooth animation */
.submenu {
    margin: 0;
    padding-left: 24px; /* match .nav-header.has-submenu left spacing */
    border-left: none;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    display: block;
    padding-top: 0;
    padding-bottom: 0;
    transition:
        max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding-top 0.3s,
        padding-bottom 0.3s;
    will-change: max-height, opacity, padding-top, padding-bottom;
}

.nav-section.active > .submenu {
    max-height: 1000px; /* Large enough for most submenus */
    opacity: 1;
    padding-top: 8px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    transition:
        max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding-top 0.3s,
        padding-bottom 0.3s;
}

.nav-header.has-submenu {
    cursor: pointer;
    position: relative;
    padding-right: 24px;
    user-select: none;
    transition: color 0.8s;
    /* Add left spacing and vertical spacing */
    padding-left: 18px;
    margin-top: 12px;
    margin-bottom: 4px;
    /* Match submenu font-size (0.9rem from styles.css .nav-item) */
    font-size: var(--paragraph-font-size);
    font-weight: 600;
    color: rgba(255,255,255,0.85);
}

.nav-header.has-submenu + .submenu {
    /* Add vertical spacing between submenus */
    margin-top: 4px;
    margin-bottom: 8px;
}

.nav-header.has-submenu:hover,
.nav-header.has-submenu:focus {
    color: rgba(255, 255, 255, 0.7);
}

.nav-header.has-submenu::after {
    content: '\f078'; /* Font Awesome chevron-down */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.3s;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

.nav-section.active > .nav-header.has-submenu::after {
    transform: translateY(-50%) rotate(-180deg); /* chevron-up */
}

/* Optional: style nested submenu with animation */
.submenu .submenu {
    border-left: 2px dashed var(--grey-700);
/*    margin-left: 10px;
    padding-left: 12px;*/
    transition:
        border-color 0.3s,
        margin-left 0.3s,
        padding-left 0.3s;
}

/* Hide admin-only sidebar links by default; shown by JS if user is admin */
.admin-only { display: none; }
.admin-only.admin-visible { display: flex; }

/* Dark mode pill toggle styles */
.darkmode-pill-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 4px;
    gap: 2px;
    width: 60px;
    height: 32px;
    position: relative;
}
.darkmode-btn {
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    z-index: 2;
    transition: background 0.2s;
    padding: 0;
}
.darkmode-btn svg {
    display: block;
    margin: 0;
}
.darkmode-pill-highlight {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1746a2;
    transition: left 0.25s cubic-bezier(.4,1.3,.6,1), transform 0.2s;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(37,99,235,0.15);
}
.darkmode-pill-toggle.dark .darkmode-pill-highlight {
    left: 32px;
}

#sidebar-darkmode-toggle-container {
  position: absolute;
  bottom: 10px; /* Restore original desktop position */
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 10;
}

@media (max-width: 768px) {
  #sidebar-darkmode-toggle-container {
    bottom: 80px !important; /* Move much higher on mobile and enforce */
  }
}

[data-theme="dark"] .sidebar {
    background: var(--sidebar-bg-dark);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--sidebar-text-dark);
}
[data-theme="dark"] .sidebar .logo,
[data-theme="dark"] .sidebar .logo i,
[data-theme="dark"] .sidebar .logo span {
    color: var(--sidebar-text-dark);
}
[data-theme="dark"] .nav-section h3 {
    color: var(--sidebar-text-dark);
}
[data-theme="dark"] .nav-item,
[data-theme="dark"] .nav-item:visited {
    color: var(--sidebar-text-dark);
}
[data-theme="dark"] .nav-item:hover,
[data-theme="dark"] .nav-item.active {
    background-color: rgba(96,165,250,0.12);
    color: var(--sidebar-icon-dark);
}
[data-theme="dark"] .nav-item i {
    color: var(--sidebar-icon-dark);
}

/* Force sidebar text and icon color to white in light mode, overriding other CSS */
html:not([data-theme="dark"]) .sidebar .nav-item,
html:not([data-theme="dark"]) .sidebar .nav-item:visited {
    color: var(--sidebar-text-light) !important;
}
html:not([data-theme="dark"]) .sidebar .nav-item i {
    color: var(--sidebar-icon-light) !important;
}
