/**
 * REPUESTÓPOLIS - Animaciones y Transiciones
 * Keyframes y animaciones reutilizables con soporte de accesibilidad
 */

/* ==================== VARIABLES CSS ==================== */

:root {
  /* Durations */
  --animation-speed-fast: 0.2s;
  --animation-speed-normal: 0.3s;
  --animation-speed-slow: 0.5s;
  --animation-speed-slower: 0.8s;
  --animation-speed-slowest: 1s;

  /* Easing functions */
  --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);
  --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
  --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
  --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ==================== ACCESSIBILITY ==================== */

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== FADE ANIMATIONS ==================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==================== SLIDE ANIMATIONS ==================== */

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

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ==================== SCALE ANIMATIONS ==================== */

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.5);
  }
}

/* ==================== BOUNCE & ELASTIC ==================== */

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
  }
}

/* ==================== SPIN & ROTATE ==================== */

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinReverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

/* ==================== SHAKE & VIBRATE ==================== */

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

@keyframes shakeY {
  0%, 100% {
    transform: translateY(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateY(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateY(5px);
  }
}

/* ==================== SHIMMER & LOADING ==================== */

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes shimmerGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes progress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ==================== HEARTBEAT ==================== */

@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  10%, 30% {
    transform: scale(0.9);
  }
  20%, 40% {
    transform: scale(1.1);
  }
}

/* ==================== UTILITY CLASSES ==================== */

/* Fade animations */
.animate-fadeIn {
  animation: fadeIn var(--animation-speed-normal) var(--ease-out-quad);
}

.animate-fadeInUp {
  animation: fadeInUp var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-fadeInDown {
  animation: fadeInDown var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-fadeInLeft {
  animation: fadeInLeft var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-fadeInRight {
  animation: fadeInRight var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-fadeOut {
  animation: fadeOut var(--animation-speed-fast) var(--ease-in-quad);
}

/* Slide animations */
.animate-slideIn {
  animation: slideIn var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-slideInRight {
  animation: slideInRight var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-slideInLeft {
  animation: slideInLeft var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-slideUp {
  animation: slideUp var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-slideDown {
  animation: slideDown var(--animation-speed-normal) var(--ease-out-cubic);
}

/* Scale animations */
.animate-scaleIn {
  animation: scaleIn var(--animation-speed-fast) var(--ease-out-quad);
}

.animate-scaleOut {
  animation: scaleOut var(--animation-speed-fast) var(--ease-in-quad);
}

.animate-zoomIn {
  animation: zoomIn var(--animation-speed-normal) var(--ease-out-cubic);
}

.animate-zoomOut {
  animation: zoomOut var(--animation-speed-normal) var(--ease-in-cubic);
}

/* Other animations */
.animate-bounce {
  animation: bounce var(--animation-speed-slowest) infinite;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-pulseGlow {
  animation: pulseGlow 2s ease-in-out infinite;
}

.animate-spin {
  animation: spin var(--animation-speed-slowest) linear infinite;
}

.animate-spinReverse {
  animation: spinReverse var(--animation-speed-slowest) linear infinite;
}

.animate-shake {
  animation: shake var(--animation-speed-slow) var(--ease-out-quad);
}

.animate-shakeY {
  animation: shakeY var(--animation-speed-slow) var(--ease-out-quad);
}

.animate-wiggle {
  animation: wiggle var(--animation-speed-slow) var(--ease-in-out-quad);
}

.animate-heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

/* ==================== SKELETON LOADERS ==================== */

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 4px;
}

.skeleton-text {
  height: 12px;
  margin-bottom: 8px;
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 4px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
}

.skeleton-card {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 8px;
  min-height: 200px;
}

/* ==================== PROGRESS BARS ==================== */

.progress-bar {
  position: relative;
  overflow: hidden;
  background-color: #e5e7eb;
  border-radius: 9999px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 9999px;
  transition: width 0.5s ease-in-out;
}

.progress-bar-animated::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progress 2s infinite;
}

/* ==================== TRANSITIONS ==================== */

.transition-all {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

.transition-smooth {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-bounce {
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ==================== HOVER EFFECTS ==================== */

.hover-lift {
  transition: transform 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-4px);
}

.hover-grow {
  transition: transform 0.2s ease;
}

.hover-grow:hover {
  transform: scale(1.05);
}

.hover-shrink {
  transition: transform 0.2s ease;
}

.hover-shrink:hover {
  transform: scale(0.95);
}

.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
}

/* ==================== TOAST / NOTIFICATION ==================== */

.toast-enter {
  animation: slideInRight 0.3s ease-out;
}

.toast-exit {
  animation: fadeOut 0.2s ease-out;
}

.notification-badge {
  animation: scaleIn 0.2s ease-out;
}

/* ==================== MODAL ==================== */

.modal-backdrop-enter {
  animation: fadeIn 0.2s ease-out;
}

.modal-backdrop-exit {
  animation: fadeOut 0.2s ease-out;
}

.modal-content-enter {
  animation: scaleIn 0.3s ease-out;
}

.modal-content-exit {
  animation: scaleOut 0.2s ease-out;
}

/* ==================== DELAY & DURATION UTILITIES ==================== */

.delay-75 {
  animation-delay: 75ms;
}

.delay-100 {
  animation-delay: 100ms;
}

.delay-150 {
  animation-delay: 150ms;
}

.delay-200 {
  animation-delay: 200ms;
}

.delay-300 {
  animation-delay: 300ms;
}

.delay-500 {
  animation-delay: 500ms;
}

.duration-fast {
  animation-duration: var(--animation-speed-fast);
}

.duration-normal {
  animation-duration: var(--animation-speed-normal);
}

.duration-slow {
  animation-duration: var(--animation-speed-slow);
}

.duration-slower {
  animation-duration: var(--animation-speed-slower);
}

.duration-slowest {
  animation-duration: var(--animation-speed-slowest);
}
