/* Note: Main CSS variables are now defined in css/settings.css 
   This file only contains sidebar-specific variables */
:root {
    --paragraph-font-size: 0.85rem;
    --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;
    /* Sidebar volta a rolar por completo */
    overflow-y: auto;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s, background 0.3s, color 0.3s;
    /* Custom scrollbar styling */
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.4) transparent !important;
}

/* Custom scrollbar para Webkit browsers (Chrome, Safari, Edge) */
.sidebar::-webkit-scrollbar {
    width: 8px !important;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35) !important;
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.55) !important;
    background-clip: padding-box;
}

.sidebar::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.7) !important;
    background-clip: padding-box;
}

.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;
    /* Alinhar peso da fonte com o dashboard */
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255,255,255,0.92);
    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);
    /* Alinhar com o dashboard: texto normal por omissão */
    font-weight: 400;
    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);
    /* Realçar apenas o item activo, tal como no dashboard */
    font-weight: 500;
}

.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;
  }
}

/* Nav header container for header + toggle button */
.nav-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 18px;
    padding-right: 8px;
    margin-top: 12px;
    margin-bottom: 4px;
}

/* Nav header styles */
.nav-header {
    cursor: pointer;
    user-select: none;
    transition: color 0.3s;
    font-size: var(--paragraph-font-size);
    font-weight: 600;
    color: rgba(255,255,255,0.96);
    flex: 1;
}

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

/* Submenu toggle button */
.submenu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s ease;
    border-radius: 4px;
}

.submenu-toggle:hover {
    color: rgba(255, 255, 255, 1);
    background-color: rgba(255, 255, 255, 0.12);
}

.submenu-toggle i {
    font-size: 0.875rem;
    transition: transform 0.3s ease;
}

/* Rotate icon when section is active */
.nav-section.active > .nav-header-container .submenu-toggle i {
    transform: rotate(90deg);
}

/* Sidebar submenu expand/collapse - with smooth animation */
.submenu {
    margin: 0;
    padding-left: 24px;
    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;
}

/* Legacy support for old .has-submenu class on headers */
.nav-header.has-submenu {
    cursor: pointer;
    position: relative;
    padding-right: 24px;
    user-select: none;
    transition: color 0.8s;
    padding-left: 18px;
    margin-top: 12px;
    margin-bottom: 4px;
    font-size: var(--paragraph-font-size);
    font-weight: 600;
    color: rgba(255,255,255,0.96);
}

.nav-header.has-submenu + .submenu {
    margin-top: 4px;
    margin-bottom: 8px;
}

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

.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 */
}

/* Reduce font size for submenu items */
.submenu .nav-item {
    font-size: 0.78rem;
}

/* 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; }

/* Sidebar states for permission visibility helper */
.nav-item.menu-hidden {
    display: none !important;
}

.nav-item.menu-locked {
    opacity: 0.62;
    cursor: not-allowed !important;
    position: relative;
    pointer-events: auto;
}

.nav-item.menu-locked:hover {
    background-color: rgba(255,255,255,0.08);
}

.nav-item.menu-locked .menu-lock-icon {
    margin-left: auto;
    margin-right: 14px;
    color: #f2b648;
    font-size: 0.82rem;
}

[data-theme="dark"] .sidebar {
    background: var(--sidebar-bg-dark);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--sidebar-text-dark);
    scrollbar-color: rgba(96, 165, 250, 0.4) transparent !important;
}

/* Custom scrollbar para modo escuro */
[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.35) !important;
}

[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.55) !important;
}

[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb:active {
    background: rgba(96, 165, 250, 0.7) !important;
}
[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);
}
[data-theme="dark"] .submenu-toggle {
    color: var(--sidebar-icon-dark);
}
[data-theme="dark"] .submenu-toggle:hover {
    color: var(--sidebar-text-dark);
    background-color: rgba(96,165,250,0.12);
}
[data-theme="dark"] .nav-header {
    color: var(--sidebar-text-dark);
}
[data-theme="dark"] .nav-header:hover {
    color: #fff;
}

/* 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;
}
html:not([data-theme="dark"]) .sidebar .submenu-toggle {
    color: var(--sidebar-text-light);
}
html:not([data-theme="dark"]) .sidebar .submenu-toggle i {
    color: var(--sidebar-icon-light);
}
