/**
 * Animations CSS Module
 * Smooth animations and transitions for Beautiful.ai design
 * Part of Decka.ai V2 Editor
 */

/* === KEYFRAME ANIMATIONS === */

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade Out */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Slide In From Left */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide In From Right */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide In From Top */
@keyframes slideInTop {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Slide In From Bottom */
@keyframes slideInBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

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

/* Bounce In */
@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

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

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

/* Loading Spinner */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Progress Bar */
@keyframes progressBar {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* Glow Effect */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--decka-primary);
  }
  50% {
    box-shadow: 0 0 20px var(--decka-primary), 0 0 30px var(--decka-primary);
  }
}

/* Float */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-6px);
  }
}

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

/* Basic Animations */
.animate-fade-in {
  animation: fadeIn var(--decka-transition-normal) ease-out;
}

.animate-fade-out {
  animation: fadeOut var(--decka-transition-normal) ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft var(--decka-transition-slow) ease-out;
}

.animate-slide-in-right {
  animation: slideInRight var(--decka-transition-slow) ease-out;
}

.animate-slide-in-top {
  animation: slideInTop var(--decka-transition-slow) ease-out;
}

.animate-slide-in-bottom {
  animation: slideInBottom var(--decka-transition-slow) ease-out;
}

.animate-scale-in {
  animation: scaleIn var(--decka-transition-normal) ease-out;
}

.animate-scale-out {
  animation: scaleOut var(--decka-transition-normal) ease-out;
}

.animate-bounce-in {
  animation: bounceIn 0.6s ease-out;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

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

.animate-spin {
  animation: spin 1s linear infinite;
}

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

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* === LOADING STATES === */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--decka-border-color);
  border-radius: 50%;
  border-top-color: var(--decka-primary);
  animation: spin 1s ease-in-out infinite;
}

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

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: var(--decka-space-2);
}

.loading-dots::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--decka-primary);
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-dots::before {
  content: '••';
  color: var(--decka-primary);
  animation: pulse 1.5s ease-in-out infinite 0.2s;
}

/* === HOVER ANIMATIONS === */
.hover-lift {
  transition: transform var(--decka-transition-normal), box-shadow var(--decka-transition-normal);
}

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

.hover-scale {
  transition: transform var(--decka-transition-fast);
}

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

.hover-glow {
  transition: box-shadow var(--decka-transition-normal);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(113, 6, 238, 0.3);
}

.hover-rotate {
  transition: transform var(--decka-transition-normal);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

/* === FOCUS ANIMATIONS === */
.focus-scale {
  transition: transform var(--decka-transition-fast);
}

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

.focus-glow {
  transition: box-shadow var(--decka-transition-normal);
}

.focus-glow:focus {
  box-shadow: 0 0 0 3px rgba(113, 6, 238, 0.2);
}

/* === ENTRANCE ANIMATIONS === */
.entrance-fade {
  opacity: 0;
  animation: fadeIn 0.6s ease-out forwards;
}

.entrance-slide-up {
  opacity: 0;
  transform: translateY(30px);
  animation: slideInBottom 0.6s ease-out forwards;
}

.entrance-scale {
  opacity: 0;
  transform: scale(0.9);
  animation: scaleIn 0.4s ease-out forwards;
}

.entrance-bounce {
  opacity: 0;
  transform: scale(0.3);
  animation: bounceIn 0.8s ease-out forwards;
}

/* === STAGGERED ANIMATIONS === */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  animation: slideInBottom 0.6s ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }

/* === SLIDE TRANSITION ANIMATIONS === */
.slide-transition-enter {
  opacity: 0;
  transform: translateX(100%);
}

.slide-transition-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 300ms, transform 300ms;
}

.slide-transition-exit {
  opacity: 1;
  transform: translateX(0);
}

.slide-transition-exit-active {
  opacity: 0;
  transform: translateX(-100%);
  transition: opacity 300ms, transform 300ms;
}

/* === MODAL ANIMATIONS === */
.modal-enter {
  opacity: 0;
  transform: scale(0.9);
}

.modal-enter-active {
  opacity: 1;
  transform: scale(1);
  transition: opacity 200ms, transform 200ms;
}

.modal-exit {
  opacity: 1;
  transform: scale(1);
}

.modal-exit-active {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 200ms, transform 200ms;
}

/* === PROGRESS ANIMATIONS === */
.progress-bar {
  position: relative;
  background: var(--decka-bg-tertiary);
  border-radius: var(--decka-radius-sm);
  overflow: hidden;
  height: 4px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--decka-primary), var(--decka-primary-light));
  border-radius: inherit;
  transition: width 0.3s ease;
}

.progress-bar-animated .progress-bar-fill {
  animation: progressBar 2s ease-in-out;
}

/* === SUCCESS/ERROR ANIMATIONS === */
.success-checkmark {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--decka-success);
  position: relative;
}

.success-checkmark::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: scaleIn 0.3s ease-out 0.2s both;
}

.error-cross {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--decka-danger);
  position: relative;
}

.error-cross::before,
.error-cross::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  background: white;
  transform-origin: center;
}

.error-cross::before {
  transform: translate(-50%, -50%) rotate(45deg);
  animation: scaleIn 0.3s ease-out 0.1s both;
}

.error-cross::after {
  transform: translate(-50%, -50%) rotate(-45deg);
  animation: scaleIn 0.3s ease-out 0.2s both;
}

/* === BUTTON ANIMATION STATES === */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  color: white;
}

/* === NOTIFICATION ANIMATIONS === */
.notification-enter {
  opacity: 0;
  transform: translateX(100%);
}

.notification-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: all 300ms ease-out;
}

.notification-exit {
  opacity: 1;
  transform: translateX(0);
}

.notification-exit-active {
  opacity: 0;
  transform: translateX(100%);
  transition: all 300ms ease-in;
}

/* === PERFORMANCE OPTIMIZATIONS === */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.hardware-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* === REDUCED MOTION SUPPORT === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .animate-pulse,
  .animate-spin,
  .animate-glow,
  .animate-float {
    animation: none;
  }
  
  .loading-spinner {
    animation: none;
    border-top-color: var(--decka-primary);
  }
  
  .hover-lift:hover,
  .hover-scale:hover {
    transform: none;
  }
  
  .stagger-children > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

/* === HIGH CONTRAST MODE === */
@media (prefers-contrast: high) {
  .animate-glow,
  .hover-glow,
  .focus-glow {
    animation: none;
    box-shadow: none;
  }
  
  .hover-glow:hover,
  .focus-glow:focus {
    box-shadow: none;
    border: 2px solid currentColor;
  }
}

/* === PRINT MODE === */
@media print {
  * {
    animation: none !important;
    transition: none !important;
  }
  
  .loading-spinner,
  .loading-dots {
    display: none;
  }
}
