/* ========================================
   Global Loading & Skeleton Styles
   ======================================== */

/* Global Loading Screen */
.global-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
  pointer-events: none;
}

.global-loading:not(.global-loading--active) {
  display: none;
}

.global-loading--active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.global-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xl);
  text-align: center;
}

.global-loading-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: pulse 2s ease-in-out infinite;
}

.global-loading-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.global-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(31, 107, 255, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.global-loading-text {
  color: var(--color-muted);
  font-size: var(--text-sm);
  margin: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

/* Enhanced Skeleton Styles */
.ui-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-alt) 25%,
    var(--color-surface) 50%,
    var(--color-surface-alt) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-load 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.ui-skeleton--animated {
  animation: skeleton-load 1.5s ease-in-out infinite;
}

@keyframes skeleton-load {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Page Loading Overlay */
.page-loading-overlay {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 11, 24, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.page-loading-overlay--active {
  opacity: 1;
  visibility: visible;
}

.page-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-2xl);
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xl);
}

/* Offline Indicator */
.offline-indicator {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  background: var(--color-error);
  color: #ffffff;
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  z-index: 2000;
  transform: translateY(-100%);
  transition: transform var(--transition);
}

.offline-indicator--active {
  transform: translateY(0);
}

.offline-indicator-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-weight: 500;
}

.offline-indicator-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Connection Lost Message */
.connection-lost {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: var(--space-2xl);
  text-align: center;
  gap: var(--space-lg);
}

.connection-lost-icon {
  width: 64px;
  height: 64px;
  color: var(--color-error);
  margin-bottom: var(--space-md);
}

.connection-lost-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin: 0;
}

.connection-lost-description {
  color: var(--color-muted);
  max-width: 500px;
  margin: 0;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .global-loading-spinner,
  .ui-skeleton,
  .ui-skeleton--animated {
    animation: none;
  }

  .global-loading-logo {
    animation: none;
    opacity: 1;
  }

  .global-loading,
  .page-loading-overlay,
  .offline-indicator {
    transition: none;
  }
}
