/**
 * Sidebar.css - Menu latéral inspiré iOS/macOS
 * Version finale corrigée - Icônes seules + expansion au survol
 */

/* Container principal de la sidebar */
.space-sidebar,
.sap-sidebar {
    position: sticky;
    top: 0;
    left: 0;
    width: 70px;
    height: 100vh;
    background: linear-gradient(180deg, 
                rgba(255, 255, 255, 0.98) 0%, 
                rgba(250, 250, 250, 0.98) 100%);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 100;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Adaptation si admin bar WordPress présent */
body.admin-bar .space-sidebar,
body.admin-bar .sap-sidebar {
    height: calc(100vh - 32px);
    top: 32px;
}

.space-sidebar:hover,
.sap-sidebar:hover {
    width: 240px;
}

/* Container parent - Flexbox pour intégration */
.space-container,
.sap-space-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    background: #f5f5f7;
}

/* Contenu principal - Prend l'espace restant */
.space-main-content,
.sap-main-content {
    flex: 1;
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f5f5f7;
}

/* Header de la sidebar (logo) */
.sidebar-header,
.sap-sidebar-header {
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    flex-shrink: 0;
}

.sap-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.sidebar-logo,
.sap-company-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.space-sidebar:hover .sidebar-logo,
.sap-sidebar:hover .sap-company-logo {
    transform: scale(1.05);
}

/* Barre de recherche */
.sidebar-search,
.sap-search-container {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.sap-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-input,
.sap-search-input {
    width: 100%;
    height: 34px;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 0;
    color: #1d1d1f;
    transition: all 0.25s ease;
    outline: none;
}

.space-sidebar:hover .sidebar-search-input,
.sap-sidebar:hover .sap-search-input {
    padding: 0 32px 0 10px;
    font-size: 13px;
}

.sidebar-search-input::placeholder,
.sap-search-input::placeholder {
    color: #86868b;
    font-size: 0;
    transition: font-size 0.25s;
}

.space-sidebar:hover .sidebar-search-input::placeholder,
.sap-sidebar:hover .sap-search-input::placeholder {
    font-size: 13px;
}

.sidebar-search-input:focus,
.sap-search-input:focus {
    background: rgba(0, 0, 0, 0.06);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.sidebar-search-icon,
.sap-search-wrapper i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #86868b;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
}

.space-sidebar:hover .sidebar-search-icon,
.sap-sidebar:hover .sap-search-wrapper i {
    opacity: 1;
}

/* Navigation - AVEC SCROLL */
.sidebar-nav,
.sap-sidebar-menu {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    /* OPTIMISATION: Scroll matériel */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sidebar-nav::-webkit-scrollbar,
.sap-sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track,
.sap-sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.sap-sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
.sap-sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Items du menu - ICÔNES CENTRÉES */
.sidebar-nav-item,
.sap-menu-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px;
    margin: 2px 6px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    text-decoration: none;
    color: inherit;
    min-height: 50px;
    /* OPTIMISATION */
    will-change: transform, background-color;
    contain: layout style paint;
}

.sidebar-nav-item:hover,
.sap-menu-item:hover {
    background: rgba(0, 122, 255, 0.08);
    transform: translateX(2px);
}

.sidebar-nav-item.active,
.sap-menu-item.active {
    background: linear-gradient(135deg, #007AFF 0%, #0066CC 100%);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

.sidebar-nav-item.active .sidebar-nav-icon,
.sidebar-nav-item.active .sidebar-nav-text,
.sap-menu-item.active .sap-menu-icon,
.sap-menu-item.active .sap-menu-label {
    color: white !important;
}

/* Icônes du menu - TOUJOURS VISIBLES */
.sidebar-nav-icon,
.sap-menu-icon {
    width: 50px;
    min-width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #1d1d1f;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    will-change: transform;
}

.sidebar-nav-item:hover .sidebar-nav-icon,
.sap-menu-item:hover .sap-menu-icon {
    transform: scale(1.08);
}

/* Texte du menu - MASQUÉ PAR DÉFAUT */
.sidebar-nav-text,
.sap-menu-label {
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    margin-left: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.2px;
}

.space-sidebar:hover .sidebar-nav-text,
.sap-sidebar:hover .sap-menu-label {
    opacity: 1;
    max-width: 150px;
    margin-left: 4px;
}

/* Badge de notification */
.sidebar-nav-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #FF3B30;
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
    transition: all 0.25s;
}

.space-sidebar:hover .sidebar-nav-badge {
    right: 10px;
}

/* Séparateur */
.sidebar-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 6px 12px;
}

/* Footer de la sidebar */
.sidebar-footer,
.sap-sidebar-footer {
    padding: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

/* Profil utilisateur */
.sidebar-user-profile,
.sap-user-info {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-user-profile:hover,
.sap-user-info:hover {
    background: rgba(0, 0, 0, 0.04);
}

.sidebar-user-avatar,
.sap-user-info img {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(0, 122, 255, 0.2);
    flex-shrink: 0;
}

.sidebar-user-info,
.sap-user-details {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: all 0.25s;
    margin-left: 0;
}

.space-sidebar:hover .sidebar-user-info,
.sap-sidebar:hover .sap-user-details {
    opacity: 1;
    max-width: 150px;
    margin-left: 10px;
}

.sidebar-user-name,
.sap-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-user-role,
.sap-user-role {
    font-size: 11px;
    color: #86868b;
    white-space: nowrap;
}

/* Mode sombre */
body.dark-mode .space-sidebar,
body.dark-mode .sap-sidebar {
    background: linear-gradient(180deg, 
                rgba(28, 28, 30, 0.98) 0%, 
                rgba(24, 24, 26, 0.98) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .sidebar-header,
body.dark-mode .sidebar-search,
body.dark-mode .sidebar-footer,
body.dark-mode .sap-sidebar-header,
body.dark-mode .sap-search-container,
body.dark-mode .sap-sidebar-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .sidebar-nav-icon,
body.dark-mode .sidebar-nav-text,
body.dark-mode .sidebar-user-name,
body.dark-mode .sap-menu-icon,
body.dark-mode .sap-menu-label,
body.dark-mode .sap-user-name {
    color: #f5f5f7;
}

body.dark-mode .sidebar-user-role,
body.dark-mode .sap-user-role {
    color: #98989d;
}

body.dark-mode .sidebar-search-input,
body.dark-mode .sap-search-input {
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f7;
}

body.dark-mode .sidebar-search-input::placeholder,
body.dark-mode .sap-search-input::placeholder {
    color: #98989d;
}

body.dark-mode .sidebar-nav-item:hover,
body.dark-mode .sap-menu-item:hover {
    background: rgba(0, 122, 255, 0.15);
}

body.dark-mode .sidebar-divider {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .sidebar-user-profile:hover,
body.dark-mode .sap-user-info:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Responsive */
@media (max-width: 768px) {
    .space-sidebar,
    .sap-sidebar {
        width: 60px;
    }
    
    .space-sidebar:hover,
    .sap-sidebar:hover {
        width: 200px;
    }
    
    .sidebar-logo,
    .sap-company-logo {
        width: 32px;
        height: 32px;
    }
    
    .sidebar-nav-icon,
    .sap-menu-icon {
        width: 44px;
        min-width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .sidebar-nav-text,
    .sap-menu-label {
        font-size: 13px;
    }
}

/* Animation au chargement */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.space-sidebar,
.sap-sidebar {
    animation: slideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Effet de brillance au survol */
.sidebar-nav-item::before,
.sap-menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
                transparent 0%, 
                rgba(255, 255, 255, 0.2) 50%, 
                transparent 100%);
    transition: left 0.4s ease;
    pointer-events: none;
}

.sidebar-nav-item:hover::before,
.sap-menu-item:hover::before {
    left: 100%;
}

/* Tooltip pour sidebar rétractée */
.sidebar-nav-item[data-tooltip]::after,
.sap-menu-item[data-label]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 75px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10000;
}

.sap-menu-item[data-label]::after {
    content: attr(data-label);
}

.space-sidebar:not(:hover) .sidebar-nav-item:hover::after,
.sap-sidebar:not(:hover) .sap-menu-item:hover::after {
    opacity: 1;
}

body.dark-mode .sidebar-nav-item[data-tooltip]::after,
body.dark-mode .sap-menu-item[data-label]::after {
    background: rgba(255, 255, 255, 0.9);
    color: #1d1d1f;
}

/* Performance - Forcer l'accélération GPU */
.space-sidebar,
.sap-sidebar,
.sidebar-nav-item,
.sap-menu-item {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* OPTIMISATION: Désactiver animations pendant scroll */
.sidebar-nav.scrolling *,
.sap-sidebar-menu.scrolling * {
    transition: none !important;
}

/* Performance - GPU Acceleration */
.space-sidebar,
.sap-sidebar,
.sidebar-nav-item,
.sap-menu-item {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}