/*
    Created on : 29 mars 2026, 17:14:05
    Author     : Morgan Vivier - https://github.com/rsquatre
*/

/* Sidebar Base Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--color-bg-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base), transform var(--transition-base);
    z-index: var(--z-fixed);
    overflow: hidden;
}

.sidebar nav {
    width: 100%;
}

.sidebar nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    width: 100%
}


.sidebar .nav-item {
    width: 100%;
    padding: 5px;
    font-size: var(--fs-4);
    margin: var(--space-2) 0;
}

.sidebar .nav-item a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.sidebar .nav-item a > span {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar .nav-item a .bi {
    font-size: var(--fs-3);
    flex-shrink: 0;
}


/* Hide text in nav items when collapsed */
[data-sidebar-collapsed="true"] .nav-item a > span {
    justify-content: center;
}

[data-sidebar-collapsed="true"] .nav-item a > span > span:not(.bi) {
    display: none;
}

[data-sidebar-collapsed="true"] .nav-item a {
    justify-content: center;
    padding: var(--space-3);
}

/* Collapsed State */
[data-sidebar-collapsed="true"] .sidebar {
    width: var(--sidebar-collapsed-width);
}


/* Sidebar Sections */
.sidebar-section {
    padding: var(--space-5) var(--space-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-section.sidebar-nav, .sidebar-section.sidebar-footer {
    padding: var(--space-5) 0;
}

.sidebar-section:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

/* Flex-grow for navigation section */
.sidebar-section.flex-grow {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* First section (logo + toggle) */
.sidebar-section:first-child {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height);
    padding: 0 var(--space-4);
}

[data-sidebar-collapsed="true"] .sidebar-section:first-child {
    justify-content: center;
}

/* Logo/Brand */
.sidebar-section:first-child > span:first-child {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-3);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

[data-sidebar-collapsed="true"] .sidebar-section:first-child > span:first-child {
    display: none;
}

/* Toggle Button */
.sidebar-collapse-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    background-color: transparent;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
    font-size: var(--fs-2);
    padding: 0;
}

.sidebar-collapse-button:hover {
    background-color: var(--color-bg-hover);
}

/* Profile Section */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    font-weight: var(--font-semibold);
}

[data-sidebar-collapsed="true"] .sidebar-profile {
    justify-content: center;
}

.sidebar-profile-picture {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background-color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--font-semibold);
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}

.sidebar-profile > span:not(.sidebar-profile-picture) {
    font-size: var(--fs-4);
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-fast);
}

[data-sidebar-collapsed="true"] .sidebar-profile > span:not(.sidebar-profile-picture) {
    display: none;
}


/* Scrollbar for navigation section */
.sidebar-section.flex-grow::-webkit-scrollbar {
    width: 6px;
}

.sidebar-section.flex-grow::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-section.flex-grow::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

.sidebar-section.flex-grow::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-light);
}

/* Mobile Toggle Button - languette sur le côté */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: var(--space-8);
    left: 0;
    width: 40px;
    height: 60px;
    background-color: var(--color-accent);
    border: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: white;
    font-size: var(--fs-2);
    cursor: pointer;
    z-index: calc(var(--z-fixed) + 1);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}

.sidebar-mobile-toggle:hover {
    width: 45px;
    background-color: var(--color-accent-hover);
}

/* Responsive - Tablet (< 1024px) */
@media (max-width: 1024px) {
    /* Start collapsed on tablet */
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    /* When expanded on tablet */
    [data-sidebar-collapsed="false"] .sidebar {
        width: var(--sidebar-width);
        box-shadow: var(--shadow-xl);
    }

    [data-sidebar-collapsed="false"] .sidebar-section:first-child {
        justify-content: space-between;
    }

    [data-sidebar-collapsed="false"] .sidebar-section:first-child > span:first-child {
        display: flex;
    }

    [data-sidebar-collapsed="false"] .sidebar-profile > span:not(.sidebar-profile-picture) {
        display: block;
    }

    [data-sidebar-collapsed="false"] .nav-item a > span > span:not(.bi) {
        display: inline;
    }

    [data-sidebar-collapsed="false"] .nav-item a {
        justify-content: flex-start;
        padding: var(--space-3) var(--space-4);
    }
}

/* Responsive - Mobile (< 768px) */
@media (max-width: 768px) {
    /* Show mobile toggle button (languette) when sidebar is hidden */
    .sidebar-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide toggle button when sidebar is visible */
    [data-sidebar-collapsed="false"] .sidebar-mobile-toggle {
        display: none;
    }
    /* Sidebar hidden by default on mobile - slides in from left */
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

    /* Show sidebar when expanded */
    [data-sidebar-collapsed="false"] .sidebar {
        transform: translateX(0);
    }

    /* Always show full content when expanded on mobile */
    [data-sidebar-collapsed="false"] .sidebar-section:first-child {
        justify-content: space-between;
    }

    [data-sidebar-collapsed="false"] .sidebar-section:first-child > span:first-child {
        display: flex;
    }

    [data-sidebar-collapsed="false"] .sidebar-profile {
        justify-content: flex-start;
    }

    [data-sidebar-collapsed="false"] .sidebar-profile > span:not(.sidebar-profile-picture) {
        display: block;
    }

    [data-sidebar-collapsed="false"] .nav-item a > span {
        justify-content: flex-start;
    }

    [data-sidebar-collapsed="false"] .nav-item a > span > span:not(.bi) {
        display: inline;
    }

    [data-sidebar-collapsed="false"] .nav-item a {
        justify-content: flex-start;
        padding: var(--space-3) var(--space-4);
    }

    /* Backdrop when sidebar is open on mobile */
    [data-sidebar-collapsed="false"].dashboard::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-fixed) - 1);
        animation: fadeIn var(--transition-fast);
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
}

