/*
 * =====================================================
 * MODAL FIXES - Corrections pour Bootstrap 5 Modals
 * =====================================================
 */

/* Garantir que le backdrop est TOUJOURS derrière le modal */
.modal-backdrop {
  z-index: 1040 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
}

.modal-backdrop.fade {
  opacity: 0 !important;
}

.modal-backdrop.show {
  opacity: 0.5 !important;
}

/* Garantir que le modal est TOUJOURS au-dessus du backdrop */
.modal {
  z-index: 1055 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  outline: 0 !important;
}

.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out !important;
  transform: translate(0, -50px) !important;
}

.modal.show .modal-dialog {
  transform: none !important;
}

/* Fix spécifique pour éviter les conflits avec AdminLTE et autres */
.modal-dialog {
  position: relative !important;
  z-index: 1056 !important;
  margin: 1.75rem auto !important;
  pointer-events: none !important;
}

.modal-content {
  position: relative !important;
  z-index: 1057 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  pointer-events: auto !important;
  background-color: #fff !important;
  background-clip: padding-box !important;
  border: 1px solid rgba(0, 0, 0, 0.2) !important;
  border-radius: 0.5rem !important;
  outline: 0 !important;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5) !important;
}

/* Améliorer la visibilité et l'interaction */
.modal.show {
  display: block !important;
  overflow-y: auto;
}

/* S'assurer que les champs de formulaire dans le modal sont interactifs */
.modal input,
.modal textarea,
.modal select,
.modal button {
  pointer-events: auto !important;
  position: relative;
  z-index: auto;
}

/* Animation d'ouverture/fermeture */
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal.fade {
  transition: opacity 0.15s linear;
}

.modal.show {
  animation: modalFadeIn 0.15s ease-out;
}

.modal.show .modal-dialog {
  animation: modalSlideIn 0.3s ease-out;
}

/* Empêcher le scroll du body quand le modal est ouvert */
body.modal-open {
  overflow: hidden;
  padding-right: 0 !important;
}

/* Fix pour le centrage vertical */
.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem * 2);
}

/* Responsive */
@media (min-width: 576px) {
  .modal-dialog {
    max-width: 500px;
    margin: 1.75rem auto;
  }

  .modal-dialog-centered {
    min-height: calc(100% - 3.5rem);
  }
}
