/**
 * Animations CSS - Animaciones y transiciones
 * Define animaciones de carga, transiciones y efectos de movimiento
 * Requisitos: 3.7, 8.7
 */

/* ==================== KEYFRAME ANIMATIONS ==================== */

/**
 * Card entrance animation - fade + slide up
 * Applied when cards first appear in the grid
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/**
 * Card exit animation - fade + slide down
 * Applied when cards are removed
 */
@keyframes cardOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/**
 * Fade in animation
 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/**
 * Fade out animation
 */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/**
 * Slide in from left
 */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/**
 * Slide in from right
 */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/**
 * Scale up animation
 */
@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/**
 * Pulse animation - for loading states
 */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/**
 * Shimmer animation - for skeleton loaders
 */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/**
 * Glow animation - pulsing glow effect
 */
@keyframes glow {
  0%,
  100% {
    text-shadow: 0 0 8px var(--theme-glow), 0 0 4px var(--theme-glow);
  }
  50% {
    text-shadow: 0 0 16px var(--theme-glow), 0 0 8px var(--theme-glow);
  }
}

/**
 * Bounce animation
 */
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/**
 * Spin animation - for loading spinners
 */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ==================== ANIMATION CLASSES ==================== */

/**
 * Card entrance animation
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
.card-in {
  animation: cardIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/**
 * Card exit animation
 */
.card-out {
  animation: cardOut 0.3s var(--ease) forwards;
}

/**
 * Fade in
 */
.fade-in {
  animation: fadeIn 0.3s var(--ease) forwards;
}

/**
 * Fade out
 */
.fade-out {
  animation: fadeOut 0.3s var(--ease) forwards;
}

/**
 * Slide in from left
 */
.slide-in-left {
  animation: slideInLeft 0.4s var(--ease) forwards;
}

/**
 * Slide in from right
 */
.slide-in-right {
  animation: slideInRight 0.4s var(--ease) forwards;
}

/**
 * Scale up
 */
.scale-up {
  animation: scaleUp 0.3s var(--ease) forwards;
}

/**
 * Pulse animation
 */
.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/**
 * Spin animation
 */
.animate-spin {
  animation: spin 1s linear infinite;
}

/**
 * Glow animation
 */
.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

/**
 * Bounce animation
 */
.animate-bounce {
  animation: bounce 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

/* ==================== TRANSITION CLASSES ==================== */

/**
 * Smooth color transition
 */
.transition-colors {
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}

/**
 * Smooth opacity transition
 */
.transition-opacity {
  transition: opacity var(--ease);
}

/**
 * Smooth transform transition
 */
.transition-transform {
  transition: transform var(--ease);
}

/**
 * Smooth all transitions
 */
.transition-all {
  transition: all var(--ease);
}

/**
 * No transition
 */
.transition-none {
  transition: none;
}

/* ==================== HOVER ANIMATIONS ==================== */

/**
 * Lift on hover - used for cards and buttons
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Glow on hover
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
.hover-glow:hover {
  text-shadow: 0 0 12px var(--theme-glow);
  transition: text-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Scale on hover
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
.hover-scale:hover {
  transform: scale(1.05);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Rotate on hover
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
.hover-rotate:hover {
  transform: rotate(5deg);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Border color on hover
 * Uses cubic-bezier(0.4,0,0.2,1) for timing
 */
.hover-border:hover {
  border-color: var(--theme);
  transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== SIDEBAR ANIMATIONS ==================== */

/**
 * Sidebar expand animation
 * Uses cubic-bezier(0.4,0,0.2,1) for smooth timing
 */
@keyframes sidebarExpand {
  from {
    width: 80px;
  }
  to {
    width: 280px;
  }
}

/**
 * Sidebar collapse animation
 * Uses cubic-bezier(0.4,0,0.2,1) for smooth timing
 */
@keyframes sidebarCollapse {
  from {
    width: 280px;
  }
  to {
    width: 80px;
  }
}

.sidebar-expanding {
  animation: sidebarExpand 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.sidebar-collapsing {
  animation: sidebarCollapse 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/**
 * Sidebar item label fade
 */
@keyframes labelFade {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.sidebar-label-fade {
  animation: labelFade var(--ease-long) forwards;
}

/* ==================== LOADING STATE ANIMATIONS ==================== */

/**
 * Loading skeleton animation
 */
.skeleton {
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/**
 * Loading spinner
 */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--theme);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ==================== SCROLL ANIMATIONS ==================== */

/**
 * Fade in on scroll
 */
.fade-on-scroll {
  opacity: 0;
  animation: fadeIn 0.6s var(--ease) forwards;
}

/**
 * Slide in on scroll
 */
.slide-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeIn 0.6s var(--ease) forwards;
}

/* ==================== MOTION PREFERENCES ==================== */

/**
 * Respect prefers-reduced-motion
 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card-in,
  .card-out,
  .fade-in,
  .fade-out,
  .slide-in-left,
  .slide-in-right,
  .scale-up,
  .animate-pulse,
  .animate-spin,
  .animate-glow,
  .animate-bounce,
  .hover-lift,
  .hover-glow,
  .hover-scale {
    animation: none !important;
    transition: none !important;
  }
}

/* ==================== VISIBILITY ANIMATIONS ==================== */

/**
 * Visible state for intersection observer
 */
.is-visible {
  animation: cardIn 0.4s var(--ease) forwards;
}

/**
 * Hidden state
 */
.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/**
 * Loading state
 */
.is-loading {
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
}

/**
 * Selected state
 */
.is-selected {
  box-shadow: 0 0 16px var(--theme-glow), var(--shadow-xl);
  border-color: var(--theme);
}

/**
 * Hovered state
 */
.is-hovered {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

/* ==================== TOOLTIP ANIMATIONS ==================== */

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip {
  animation: tooltipFadeIn 0.2s var(--ease) forwards;
}

/* ==================== MODAL ANIMATIONS ==================== */

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal {
  animation: modalFadeIn 0.3s var(--ease) forwards;
}

.modal-content {
  animation: modalScaleIn 0.3s var(--ease) forwards;
}

/* ==================== STAGGER ANIMATIONS ==================== */

.stagger-1 {
  animation-delay: 0s;
}

.stagger-2 {
  animation-delay: 50ms;
}

.stagger-3 {
  animation-delay: 100ms;
}

.stagger-4 {
  animation-delay: 150ms;
}

.stagger-5 {
  animation-delay: 200ms;
}

.stagger-6 {
  animation-delay: 250ms;
}

.stagger-7 {
  animation-delay: 300ms;
}

.stagger-8 {
  animation-delay: 350ms;
}

.stagger-9 {
  animation-delay: 400ms;
}

.stagger-10 {
  animation-delay: 450ms;
}
