/* ============================================================
   FILE: 06-animations.css
   Motion & Animation Effects
   Keyframes, transitions, and entrance animations
   ============================================================ */

/* Entrance Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

/* Loading & State Animations */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
  }
  50% {
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.7);
  }
}

/* Button Effects */
@keyframes ripple {
  to {
    width: 500px;
    height: 500px;
    opacity: 0;
  }
}

/* Counter Animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Progress Bar Animation */
@keyframes progressFill {
  from {
    width: 0%;
  }
  to {
    width: var(--progress-value, 100%);
  }
}

/* Bounce Animation */
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

/* Apply Animations to Components */

/* Cards */
.card {
  animation: slideUp 0.5s ease-out;
}

.card:nth-child(2) {
  animation-delay: 0.1s;
}

.card:nth-child(3) {
  animation-delay: 0.2s;
}

.card:nth-child(4) {
  animation-delay: 0.3s;
}

.card:nth-child(5) {
  animation-delay: 0.4s;
}

.card:nth-child(n + 6) {
  animation-delay: 0.5s;
}

/* Stat Cards */
.stat-card {
  animation: slideUp 0.5s ease-out;
}

.stat-card:nth-child(1) {
  animation-delay: 0s;
}

.stat-card:nth-child(2) {
  animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
  animation-delay: 0.2s;
}

.stat-card:nth-child(4) {
  animation-delay: 0.3s;
}

/* Stat Values Counter */
.stat-card__value {
  animation: countUp 0.8s ease-out;
}

/* Sidebar */
.sidebar {
  animation: slideInLeft 0.4s ease-out;
}

/* Page Header */
.page-header {
  animation: slideDown 0.4s ease-out;
}

/* Tab Content */
.tab-content {
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  animation: fadeIn 0.3s ease-out forwards;
}

/* Loading States */
.skeleton {
  animation: shimmer 2s infinite;
}

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

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

.loading-bounce {
  animation: bounce 1s ease-in-out infinite;
}

/* Glow Effects */
.glow-effect {
  animation: glow 2s ease-in-out infinite;
}

/* Button Click Ripple */
.btn.ripple::before {
  animation: ripple 0.6s ease-out;
}

/* Progress Bar */
.probability-card__bar-fill {
  animation: progressFill var(--transition-slow) ease-out forwards;
}

/* Hover Scale Animations */
button,
a,
.clickable {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

button:hover:not(:disabled),
a:hover,
.clickable:hover {
  transform: translateY(-2px);
}

/* Focus Animations */
:focus-visible {
  transition: outline-color var(--transition-fast);
}

/* Badge Pulse */
.badge {
  transition: all var(--transition-base);
}

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

/* Dropdown Animation */
.dropdown {
  animation: slideDown var(--transition-base);
}

/* Modal Slide */
.modal-overlay {
  animation: fadeIn var(--transition-base);
}

.modal {
  animation: slideUp var(--transition-base);
}

/* Tooltip Animation */
.tooltip {
  animation: fadeIn var(--transition-fast);
  animation-delay: 0.2s;
}

/* Alert/Notification Animation */
.alert {
  animation: slideInRight var(--transition-base);
}

.alert.dismissing {
  animation: slideInRight var(--transition-base) reverse;
}

/* Form Input Focus */
.text-input:focus,
.select-custom:focus {
  animation: glow 1.5s ease-in-out forwards;
}

/* Stagger Animation for Lists */
.list-item {
  opacity: 0;
  animation: slideUp 0.4s ease-out forwards;
}

.list-item:nth-child(1) {
  animation-delay: 0s;
}

.list-item:nth-child(2) {
  animation-delay: 0.1s;
}

.list-item:nth-child(3) {
  animation-delay: 0.2s;
}

.list-item:nth-child(4) {
  animation-delay: 0.3s;
}

.list-item:nth-child(5) {
  animation-delay: 0.4s;
}

.list-item:nth-child(n + 6) {
  animation-delay: 0.5s;
}

/* Smooth Color Transitions */
* {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: var(--transition-fast);
  transition-timing-function: ease;
}

/* Disable transitions on disabled elements */
:disabled {
  transition: none !important;
}

/* Reduce motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* Performance Optimization */
.animate-on-scroll {
  opacity: 0;
  animation: slideUp 0.6s ease-out forwards;
}

.animate-on-scroll.in-view {
  animation-play-state: running;
}

/* Intersection Observer Triggered */
.intersecting {
  animation: slideUp 0.6s ease-out forwards;
}

/* High Performance GPU-Accelerated Animations */
.high-perf {
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Remove animation after it completes to reduce CPU usage */
.animate-once {
  animation-fill-mode: forwards;
}

/* Prefers Color Scheme - Light Mode Ready (if future needed) */
@media (prefers-color-scheme: dark) {
  /* Already dark mode, no changes needed */
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  button,
  a,
  .clickable {
    transition: none;
  }

  button:active,
  a:active,
  .clickable:active {
    transform: scale(0.98);
  }
}
