/**
 * Performance-Optimized Animations
 * 60fps smooth animations using GPU acceleration
 */

/* ===== Hardware Acceleration ===== */
.gpu-accelerated,
.card,
.btn,
.modal,
.toast {
  transform: translateZ(0);
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* ===== Smooth Card Hover ===== */
.card {
  transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1),
              box-shadow 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Disable hover on touch devices */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
}

/* ===== Staggered List Animation ===== */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-in {
  animation: slideInUp 0.3s ease-out forwards;
}

.animate-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-fade {
  animation: fadeIn 0.2s ease-out forwards;
}

/* Stagger delay for list items */
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }
.stagger-item:nth-child(5) { animation-delay: 200ms; }
.stagger-item:nth-child(6) { animation-delay: 250ms; }
.stagger-item:nth-child(7) { animation-delay: 300ms; }
.stagger-item:nth-child(8) { animation-delay: 350ms; }
.stagger-item:nth-child(9) { animation-delay: 400ms; }
.stagger-item:nth-child(10) { animation-delay: 450ms; }

/* ===== Button States ===== */
.btn {
  transition: transform 0.15s ease,
              background-color 0.2s ease,
              box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  transform: none;
  opacity: 0.6;
}

/* ===== Loading Spinner ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Pulse Animation ===== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

/* ===== Toast Animations ===== */
@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

.toast-enter {
  animation: toastSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-exit {
  animation: toastSlideOut 0.2s ease-in forwards;
}

/* ===== Modal Animations ===== */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal.fade .modal-dialog {
  animation: modalFadeIn 0.25s ease-out;
}

.modal.fade.show .modal-backdrop {
  animation: modalBackdropIn 0.2s ease-out;
}

/* ===== Skeleton Shimmer ===== */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 0%,
    var(--bg-card) 50%,
    var(--bg-secondary) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ===== Progress Bar Animation ===== */
@keyframes progressPulse {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

.progress-indeterminate .progress-bar {
  animation: progressPulse 2s ease-in-out infinite;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .skeleton {
    animation: none;
    background: var(--bg-secondary);
  }
}

/* ===== Content Loading States ===== */
.content-loading {
  position: relative;
  overflow: hidden;
}

.content-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

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

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

/* ===== Focus States ===== */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}
