/**
 * Loading Styles CSS
 * Styles for progress bars, loading overlays, skeletons, and page transitions
 */

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

#top-progress-bar {
  /* Defined in progress-bar.js for better control */
  /* Additional enhancements can be added here */
}

#top-progress-bar-inner {
  /* Smooth hardware-accelerated animations */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ============================================
   LOADING OVERLAY (for 500ms+ loads)
   ============================================ */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99998; /* Just below progress bar */
  background-color: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Spinner animation */
.loading-overlay .spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #f59e0b; /* Amber color */
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  transform: translateZ(0);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   SKELETON SHIMMER ANIMATION
   ============================================ */

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

/* Enhanced shimmer effect for skeleton screens */
.skeleton-shimmer {
  animation: shimmer 2s ease-in-out infinite;
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
}

/* Skeleton screen container */
#skeleton-screen-container {
  animation: fadeIn 0.2s ease-in;
}

/* ============================================
   PAGE TRANSITION ANIMATIONS
   ============================================ */

/* Fade out animation */
.page-fade-out {
  animation: fadeOut 0.15s ease-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Fade in animation */
.page-fade-in {
  animation: fadeIn 0.2s ease-in forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth transition for content updates */
.content-transitioning {
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

/* ============================================
   ROUTER LOADING STATE
   ============================================ */

/* Applied to main content during navigation */
.router-loading {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}

/* Prevent layout shift during loading */
.router-loading * {
  cursor: wait !important;
}

/* ============================================
   ERROR OVERLAY
   ============================================ */

.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99998;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.error-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.error-overlay-content {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-overlay h3 {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 12px;
}

.error-overlay p {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 24px;
  line-height: 1.5;
}

.error-overlay-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.error-overlay button {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  border: none;
  outline: none;
}

.error-overlay .btn-primary {
  background-color: #f59e0b;
  color: white;
}

.error-overlay .btn-primary:hover {
  background-color: #d97706;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.error-overlay .btn-secondary {
  background-color: #f3f4f6;
  color: #6b7280;
}

.error-overlay .btn-secondary:hover {
  background-color: #e5e7eb;
  color: #374151;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU acceleration hints for animations */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
  will-change: transform, opacity;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-overlay,
  .error-overlay,
  #skeleton-screen-container {
    animation: none;
    transition: none;
  }
}

/* ============================================
   SMOOTH SCROLL ENHANCEMENTS
   ============================================ */

html.smooth-scroll {
  scroll-behavior: smooth;
}

/* Disable smooth scroll during rapid navigation */
html.navigating {
  scroll-behavior: auto;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide element while maintaining space */
.invisible {
  visibility: hidden;
}

/* Hide element completely */
.hidden {
  display: none !important;
}

/* Prevent text selection during transitions */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Loading cursor */
.cursor-loading {
  cursor: wait !important;
}

/* Prevent click events */
.pointer-events-none {
  pointer-events: none !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
  /* Smaller spinner on mobile */
  .loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border-width: 3px;
  }

  /* Smaller error overlay padding */
  .error-overlay-content {
    padding: 24px;
    margin: 16px;
  }
  
  .error-overlay h3 {
    font-size: 20px;
  }
  
  .error-overlay p {
    font-size: 14px;
  }
}

/* ============================================
   DARK MODE SUPPORT (future enhancement)
   ============================================ */

@media (prefers-color-scheme: dark) {
  .skeleton-shimmer {
    background: linear-gradient(
      90deg,
      #2d2d2d 0%,
      #3d3d3d 20%,
      #2d2d2d 40%,
      #2d2d2d 100%
    );
  }
  
  .error-overlay-content {
    background: #1f2937;
  }
  
  .error-overlay h3 {
    color: #f9fafb;
  }
  
  .error-overlay p {
    color: #d1d5db;
  }
}

