/* ============================================================
 * NextGen MIS — Loader
 * ------------------------------------------------------------
 * A clean, on-brand loader: the NextGen emblem gently pulses in
 * the centre of a spinning amber-accented ring. Used for:
 *   - the reusable .ng-loader component
 *   - the DataTables processing indicator (override)
 *   - the jQuery LoadingOverlay image (best-effort)
 * ============================================================ */

/* ---------- REUSABLE LOADER ---------- */
.ng-loader {
  display: inline-block;
  position: relative;
  width: 56px;
  height: 56px;
  vertical-align: middle;
}

/* Spinning ring */
.ng-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  border: 3px solid var(--color-sage-100);
  border-top-color: var(--color-amber-500);
  animation: ng-loader-spin 0.9s linear infinite;
}

/* Brand emblem, gently pulsing */
.ng-loader::after {
  content: "";
  position: absolute;
  inset: 11px;
  background: url(/img/NextGen_logo_FA3.svg) center / contain no-repeat;
  animation: ng-loader-pulse 1.6s ease-in-out infinite;
}

.ng-loader--sm { width: 36px; height: 36px; }
.ng-loader--sm::after { inset: 7px; }
.ng-loader--lg { width: 80px; height: 80px; }
.ng-loader--lg::after { inset: 16px; }

/* Optional centred full-area variant */
.ng-loader-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  width: 100%;
}

@keyframes ng-loader-spin {
  to { transform: rotate(360deg); }
}
@keyframes ng-loader-pulse {
  0%, 100% { transform: scale(0.9);  opacity: 0.7; }
  50%      { transform: scale(1);    opacity: 1; }
}

/* Honour reduced-motion: drop the spin, keep a soft pulse only */
@media (prefers-reduced-motion: reduce) {
  .ng-loader::before { animation: none; border-top-color: var(--color-amber-500); }
  .ng-loader::after  { animation: ng-loader-pulse 2.4s ease-in-out infinite; }
}

/* ---------- DATATABLES PROCESSING INDICATOR ---------- */
/* Replaces the old /img/loading.svg background with the brand loader. */
.dataTables_wrapper .dataTables_processing {
  background: transparent !important;     /* no white box */
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
  width: 56px !important;
  height: 56px !important;
  padding: 0 !important;
  left: 50% !important;
  margin-left: -28px !important;          /* centred horizontally */
  top: 50% !important;
  margin-top: -28px !important;           /* centred vertically */
  font-size: 0 !important;                /* hide the "Processing..." text */
  color: transparent !important;
  z-index: var(--z-sticky) !important;    /* sit ON TOP of table rows (was painted behind) */
}
.dataTables_wrapper .dataTables_processing::before {
  content: "";
  position: absolute;
  inset: 0;                                /* ring fills the 56px box */
  border-radius: var(--radius-full);
  border: 3px solid var(--color-sage-100);
  border-top-color: var(--color-amber-500);
  animation: ng-loader-spin 0.9s linear infinite;
}
.dataTables_wrapper .dataTables_processing::after {
  content: "";
  position: absolute;
  inset: 11px;                             /* concentric emblem — centred both axes */
  background: url(/img/NextGen_logo_FA3.svg) center / contain no-repeat;
  animation: ng-loader-pulse 1.6s ease-in-out infinite;
}

/* ---------- jQuery LoadingOverlay (pageLoading) ---------- */
/* This `!important` scrim overrides the plugin's inline background, so the veil
   must be themed HERE (a JS option can't win against it). Light keeps the white
   veil; dark gets a matching dark veil — otherwise the overlay (shown during the
   on-load reference fetch) flashes white over the dark page on reload. */
.loadingoverlay {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(1px);
}
:root[data-theme="dark"] .loadingoverlay {
  background: rgba(22, 21, 19, 0.7) !important;   /* --color-bg-app dark @ 0.7 */
}
