/* ================================================================ */
/* ===== استایل‌های پایه (ضروری برای عملکرد کاروسل) ===== */
/* ================================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f5f5f5; }

/* ================================================================ */
/* ===== بخش محصولات جدید (بالای کاروسل) ===== */
/* ================================================================ */
.nproduct {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  margin: 10px;
  border: solid 1px var(--accent);
  border-radius: 20px;
  margin-top: 20px;
}
.nproduct.new { background-color: #00ff1694; }

.newproduct {
  display: flex;
  justify-content: space-between;
  border-radius: 20px;
  margin: 10px;
  align-items: center;
  height: 70px;
}
.newproduct p:nth-child(1) { font-size: 1.5rem; padding: 10px; }
.newproduct p:nth-child(3) {
  background-color: #19f541;
  font-size: 1rem;
  cursor: pointer;
  margin-left: 30px;
  text-align: center;
  padding: 20px;
  border-radius: 20px;
  position: relative;
}
.line {
  flex-grow: 1;
  height: 2px;
  background-color: rgb(124, 124, 124);
  margin: 0 20px;
}

/* ================================================================ */
/* ===== کاروسل - بهینه شده برای پرفورمنس بالا ===== */
/* ================================================================ */
/* این بخش را پیدا کنید و دقیقاً جایگزین کنید */
.nxf-carousel {
  position: relative;
  max-width: 1500px;
  margin: 40px auto;
  overflow: hidden; /* فقط همین را نگه دارید */
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  padding: 20px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  max-height: 500px;
  direction: rtl;
  /* حذف شد: contain: layout style paint; */
}

.nxf-carousel-track {
  display: flex;
  gap: 0 !important;
  overflow: visible !important; /* به حالت اول برگشت */
  touch-action: none; /* به حالت اول برگشت */
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}
.nxf-carousel-track.nxf-dragging {
  cursor: grabbing;
  transition: none !important;
}

/* آیتم‌ها */
.nxf-carousel-item {
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  height: 100% !important;
  min-height: unset !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  background: transparent !important;
  display: flex;
  align-items: stretch;
}

/* Fade Effect */
.nxf-carousel.nxf-effect-fade .nxf-carousel-track {
  display: block;
  position: relative;
  height: 300px;
}
.nxf-carousel.nxf-effect-fade .nxf-carousel-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  z-index: 1;
}
.nxf-carousel.nxf-effect-fade .nxf-carousel-item.nxf-active {
  opacity: 1;
  z-index: 2;
}

/* ================================================================ */
/* ===== کارت‌های محصول (بدن اصلی) ===== */
/* ================================================================ */
.nxf-carousel-item .card {
  /* حذف شد: backdrop-filter: blur(4px); (عامل اصلی لگ دسکتاپ) */
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  box-shadow: 0 8px 32px var(--shadow-light, rgba(0,0,0,0.06));
  /* بهینه سازی: فقط پراپرتی‌های خاص را ترنزیشن بده */
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              box-shadow 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              background 0.35s ease;
  display: flex;
  flex-direction: column;
  width: calc(100% - 20px);
  margin: 0 10px;
  height: 100%;
  padding: 18px 16px 22px;
  position: relative;
  list-style: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  /* حذف شد: animation: fadeInUp... (جلوگیری از انیمیشن 30 کلون همزمان) */
}

.nxf-carousel-item .card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 60px var(--shadow-medium, rgba(0,0,0,0.12));
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
}

.nxf-carousel-item .card a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.nxf-carousel-item .card .img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--bg-light, #f8f9fa);
  display: block;
  transition: transform 0.4s ease;
}
.nxf-carousel-item .card:hover .img { transform: scale(1.02); }

.nxf-carousel-item .card .cardheader {
  margin-top: 14px;
  flex-grow: 1;
  position: relative;
}
.nxf-carousel-item .card .cardtitle {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark, #0f172a);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 3em;
  margin: 0;
}
.nxf-carousel-item .card .cardheader::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-blue, #3b82f6), #8b5cf6);
  border-radius: 4px;
  margin-top: 6px;
  transition: width 0.3s ease;
}
.nxf-carousel-item .card:hover .cardheader::after { width: 60px; }

.nxf-carousel-item .card hr {
  margin: 12px 0 10px;
  border: none;
  border-top: 1.5px solid var(--border-light, #f1f5f9);
}

.nxf-carousel-item .card .cardprice {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.nxf-carousel-item .card .cardprice h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-blue, #3b82f6);
  margin: 0;
}
.nxf-carousel-item .card .cardprice strike {
  font-size: 0.95rem;
  color: var(--text-light, #94a3b8);
  margin-inline-end: 6px;
}
.nxf-carousel-item .card .out-of-stock {
  color: var(--discount-red, #ef4444);
  font-weight: 700;
  font-size: 1rem;
}

/* برچسب‌های تخفیف */
.nxf-carousel-item .card .discount-button {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  z-index: 5;
}
.nxf-carousel-item .card .discount-button button {
  background: linear-gradient(135deg, var(--discount-red, #ef4444), #dc2626);
  color: #fff;
  border: none;
  padding: 5px 16px;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: default;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.nxf-carousel-item .card .discount-percentage {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  background: linear-gradient(135deg, var(--discount-orange, #f59e0b), #d97706);
  color: #fff;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  z-index: 5;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* دکمه افزودن به سبد */
.nxf-carousel-item .card .card__action {
  color: white;
  padding: 10px 15px;
  margin-bottom: 10px;
  text-align: center;
  position: absolute;
  display: block;
  font-size: 16px;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.3s ease, left 0.3s ease;
  top: 10%;
  left: 60%;
  opacity: 0;
}

.nxf-carousel-item .card .card__action button.add-to-cart,
.nxf-carousel-item .card .card__action .open-modal-btn {
  position: relative;
  border: 1px solid #002aff;
  border-radius: 40px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 1px;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
  background-size: 200% auto;
  animation: shimmer 3s linear infinite;
  z-index: 2;
  line-height: 1.5;
}

.nxf-carousel-item .card .card__action .icon {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  padding: 0;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.card:hover .card__action,
.nxf-carousel-item:hover .card__action {
  opacity: 1;
  left: 10%;
}
.nxf-carousel-item .card:hover .card__action .icon {
  opacity: 1;
  pointer-events: auto;
  left: 10px;
  right: auto;
  border-color: #002aff;
  transform: scale(1.05) rotate(-2deg);
}
.nxf-carousel-item .card .card__action .icon:hover {
  background: linear-gradient(135deg, #90EE90, #defade);
  color: #fff;
  transform: scale(1.15) rotate(0deg);
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.4);
  border-color: #3b82f6;
}

/* دکمه‌های قبلی/بعدی */
.nxf-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  /* حذف شد backdrop-filter برای دکمه ها چون باعث لگ اسکرول میشود */
  background: rgb(68 154 48 / 80%); /* کمی کدرتر شد تا نیازی به بلور نباشد */
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, background 0.3s ease;
  will-change: transform;
}
.nxf-carousel-arrow:hover {
  background: rgb(75 163 54 / 100%);
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.nxf-carousel-arrow:active { transform: translateY(-50%) scale(0.95); }

.nxf-carousel-arrow.nxf-prev { inset-inline-end: 16px; inset-inline-start: auto; }
.nxf-carousel-arrow.nxf-next { inset-inline-start: 16px; inset-inline-end: auto; }

.nxf-carousel-arrow.nxf-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* نقاط راهنما */
.nxf-carousel-dots {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}
.nxf-carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease;
}
.nxf-carousel-dot.nxf-active {
  width: 32px;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
  transform: scale(1);
}
.nxf-carousel-dot:hover { background: rgba(255, 255, 255, 0.7); transform: scale(1.2); }

 
/* ================================================================ */
/* ===== نوار پیشرفت متغیر و سفارشی ===== */
/* ================================================================ */
.nxf-carousel-progress-bar {
  position: absolute;
   top: 2px;
  left: 0;
  right: 0;
  /* ⭐ استفاده از متغیرهای ارسالی از جاوااسکریپت با مقدار پیش‌فرض */
  height: var(--progress-height, 3px);
  background: var(--progress-color, rgba(255, 0, 251, 0.69));
  /* گردی لبه‌ها به صورت خودکار بر اساس ضخامت تنظیم می‌شود */
  border-radius: calc(var(--progress-height, 3px) / 2) calc(var(--progress-height, 3px) / 2) 0 0;
  z-index: 20;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* وقتی کلاس اکتیو به کاروسل اضافه شود */
.nxf-carousel.nxf-autoplay-active .nxf-carousel-progress-bar {
  opacity: 1;
  transform: scaleX(1);
  transition: transform var(--autoplay-interval, 3000ms) linear, opacity 0.3s ease;
}
/* ================================================================ */
/* ===== واکنش‌گرایی ===== */
/* ================================================================ */
@media (max-width: 992px) {
  .nxf-carousel { max-width: 100%; border-radius: 12px; padding: 14px 0; }
  .nxf-carousel-item .card { margin: 0 8px; width: calc(100% - 16px); }
  .nxf-carousel-item .card .img { height: 160px; }
  .nxf-carousel-arrow { width: 44px; height: 44px; font-size: 1.5rem; }
  .nxf-carousel-arrow.nxf-prev { inset-inline-end: 10px; }
  .nxf-carousel-arrow.nxf-next { inset-inline-start: 10px; }
}

@media (max-width: 768px) {
  .nxf-carousel-item .card .img { height: 140px; }
  .nxf-carousel-item .card .cardtitle { font-size: 0.95rem; }
  .nxf-carousel-item .card .cardprice h3 { font-size: 1.05rem; }
  .nxf-carousel-item .card .discount-percentage { width: 38px; height: 38px; font-size: 0.85rem; }
  .nxf-carousel-item .card .card__action .icon { width: 42px; height: 42px; font-size: 20px; }
}

@media (max-width: 576px) {
  .nxf-carousel { border-radius: 8px; padding: 10px 0; }
  .nxf-carousel-item .card { margin: 0 5px; width: calc(100% - 10px); padding: 12px 10px 16px; border-radius: 12px; }
  .nxf-carousel-item .card .img { height: 120px; }
  .nxf-carousel-item .card .cardtitle { font-size: 0.85rem; height: 2.6em; }
  .nxf-carousel-item .card .cardprice h3 { font-size: 0.95rem; }
  .nxf-carousel-item .card .cardprice strike { font-size: 0.8rem; }
  .nxf-carousel-item .card .discount-percentage { width: 32px; height: 32px; font-size: 0.7rem; }
  .nxf-carousel-item .card .discount-button button { font-size: 0.6rem; padding: 3px 10px; }
  .nxf-carousel-item .card .card__action .icon { width: 36px; height: 36px; font-size: 16px; }
  .nxf-carousel-arrow { width: 36px; height: 36px; font-size: 1.2rem; }
  .nxf-carousel-arrow.nxf-prev { inset-inline-end: 6px; }
  .nxf-carousel-arrow.nxf-next { inset-inline-start: 6px; }
  .nxf-carousel-dot { width: 8px; height: 8px; }
  .nxf-carousel-dot.nxf-active { width: 24px; }
}

@media screen and (max-width: 1023px) {
  .nxf-carousel-item .card .card__action { opacity: 1; left: 5%; }
  .nxf-carousel-item .card .card__action .icon { opacity: 1; background: rgb(0 255 71 / 42%); }
  .newproduct { margin: 10px 10px; height: 30px; margin-top: inherit; }
  .newproduct p:nth-child(1) { font-size: 1.1rem; padding: 2px; }
  .newproduct p:nth-child(3) { margin-left: 2px; }
}

/* ================================================================ */
/* ===== انیمیشن‌ها ===== */
/* ================================================================ */
/* فقط شیمر باقی ماند زیرا روی دکمه کوچک است و مشکلی ایجاد نمی‌کند */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@media (prefers-reduced-motion: reduce) {
  .nxf-carousel-track {
    transition: none !important;
  }
  .nxf-carousel-item .card {
    transition: none !important;
  }
  .nxf-carousel-item .card .img {
    transition: none !important;
  }
  /* غیرفعال کردن انیمیشن شیمر دکمه ها */
  .nxf-carousel-item .card .card__action button {
    animation: none !important;
  }
}