/**
 * Loader Minimalista Corregido - Mecatecno Metalúrgica
 * Progress bar nítida y brillante con efectos elegantes
 */

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--black);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  animation: loaderFadeIn 0.8s ease-out forwards;
  overflow: hidden;
}

.page-loader.show {
  opacity: 1;
  visibility: visible;
}

/* Fondo ambiente sutil */
.loader-ambient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, 
    rgba(125, 14, 223, 0.05) 0%, 
    transparent 60%);
  z-index: 1;
  animation: ambientPulse 4s ease-in-out infinite;
}

/* Contenedor principal */
.minimal-loader-content {
  position: relative;
  z-index: 5;
  text-align: center;
  transform: translateY(30px);
  opacity: 0;
  animation: contentSlideUp 1s ease-out 0.2s forwards;
}

/* Contenedor de la barra de progreso */
.minimal-progress-container {
  width: 400px;
  margin-bottom: 3rem;
  position: relative;
}

/* Track de la barra (fondo) */
.minimal-progress-track {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

/* Línea de progreso brillante */
.minimal-progress-line {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.8) 0%,
    rgba(255, 255, 255, 1) 50%,
    rgba(255, 255, 255, 0.8) 100%);
  border-radius: 2px;
  position: relative;
  transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 0 10px rgba(255, 255, 255, 0.6),
    0 0 20px rgba(255, 255, 255, 0.4),
    0 0 30px rgba(255, 255, 255, 0.2);
}

/* Efecto shimmer que se mueve */
.minimal-progress-line::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -30px;
  width: 30px;
  height: 4px;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(255, 255, 255, 0.9) 50%,
    transparent 100%);
  border-radius: 2px;
  animation: shimmerMove 1.8s ease-in-out infinite;
}

/* Punto brillante al final */
.minimal-progress-line::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, 
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.6) 40%,
    transparent 70%);
  border-radius: 50%;
  animation: pointGlow 1.5s ease-in-out infinite;
}

/* Texto de estado elegante */
.minimal-status-text {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(15px);
  animation: statusTextAppear 0.6s ease-out 0.8s forwards;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Estados específicos del texto */
.minimal-status-text.loading { color: rgba(255, 255, 255, 0.7); }
.minimal-status-text.preparing { color: rgba(125, 14, 223, 0.9); }
.minimal-status-text.optimizing { color: rgba(155, 11, 195, 0.9); }
.minimal-status-text.finalizing { color: rgba(183, 44, 222, 0.9); }
.minimal-status-text.completed { 
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

/* Efectos de salida MÁS RÁPIDOS */
.page-loader.exit {
  animation: loaderFadeOut 0.6s ease-out forwards; /* Reducido de 1.2s */
}

.page-loader.exit .minimal-loader-content {
  animation: contentExitSlide 0.4s ease-out forwards; /* Reducido de 1s */
}

.page-loader.exit .loader-ambient {
  animation: ambientExpand 0.5s ease-out forwards; /* Reducido de 1s */
}

/* Línea de salida MÁS RÁPIDA */
.exit-line {
  animation: exitLineExpand 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; /* Reducido de 1s */
}

/* ANIMACIONES */
@keyframes loaderFadeIn {
  0% {
    opacity: 0;
    visibility: hidden;
    -webkit-backdrop-filter: blur(0px);
    backdrop-filter: blur(0px);
  }
  1% {
    visibility: visible;
  }
  100% {
    opacity: 1;
    visibility: visible;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
}

@keyframes contentSlideUp {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes statusTextAppear {
  0% {
    opacity: 0;
    transform: translateY(15px);
    letter-spacing: 6px;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: 3px;
  }
}

@keyframes shimmerMove {
  0% { 
    left: -30px; 
    opacity: 0; 
  }
  30% { 
    opacity: 1; 
  }
  70% { 
    opacity: 1; 
  }
  100% { 
    left: 100%; 
    opacity: 0; 
  }
}

@keyframes pointGlow {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.4);
    opacity: 1;
  }
}

@keyframes ambientPulse {
  0%, 100% { 
    opacity: 0.05; 
    transform: scale(1); 
  }
  50% { 
    opacity: 0.08; 
    transform: scale(1.1); 
  }
}

@keyframes loaderFadeOut {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@keyframes contentExitSlide {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-15px) scale(0.98);
  }
}

@keyframes ambientExpand {
  0% {
    opacity: 0.05;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(2);
  }
}

@keyframes exitLineExpand {
  0% {
    width: 0;
    opacity: 1;
  }
  50% {
    width: 100vw;
    opacity: 0.8;
  }
  100% {
    width: 100vw;
    opacity: 0;
  }
}

/* RESPONSIVE DESIGN */

/* Tablet Grande (1024px - 1200px) */
@media (max-width: 1200px) {
  .minimal-progress-container {
    width: 350px;
  }
  
  .minimal-status-text {
    font-size: 0.95rem;
    letter-spacing: 2.5px;
  }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .minimal-progress-container {
    width: 320px;
    margin-bottom: 2.5rem;
  }
  
  .minimal-status-text {
    font-size: 0.9rem;
    letter-spacing: 2px;
  }
}

/* Móvil Grande (480px - 768px) */
@media (max-width: 768px) {
  .minimal-progress-container {
    width: 280px;
    margin-bottom: 2rem;
  }
  
  .minimal-status-text {
    font-size: 0.85rem;
    letter-spacing: 1.5px;
  }
}

/* Móvil Pequeño (320px - 480px) */
@media (max-width: 480px) {
  .minimal-progress-container {
    width: 240px;
    margin-bottom: 1.8rem;
  }
  
  .minimal-status-text {
    font-size: 0.8rem;
    letter-spacing: 1px;
  }
}

/* Móvil Extra Pequeño (< 320px) */
@media (max-width: 320px) {
  .minimal-progress-container {
    width: 200px;
    margin-bottom: 1.5rem;
  }
  
  .minimal-status-text {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
  }
}

/* Orientación horizontal */
@media (max-width: 768px) and (orientation: landscape) {
  .minimal-progress-container {
    width: 300px;
    margin-bottom: 1.5rem;
  }
  
  .minimal-status-text {
    font-size: 0.8rem;
    letter-spacing: 1.5px;
  }
}

/* Pantallas muy bajas */
@media (max-height: 500px) {
  .minimal-progress-container {
    width: 250px;
    margin-bottom: 1rem;
  }
  
  .minimal-status-text {
    font-size: 0.75rem;
    letter-spacing: 1px;
  }
}