/* ============================================
   الحركات والانتقالات — مدير التوصيل
   Animations, Transitions, Motion Design
   ============================================ */

/* ── Page Transitions ── */
.page-enter {
  animation: page-fade-in 0.35s ease-out forwards;
}

.page-exit {
  animation: page-fade-out 0.2s ease-in forwards;
}

@keyframes page-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes page-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ── Staggered Card Entrance ── */
.stagger-in > * {
  opacity: 0;
  transform: translateY(16px);
  animation: stagger-fade-in 0.4s ease-out forwards;
}

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

@keyframes stagger-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Scale In ── */
.scale-in {
  animation: scale-in-anim 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scale-in-anim {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Slide In ── */
.slide-in-right {
  animation: slide-right 0.35s ease-out forwards;
}

@keyframes slide-right {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-left {
  animation: slide-left 0.35s ease-out forwards;
}

@keyframes slide-left {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-up {
  animation: slide-up 0.35s ease-out forwards;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Counter Animation ── */
.counter-value {
  display: inline-block;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Pulse ── */
.pulse {
  animation: pulse-anim 2s ease-in-out infinite;
}

@keyframes pulse-anim {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* ── Shake (Error) ── */
.shake {
  animation: shake-anim 0.5s ease-in-out;
}

@keyframes shake-anim {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ── Bounce In ── */
.bounce-in {
  animation: bounce-in-anim 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bounce-in-anim {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Float ── */
.float {
  animation: float-anim 3s ease-in-out infinite;
}

@keyframes float-anim {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* ── Spin ── */
.spin {
  animation: spin-anim 1s linear infinite;
}

@keyframes spin-anim {
  to { transform: rotate(360deg); }
}

/* ── Gradient Shift (for decorative backgrounds) ── */
.gradient-shift {
  background-size: 200% 200%;
  animation: gradient-shift-anim 8s ease infinite;
}

@keyframes gradient-shift-anim {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Number Count Up (helper) ── */
.count-up {
  transition: opacity 0.3s ease;
}

/* ── Chart Reveal ── */
.chart-reveal {
  opacity: 0;
  animation: chart-reveal-anim 0.8s ease-out 0.3s forwards;
}

@keyframes chart-reveal-anim {
  from {
    opacity: 0;
    transform: scaleY(0.8);
    transform-origin: bottom;
  }
  to {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: bottom;
  }
}

/* ── Item Add/Remove ── */
.item-add {
  animation: item-add-anim 0.3s ease-out forwards;
}

@keyframes item-add-anim {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    max-height: 200px;
    transform: translateX(0);
  }
}

.item-remove {
  animation: item-remove-anim 0.3s ease-in forwards;
}

@keyframes item-remove-anim {
  from {
    opacity: 1;
    max-height: 200px;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    max-height: 0;
    transform: translateX(-20px);
  }
}

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