/**
 * Spinner/Loading Component Styles
 * Unified loading indicators
 */

/* ===========================================
   BASE SPINNER
   =========================================== */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spinner-rotate 0.7s linear infinite;
}

/* ===========================================
   SPINNER SIZES
   =========================================== */

.spinner-xs {
  width: 12px;
  height: 12px;
  border-width: 1px;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.spinner-md {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.spinner-xl {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* ===========================================
   SPINNER COLORS
   =========================================== */

.spinner-primary {
  border-top-color: var(--color-primary);
}

.spinner-accent {
  border-top-color: var(--color-accent);
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
}

.spinner-success {
  border-top-color: var(--color-success);
}

/* ===========================================
   SPINNER ANIMATION
   =========================================== */

@keyframes spinner-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===========================================
   LOADING OVERLAY
   =========================================== */

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 10;
}

.loading-overlay-dark {
  background-color: rgba(0, 0, 0, 0.5);
}

.loading-overlay .spinner {
  /* Default spinner in overlay */
}

/* ===========================================
   LOADING INLINE
   =========================================== */

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
}

.loading-inline .spinner {
  flex-shrink: 0;
}

/* ===========================================
   LOADING FULL PAGE
   =========================================== */

.loading-fullpage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-background);
  z-index: var(--z-modal);
}

/* ===========================================
   SKELETON LOADER
   =========================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-border-light) 0%,
    var(--color-background) 50%,
    var(--color-border-light) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: var(--spacing-2);
  border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-circle {
  border-radius: var(--radius-full);
}

.skeleton-card {
  aspect-ratio: 3/4;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-button {
  height: 36px;
  width: 100px;
  border-radius: var(--radius-sm);
}

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

/* ===========================================
   PROGRESS BAR
   =========================================== */

.progress {
  width: 100%;
  height: 4px;
  background-color: var(--color-border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.progress-bar-accent {
  background-color: var(--color-accent);
}

.progress-bar-success {
  background-color: var(--color-success);
}

/* Indeterminate progress */
.progress-indeterminate .progress-bar {
  width: 30%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* ===========================================
   REDUCED MOTION
   =========================================== */

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .skeleton,
  .progress-indeterminate .progress-bar {
    animation: none;
  }

  .skeleton {
    background: var(--color-border-light);
  }
}
