/* Variables globales, alineadas con MainPage.css */
:root {
  --bg-gradient-start: #00b4d8;
  --bg-gradient-end: #25d366;
  --font-family: 'Roboto', sans-serif;
  --text-color: #ffffff;
  --transition-duration: 0.5s; /* Para fade-in */
}

/* Fondo de la página de carga */
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  font-family: var(--font-family);
}

/* Estilos para el div de carga inicial (#loading) */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  z-index: 9999;
  margin: 0;
  padding: 0;
  animation: fadeIn 0.5s ease-in;
  transition: opacity 0.3s ease-out;
  overflow: hidden;
}

/* Animación de fondo sutil */
#loading-background-animation {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 70%);
  animation: backgroundMove 20s linear infinite;
  z-index: 0;
  pointer-events: none;
}

/* Contenedor del contenido (debe estar sobre la animación de fondo) */
#loading-content {
  position: relative;
  z-index: 1;
}

/* Fade-out suave antes de ocultar */
#loading.fade-out {
  opacity: 0;
}


/* Logo con animación pulse y sombra */
#loading-logo {
  width: 120px;
  height: auto;
  animation: logoFadeIn 0.6s ease-in, logoPulse 2s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
  will-change: transform;
}

/* Contenedor del texto y puntos */
#loading-text-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: textFadeIn 0.8s ease-in;
}

/* Texto "Cargando" */
#loading-text {
  color: var(--text-color);
  font-size: 18px;
  font-weight: 500;
  opacity: 0.95;
  font-family: var(--font-family);
}

/* Contenedor de puntos animados */
.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Puntos animados individuales */
.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-color);
  border-radius: 50%;
  opacity: 0.9;
  animation: dotBounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Animaciones */
@keyframes logoFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes logoPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

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

@keyframes dotBounce {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  50% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

@keyframes backgroundMove {
  0% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(50px, 50px);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* Responsive: ajustes para pantallas pequeñas */
@media (max-width: 768px) {
  #loading-logo {
    width: 100px;
  }
  
  #loading-text {
    font-size: 16px;
  }
  
  .loading-dots span {
    width: 6px;
    height: 6px;
  }
  
  #loading-content {
    gap: 20px;
  }
}

/* Contenedor del loader */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 30px;
  box-sizing: border-box;
  opacity: 0; /* Inicialmente invisible para fade-in */
  animation: fadeIn var(--transition-duration) ease-in forwards;
}

/* Animación de fade-in */
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Logo durante la carga */
.loading-logo {
  width: 150px; /* Tamaño fijo, similar al comportamiento por defecto */
  height: auto;
  margin-bottom: 30px;
}

/* Loader de tres puntos animados */
.loader {
  display: flex;
  gap: 10px;
}

.loader span {
  width: 15px; /* Tamaño fijo */
  height: 15px;
  background: var(--text-color);
  border-radius: 50%;
  animation: bounce 0.6s ease-in-out infinite alternate;
}

.loader span:nth-child(2) {
  animation-delay: 0.2s;
}

.loader span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  to {
    transform: translateY(-15px);
    opacity: 0.7;
  }
}

/* Texto de carga */
.loading-text {
  color: var(--text-color);
  font-size: 18px; /* Tamaño fijo */
  font-weight: 500;
  margin-top: 20px;
  opacity: 0.9;
}

/* Estilo para el mensaje de noscript */
noscript {
  position: fixed;
  bottom: 20px;
  color: var(--text-color);
  font-size: 14px;
  text-align: center;
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}