.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-8);
  text-align: center;
}

/* Default Loading State */
.loading-default {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-4);
}

.loading-spinner-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-3);
}

.loading-spinner {
  animation: spin 1s linear infinite;
  color: var(--primary-500);
  filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.3));
}

.loading-spinner-small {
  font-size: var(--text-xl);
}

.loading-spinner-medium {
  font-size: var(--text-4xl);
}

.loading-spinner-large {
  font-size: var(--text-5xl);
}

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

.loading-progress {
  width: 140px;
  height: 6px;
  background: var(--bg-gradient-card);
  border-radius: var(--radius-full);
  overflow: hidden;
  box-shadow: var(--shadow-inner);
  border: 1px solid var(--border-color);
}

.loading-progress-bar {
  height: 100%;
  background: var(--bg-gradient-civic);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.loading-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

.loading-message {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-1);
}

.loading-message p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: var(--font-primary);
}

.loading-percentage {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-weight: var(--font-medium);
}

/* Minimal Loading State */
.loading-minimal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2);
}

.loading-spinner-minimal {
  font-size: var(--text-base);
  color: var(--primary-500);
  animation: spin 1s linear infinite;
  filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.2));
}

/* Inline Loading State */
.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-1) 0;
}

.loading-spinner-inline {
  font-size: var(--text-sm);
  color: var(--primary-500);
  animation: spin 1s linear infinite;
}

.loading-inline span {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

/* Size Variants */
.loading-small {
  padding: var(--spacing-4);
}

.loading-large {
  padding: var(--spacing-12);
  min-height: 240px;
}

/* Enhanced Timeout State */
.loading-timeout {
  padding: var(--spacing-12) var(--spacing-8);
}

.loading-timeout-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-4);
  max-width: 480px;
  background: var(--bg-card);
  padding: var(--spacing-8);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.loading-timeout-icon {
  font-size: var(--text-5xl);
  color: var(--civic-gold-500);
  margin-bottom: var(--spacing-2);
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.3));
}

.loading-timeout-content h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  font-family: var(--font-primary);
  text-align: center;
}

.loading-timeout-content p {
  margin: 0;
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  text-align: center;
  font-size: var(--text-base);
}

.loading-retry-btn {
  background: var(--bg-gradient-civic);
  color: var(--text-inverse);
  border: none;
  padding: var(--spacing-3) var(--spacing-6);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: var(--font-primary);
  cursor: pointer;
  transition: var(--transition-all);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-2);
}

.loading-retry-btn:hover {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.loading-retry-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Loading States for Specific Components */
.loading-table {
  width: 100%;
  min-height: 360px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
}

.loading-chart {
  width: 100%;
  min-height: 300px;
  background: var(--bg-gradient-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* Enhanced Loading overlay for existing content */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: inherit;
}

/* Enhanced Pulse animation for skeleton elements */
.loading-pulse {
  animation: pulse 2s ease-in-out infinite;
  background: linear-gradient(90deg, var(--slate-200) 25%, var(--slate-100) 50%, var(--slate-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Enhanced Mobile optimizations */
@media (max-width: 768px) {
  .loading-state {
    padding: var(--spacing-6) var(--spacing-4);
  }
  
  .loading-large {
    padding: var(--spacing-8) var(--spacing-4);
    min-height: 180px;
  }
  
  .loading-timeout {
    padding: var(--spacing-8) var(--spacing-4);
  }
  
  .loading-timeout-content {
    padding: var(--spacing-6);
    max-width: 100%;
  }
  
  .loading-timeout-icon {
    font-size: var(--text-4xl);
  }
  
  .loading-timeout-content h3 {
    font-size: var(--text-xl);
  }
  
  .loading-retry-btn {
    width: 100%;
    max-width: 240px;
  }
  
  .loading-spinner-large {
    font-size: var(--text-4xl);
  }
  
  .loading-progress {
    width: 120px;
  }
}

@media (max-width: 480px) {
  .loading-state {
    padding: var(--spacing-4) var(--spacing-3);
  }
  
  .loading-timeout-content {
    padding: var(--spacing-4);
  }
  
  .loading-timeout-content h3 {
    font-size: var(--text-lg);
  }
  
  .loading-spinner-large {
    font-size: var(--text-3xl);
  }
}

/* Enhanced Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  .loading-spinner-minimal,
  .loading-spinner-inline {
    animation: none;
  }
  
  .loading-spinner::after,
  .loading-spinner-minimal::after,
  .loading-spinner-inline::after {
    content: '●';
    animation: pulse 1s ease-in-out infinite;
  }
  
  .loading-progress-bar,
  .loading-progress-bar::after {
    transition: none;
    animation: none;
  }
  
  .loading-pulse {
    animation: none;
    background: var(--slate-200);
  }
  
  .loading-retry-btn:hover {
    transform: none;
  }
}