/**
 * Global loader overlay — Online Booking style (white wash + blocks interaction).
 * Applies to ngLoader (.loader), #loadingImage, and mobile .im-loader-overlay.
 */

/* ngLoader full-screen block (overrides weak rgba(0,0,0,0.22) from ngLoader).
   Do not force display when .ng-hide — Angular must be able to hide the loader. */
.loader:not(.mm-local-loader) {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  z-index: 200000 !important;
  background: rgba(255, 255, 255, 0.15) !important;
  pointer-events: auto !important;
  cursor: wait !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  touch-action: none !important;
  box-sizing: border-box !important;
}

.loader:not(.mm-local-loader):not(.ng-hide) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.loader.ng-hide {
  display: none !important;
  pointer-events: none !important;
}

/* Rego / Customer / Part No. typeahead — old in-popup spinner (no full-screen flash). */
.loader.mm-local-loader {
  position: absolute !important;
  inset: auto !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  z-index: 10060 !important;
  background: transparent !important;
  pointer-events: none !important;
  cursor: default !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  touch-action: auto !important;
  box-sizing: border-box !important;
}

.loader.mm-local-loader:not(.ng-hide) {
  display: block !important;
}

/* Keep spinner/message group centered (ngLoader template inner div) */
.loader > div {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  margin: 0 auto !important;
  pointer-events: none !important;
}

/* Darker message chip so text stays readable on white wash */
.loader > div[style*="background-color"],
.loader .loader-message,
.loader [class*="message"] {
  color: #374151 !important;
}

body.mm-loader-active {
  cursor: wait !important;
}

body.mm-loader-active #tpAppRoot {
  /* Overlay sits above; this blocks accidental focus into the app underneath */
  pointer-events: none !important;
}

/* Allow the overlay itself (appended to body, outside #tpAppRoot) to receive events */
body.mm-loader-active .loader:not(.mm-local-loader),
body.mm-loader-active #loadingImage {
  pointer-events: auto !important;
}

/* #loadingImage (gate / login / legacy show) — match booking overlay */
div#loadingImage {
  position: fixed !important;
  inset: 0 !important;
  z-index: 200001 !important;
  background: rgba(255, 255, 255, 0.15) !important;
  pointer-events: auto !important;
  cursor: wait !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  touch-action: none !important;
}

div#loadingImage .mm-loader-panel {
  background: transparent !important;
  box-shadow: none !important;
}

/* Demo Data — restore original dark wash + ajax-loader.gif only */
div#loadingImage.mm-loader-classic {
  background: rgba(31, 31, 31, 0.68) !important;
  z-index: 999999999999 !important;
  cursor: default !important;
  -webkit-user-select: auto !important;
  user-select: auto !important;
  touch-action: auto !important;
}

div#loadingImage.mm-loader-classic .mm-loader-panel {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
  max-width: none !important;
  min-width: 0 !important;
}

div#loadingImage.mm-loader-classic .mm-loader-gif {
  display: block !important;
}

div#loadingImage.mm-loader-classic .mm-loader-spinner,
div#loadingImage.mm-loader-classic .mm-loader-message {
  display: none !important;
}

/* Mobile document screens (.im-loader-overlay) */
.im-loader-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 200000 !important;
  background: rgba(255, 255, 255, 0.15) !important;
  pointer-events: auto !important;
  cursor: wait !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  touch-action: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/*
 * Alertify defaults to z-index 99999; mm loaders use 200000+.
 * Keep dialogs above the WORKING overlay so Yes/No stay clickable.
 */
.alertify,
.alertify-cover,
.alertify-logs,
.alertify .ajs-dimmer,
.alertify .ajs-modal {
  z-index: 200100 !important;
}
