/**
 * Modal fixes for HJA application
 * These styles ensure Bootstrap modals appear correctly and are accessible
 */

/* Ensure only one backdrop exists and has correct position */
.modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  pointer-events: auto !important; /* Ensures backdrop clicks work */
}

/* Reset any extra modal backdrops */
.modal-backdrop + .modal-backdrop {
  display: none !important; /* Prevent multiple backdrops */
}

/* Ensure modal has correct z-index and position */
.modal {
  z-index: 1050 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  outline: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  pointer-events: none !important; /* Modal itself has no pointer events */
}

/* Fix modal dialog positioning */
.modal-dialog {
  position: relative !important;
  margin: 1.75rem auto !important;
  pointer-events: all !important; /* Dialog has pointer events */
  z-index: 1060 !important; /* Ensure dialog is above backdrop */
}

/* Fix modal content styling */
.modal-content {
  position: relative !important;
  background-color: #fff !important;
  pointer-events: all !important; /* Content has pointer events */
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
  border-radius: 0.3rem !important;
  outline: 0 !important;
  border: 1px solid rgba(0, 0, 0, 0.2) !important;
  z-index: 1061 !important; /* Ensure content is above dialog */
}

/* Ensure content beneath modal is not focusable */
body.modal-open {
  overflow: hidden !important;
  padding-right: 0 !important; /* Fix for scrollbar shift */
}

/* Prevent transform issues that can affect modal display */
.modal *, .modal-dialog *, .modal-content * {
  transform: none !important; 
  transition: none !important;
}

/* Fix for sidebar z-index conflicts */
body.modal-open .sidebar, 
body.modal-open .topnav {
  z-index: 1039 !important;
}

/* Fix pointer events for elements inside modal */
.modal button,
.modal input,
.modal select,
.modal textarea,
.modal a,
.modal-header button.close,
.modal-footer button {
  pointer-events: all !important;
  position: relative !important;
  z-index: 1062 !important;
}

/* Ensure forms inside modals are properly visible */
.modal-body .form-group {
  position: static !important;
  pointer-events: all !important;
}

/* Fix for nested dropdowns inside modals */
.modal .dropdown-menu {
  z-index: 1063 !important;
}

/* Fix for newAdjustmentModal specifically */
#newAdjustmentModal {
  pointer-events: all !important;
}

#newAdjustmentModal .modal-dialog,
#newAdjustmentModal .modal-content,
#newAdjustmentModal .modal-body,
#newAdjustmentModal .modal-footer,
#newAdjustmentModal form,
#newAdjustmentModal .form-group,
#newAdjustmentModal input,
#newAdjustmentModal select,
#newAdjustmentModal button {
  pointer-events: all !important;
  position: relative !important;
  z-index: 1062 !important;
}
