/* public/css/animations.css */
/* KB Med Design System - Animations & Transitions */

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   KEYFRAMES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

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

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

/* Slide Animations */
@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

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

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

/* 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 */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

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

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

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

/* Progress bar animation */
@keyframes progress {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   UTILITY CLASSES - Animations
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.animate-fadeIn {
  animation: fadeIn var(--transition-base) ease-out;
}

.animate-fadeOut {
  animation: fadeOut var(--transition-base) ease-out;
}

.animate-slideInUp {
  animation: slideInUp var(--transition-base) ease-out;
}

.animate-slideInDown {
  animation: slideInDown var(--transition-base) ease-out;
}

.animate-slideInLeft {
  animation: slideInLeft var(--transition-base) ease-out;
}

.animate-slideInRight {
  animation: slideInRight var(--transition-base) ease-out;
}

.animate-scaleIn {
  animation: scaleIn var(--transition-base) ease-out;
}

.animate-scaleOut {
  animation: scaleOut var(--transition-base) ease-out;
}

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

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

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

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   UTILITY CLASSES - Transitions
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

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

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

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

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

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

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

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   HOVER EFFECTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

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

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

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

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

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(54, 83, 164, 0.3);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   SKELETON LOADING
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-200) 25%,
    var(--neutral-100) 50%,
    var(--neutral-200) 75%
  );
  background-size: 2000px 100%;
  animation: shimmer 2s infinite linear;
  border-radius: var(--radius-md);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--neutral-700) 25%,
    var(--neutral-600) 50%,
    var(--neutral-700) 75%
  );
  background-size: 2000px 100%;
}

.skeleton-text {
  height: 1rem;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-lg);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   PAGE TRANSITIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.page-transition-enter {
  animation: fadeIn var(--transition-base) ease-out;
}

.page-transition-exit {
  animation: fadeOut var(--transition-fast) ease-out;
}

/* Stagger children animations */
.stagger-children > * {
  opacity: 0;
  animation: slideInUp var(--transition-base) ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LOADING STATES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-primary);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

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

.dots-loading {
  display: inline-flex;
  gap: 4px;
}

.dots-loading span {
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  animation: pulse 1.4s ease-in-out infinite;
}

.dots-loading span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots-loading span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.progress-bar-indeterminate {
  position: relative;
  overflow: hidden;
}

.progress-bar-indeterminate::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background: var(--color-primary);
  animation: progress 1.5s ease-in-out infinite;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MICRO-INTERACTIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Ripple effect (click feedback) */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
  width: 300px;
  height: 300px;
}

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

.focus-ring:focus-visible {
  box-shadow: 0 0 0 3px var(--color-primary), 0 0 0 5px rgba(54, 83, 164, 0.2);
}

/* Attention seeker (for errors or important items) */
@keyframes attention {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.attention {
  animation: attention 0.5s ease-in-out 3;
}

/* ═══════════════════════════════════════════════════════════════════
   KB Med — Animations
   À AJOUTER à la fin de public/css/animations.css
   ═══════════════════════════════════════════════════════════════════ */


/* ── 1. TRANSITIONS ENTRE PAGES ─────────────────────────────────── */

body {
  /* On utilise l'animation fadeIn que tu as déjà définie en haut de ton fichier */
  animation: fadeIn 0.3s ease-out forwards; 
}

body.page-enter {
  opacity: 0;
}

body.page-enter-active {
  opacity: 1;
}

body.page-exit {
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}


/* ── 2. STAGGER — LIGNES DE TABLEAU ────────────────────────────── */

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

tr.row-enter {
  animation: rowSlideIn 0.2s ease-out both;
}


/* ── 3. MODALS ──────────────────────────────────────────────────── */

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
  }
}

.modal-enter {
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-exit {
  animation: modalOut 0.15s ease-in both;
}


/* ── 4. RIPPLE — BOUTONS ────────────────────────────────────────── */

@keyframes rippleEffect {
  from {
    transform: scale(0);
    opacity: 0.35;
  }
  to {
    transform: scale(1);
    opacity: 0;
  }
}

.kb-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  pointer-events: none;
  animation: rippleEffect 0.55s ease-out forwards;
  z-index: 0;
}

/* Ripple foncé sur les boutons clairs */
.btn-secondary .kb-ripple,
.btn-ghost .kb-ripple {
  background: rgba(44, 90, 160, 0.12);
}


/* ── 5. PULSE — BADGES URGENTS ──────────────────────────────────── */

@keyframes kbPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%       { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

.kb-pulse {
  animation: kbPulse 1.8s ease-in-out infinite;
}


/* ── 6. ENTRÉES GÉNÉRIQUES ──────────────────────────────────────── */

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

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

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

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

/* Classes utilitaires */
.animate-fade-in    { animation: fadeIn     0.25s ease-out both; }
.animate-fade-up    { animation: fadeInUp   0.25s ease-out both; }
.animate-slide-up   { animation: slideInUp  0.3s  ease-out both; }
.animate-slide-right{ animation: slideInRight 0.25s ease-out both; }


/* ── 7. HOVER AMÉLIORÉ — CARTES ─────────────────────────────────── */

/* Appliqué automatiquement aux cartes du site */
.stat-card,
.widget,
.rma-card,
.device-card,
.loans-kpi,
.checklist-card-wrap {
  transition:
    box-shadow 0.15s ease,
    transform  0.15s ease,
    border-color 0.15s ease !important;
}


/* ── 8. SIDEBAR — INDICATEUR ACTIF ANIMÉ ───────────────────────── */

.sidebar-nav a.active,
.sidebar-nav .nav-link.active {
  position: relative;
}

.sidebar-nav a.active::before,
.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
  animation: slideInRight 0.2s ease-out both;
}


/* ── 9. SPINNER D'ÉTAT LOADING ──────────────────────────────────── */

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

.fa-spin {
  animation: spin 0.8s linear infinite;
}


/* ── 10. PERFORMANCE — DÉSACTIVE SUR MOBILE ─────────────────────── */

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