/* MedLegal AI — shared large loading spinner / full-screen overlay.
 * v1 — May 12 2026. Replaces the previous 14px-22px micro-spinners that
 * users couldn't see. Now 88px primary, full-viewport semi-transparent
 * backdrop, optional status text, optional progress messaging.
 *
 * Usage (HTML pages):
 *   <link rel="stylesheet" href="/shared/spinner.css">
 *   <script src="/shared/spinner.js" defer></script>
 *   ...
 *   MedLegalLoader.show('Analyzing your records…');
 *   MedLegalLoader.update('Extracting medications (step 2 of 4)…');
 *   MedLegalLoader.hide();
 *
 * Usage (React/Vite frontends):
 *   import the asset via index.html <link>, then call window.MedLegalLoader.*
 *
 * Inline-spinner usage (smaller, for buttons):
 *   <span class="ml-spin"></span> ANALYZING…
 */

/* ─── Full-screen overlay ─────────────────────────────────────────────── */

.ml-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(10, 14, 23, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: ml-overlay-in 0.18s ease-out;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@keyframes ml-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ml-loader-overlay[hidden] { display: none !important; }

/* ─── Spinner ring (88px, brand blue, dual-ring breathe-pulse) ────────── */

.ml-loader-ring {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 24px;
}

.ml-loader-ring::before,
.ml-loader-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px solid transparent;
}

.ml-loader-ring::before {
  border-top-color: #3b82f6;     /* blue */
  border-right-color: #3b82f6;
  animation: ml-spin 1.1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.ml-loader-ring::after {
  border-bottom-color: #8b5cf6;  /* purple, opposite direction */
  border-left-color: #8b5cf6;
  animation: ml-spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse;
  opacity: 0.7;
}

@keyframes ml-spin {
  to { transform: rotate(360deg); }
}

/* ─── Status / message text ───────────────────────────────────────────── */

.ml-loader-text {
  color: #f9fafb;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  max-width: 480px;
  padding: 0 20px;
  animation: ml-text-pulse 2.4s ease-in-out infinite;
}

.ml-loader-sub {
  color: #9ca3af;
  font-size: 14px;
  margin-top: 8px;
  text-align: center;
  max-width: 480px;
  padding: 0 20px;
}

@keyframes ml-text-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

/* ─── Optional progress dots row (3 dots, bounce) ─────────────────────── */

.ml-loader-dots {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.ml-loader-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  animation: ml-dot-bounce 1.4s ease-in-out infinite both;
}

.ml-loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.ml-loader-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes ml-dot-bounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ─── Inline spinner (for buttons + form-row indicators) ──────────────── */

.ml-spin {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: ml-spin 0.85s linear infinite;
  vertical-align: middle;
  margin-right: 10px;
}

/* Larger inline spinner — for empty-state tables, loading lists, etc. */
.ml-spin-lg {
  display: inline-block;
  width: 48px;
  height: 48px;
  border: 4px solid #1f2937;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: ml-spin 0.85s linear infinite;
  vertical-align: middle;
}

/* Reduced motion — respect user accessibility preference */
@media (prefers-reduced-motion: reduce) {
  .ml-loader-ring::before,
  .ml-loader-ring::after,
  .ml-spin,
  .ml-spin-lg,
  .ml-loader-dots span,
  .ml-loader-text {
    animation-duration: 3s;
    animation-timing-function: linear;
  }
}
