/**
 * GeoFazendas Loading Indicator Component
 * =========================================
 * 
 * Global loading indicator with animated SVG frames.
 * Uses 202 SVG frames (000.svg - 201.svg) animated via JavaScript.
 * 
 * USAGE:
 * ------
 * 1. Include this CSS in your page
 * 2. Include loading-indicator.js
 * 3. Use GFLoadingIndicator.show(container, options) to display
 * 
 * VARIANTS:
 * ---------
 * - .gf-loading--overlay: Full overlay on parent container (default for maps)
 * - .gf-loading--inline: Inline loading indicator
 * - .gf-loading--fullscreen: Fullscreen overlay
 * 
 * DATA ATTRIBUTES:
 * ----------------
 * - data-gf-loading: Marks the loading indicator container
 * - data-gf-loading-animation: Container for SVG frame animation
 * - data-gf-loading-message: Text message element
 * - data-gf-loading-progress: Optional progress indicator
 * 
 * @see templates/AGENTS.md for full documentation
 */

/* ==========================================================================
   Base Loading Indicator
   ========================================================================== */

.gf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  z-index: 1000;
}

.gf-loading[hidden] {
  display: none !important;
}

/* Animation Container */
.gf-loading__animation {
  width: 80px;
  height: 80px;
  position: relative;
}

.gf-loading__animation img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Message Text */
.gf-loading__message {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--bs-body-color, #212529);
  text-align: center;
  max-width: 280px;
  line-height: 1.4;
}

/* Progress Bar (optional) */
.gf-loading__progress {
  width: 100%;
  max-width: 200px;
  height: 4px;
  background-color: var(--bs-secondary-bg, #e9ecef);
  border-radius: 2px;
  overflow: hidden;
}

.gf-loading__progress-bar {
  height: 100%;
  background-color: var(--gf-success, #198754);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

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

@keyframes gf-loading-progress {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(200%);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* ==========================================================================
   Overlay Variant (for maps and containers)
   ========================================================================== */

.gf-loading--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(2px);
  border-radius: inherit;
}

/* Dark theme overlay */
.gf-loading--overlay.gf-loading--dark {
  background-color: rgba(33, 37, 41, 0.92);
}

.gf-loading--overlay.gf-loading--dark .gf-loading__message {
  color: #fff;
}

/* ==========================================================================
   Inline Variant
   ========================================================================== */

.gf-loading--inline {
  display: inline-flex;
  flex-direction: row;
  padding: 0.5rem;
  gap: 0.75rem;
}

.gf-loading--inline .gf-loading__animation {
  width: 24px;
  height: 24px;
}

.gf-loading--inline .gf-loading__message {
  font-size: 0.875rem;
}

/* ==========================================================================
   Fullscreen Variant
   ========================================================================== */

.gf-loading--fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.98);
  z-index: 9999;
}

/* ==========================================================================
   Map-Specific Styles
   ========================================================================== */

.gf-loading--map {
  /* Ensure it appears above Leaflet layers (Leaflet uses 400-1000) */
  z-index: 1050;
  /* Center content in the middle of the map */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Full coverage with dark semi-transparent background */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
  border-radius: inherit;
}

/* Make logo white on dark background */
.gf-loading--map .gf-loading__animation img {
  filter: brightness(0) invert(1);
}

.gf-loading--map .gf-loading__animation {
  width: 72px;
  height: 72px;
}

.gf-loading--map .gf-loading__message {
  background-color: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  font-size: 0.875rem;
  font-weight: 500;
}

/* ==========================================================================
   Satellite Loading Specific
   ========================================================================== */

.gf-loading--satellite .gf-loading__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: var(--gf-success, #198754);
  border-radius: 50%;
  color: #fff;
  margin-bottom: 0.5rem;
}

.gf-loading--satellite .gf-loading__icon .material-icons-outlined {
  font-size: 1.25rem;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 575.98px) {
  .gf-loading__animation {
    width: 64px;
    height: 64px;
  }

  .gf-loading__message {
    font-size: 0.875rem;
    max-width: 240px;
  }

  .gf-loading--map .gf-loading__animation {
    width: 56px;
    height: 56px;
  }
}

/* ==========================================================================
   Animation States
   ========================================================================== */

/* Fade in/out transitions */
.gf-loading--animate-in {
  animation: gf-loading-fade-in 0.2s ease-out forwards;
}

.gf-loading--animate-out {
  animation: gf-loading-fade-out 0.2s ease-in forwards;
}

@keyframes gf-loading-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes gf-loading-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Pulse animation for the logo */
.gf-loading__animation--pulse {
  animation: gf-loading-pulse 2s ease-in-out infinite;
}

@keyframes gf-loading-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}
