/* ===================================================================
   MÓDULO ANIMATIONS - Animaciones y transiciones
   ================================================================= */

/* ===================================================================
   KEYFRAMES PRINCIPALES
   ================================================================= */

@keyframes submenuSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes submenuSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
}

@keyframes cartBounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(242, 103, 34, 0.3);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(242, 103, 34, 0);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes slideInFromTop {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInFromBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.8);
    opacity: 0;
  }
}

@keyframes rotateIn {
  from {
    transform: rotate(-180deg) scale(0.8);
    opacity: 0;
  }
  to {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes elasticIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
  75% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===================================================================
   ANIMACIONES ESPECÍFICAS DEL HEADER
   ================================================================= */

/* Animación de entrada del header */
body.meloopets-header .meloopets-header__top-bar {
  animation: slideInFromTop 0.6s ease-out;
}

body.meloopets-header .meloopets-header__middle-bar {
  animation: slideInFromTop 0.6s ease-out 0.1s both;
}

body.meloopets-header .meloopets-header__bottom-bar {
  animation: slideInFromTop 0.6s ease-out 0.2s both;
}

/* Animación de las redes sociales */
body.meloopets-header .meloopets-social-link {
  animation: elasticIn 0.5s ease-out;
}

body.meloopets-header .meloopets-social-link:nth-child(1) { animation-delay: 0.3s; }
body.meloopets-header .meloopets-social-link:nth-child(2) { animation-delay: 0.4s; }
body.meloopets-header .meloopets-social-link:nth-child(3) { animation-delay: 0.5s; }
body.meloopets-header .meloopets-social-link:nth-child(4) { animation-delay: 0.6s; }

/* Animación del logo */
body.meloopets-header .meloopets-logo {
  animation: scaleIn 0.6s ease-out 0.4s both;
}

/* Animación de los elementos de navegación */
body.meloopets-header .meloopets-nav-item {
  animation: slideInFromBottom 0.5s ease-out;
}

body.meloopets-header .meloopets-nav-item:nth-child(1) { animation-delay: 0.5s; }
body.meloopets-header .meloopets-nav-item:nth-child(2) { animation-delay: 0.6s; }
body.meloopets-header .meloopets-nav-item:nth-child(3) { animation-delay: 0.7s; }
body.meloopets-header .meloopets-nav-item:nth-child(4) { animation-delay: 0.8s; }

/* ===================================================================
   ANIMACIONES DE SUBMENÚS
   ================================================================= */



body.meloopets-header .meloopets-nav-item:hover .meloopets-submenu {
  animation: submenuSlideIn var(--transition-slow) var(--transition-bounce);
}

body.meloopets-header .meloopets-submenu-column:nth-child(1) { animation-delay: 0s; animation: columnFadeIn 0.5s ease forwards;}
body.meloopets-header .meloopets-submenu-column:nth-child(2) { animation-delay: 0s; animation: columnFadeIn 0.5s ease forwards;}
body.meloopets-header .meloopets-submenu-column:nth-child(3) { animation-delay: 0s; animation: columnFadeIn 0.5s ease forwards;}
body.meloopets-header .meloopets-submenu-column:nth-child(4) { animation-delay: 0s; animation: columnFadeIn 0.5s ease forwards;}

body.meloopets-header .meloopets-submenu-link {
  animation: fadeIn 0.3s ease-out;
}

body.meloopets-header .meloopets-submenu-link:nth-child(1) { animation-delay: 0.1s; }
body.meloopets-header .meloopets-submenu-link:nth-child(2) { animation-delay: 0.15s; }
body.meloopets-header .meloopets-submenu-link:nth-child(3) { animation-delay: 0.2s; }
body.meloopets-header .meloopets-submenu-link:nth-child(4) { animation-delay: 0.25s; }

/* ===================================================================
   ANIMACIONES DE HOVER
   ================================================================= */

/* Efecto hover con lift */
body.meloopets-header .meloopets-hover-lift {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

body.meloopets-header .meloopets-hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Efecto hover con escala */
body.meloopets-header .meloopets-hover-scale {
  transition: transform var(--transition-normal);
}

body.meloopets-header .meloopets-hover-scale:hover {
  transform: scale(1.05);
}

/* Efecto hover con glow */
body.meloopets-header .meloopets-hover-glow {
  transition: all var(--transition-normal);
}

body.meloopets-header .meloopets-hover-glow:hover {
  animation: pulseGlow 1.5s infinite;
}

/* Efecto hover con shimmer */
body.meloopets-header .meloopets-hover-shimmer {
  position: relative;
  overflow: hidden;
}

body.meloopets-header .meloopets-hover-shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
  z-index: 1;
}

body.meloopets-header .meloopets-hover-shimmer:hover::before {
  animation: shimmer 0.8s ease-out;
}

/* ===================================================================
   ANIMACIONES DEL CARRITO
   ================================================================= */

body.meloopets-header .meloopets-header-actions .meloopets-cart-link .meloopets-cart-count {
  animation: meloopets-cart-pulse 3s infinite;
  transition: all 0.3s ease;
}

@keyframes meloopets-cart-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(242, 103, 34, 0.7);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(242, 103, 34, 0);
  }
}

/* Animación cuando se añade al carrito */
body.meloopets-header .meloopets-cart-count.updated {
  animation: cartBounce 0.6s ease-out;
}

/* ===================================================================
   ANIMACIONES MÓVILES
   ================================================================= */

@media (max-width: 770px) {
  
  /* Animación del menú hamburguesa */
  body.meloopets-header .meloopets-hamburger-line {
    transition: all var(--transition-normal);
    transform-origin: center;
  }
  
  /* Animación del menú móvil */
  body.meloopets-header .meloopets-mobile-menu {
    animation: slideInFromLeft 0.4s ease-out;
  }
  
  body.meloopets-header .meloopets-mobile-nav-item {
    animation: slideInFromLeft 0.3s ease-out;
  }
  
  body.meloopets-header .meloopets-mobile-nav-item:nth-child(1) { animation-delay: 0.1s; }
  body.meloopets-header .meloopets-mobile-nav-item:nth-child(2) { animation-delay: 0.15s; }
  body.meloopets-header .meloopets-mobile-nav-item:nth-child(3) { animation-delay: 0.2s; }
  body.meloopets-header .meloopets-mobile-nav-item:nth-child(4) { animation-delay: 0.25s; }
  body.meloopets-header .meloopets-mobile-nav-item:nth-child(5) { animation-delay: 0.3s; }
  
  /* Animación de la búsqueda móvil */
  body.meloopets-header .meloopets-mobile-search {
    animation: slideInFromTop 0.3s ease-out;
  }
}

/* ===================================================================
   CLASES UTILITARIAS DE ANIMACIÓN
   ================================================================= */

/* Entradas */
body.meloopets-header .meloopets-animate-slideInTop {
  animation: slideInFromTop 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-slideInBottom {
  animation: slideInFromBottom 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-slideInLeft {
  animation: slideInFromLeft 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-slideInRight {
  animation: slideInFromRight 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-fadeIn {
  animation: fadeIn 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-scaleIn {
  animation: scaleIn 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-rotateIn {
  animation: rotateIn 0.5s ease-out;
}

body.meloopets-header .meloopets-animate-elasticIn {
  animation: elasticIn 0.6s ease-out;
}

/* Salidas */
body.meloopets-header .meloopets-animate-fadeOut {
  animation: fadeOut 0.3s ease-out;
}

body.meloopets-header .meloopets-animate-scaleOut {
  animation: scaleOut 0.3s ease-out;
}

/* ===================================================================
   CONFIGURACIÓN DE DELAYS
   ================================================================= */

body.meloopets-header .meloopets-delay-1 { animation-delay: 0.1s; }
body.meloopets-header .meloopets-delay-2 { animation-delay: 0.2s; }
body.meloopets-header .meloopets-delay-3 { animation-delay: 0.3s; }
body.meloopets-header .meloopets-delay-4 { animation-delay: 0.4s; }
body.meloopets-header .meloopets-delay-5 { animation-delay: 0.5s; }

/* ===================================================================
   ANIMACIONES DE SCROLL
   ================================================================= */

body.meloopets-header .meloopets-scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease-out;
}

body.meloopets-header .meloopets-scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ===================================================================
   CONFIGURACIÓN PARA MOVIMIENTO REDUCIDO
   ================================================================= */

@media (prefers-reduced-motion: reduce) {
  body.meloopets-header * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  body.meloopets-header *::before {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  body.meloopets-header *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================================================================
   PERFORMANCE OPTIMIZATIONS
   ================================================================= */

/* Optimizar animaciones para GPU */
body.meloopets-header .meloopets-gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Optimizar elementos que se animan frecuentemente */
body.meloopets-header .meloopets-submenu,
body.meloopets-header .meloopets-mobile-menu,
body.meloopets-header .meloopets-mobile-search,
body.meloopets-header .meloopets-search-overlay {
  will-change: transform, opacity;
}

/* ===================================================================
   ANIMACIONES ESPECIALES DE CARGA
   ================================================================= */

@keyframes headerLoadIn {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  50% {
    transform: translateY(10px);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

body.meloopets-header.loading .meloopets-header__top-bar {
  animation: headerLoadIn 0.8s ease-out;
}

body.meloopets-header.loading .meloopets-header__middle-bar {
  animation: headerLoadIn 0.8s ease-out 0.1s both;
}

body.meloopets-header.loading .meloopets-header__bottom-bar {
  animation: headerLoadIn 0.8s ease-out 0.2s both;
}

@media (min-width: 771px) {
  body.meloopets-header .meloopets-hamburger-line,
  body.meloopets-header .meloopets-mobile-menu,
  body.meloopets-header .meloopets-mobile-nav-item {
    display: none;
  }
}
