/**
 * AMRINOVA - Lightweight Circular Loading Spinner & Transition System
 * Step 2: Zero-Dependency, Pure CSS3, Accessibility-Compliant
 * Brand Colors: Primary Teal (#0d9488) / Emerald (#059669) / Dark Slate (#0f172a)
 */

/* 1. Base Circular Spinner Component */
.amr-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  vertical-align: middle;
  border-radius: 50%;
  box-sizing: border-box;
  border: 3px solid rgba(15, 23, 42, 0.15); /* Slate 900 15% */
  border-top-color: #0d9488; /* AMRINOVA Primary Teal */
  animation: amrSpin 0.75s linear infinite;
  flex-shrink: 0;
}

/* Size Variants */
.amr-spinner-xs {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.amr-spinner-sm {
  width: 18px;
  height: 18px;
  border-width: 2.2px;
}

.amr-spinner-md {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.amr-spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3.5px;
}

/* Color Themes */
.amr-spinner-emerald {
  border-color: rgba(5, 150, 105, 0.18);
  border-top-color: #059669;
}

.amr-spinner-white {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
}

.amr-spinner-amber {
  border-color: rgba(217, 119, 6, 0.2);
  border-top-color: #d97706;
}

/* Continuous Rotation Keyframes */
@keyframes amrSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 2. Button Loading State (.amr-btn-loading) */
button.amr-btn-loading,
.amr-btn-loading {
  position: relative !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  opacity: 0.88 !important;
  user-select: none !important;
}

button.amr-btn-loading .amr-spinner,
.amr-btn-loading .amr-spinner {
  margin-right: 8px;
}

/* 3. Page Loading Overlay (#amrPageLoader) */
.amr-page-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background-color: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.amr-page-loader.amr-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.amr-page-loader-card {
  background-color: #ffffff;
  color: #0f172a;
  padding: 16px 24px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 90vw;
  user-select: none;
}

/* Dark mode card styling */
.dark-theme .amr-page-loader-card,
[data-theme="dark"] .amr-page-loader-card,
body.bg-slate-950 .amr-page-loader-card,
html.bg-slate-950 .amr-page-loader-card {
  background-color: #1e293b;
  color: #f8fafc;
  border-color: #334155;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

.amr-page-loader-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: inherit;
}

/* 4. Input micro-spinner slot for search */
.amr-input-spinner-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}

.amr-input-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  pointer-events: none;
}

.amr-input-spinner-wrap.amr-searching .amr-input-spinner {
  display: inline-block;
}

/* 5. Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .amr-spinner {
    animation: amrPulse 1.4s ease-in-out infinite !important;
    border-top-color: currentColor;
  }
  @keyframes amrPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
  }
  .amr-page-loader {
    transition: none !important;
  }
}

/* 6. Screen reader only helper */
.amr-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
