/**
 * CSRF Modal Fix - Ensures modals are always visible and clickable
 * Prevents invisible overlays from blocking user interaction
 */

/* Remove any invisible overlays that might be blocking interaction */
body::before,
body::after {
  pointer-events: none !important;
}

/* Ensure CSRF modals are always on top and visible */
.csrf-modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.7) !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  pointer-events: all !important;
}

.livewire-expired-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: rgba(0, 0, 0, 0.7) !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  pointer-events: all !important;
}

/* Ensure modal content is clickable */
.csrf-modal-overlay>*,
.livewire-expired-modal>* {
  pointer-events: all !important;
}

/* Fix for any Bootstrap modals that might be invisible */
.modal.show {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.modal-backdrop {
  z-index: 999998 !important;
}

.modal {
  z-index: 999999 !important;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden !important;
}

/* Fix for Livewire loading states that might create overlays */
[wire\:loading] {
  pointer-events: none !important;
}

[wire\:loading].overlay {
  z-index: 999997 !important;
}

/* Ensure buttons in modals are always clickable */
.csrf-modal-overlay button,
.livewire-expired-modal button,
.modal button {
  pointer-events: all !important;
  cursor: pointer !important;
}

/* Fix for any transparent overlays */
div[style*="position: fixed"][style*="z-index"] {
  min-height: 1px !important;
}

/* Ensure modal dialogs are visible */
.modal-dialog {
  pointer-events: all !important;
}

/* Animation for modal appearance */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.csrf-modal-overlay>div,
.livewire-expired-modal>div {
  animation: modalFadeIn 0.3s ease-out !important;
}

/* Fix for SweetAlert2 overlays if they conflict */
.swal2-container {
  z-index: 999990 !important;
}

/* Ensure no element blocks the entire page */
*:not(.csrf-modal-overlay):not(.livewire-expired-modal):not(.modal):not(.modal-backdrop) {
  pointer-events: auto !important;
}

/* Fix for any full-screen overlays that shouldn't be there */
div[style*="position: fixed"][style*="width: 100%"][style*="height: 100%"]:not(.csrf-modal-overlay):not(.livewire-expired-modal):not(.modal):not(.modal-backdrop) {
  pointer-events: none !important;
}

/* Allow clicks through loading overlays */
.loading-overlay {
  pointer-events: none !important;
}

.loading-overlay>* {
  pointer-events: all !important;
}

/* Debug helper - uncomment to see all fixed position elements */
/*
[style*="position: fixed"] {
    outline: 2px solid red !important;
}
*/