/* GuardSync - Sidebar d'édition unifié */
/* Ce fichier remplace et unifie tous les styles de sidebar d'édition */

/* IMPORTANT: Forcer l'isolation pour créer un nouveau contexte de stacking au niveau racine */
.edit-sidebar {
    /* Positionnement fixe pour couvrir tout l'écran */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    
    /* Z-index TRÈS élevé et isolation pour garantir qu'on est au-dessus de tout */
    z-index: 999999 !important;
    isolation: isolate !important;
    
    /* État caché par défaut */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    
    /* Animation */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.edit-sidebar.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

/* Overlay (fond sombre) */
.edit-sidebar-overlay {
    position: fixed !important; /* Fixed pour couvrir tout l'écran */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: transparent;
    transition: background 0.3s ease;
    z-index: 999998 !important; /* Juste en dessous du content */
}

.edit-sidebar.active .edit-sidebar-overlay {
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(3px);
}

/* Contenu de la sidebar */
.edit-sidebar-content {
    position: fixed !important; /* Fixed pour être indépendant du scroll */
    top: 0 !important;
    right: -450px; /* Caché à droite par défaut */
    bottom: 0 !important;
    width: 450px;
    max-width: 90vw; /* Maximum 90% de la largeur de l'écran */
    height: 100vh !important;
    background: #ffffff;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999999 !important; /* Z-index maximal */
    
    /* Empêcher le débordement */
    overflow: hidden;
}

.edit-sidebar.active .edit-sidebar-content {
    right: 0 !important; /* Slide in */
}

/* Header de la sidebar */
.edit-sidebar-header {
    padding: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Ne pas rétrécir */
    min-height: 80px;
}

.edit-sidebar-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Bouton de fermeture */
.btn-close-sidebar {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.25rem;
    font-weight: bold;
}

.btn-close-sidebar:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

/* Body de la sidebar */
.edit-sidebar-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
    
    /* Scrollbar personnalisée */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f1f5f9;
}

.edit-sidebar-body::-webkit-scrollbar {
    width: 8px;
}

.edit-sidebar-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.edit-sidebar-body::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.edit-sidebar-body::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Footer de la sidebar */
.edit-sidebar-footer {
    padding: 1.5rem;
    border-top: 2px solid #e5e7eb;
    background: white;
    display: flex;
    gap: 1rem;
    flex-shrink: 0; /* Ne pas rétrécir */
    min-height: 90px;
}

.edit-sidebar-footer .btn {
    flex: 1;
    padding: 0.75rem;
    font-weight: 500;
}

/* Styles du formulaire dans la sidebar */
.edit-sidebar-body .form-label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edit-sidebar-body .form-control,
.edit-sidebar-body .form-select {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
}

.edit-sidebar-body .form-control:focus,
.edit-sidebar-body .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.edit-sidebar-body .text-danger {
    color: #ef4444;
    font-weight: 600;
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .edit-sidebar-content {
        width: 100vw !important;
        max-width: 100vw !important;
        right: -100vw;
    }
    
    .edit-sidebar.active .edit-sidebar-content {
        right: 0 !important;
    }
    
    .edit-sidebar-header {
        padding: 1.25rem;
    }
    
    .edit-sidebar-body {
        padding: 1rem;
    }
    
    .edit-sidebar-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .edit-sidebar-footer .btn {
        width: 100%;
    }
}

/* Animations supplémentaires */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.edit-sidebar.active .edit-sidebar-content {
    animation: slideIn 0.3s ease-out;
}

/* Fix pour éviter le scroll de la page en arrière-plan */
body.sidebar-open {
    overflow: hidden !important;
}

/* S'assurer que la sidebar est toujours au-dessus */
.edit-sidebar * {
    box-sizing: border-box;
}

/* Protection contre les conflits avec Bootstrap modals */
.modal-backdrop {
    z-index: 9000 !important; /* En dessous de notre sidebar */
}

.modal {
    z-index: 9500 !important; /* En dessous de notre sidebar */
}