/**
 * Lavhome Loader - Machine à Laver Animée
 * Loader optimisé pour les soumissions de formulaires (3-10s)
 */

/* Import Titillium Web */
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');

/* ============================================
   OVERLAY MODAL
   ============================================ */
.lavhome-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */
.lavhome-loader-container {
  background: #ffffff;
  border-radius: 20px;
  padding: 50px 40px 40px;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  position: relative;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Titillium Web', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   MACHINE À LAVER - SVG ANIMÉ
   ============================================ */
.lavhome-washing-machine {
  width: 56px;
  height: 56px;
  margin: 0 auto 30px;
  position: relative;
  animation: machineVibrate 4s ease-in-out infinite;
  overflow: visible; /* Permet aux bulles de dépasser */
}

.lavhome-washing-machine svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.1));
  overflow: visible; /* Permet aux bulles de s'envoler au-dessus */
}

/* Animation de vibration de la machine (intermittente) */
@keyframes machineVibrate {
  0%, 30% {
    transform: translate(0, 0);
  }
  31% {
    transform: translate(-0.5px, 0.5px);
  }
  32% {
    transform: translate(0.5px, -0.5px);
  }
  33% {
    transform: translate(-0.5px, -0.5px);
  }
  34% {
    transform: translate(0.5px, 0.5px);
  }
  35% {
    transform: translate(-0.5px, 0);
  }
  36% {
    transform: translate(0.5px, 0);
  }
  37%, 60% {
    transform: translate(0, 0);
  }
  61% {
    transform: translate(-1px, 0.5px);
  }
  62% {
    transform: translate(1px, -0.5px);
  }
  63% {
    transform: translate(-1px, -0.5px);
  }
  64% {
    transform: translate(1px, 0.5px);
  }
  65% {
    transform: translate(-0.5px, 0);
  }
  66% {
    transform: translate(0.5px, 0);
  }
  67% {
    transform: translate(-0.5px, 0.5px);
  }
  68% {
    transform: translate(0.5px, -0.5px);
  }
  69%, 100% {
    transform: translate(0, 0);
  }
}

/* Animation de rotation du tambour */
.lavhome-washing-machine .spinner {
  transform-origin: 257.84px 305.93px;
  animation: drumRotate 2s linear infinite;
}

@keyframes drumRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Animation des bulles qui s'envolent */
.lavhome-washing-machine .bubble {
  animation: bubbleFloat 3s ease-in-out infinite;
}

.lavhome-washing-machine .bubble-1 {
  animation-delay: 0s;
}

.lavhome-washing-machine .bubble-2 {
  animation-delay: 0.6s;
}

.lavhome-washing-machine .bubble-3 {
  animation-delay: 1.2s;
}

.lavhome-washing-machine .bubble-4 {
  animation-delay: 1.8s;
}

.lavhome-washing-machine .bubble-5 {
  animation-delay: 2.4s;
}

@keyframes bubbleFloat {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0;
  }
  5% {
    opacity: 0.6;
  }
  15% {
    opacity: 0.8;
  }
  50% {
    opacity: 0.7;
    transform: translateY(-60px) scale(1.2);
  }
  85% {
    opacity: 0.4;
  }
  100% {
    transform: translateY(-150px) scale(0.8);
    opacity: 0;
  }
}

/* ============================================
   TITRE PRINCIPAL
   ============================================ */
.lavhome-loader-title {
  font-size: 20px;
  font-weight: 600;
  color: #2a2a2a;
  margin-bottom: 24px;
  line-height: 1.4;
  font-family: 'Titillium Web', sans-serif !important;
}

/* ============================================
   ÉTAPES DE PROGRESSION
   ============================================ */
.lavhome-loader-steps {
  margin: 25px 0 30px;
  text-align: left;
}

.lavhome-loader-step {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #494949;
  transition: all 0.3s ease;
  font-family: 'Titillium Web', sans-serif;
}

.lavhome-loader-step-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
}

/* État : En attente */
.lavhome-loader-step.pending .lavhome-loader-step-icon {
  background: #f0f0f0;
  color: #9aa0a6;
  border: 2px solid #e0e0e0;
}

.lavhome-loader-step.pending .lavhome-loader-step-text {
  color: #9aa0a6;
}

/* État : En cours */
.lavhome-loader-step.active .lavhome-loader-step-icon {
  background: #3a8c8e;
  color: white;
  border: 2px solid #3a8c8e;
  animation: pulse 1.5s ease-in-out infinite;
}

.lavhome-loader-step.active .lavhome-loader-step-text {
  color: #2a2a2a;
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(58, 140, 142, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(58, 140, 142, 0);
  }
}

/* État : Complété */
.lavhome-loader-step.completed .lavhome-loader-step-icon {
  background: #28a745;
  color: white;
  border: 2px solid #28a745;
}

.lavhome-loader-step.completed .lavhome-loader-step-text {
  color: #28a745;
}

/* Checkmark animé */
.lavhome-loader-step.completed .lavhome-loader-step-icon::after {
  content: "✓";
  font-size: 12px;
  animation: checkmark 0.3s ease;
}

@keyframes checkmark {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Spinner pour état actif */
.lavhome-loader-step.active .lavhome-loader-step-icon::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   BARRE DE PROGRESSION
   ============================================ */
.lavhome-loader-progress-wrapper {
  margin: 30px 0 20px;
}

.lavhome-loader-progress-bar {
  width: 100%;
  height: 8px;
  background: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.lavhome-loader-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3a8c8e 0%, #2d7072 100%);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 10px rgba(58, 140, 142, 0.3);
}

/* Animation de "shimmer" sur la barre */
.lavhome-loader-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.lavhome-loader-progress-text {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #3a8c8e;
  font-family: 'Titillium Web', sans-serif;
}

/* ============================================
   MESSAGE SECONDAIRE
   ============================================ */
.lavhome-loader-message {
  font-size: 14px;
  color: #9aa0a6;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Titillium Web', sans-serif;
}

/* Icône hourglass SVG */
.lavhome-loader-message-icon {
  width: 14px;
  height: 14px;
  fill: #3a8c8e;
  animation: hourglassRotate 2s linear infinite;
}

@keyframes hourglassRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   ÉTAT SUCCESS (CHECKMARK GÉANT)
   ============================================ */
.lavhome-loader-success {
  display: none;
}

.lavhome-loader-container.success .lavhome-loader-content {
  display: none;
}

.lavhome-loader-container.success .lavhome-loader-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.lavhome-loader-success-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #28a745;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  animation: successPop 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.lavhome-loader-success-icon::after {
  content: "✓";
  font-size: 60px;
  color: white;
  font-weight: bold;
}

@keyframes successPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.lavhome-loader-success-title {
  font-size: 24px;
  font-weight: 700;
  color: #28a745;
  margin-bottom: 10px;
  font-family: 'Titillium Web', sans-serif;
}

.lavhome-loader-success-message {
  font-size: 16px;
  color: #494949;
  font-family: 'Titillium Web', sans-serif;
}

/* ============================================
   ÉTAT ERROR
   ============================================ */
.lavhome-loader-container.error .lavhome-washing-machine {
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.lavhome-loader-container.error .lavhome-loader-title {
  color: #dc3545;
}

.lavhome-loader-container.error .lavhome-loader-progress-fill {
  background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
}

/* ============================================
   ANIMATION DE SORTIE
   ============================================ */
.lavhome-loader-overlay.fadeout {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  .lavhome-loader-container {
    padding: 40px 25px 30px;
    max-width: 95%;
  }

  .lavhome-washing-machine {
    width: 48px;
    height: 48px;
  }

  .lavhome-loader-title {
    font-size: 18px;
  }

  .lavhome-loader-step {
    font-size: 13px;
  }

  .lavhome-loader-step-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    font-size: 11px;
  }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .lavhome-loader-overlay,
  .lavhome-loader-container,
  .lavhome-washing-machine .spinner,
  .lavhome-loader-step,
  .lavhome-loader-progress-fill {
    animation: none !important;
    transition: none !important;
  }
}
