/* ==========================================================================
   LOADING STATES
   Modern loading component styles using design tokens
   ========================================================================== */

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

.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-neutral-300);
  border-right-color: var(--color-primary-700);
  border-radius: var(--radius-full);
  animation: spinner-rotate 0.75s linear infinite;
}

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

/* Spinner sizes */
.spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

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

/* Spinner colors */
.spinner-primary {
  border-color: var(--color-primary-200);
  border-right-color: var(--color-primary-700);
}

.spinner-light {
  border-color: rgba(255, 255, 255, 0.3);
  border-right-color: var(--color-neutral-0);
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-modal);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-overlay);
}

.loading-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--padding-xl);
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.loading-overlay-text {
  font-size: var(--text-md);
  font-weight: var(--font-medium);
  color: var(--color-neutral-700);
}

/* ====================
   LOADING BAR
   ==================== */

.loading-bar {
  position: relative;
  width: 100%;
  height: 4px;
  background-color: var(--color-neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loading-bar-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: var(--color-primary-700);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--ease-out);
}

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

@keyframes loading-bar-slide {
  0% {
    left: -30%;
  }
  100% {
    left: 100%;
  }
}

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

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

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

/* Skeleton variants */
.skeleton-text {
  height: 1rem;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}

.skeleton-text-lg {
  height: 1.5rem;
}

.skeleton-circle {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
}

.skeleton-rect {
  width: 100%;
  height: 200px;
}

/* ====================
   PULSE LOADER
   ==================== */

.pulse-loader {
  display: inline-flex;
  gap: var(--gap-xs);
  align-items: center;
}

.pulse-dot {
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--color-primary-700);
  border-radius: var(--radius-full);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.pulse-dot:nth-child(1) {
  animation-delay: 0s;
}

.pulse-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.pulse-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

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

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-sm);
  color: var(--color-neutral-600);
  font-size: var(--text-sm);
}

/* ====================
   COMPONENT LOADING STATE
   ==================== */

.is-loading {
  position: relative;
  pointer-events: none;
}

.is-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.is-loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  margin-left: -1rem;
  margin-top: -1rem;
  border: 3px solid var(--color-neutral-300);
  border-right-color: var(--color-primary-700);
  border-radius: var(--radius-full);
  animation: spinner-rotate 0.75s linear infinite;
}
