/* sidebar.css - Style modernisé pour la barre latérale ArtiStock */

/* ----- VARIABLES ----- */
:root {
    --sidebar-width: 260px;
    --sidebar-min-width: 80px;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --sidebar-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --hover-bg: #f1f5f9;
    --active-item-bg: #f0f7ff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.25s ease;
    --header-height: 60px;
}

/* ----- STRUCTURE GÉNÉRALE ----- */
body {
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

/* ----- BARRE LATÉRALE ----- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-speed);
    z-index: 1040;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch; /* Meilleur défilement sur iOS */
}

.sidebar.minimized {
    width: var(--sidebar-min-width);
}

/* ----- HEADER DE LA BARRE LATÉRALE ----- */
.sidebar-header {
    height: var(--header-height);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background-color: var(--sidebar-bg);
    z-index: 10;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: color var(--transition-speed);
}

.sidebar-brand:hover {
    color: var(--primary-hover);
}

.sidebar-brand-text {
    margin-top: 2px;
}

.sidebar-brand-icon {
    display: none; /* Caché en desktop */
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sidebar.minimized .sidebar-brand-text {
    display: none;
}

.sidebar.minimized .sidebar-brand-icon {
    display: flex; /* Visible quand la sidebar est minimisée */
}

/* En mobile, on affiche le logo */
@media (max-width: 991.98px) {
    .sidebar.show .sidebar-brand-icon {
        display: flex;
        margin-left: 1rem;
    }
}

.minimize-toggle {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed);
}

.sidebar.minimized .minimize-toggle {
    display: none; /* Cacher le bouton lorsque la sidebar est minimisée */
}

.minimize-toggle:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

/* ----- SECTION UTILISATEUR ----- */
.sidebar-user {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: background-color var(--transition-speed);
}

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

.sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-right: 1rem;
    box-shadow: var(--shadow-sm);
}

.sidebar.minimized .sidebar-avatar {
    width: 40px;
    height: 40px;
    margin: 0 auto 0.5rem;
}

.sidebar-username {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    /* Suppression de la marge en bas puisqu'il n'y a plus de rôle */
}

/* Classe sidebar-role supprimée puisque plus utilisée */

.sidebar.minimized .sidebar-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
}

.sidebar.minimized .sidebar-username {
    display: none;
}

/* ----- NAVIGATION ----- */
.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.sidebar-divider {
    height: 1px;
    margin: 1rem 1.25rem;
    background-color: var(--border-color);
}

.sidebar-category {
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.sidebar.minimized .sidebar-heading {
    display: none;
}

.sidebar-item {
    padding: 0.75rem 1.25rem;
    margin: 0.125rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-speed);
    position: relative;
}

.sidebar-item:hover {
    background-color: var(--hover-bg);
    color: var(--primary-color);
}

.sidebar-item.active {
    background-color: var(--active-item-bg);
    color: var(--primary-color);
    font-weight: 500;
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 3px;
    background-color: var(--primary-color);
    border-radius: 0 4px 4px 0;
}

.sidebar.minimized .sidebar-item {
    justify-content: center;
    padding: 0.75rem 0;
    margin: 0.125rem 0.5rem;
}

.sidebar.minimized .sidebar-item.active::before {
    left: -0.5rem;
}

.sidebar-icon {
    font-size: 1.25rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
    color: var(--text-secondary);
    transition: color var(--transition-speed);
}

.sidebar-item:hover .sidebar-icon,
.sidebar-item.active .sidebar-icon {
    color: var(--primary-color);
}

.sidebar.minimized .sidebar-icon {
    margin-right: 0;
}

.sidebar-text {
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.95rem;
}

.sidebar.minimized .sidebar-text {
    display: none;
}

/* ----- FOOTER ----- */
.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    margin-top: auto;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    color: var(--text-secondary);
    background-color: transparent;
    border: 1px solid var(--border-color);
    transition: all var(--transition-speed);
    font-weight: 500;
    font-size: 0.9rem;
    width: 100%;
}

.btn-logout:hover {
    background-color: #f9fafb;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-logout i {
    margin-right: 0.5rem;
}

.sidebar.minimized .btn-logout {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 8px;
}

.sidebar.minimized .btn-text {
    display: none;
}

.sidebar.minimized .btn-logout i {
    margin-right: 0;
}

/* ----- OVERLAY ET BOUTON D'EXPANSION ----- */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    display: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-backdrop.show {
    display: block;
}

.expand-toggle {
    position: fixed;
    left: calc(var(--sidebar-min-width) - 16px);
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1050;
    box-shadow: var(--shadow-sm);
    display: none;
    color: var(--text-secondary);
    transition: box-shadow var(--transition-speed);
}

.expand-toggle:hover {
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}

.sidebar.minimized ~ .expand-toggle {
    display: flex;
}

/* ----- CONTENU PRINCIPAL ----- */
.content-with-sidebar {
    margin-left: var(--sidebar-width);
    transition: margin var(--transition-speed);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-with-sidebar.expanded {
    margin-left: var(--sidebar-min-width);
}

/* ----- TOP NAVBAR MOBILE ----- */
.top-navbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--sidebar-bg);
    box-shadow: var(--shadow-sm);
    padding: 0 1rem;
    z-index: 1030;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
    margin-left: 0.5rem;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    margin-right: 0.5rem;
    font-weight: 700;
}

.brand-text {
    margin-top: 2px;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background-color var(--transition-speed);
}

.sidebar-toggle:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.navbar-actions {
    display: flex;
    align-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0.375rem 0.5rem;
    color: var(--text-primary);
    border-radius: 8px;
    transition: background-color var(--transition-speed);
}

.user-menu:hover {
    background-color: var(--hover-bg);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin-right: 0.5rem;
}

/* ----- DROPDOWN MENU ----- */
.dropdown-menu {
    min-width: 12rem;
    padding: 0.5rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.dropdown-item {
    padding: 0.625rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--hover-bg);
    color: var(--primary-color);
}

.dropdown-divider {
    margin: 0.375rem 0;
    border-top: 1px solid var(--border-color);
}

/* ----- MAIN CONTENT ----- */
main {
    padding: 1.5rem 0;
    flex: 1 0 auto;
}

/* ----- FOOTER ----- */
.app-footer {
    margin-top: auto;
    background-color: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
}

.copyright {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-brand {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
}

.footer-brand:hover {
    color: var(--primary-hover);
}

.footer-nav {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-speed);
}

.footer-link:hover {
    color: var(--primary-color);
}

/* ----- RESPONSIVE ----- */
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        box-shadow: none;
    }
    
    .sidebar.show {
        left: 0;
        box-shadow: var(--shadow-md);
    }
    
    .minimize-toggle {
        display: none;
    }
    
    .content-with-sidebar,
    .content-with-sidebar.expanded {
        margin-left: 0;
    }
    
    .top-navbar {
        display: flex;
    }
    
    .expand-toggle {
        display: none !important;
    }
    
    /* Ajuster le padding du contenu pour la top navbar */
    .content-with-sidebar {
        padding-top: var(--header-height);
    }
    
    /* Footer mobile */
    .footer-nav {
        justify-content: center;
        margin-top: 1rem;
    }
}

@media (max-width: 576px) {
    :root {
        --sidebar-width: 100%;
    }
    
    .sidebar-user {
        padding: 1rem;
    }
    
    .sidebar-avatar {
        width: 40px;
        height: 40px;
    }
    
    .sidebar-header {
        padding: 0 1rem;
    }
    
    .sidebar-item {
        padding: 0.75rem 1rem;
    }
    
    .footer-nav {
        gap: 0.75rem;
    }
}