/* ==================== Fix para el Loading Spinner ==================== */

/* Overlay de fondo oscuro */
#loadingOverlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background-color: rgba(0, 0, 0, 0.6) !important;
  z-index: 9998 !important;
}

#loadingOverlay.d-none {
  display: none !important;
}

#loadingOverlay.d-block {
  display: block !important;
}

/* Contenedor del loader - centrado perfectamente */
#contenedor {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 10000 !important;
  background: white !important;
  padding: 2.5rem 3rem !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25) !important;
  min-width: 250px !important;
  height: auto !important;
  justify-content: center !important;
  align-items: center !important;
  flex-direction: column !important;
  text-align: center !important;
}

/* Oculto por defecto - IMPORTANTE */
#contenedor.d-none {
  display: none !important;
}

/* Cuando está visible */
#contenedor.d-flex {
  display: flex !important;
}

/* Spinner específico */
#contenedor .spinner-border {
  width: 3rem !important;
  height: 3rem !important;
  border-width: 0.3rem !important;
  margin: 0 auto !important;
  display: block !important;
  flex-shrink: 0 !important;
}

/* Texto del spinner */
#contenedor p {
  margin-top: 1rem !important;
  margin-bottom: 0 !important;
  font-size: 1rem !important;
  font-weight: 500 !important;
  color: #6c757d !important; /* Gris secundario de Bootstrap */
}

/* Móviles */
@media (max-width: 768px) {
  #contenedor {
    padding: 2rem 3rem !important;
    min-width: 240px !important;
    width: 85% !important;
    max-width: 320px !important;
  }

  #contenedor .spinner-border {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }

  #contenedor p {
    font-size: 0.95rem !important;
  }
}

/* Móviles pequeños */
@media (max-width: 480px) {
  #contenedor {
    padding: 1.5rem 2rem !important;
    min-width: 200px !important;
  }

  #contenedor .spinner-border {
    width: 2rem !important;
    height: 2rem !important;
    border-width: 0.25rem !important;
  }

  #contenedor p {
    font-size: 0.9rem !important;
  }
}

/* Overlay de fondo opcional */
#contenedor::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: -1;
  width: 100vw;
  height: 100vh;
  margin-left: -50vw;
  margin-top: -50vh;
}

/* Animación suave de entrada */
#contenedor {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Asegurar que el spinner gire correctamente */
.spinner-border {
  animation: spinner-border 0.75s linear infinite !important;
}

@keyframes spinner-border {
  to {
    transform: rotate(360deg);
  }
}

/* Estilos para la barra de progreso del modal */
#autoCloseProgress {
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

#autoCloseProgress .progress-bar {
  animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 2px 4px rgba(252, 1, 14, 0.3);
  }
  50% {
    box-shadow: 0 2px 8px rgba(252, 1, 14, 0.5);
  }
}

/* Animación del contador */
#countdownNumber {
  display: inline-block;
  min-width: 20px;
  animation: pulse-number 1s ease-in-out infinite;
}

@keyframes pulse-number {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}