/* ============================================
   ADMIN PANEL - ANIMATIONS
   Keyframes, transitions, micro-interactions
   ============================================ */

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

/* 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);
  }
}

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

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

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

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

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

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

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

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

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

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

/* Progress bar animation */
@keyframes progress {
  from {
    transform: scaleX(0);
    transform-origin: left;
  }
  to {
    transform: scaleX(1);
    transform-origin: left;
  }
}

/* Shimmer/skeleton loading */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Ripple effect */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Glow effect */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.8);
  }
}

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

/* Fade utilities */
.animate-fadeIn {
  animation: fadeIn 0.3s var(--ease-smooth);
}

.animate-fadeInUp {
  animation: fadeInUp 0.4s var(--ease-smooth);
}

.animate-fadeInDown {
  animation: fadeInDown 0.4s var(--ease-smooth);
}

/* Slide utilities */
.animate-slideInRight {
  animation: slideInRight 0.3s var(--ease-smooth);
}

.animate-slideInLeft {
  animation: slideInLeft 0.3s var(--ease-smooth);
}

/* Scale utilities */
.animate-scaleIn {
  animation: scaleIn 0.2s var(--ease-smooth);
}

/* Shake utility */
.animate-shake {
  animation: shake 0.5s var(--ease-bounce);
}

/* Pulse utility */
.animate-pulse {
  animation: pulse 2s var(--ease-smooth) infinite;
}

/* Spin utility */
.animate-spin {
  animation: spin 1s linear infinite;
}

/* === TRANSITION UTILITIES === */

.transition-all {
  transition: all var(--transition);
}

.transition-colors {
  transition: color var(--transition),
              background-color var(--transition),
              border-color var(--transition);
}

.transition-transform {
  transition: transform var(--transition);
}

.transition-opacity {
  transition: opacity var(--transition);
}

.transition-slow {
  transition-duration: var(--duration-slow);
}

.transition-fast {
  transition-duration: var(--duration-fast);
}

/* === MICRO-INTERACTIONS === */

/* Button press effect */
.btn-press {
  position: relative;
  overflow: hidden;
}

.btn-press::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-press:active::before {
  width: 300px;
  height: 300px;
}

/* Card lift on hover */
.card-lift {
  transition: transform var(--transition),
              box-shadow var(--transition);
}

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

@media (hover: none) {
  .card-lift:hover {
    transform: none;
  }
}

/* Link underline animation */
.link-underline {
  position: relative;
  text-decoration: none;
}

.link-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width var(--transition);
}

.link-underline:hover::after {
  width: 100%;
}

/* Focus ring animation */
.focus-ring {
  transition: box-shadow var(--transition);
}

.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* === LOADING STATES === */

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(226, 232, 240, 1) 0%,
    rgba(203, 213, 225, 1) 50%,
    rgba(226, 232, 240, 1) 100%
  );
  background-size: 2000px 100%;
  animation: shimmer 2s linear infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-button {
  height: 2.5rem;
  width: 120px;
  border-radius: var(--radius-md);
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--color-border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  animation: progress 2s var(--ease-smooth) forwards;
}

/* === NOTIFICATION ANIMATIONS === */

/* Toast entrance/exit */
.toast-enter {
  animation: slideInRight 0.3s var(--ease-smooth);
}

.toast-exit {
  animation: slideOutRight 0.3s var(--ease-smooth);
}

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

/* Modal backdrop */
.modal-backdrop-enter {
  animation: fadeIn 0.2s var(--ease-smooth);
}

.modal-backdrop-exit {
  animation: fadeOut 0.2s var(--ease-smooth);
}

/* Modal content */
.modal-enter {
  animation: scaleIn 0.3s var(--ease-smooth);
}

.modal-exit {
  animation: scaleOut 0.2s var(--ease-smooth);
}

/* === PAGE TRANSITION === */

/* View transition */
.view-transition {
  animation: fadeInUp 0.4s var(--ease-smooth);
}

/* === INTERACTIVE FEEDBACK === */

/* Button loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

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

/* Input focus glow */
.input-glow:focus {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1),
              0 0 20px rgba(99, 102, 241, 0.15);
}

/* === SCROLL ANIMATIONS === */

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Scroll reveal (for use with JS) */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease-smooth),
              transform 0.6s var(--ease-smooth);
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* === STAGGER ANIMATIONS === */

/* Stagger children with delay */
.stagger > * {
  animation: fadeInUp 0.4s var(--ease-smooth);
  animation-fill-mode: both;
}

.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* === ATTENTION GRABBERS === */

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

.animate-wiggle {
  animation: wiggle 0.5s var(--ease-bounce);
}

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

.animate-heartbeat {
  animation: heartbeat 1.5s var(--ease-smooth) infinite;
}

/* === PERFORMANCE OPTIMIZATIONS === */

/* Will-change for animated elements */
.will-animate {
  will-change: transform, opacity;
}

/* Remove will-change after animation */
.animated {
  will-change: auto;
}

/* Hardware acceleration */
.hw-accelerate {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* === REDUCED MOTION OVERRIDES === */
@media (prefers-reduced-motion: reduce) {
  /* Disable all animations for users who prefer reduced motion */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .skeleton {
    animation: none;
    background: rgba(226, 232, 240, 1);
  }
  
  .scroll-reveal {
    opacity: 1;
    transform: none;
  }
  
  .stagger > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
