/**
 * ============================================================
 * GESTION JD AUTOMOBILES v2.0 — Animations
 * ============================================================
 * CSS Animations & Keyframes
 */

/* ============================================================
   FADE IN ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

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

/* ============================================================
   SLIDE ANIMATIONS
   ============================================================ */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  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 scaleUp {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.05);
  }
}

/* ============================================================
   ROTATE ANIMATIONS
   ============================================================ */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

/* ============================================================
   BOUNCE ANIMATIONS
   ============================================================ */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

/* ============================================================
   SHAKE ANIMATIONS
   ============================================================ */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* ============================================================
   GLOW ANIMATIONS
   ============================================================ */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.6);
  }
}

@keyframes textGlow {
  0%, 100% {
    text-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
  }
  50% {
    text-shadow: 0 0 20px rgba(46, 204, 113, 0.6), 0 0 30px rgba(46, 204, 113, 0.4);
  }
}

/* ============================================================
   LOADING ANIMATIONS
   ============================================================ */
@keyframes loading {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes spinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes dots {
  0%, 20% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ============================================================
   ANIMATION CLASSES
   ============================================================ */
.animate-fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease forwards;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease forwards;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.6s ease forwards;
}

.animate-fade-in-right {
  animation: fadeInRight 0.6s ease forwards;
}

.animate-scale-in {
  animation: scaleIn 0.5s ease forwards;
}

.animate-bounce {
  animation: bounce 2s ease infinite;
}

.animate-pulse {
  animation: pulse 2s ease infinite;
}

.animate-glow {
  animation: glow 2s ease infinite;
}

/* ============================================================
   DELAY CLASSES
   ============================================================ */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }

/* ============================================================
   DURATION CLASSES
   ============================================================ */
.duration-300 { animation-duration: 300ms; }
.duration-500 { animation-duration: 500ms; }
.duration-700 { animation-duration: 700ms; }
.duration-1000 { animation-duration: 1000ms; }

/* ============================================================
   INTERSECTION OBSERVER ANIMATIONS
   ============================================================ */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children animation */
.animate-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.animate-stagger.is-visible > *:nth-child(1) { transition-delay: 100ms; }
.animate-stagger.is-visible > *:nth-child(2) { transition-delay: 200ms; }
.animate-stagger.is-visible > *:nth-child(3) { transition-delay: 300ms; }
.animate-stagger.is-visible > *:nth-child(4) { transition-delay: 400ms; }
.animate-stagger.is-visible > *:nth-child(5) { transition-delay: 500ms; }
.animate-stagger.is-visible > *:nth-child(6) { transition-delay: 600ms; }

.animate-stagger.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   LOADING STATES
   ============================================================ */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(46, 204, 113, 0.1),
    transparent
  );
  animation: loading 1.5s infinite;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-border);
  border-top-color: var(--green-primary);
  border-radius: 50%;
  animation: spinner 1s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

/* Dots loader */
.dots-loader {
  display: inline-flex;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  background: var(--green-primary);
  border-radius: 50%;
  animation: dots 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* ============================================================
   TRANSITION CLASSES
   ============================================================ */
.transition-all {
  transition: all 0.3s ease;
}

.transition-opacity {
  transition: opacity 0.3s ease;
}

.transition-transform {
  transition: transform 0.3s ease;
}

.transition-colors {
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* ============================================================
   HOVER EFFECTS
   ============================================================ */
.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.4);
}

.hover-scale:hover {
  transform: scale(1.02);
}

/* ============================================================
   HERO PARTICLES BACKGROUND
   ============================================================ */
.particles-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--green-primary);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 15s infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(100vh) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-100vh) translateX(100px);
    opacity: 0;
  }
}

/* ============================================================
   COUNTER ANIMATION
   ============================================================ */
.counter {
  display: inline-block;
}

.counter.js-counter-loading {
  opacity: 0.5;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green-primary), var(--green-dark));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* ============================================================
   NOTIFICATION TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  z-index: 10000;
  animation: slideInUp 0.3s ease forwards;
}

.toast.removing {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface) 25%,
    var(--bg-elevated) 50%,
    var(--bg-surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-title {
  height: 1.5em;
  margin-bottom: 0.75em;
}

.skeleton-image {
  aspect-ratio: 16 / 10;
  width: 100%;
}

/* ============================================================
   MODAL ANIMATIONS
   ============================================================ */
.modal {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active .modal-backdrop {
  opacity: 1;
}

.modal-content {
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

/* ============================================================
   RIPPLE EFFECT
   ============================================================ */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(46, 204, 113, 0.3) 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}
