/* ==========================================================================
   NuViOLive Loading States & Skeletons
   Modern, accessible UI loading states for async operations, form submissions,
   table fetches, and media initialization.
   ========================================================================== */

@keyframes spinnerRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes shimmerWave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.98); }
}

/* Spinner component */
.ui-spinner {
  display: inline-block;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid currentColor;
  border-right-color: transparent !important;
  border-radius: 9999px;
  animation: spinnerRotate 0.65s linear infinite;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

.ui-spinner-sm {
  width: 0.95rem;
  height: 0.95rem;
  border-width: 1.75px;
}

.ui-spinner-lg {
  width: 2.25rem;
  height: 2.25rem;
  border-width: 3px;
}

/* Button Loading State */
.btn-loading,
button.is-loading,
.submit-button.is-loading {
  position: relative !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  opacity: 0.82;
}

.btn-loading-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Shimmer Skeleton Placeholder */
.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    rgba(226, 232, 240, 0.6) 25%,
    rgba(241, 245, 249, 0.9) 50%,
    rgba(226, 232, 240, 0.6) 75%
  );
  background-size: 200% 100%;
  animation: shimmerWave 1.6s ease-in-out infinite;
  border-radius: 0.375rem;
}

[data-theme="midnight"] .skeleton-shimmer {
  background: linear-gradient(
    90deg,
    rgba(31, 41, 55, 0.6) 25%,
    rgba(55, 65, 81, 0.8) 50%,
    rgba(31, 41, 55, 0.6) 75%
  );
  background-size: 200% 100%;
}

.skeleton-text {
  height: 0.9rem;
  margin-bottom: 0.5rem;
  border-radius: 9999px;
}

.skeleton-text.sm { height: 0.75rem; }
.skeleton-text.lg { height: 1.25rem; }
.skeleton-text.w-24 { width: 6rem; }
.skeleton-text.w-32 { width: 8rem; }
.skeleton-text.w-48 { width: 12rem; }
.skeleton-text.w-full { width: 100%; }

.skeleton-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
}

.skeleton-badge {
  width: 5rem;
  height: 1.4rem;
  border-radius: 9999px;
}

/* Table Loading Rows */
.table-loading-row td {
  padding: 1rem 1.25rem;
}

/* Async View Card Loading State */
.view-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: #64748b;
}

[data-theme="midnight"] .view-loading-state {
  color: #9ca3af;
}

.view-loading-state .loading-radar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  background: #eff6ff;
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  border: 1px solid #bfdbfe;
  animation: pulseGlow 2s infinite ease-in-out;
}

[data-theme="midnight"] .view-loading-state .loading-radar {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.25);
}

.view-loading-state .loading-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.35rem;
}

[data-theme="midnight"] .view-loading-state .loading-title {
  color: #f9fafb;
}

.view-loading-state .loading-desc {
  font-size: 0.9rem;
  color: #64748b;
  max-width: 24rem;
  line-height: 1.5;
}

[data-theme="midnight"] .view-loading-state .loading-desc {
  color: #9ca3af;
}
