/**
 * medConnect — Premium logo-only global loader
 * Upright logo with gentle float, soft pulse, and breathing glow.
 */

:root {
  --mc-gl-teal: #069396;
  --mc-gl-teal-glow: rgba(6, 147, 150, 0.5);
  --mc-gl-teal-soft: rgba(6, 147, 150, 0.2);
  --mc-gl-fade: 360ms;
  --mc-gl-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mc-gl-z: 10060;
  --mc-gl-logo-size: 200px;
  --mc-gl-stage-size: 260px;
  --mc-gl-breathe-duration: 3.2s;
  --mc-gl-glow-duration: 4.8s;

  --mc-gl-backdrop: rgba(240, 249, 255, 0.38);
  --mc-gl-backdrop-blur: 10px;
  --mc-gl-text: #0f172a;
  --mc-gl-text-muted: #475569;
  --mc-gl-glow: rgba(6, 147, 150, 0.28);
}

html[data-theme-resolved='dark'] {
  --mc-gl-backdrop: rgba(15, 23, 42, 0.48);
  --mc-gl-backdrop-blur: 12px;
  --mc-gl-text: #f1f5f9;
  --mc-gl-text-muted: #94a3b8;
  --mc-gl-glow: rgba(6, 147, 150, 0.42);
  --mc-gl-teal-glow: rgba(6, 147, 150, 0.65);
}

/* ── Fullscreen overlay ─────────────────────────────────────── */
.mc-global-loader,
.mc-loader,
.mc-loader-panel {
  position: fixed;
  inset: 0;
  z-index: var(--mc-gl-z);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  margin: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  border: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--mc-gl-fade) var(--mc-gl-ease),
    visibility var(--mc-gl-fade) var(--mc-gl-ease);
}

.mc-global-loader--boot {
  z-index: 10070;
}

.mc-global-loader--modal,
.mc-global-loader--boot {
  background: var(--mc-gl-backdrop);
  backdrop-filter: blur(var(--mc-gl-backdrop-blur));
  -webkit-backdrop-filter: blur(var(--mc-gl-backdrop-blur));
}

.mc-global-loader--visible,
.mc-global-loader.mc-global-loader--visible,
.mc-loader--visible,
.mc-loader-panel--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mc-global-loader--exit,
.mc-loader--exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.mc-global-loader[hidden]:not(.mc-global-loader--visible) {
  display: none !important;
}

body.mc-global-loader-active,
body.mc-loader-active,
body.mc-login-loading-active,
body.mc-global-loader--boot-active,
body.mc-global-loader--modal-active {
  overflow: hidden !important;
  touch-action: none;
}

/* ── Invisible layout wrapper (no card/box) ─────────────────── */
.mc-loader__panel,
.mc-loader-panel__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  padding: 0;
  margin: 0;
  text-align: center;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  animation: mc-gl-content-in 0.45s var(--mc-gl-ease) both;
}

@keyframes mc-gl-content-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Status text ─────────────────────────────────────────────── */
.mc-loader__title,
.mc-loader__tagline,
.mc-loader__hint,
.mc-loader__progress {
  display: none !important;
}

.mc-loader__status {
  display: none;
  margin: 28px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--mc-gl-text);
}

.mc-global-loader--modal .mc-loader__status,
.mc-global-loader--boot .mc-loader__status {
  display: block;
}

/* ── Logo stage ─────────────────────────────────────────────── */
.mc-global-loader__stage,
.mc-loader__brand-stage {
  position: relative;
  width: var(--mc-gl-stage-size);
  height: var(--mc-gl-stage-size);
  margin: 0;
  flex-shrink: 0;
}

.mc-global-loader__glow,
.mc-loader__glow {
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--mc-gl-glow) 0%, transparent 70%);
  animation: mc-gl-glow-breathe var(--mc-gl-glow-duration) ease-in-out infinite;
  pointer-events: none;
  will-change: transform, opacity;
}

.mc-global-loader__ring,
.mc-loader__ring {
  display: none;
}

.mc-global-loader__logo-wrap,
.mc-loader__logo-float {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mc-gl-logo-breathe var(--mc-gl-breathe-duration) ease-in-out infinite;
  will-change: transform;
}

.mc-global-loader__logo,
.mc-loader__logo {
  width: var(--mc-gl-logo-size);
  height: var(--mc-gl-logo-size);
  object-fit: contain;
  display: block;
  transform: none;
  filter:
    drop-shadow(0 0 24px var(--mc-gl-teal-glow))
    drop-shadow(0 0 48px rgba(6, 147, 150, 0.18))
    drop-shadow(0 6px 16px rgba(6, 147, 150, 0.14));
}

.mc-global-loader__sr-only,
.mc-loader__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Animated dots below status ──────────────────────────────── */
.mc-loader__dots {
  display: none;
  gap: 7px;
  margin-top: 14px;
  height: 8px;
  align-items: center;
  justify-content: center;
}

.mc-global-loader--modal .mc-loader__dots,
.mc-global-loader--boot .mc-loader__dots {
  display: flex;
}

.mc-loader__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mc-gl-teal);
  opacity: 0.3;
  animation: mc-gl-dot-bounce 1.1s ease-in-out infinite;
}

.mc-loader__dot:nth-child(2) { animation-delay: 0.16s; }
.mc-loader__dot:nth-child(3) { animation-delay: 0.32s; }

/* ── Keyframes (transform + opacity only for 60 FPS) ─────────── */
@keyframes mc-gl-logo-breathe {
  0%, 100% {
    transform: translateY(0) scale(0.95);
  }
  50% {
    transform: translateY(-8px) scale(1);
  }
}

@keyframes mc-gl-glow-breathe {
  0%, 100% {
    opacity: 0.45;
    transform: scale(0.88);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.06);
  }
}

@keyframes mc-gl-dot-bounce {
  0%, 80%, 100% {
    opacity: 0.28;
    transform: translateY(0) scale(0.9);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px) scale(1);
  }
}

/* ── Inline mini loaders (buttons / tables) ──────────────────── */
.mc-global-mini,
.spinner:not([hidden]),
.btn-spinner:not([hidden]),
.mc-btn-spinner:not([hidden]),
.bhw-btn-spinner:not([hidden]),
.pts-btn__spinner:not([hidden]),
.pd-spinner:not([hidden]),
.ref-spinner,
.staff-apps-loading__spinner,
.ocr-status-spinner:not([hidden]),
.saving-spinner {
  display: inline-block !important;
  position: relative;
  width: 34px !important;
  height: 10px !important;
  min-width: 34px;
  min-height: 10px;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  vertical-align: middle;
  animation: none !important;
}

.mc-global-mini::before,
.spinner:not([hidden])::before,
.btn-spinner:not([hidden])::before,
.mc-btn-spinner:not([hidden])::before,
.bhw-btn-spinner:not([hidden])::before,
.pts-btn__spinner:not([hidden])::before,
.pd-spinner:not([hidden])::before,
.ref-spinner::before,
.staff-apps-loading__spinner::before,
.ocr-status-spinner:not([hidden])::before,
.saving-spinner::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 2px;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 13px 0 0 currentColor, 26px 0 0 currentColor;
  opacity: 0.55;
  animation: mc-gl-dot 1s ease-in-out infinite;
}

@keyframes mc-gl-dot {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.mc-inline-loading,
.staff-apps-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 16px;
  color: var(--mc-gl-text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
}

.mc-inline-loading .mc-global-loader__stage,
.staff-apps-loading .mc-global-loader__stage,
.staff-apps-loading .mc-loader__brand-stage {
  --mc-gl-stage-size: 56px;
  --mc-gl-logo-size: 36px;
  width: 56px;
  height: 56px;
}

.mc-inline-loading .mc-global-loader__logo,
.staff-apps-loading .mc-global-loader__logo,
.staff-apps-loading .mc-loader__logo {
  filter: drop-shadow(0 0 8px var(--mc-gl-teal-glow));
}

.mc-inline-loading .mc-global-loader__logo-wrap,
.staff-apps-loading .mc-global-loader__logo-wrap,
.staff-apps-loading .mc-loader__logo-float {
  animation: mc-gl-logo-breathe 2.8s ease-in-out infinite;
}

.bhw-patient-picker-loading,
.bhw-records-loading,
.bhw-cons-loading .mc-inline-loading {
  padding: 18px 16px;
}

.bhw-cons-loading,
.bhw-cons-empty,
.bhw-cons-error {
  text-align: center;
  padding: 24px 12px !important;
  color: #64748b;
  font-size: 12px;
  white-space: normal;
}

.bhw-records-loading {
  display: block;
  padding: 0;
}

.bhw-records-loading::before {
  display: none;
}

.bhw-patient-picker-loading {
  padding: 0;
  text-align: center;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --mc-gl-logo-size: 180px;
    --mc-gl-stage-size: 230px;
  }

  .mc-loader__status {
    font-size: 0.98rem;
    margin-top: 22px;
  }
}

@media (max-width: 480px) {
  :root {
    --mc-gl-logo-size: 148px;
    --mc-gl-stage-size: 190px;
  }

  .mc-loader__status {
    font-size: 0.92rem;
    margin-top: 18px;
  }
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mc-global-loader__logo,
  .mc-loader__logo,
  .mc-global-loader__logo-wrap,
  .mc-global-loader__glow,
  .mc-loader__logo-float,
  .mc-loader__glow,
  .mc-loader__dot,
  .mc-loader__panel,
  .spinner:not([hidden])::before,
  .btn-spinner:not([hidden])::before {
    animation: none !important;
  }

  .mc-global-loader__logo-wrap,
  .mc-loader__logo-float {
    transform: none;
  }
}
