:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-mobile-width: 260px;
    --bg-page: #E9E4DF;
    --panel-dark: #2A211E;
    --panel-dark-2: #1B1412;
    --panel-white: #FFFFFF;
    --text-white: #FFFFFF;
    --text-muted: #CFC6C0;
    --text-dark: #1F2530;
    --text-soft: #8C8681;
    --border: #E8E4E0;
    --button-gradient: linear-gradient(90deg, #FF7A18 0%, #FF4D8D 100%);
    --accent-orange: #FF7A18;
    --accent-pink: #FF4D8D;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body.dashboard-page,
body.permissions-page {
    min-height: 100vh;
    overflow: hidden;
}

.dashboard-shell,
.permissions-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.permissions-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
    background: transparent;
}

.permissions-shell.sidebar-collapsed .permissions-main {
    /* Flex automatically handles the width change */
}

.permissions-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* =======================================
   DESKTOP SIDEBAR - INLINE LAYOUT
   ======================================= */

.dashboard-sidebar {
    background: linear-gradient(180deg, rgba(42, 33, 30, 0.96), rgba(27, 20, 18, 0.98));
    color: var(--text-white);
    font-family: inherit;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100vh;
    overflow: hidden;
    flex: 0 0 var(--sidebar-width);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 12px 0 48px rgba(14, 10, 8, 0.12);
    transition: width 0.28s ease, min-width 0.28s ease, max-width 0.28s ease;
    z-index: 1050;
}

.dashboard-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
    flex: 0 0 var(--sidebar-collapsed-width);
}

.sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 2000;
    padding: 0.75rem 0.75rem;
}

.brand-icon {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-orange);
    font-weight: 800;
    letter-spacing: 0.15em;
    font-size: 12px;
}

.brand-title span {
    display: block;
    font-size: 13px;
    font-weight: 700;
}

.brand-title small {
    display: block;
    color: rgba(255, 255, 255, 0.64);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 9px;
    font-weight: 600;
}

.sidebar-toggle {
    color: rgba(255, 255, 255, 0.72);
    background: transparent;
    border: none;
    position: relative;
    z-index: 2000;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sidebar-toggle:hover {
    color: var(--accent-orange);
}

.sidebar-toggle .material-symbols-outlined {
    font-size: 20px;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    min-width: 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-white) !important;
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    min-height: 36px;
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.dashboard-sidebar .section-toggle {
    color: var(--text-white) !important;
}

.dashboard-sidebar .nav-text,
.dashboard-sidebar .section-title {
    color: var(--text-white) !important;
    display: inline-block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 56px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-sidebar .section-toggle {
    min-width: 0;
}

.nav-link {
    position: relative;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-orange) !important;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-orange) !important;
    font-weight: var(--font-weight-semibold);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 4px;
    background: var(--gradient-primary);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.nav-link .material-symbols-outlined {
    font-size: 1.35rem;
}

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-feature-settings: 'liga';
    word-wrap: normal;
}

.nav-link .material-symbols-outlined,
.section-toggle .material-symbols-outlined,
.nav-dropdown .nav-link .material-symbols-outlined {
    width: 20px;
    min-width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-section-dropdown {
    margin: 0;
}

.section-toggle {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    color: rgba(255, 255, 255, 0.82);
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease;
    border: none;
    background: transparent;
    width: 100%;
    justify-content: space-between;
    font-weight: 500;
    font-size: 13px;
    text-align: left;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    min-height: 36px;
}

.section-toggle:hover,
.section-toggle.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-white);
}

.section-title {
    flex: 1;
    text-align: left;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-chevron {
    font-size: 18px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.section-toggle[aria-expanded="false"] .section-chevron {
    transform: rotate(-90deg);
}

.section-toggle[aria-expanded="true"] .section-chevron {
    transform: rotate(0deg);
}

.sidebar-section-dropdown .collapse {
    margin-top: 0.25rem;
}

.sidebar-section-dropdown .collapse .nav-link {
    padding-left: 1.9rem;
    font-size: 12px;
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-sidebar.collapsed .nav-text,
.dashboard-sidebar.collapsed .section-title,
.dashboard-sidebar.collapsed .section-chevron {
    display: none;
}

.dashboard-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.65rem 0;
    gap: 0;
    width: 100%;
}

.dashboard-sidebar.collapsed .section-toggle {
    justify-content: center;
    padding: 0.75rem 0;
    width: 100%;
}

.dashboard-sidebar.collapsed .brand-title {
    display: none;
}

.dashboard-sidebar.collapsed .brand-icon {
    justify-content: center;
}

.dashboard-sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.dashboard-sidebar.collapsed .collapse {
    display: none;
}

.sidebar-backdrop {
    display: none;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    transition: opacity 0.24s ease, visibility 0.24s ease;
    z-index: 1040;
}

.sidebar-backdrop.show {
    display: block;
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

@media (max-width: 991px) {

    /* Switch to overlay drawer mode on mobile */
    .dashboard-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: var(--sidebar-mobile-width);
        min-width: var(--sidebar-mobile-width);
        max-width: var(--sidebar-mobile-width);
        transform: translateX(-100%);
        transition: transform 0.28s ease, width 0.28s ease;
        z-index: 1050;
    }

    .dashboard-sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Desktop collapse state should NOT be visible on mobile drawer */
    .dashboard-sidebar.collapsed {
        width: var(--sidebar-mobile-width);
        min-width: var(--sidebar-mobile-width);
        max-width: var(--sidebar-mobile-width);
    }

    .sidebar-backdrop {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        pointer-events: all;
    }

    .sidebar-backdrop.show {
        display: block !important;
    }

    .dashboard-main,
    .permissions-main {
        width: 100%;
        margin-left: 0;
        min-width: 0;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

.sidebar-section-dropdown .collapse .nav-link {
    padding-left: 2.5rem;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-section-dropdown .collapse .nav-link .material-symbols-outlined {
    font-size: 1.2rem;
}

.nav-dropdown>.nav-link {
    justify-content: space-between;
    width: 100%;
    flex: 0 1 auto;
    min-width: 0;
}

.nav-dropdown .dropdown-icon {
    font-size: 1rem;
}

.nav-dropdown .collapse .nav-link {
    padding-left: 2.5rem;
    font-size: 12px;
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-dropdown .collapse .nav-link .material-symbols-outlined {
    font-size: 1.2rem;
}

.nav-dropdown .collapse {
    margin-top: 0.25rem;
}

.nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity 0.24s ease, max-width 0.24s ease;
    max-width: calc(100% - 56px);
}

.dashboard-sidebar.collapsed .nav-text,
.dashboard-sidebar.collapsed .section-title {
    opacity: 0;
    max-width: 0;
}

.dashboard-sidebar.collapsed .section-toggle {
    justify-content: center;
}

.dashboard-sidebar.collapsed .section-chevron,
.dashboard-sidebar.collapsed .dropdown-icon {
    display: none;
}

.dashboard-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.95rem 0;
}

.dashboard-sidebar.collapsed .brand-title,
.dashboard-sidebar.collapsed .breadcrumb-label,
.dashboard-sidebar.collapsed .breadcrumb-current {
    display: none;
}

.dashboard-sidebar.collapsed .sidebar-toggle {}

.btn-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.82);
}