/* ==========================================================
   ANIMATIONS.CSS
   فایل مشترک انیمیشن‌ها - تو همه‌ی صفحه‌ها لینک می‌شه
   شامل: ورود صفحه، هاور دکمه‌ها و لینک‌ها، ورود پلکانی لیست‌ها،
   مودال‌ها، اینپوت‌ها و چند کلاس کمکی برای استفاده‌ی دستی
   ========================================================== */

/* ---------- ۱. ورود کلی صفحه (Page Enter) ---------- */
@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  animation: pageFadeIn 0.5s ease both;
}

/* ---------- ۲. هاور و کلیک روی دکمه‌ها و لینک‌ها ---------- */
/* تقریباً همه‌ی دکمه‌ها و لینک‌های رنگی این سایت با کلاس bg-* ساخته شدن */
button,
a[class*="bg-"],
a.mobile-link,
.filter-btn,
.sort-btn,
.new-day-btn,
.modal-btn {
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease,
    opacity 0.18s ease;
}

button:hover:not(:disabled):not(.no-anim),
a[class*="bg-"]:hover:not(.no-anim),
.filter-btn:hover,
.sort-btn:hover,
.new-day-btn:hover,
.modal-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

button:active:not(:disabled):not(.no-anim),
a[class*="bg-"]:active:not(.no-anim),
.filter-btn:active,
.sort-btn:active,
.new-day-btn:active,
.modal-btn:active {
  transform: translateY(0) scale(0.96);
  filter: brightness(0.97);
  transition-duration: 0.08s;
}

/* لینک‌های ساده‌ی موبایل (آیکون‌های ناوبری پایین) - بزرگنمایی ملایم آیکون */
a.mobile-link i {
  display: inline-block;
  transition: transform 0.2s ease, color 0.2s ease;
}
a.mobile-link:hover i,
a.mobile-link:active i {
  transform: scale(1.18);
}

/* دکمه‌ی همبرگری موبایل */
#openDaysMobile {
  transition: transform 0.2s ease;
}
#openDaysMobile:active {
  transform: scale(0.85) rotate(90deg);
}

/* ---------- ۳. اینپوت‌ها ---------- */
input,
textarea,
select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
input:focus,
textarea:focus,
select:focus {
  transform: translateY(-1px);
}

/* ---------- ۴. کارت‌ها و ردیف‌های لیست - ورود پلکانی ---------- */
@keyframes itemFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#cards > li,
#daysList > div,
#invoiceRows > tr,
#transactionsList > *,
#customersList > *,
#suppliersList > *,
#purchasesList > *,
#categoriesContainer > *,
.animate-in {
  animation: itemFadeIn 0.4s ease both;
}

/* تاخیر پلکانی برای ۱۲ آیتم اول هر لیست - ظاهر طبیعی‌تر */
#cards > li:nth-child(1), #daysList > div:nth-child(1), #transactionsList > *:nth-child(1),
#customersList > *:nth-child(1), #suppliersList > *:nth-child(1), #purchasesList > *:nth-child(1),
#categoriesContainer > *:nth-child(1) { animation-delay: 0.02s; }

#cards > li:nth-child(2), #daysList > div:nth-child(2), #transactionsList > *:nth-child(2),
#customersList > *:nth-child(2), #suppliersList > *:nth-child(2), #purchasesList > *:nth-child(2),
#categoriesContainer > *:nth-child(2) { animation-delay: 0.06s; }

#cards > li:nth-child(3), #daysList > div:nth-child(3), #transactionsList > *:nth-child(3),
#customersList > *:nth-child(3), #suppliersList > *:nth-child(3), #purchasesList > *:nth-child(3),
#categoriesContainer > *:nth-child(3) { animation-delay: 0.1s; }

#cards > li:nth-child(4), #daysList > div:nth-child(4), #transactionsList > *:nth-child(4),
#customersList > *:nth-child(4), #suppliersList > *:nth-child(4), #purchasesList > *:nth-child(4),
#categoriesContainer > *:nth-child(4) { animation-delay: 0.14s; }

#cards > li:nth-child(5), #daysList > div:nth-child(5), #transactionsList > *:nth-child(5),
#customersList > *:nth-child(5), #suppliersList > *:nth-child(5), #purchasesList > *:nth-child(5),
#categoriesContainer > *:nth-child(5) { animation-delay: 0.18s; }

#cards > li:nth-child(6), #daysList > div:nth-child(6), #transactionsList > *:nth-child(6),
#customersList > *:nth-child(6), #suppliersList > *:nth-child(6), #purchasesList > *:nth-child(6),
#categoriesContainer > *:nth-child(6) { animation-delay: 0.22s; }

#cards > li:nth-child(n+7), #daysList > div:nth-child(n+7), #transactionsList > *:nth-child(n+7),
#customersList > *:nth-child(n+7), #suppliersList > *:nth-child(n+7), #purchasesList > *:nth-child(n+7),
#categoriesContainer > *:nth-child(n+7) { animation-delay: 0.26s; }

/* کارت‌ها هنگام هاور کمی بالا میان */
#cards > li,
#customersList > *,
#suppliersList > *,
#purchasesList > *,
#transactionsList > * {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#cards > li:hover,
#customersList > *:hover,
#suppliersList > *:hover,
#purchasesList > *:hover,
#transactionsList > *:hover {
  transform: translateY(-2px);
}

/* ---------- ۵. مودال‌ها ---------- */
/* استایل پایه‌ی مودال (باز/بسته شدن) قبلاً تو styles.css هست،
   اینجا فقط یه افکت ورود ملایم‌تر به خود جعبه‌ی مودال اضافه می‌کنیم */
@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.modal-overlay.active .modal-box {
  animation: modalPopIn 0.3s ease both;
}

/* ---------- ۶. رفتن به صفحه‌ی دیگه (لینک‌های ناوبری) ---------- */
/* یه افکت کوتاه موقع کلیک روی لینک‌ها تا حس جابجایی نرم‌تر بشه */
a {
  transition: opacity 0.15s ease;
}
a:active {
  opacity: 0.75;
}

/* ---------- ۷. کلاس‌های کمکی برای استفاده‌ی دستی در JS/HTML ---------- */
.fade-in {
  animation: itemFadeIn 0.4s ease both;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.pop-in {
  animation: popIn 0.3s ease both;
}

@keyframes shakeError {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake {
  animation: shakeError 0.5s ease;
}

@keyframes softPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.pulse {
  animation: softPulse 1.4s ease-in-out infinite;
}

/* ---------- ۸. احترام به تنظیمات کاهش انیمیشن سیستم کاربر ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}