/**
 * Loading Indicator Styles
 * Visual feedback for HTMX content loading
 */

/* Loading Indicator Overlay */
.htmx-loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.htmx-loading-indicator.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: var(--color-surface-1);
  padding: 2rem;
  border-radius: 8px;
  border: 2px solid var(--color-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--color-default-fg);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Loading State for Content Area */
.htmx-loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Content Skeleton Loader */
.content-skeleton {
  padding: 2rem;
  animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-header {
  height: 3rem;
  background: var(--color-surface-2);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  width: 60%;
}

.skeleton-line {
  height: 1rem;
  background: var(--color-surface-2);
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.skeleton-line.short {
  width: 70%;
}

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

/* Progress Bar (Alternative Style) */
.htmx-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-brand);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 10000;
  opacity: 0;
}

.htmx-progress-bar.loading {
  opacity: 1;
  animation: progress 2s ease-in-out;
}

@keyframes progress {
  0% {
    transform: scaleX(0);
  }
  50% {
    transform: scaleX(0.7);
  }
  100% {
    transform: scaleX(0.95);
  }
}

/* Error Message Styles */
.error-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  min-height: 400px;
}

.error-message h2 {
  color: var(--color-error-fg);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.error-message p {
  color: var(--color-muted-fg);
  margin-bottom: 2rem;
  max-width: 400px;
}

.error-message button {
  margin-top: 1rem;
}

/* Loading indicator for specific elements */
[hx-get].htmx-request {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

[hx-get].htmx-request::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .spinner-ring,
  [hx-get].htmx-request::after {
    animation: none;
    border-top-color: var(--color-brand);
  }
  
  .content-skeleton {
    animation: none;
    opacity: 0.7;
  }
  
  .htmx-loading-indicator,
  .htmx-loading {
    transition: none;
  }
}
