/* ============================
   Animation Keyframes
   ============================ */

/* Fade 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);
  }
}

/* Scale animations */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Rotation animations */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.8);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* Slide animations */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Bounce animations */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0,0,0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -30px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0,-4px,0);
  }
}

/* Pulse animations */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(192, 192, 192, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(192, 192, 192, 0.6);
  }
}

/* Shake animations */
@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* Wobble animation */
@keyframes wobble {
  0% {
    transform: none;
  }
  15% {
    transform: translate3d(-25%, 0, 0) rotate3d(0, 0, 1, -5deg);
  }
  30% {
    transform: translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg);
  }
  45% {
    transform: translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg);
  }
  60% {
    transform: translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg);
  }
  75% {
    transform: translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg);
  }
  100% {
    transform: none;
  }
}

/* Typography animations */
@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blinkCursor {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: var(--primary-color);
  }
}

/* Background animations */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes floating {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes floatingReverse {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(20px);
  }
}

/* Loading animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes loadingDots {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes progressBar {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

/* Flip animations */
@keyframes flipInX {
  from {
    transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
    opacity: 0;
  }
  40% {
    transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
  }
  60% {
    transform: perspective(400px) rotate3d(1, 0, 0, 10deg);
    opacity: 1;
  }
  80% {
    transform: perspective(400px) rotate3d(1, 0, 0, -5deg);
  }
  to {
    transform: perspective(400px);
    opacity: 1;
  }
}

@keyframes flipInY {
  from {
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
    opacity: 0;
  }
  40% {
    transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
  }
  60% {
    transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
    opacity: 1;
  }
  80% {
    transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }
  to {
    transform: perspective(400px);
    opacity: 1;
  }
}

/* Zoom animations */
@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  50% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
  50% {
    opacity: 1;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  to {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
}

/* ============================
   Animation Utility Classes
   ============================ */

/* Base animation classes */
.animate {
  animation-duration: 0.5s;
  animation-fill-mode: both;
}

.animate-slow {
  animation-duration: 1s;
  animation-fill-mode: both;
}

.animate-fast {
  animation-duration: 0.3s;
  animation-fill-mode: both;
}

.animate-infinite {
  animation-iteration-count: infinite;
}

/* Fade animations */
.fade-in {
  animation-name: fadeIn;
}

.fade-in-up {
  animation-name: fadeInUp;
}

.fade-in-down {
  animation-name: fadeInDown;
}

.fade-in-left {
  animation-name: fadeInLeft;
}

.fade-in-right {
  animation-name: fadeInRight;
}

/* Scale animations */
.scale-in {
  animation-name: scaleIn;
}

.scale-in-bounce {
  animation-name: scaleInBounce;
}

/* Slide animations */
.slide-in-left {
  animation-name: slideInLeft;
}

.slide-in-right {
  animation-name: slideInRight;
}

.slide-in-up {
  animation-name: slideInUp;
}

.slide-in-down {
  animation-name: slideInDown;
}

/* Bounce animations */
.bounce-in {
  animation-name: bounceIn;
}

.bounce {
  animation-name: bounce;
}

/* Rotation animations */
.rotate {
  animation-name: rotate;
}

.rotate-in {
  animation-name: rotateIn;
}

/* Pulse animations */
.pulse {
  animation-name: pulse;
}

.pulse-glow {
  animation-name: pulseGlow;
}

/* Shake and wobble */
.shake {
  animation-name: shake;
}

.wobble {
  animation-name: wobble;
}

/* Flip animations */
.flip-in-x {
  animation-name: flipInX;
}

.flip-in-y {
  animation-name: flipInY;
}

/* Zoom animations */
.zoom-in {
  animation-name: zoomIn;
}

.zoom-out {
  animation-name: zoomOut;
}

/* Floating animations */
.floating {
  animation-name: floating;
  animation-duration: 3s;
  animation-iteration-count: infinite;
}

.floating-reverse {
  animation-name: floatingReverse;
  animation-duration: 3s;
  animation-iteration-count: infinite;
}

/* Loading animations */
.spin {
  animation-name: spin;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

.loading-dots {
  animation-name: loadingDots;
  animation-duration: 1.4s;
  animation-iteration-count: infinite;
}

/* ============================
   Animation Delays
   ============================ */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* ============================
   Scroll-triggered Animations
   ============================ */
.scroll-animate {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease-out;
}

.scroll-animate.animated {
  opacity: 1;
  transform: translateY(0);
}

.scroll-animate-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: all 0.6s ease-out;
}

.scroll-animate-left.animated {
  opacity: 1;
  transform: translateX(0);
}

.scroll-animate-right {
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.6s ease-out;
}

.scroll-animate-right.animated {
  opacity: 1;
  transform: translateX(0);
}

.scroll-animate-scale {
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.6s ease-out;
}

.scroll-animate-scale.animated {
  opacity: 1;
  transform: scale(1);
}

/* ============================
   Hover Animations
   ============================ */
.hover-lift {
  transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform 0.3s ease-out;
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-rotate {
  transition: transform 0.3s ease-out;
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-glow {
  transition: box-shadow 0.3s ease-out;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(192, 192, 192, 0.4);
}

.hover-bounce {
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.hover-bounce:hover {
  transform: scale(1.1);
}

/* ============================
   Text Animations
   ============================ */
.typewriter {
  overflow: hidden;
  border-right: 2px solid var(--primary-color);
  white-space: nowrap;
  animation: 
    typewriter 3s steps(40, end),
    blinkCursor 0.75s step-end infinite;
}

.text-gradient-animate {
  background: linear-gradient(-45deg, #6c5ce7, #a29bfe, #fd79a8, #fdcb6e);
  background-size: 400% 400%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 3s ease infinite;
}

.text-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

.text-shake {
  animation: shake 0.5s ease-in-out;
}

/* ============================
   Button Animations
   ============================ */
.btn-animate {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-animate::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;
}

.btn-animate:hover::before {
  left: 100%;
}

.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-ripple:hover::after {
  width: 180px;
  height: 180px;
}

/* ============================
   Card Animations
   ============================ */
.card-animate {
  transition: all 0.3s ease;
}

.card-animate:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: var(--shadow-xl);
}

.card-flip {
  perspective: 1000px;
}

.card-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
  transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.card-flip-back {
  transform: rotateY(180deg);
}

/* ============================
   Loading Animations
   ============================ */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(192, 192, 192, 0.1);
  border-left: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-dots-container {
  display: flex;
  gap: 5px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: loadingDots 1.4s infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.loading-wave {
  display: flex;
  gap: 2px;
}

.loading-wave-bar {
  width: 4px;
  height: 20px;
  background: var(--primary-color);
  animation: loadingWave 1s ease-in-out infinite;
}

.loading-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.loading-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.loading-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.loading-wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes loadingWave {
  0%, 40%, 100% {
    transform: scaleY(0.4);
  }
  20% {
    transform: scaleY(1);
  }
}

/* ============================
   Progress Animations
   ============================ */
.progress-bar-animated {
  animation: progressBar 2s ease-out;
}

.progress-circle {
  transform: rotate(-90deg);
}

.progress-circle-path {
  stroke-dasharray: 251.2;
  stroke-dashoffset: 251.2;
  animation: progressCircle 2s ease-out forwards;
}

@keyframes progressCircle {
  to {
    stroke-dashoffset: 0;
  }
}

/* ============================
   Parallax Effects
   ============================ */
.parallax-slow {
  transform: translateZ(0);
  will-change: transform;
}

.parallax-medium {
  transform: translateZ(0);
  will-change: transform;
}

.parallax-fast {
  transform: translateZ(0);
  will-change: transform;
}

/* ============================
   Scroll Animations
   ============================ */
.scroll-reveal {
  opacity: 0;
  visibility: hidden;
  transition: all 0.6s ease-out;
}

.scroll-reveal.revealed {
  opacity: 1;
  visibility: visible;
}

.scroll-reveal-up {
  transform: translateY(50px);
}

.scroll-reveal-up.revealed {
  transform: translateY(0);
}

.scroll-reveal-down {
  transform: translateY(-50px);
}

.scroll-reveal-down.revealed {
  transform: translateY(0);
}

.scroll-reveal-left {
  transform: translateX(-50px);
}

.scroll-reveal-left.revealed {
  transform: translateX(0);
}

.scroll-reveal-right {
  transform: translateX(50px);
}

.scroll-reveal-right.revealed {
  transform: translateX(0);
}

.scroll-reveal-scale {
  transform: scale(0.8);
}

.scroll-reveal-scale.revealed {
  transform: scale(1);
}

/* ============================
   Stagger Animations
   ============================ */
.stagger-item {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease-out;
}

.stagger-item.animated {
  opacity: 1;
  transform: translateY(0);
}

.stagger-item:nth-child(1) { transition-delay: 0.1s; }
.stagger-item:nth-child(2) { transition-delay: 0.2s; }
.stagger-item:nth-child(3) { transition-delay: 0.3s; }
.stagger-item:nth-child(4) { transition-delay: 0.4s; }
.stagger-item:nth-child(5) { transition-delay: 0.5s; }
.stagger-item:nth-child(6) { transition-delay: 0.6s; }

/* ============================
   Performance Optimizations
   ============================ */
.gpu-accelerated,
.floating-element,
.hero-title,
.feature-card,
.product-card,
.stat-card,
.btn {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
  will-change: transform;
}

/* Optimize heavy animations */
@keyframes floating {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -20px, 0);
  }
}

@keyframes floatingReverse {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, 20px, 0);
  }
}

/* Reduce motion for accessibility and performance on low-end devices */
@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;
    will-change: auto !important;
  }
}

/* Performance optimization for slower devices */
@media (max-width: 768px) {
  .floating,
  .floating-reverse,
  .parallax-slow,
  .parallax-medium,
  .parallax-fast {
    animation: none !important;
    transform: none !important;
  }
}

/* ============================
   Custom Animation Combinations
   ============================ */
.hero-title-animate {
  animation: fadeInUp 1s ease-out;
}

.hero-description-animate {
  animation: fadeInUp 1s ease-out 0.3s both;
}

.hero-buttons-animate {
  animation: fadeInUp 1s ease-out 0.6s both;
}

.stats-counter-animate {
  animation: scaleInBounce 0.8s ease-out;
}

.feature-card-animate {
  animation: fadeInUp 0.8s ease-out;
}

.product-card-animate {
  animation: scaleIn 0.6s ease-out;
}

.nav-slide-down {
  animation: slideInDown 0.3s ease-out;
}

.modal-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.toast-slide-in {
  animation: slideInRight 0.4s ease-out;
}

.tooltip-bounce-in {
  animation: bounceIn 0.4s ease-out;
}
