/**
 * Carousel Styles for Elementor Product Addon
 */

/* کلاس اصلی کروسل */
.epa-carousel {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

/* کانتینر اسلایدها */
.epa-carousel-wrapper {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  gap: 20px; /* مقدار پیش‌فرض */
  padding: 0;
  margin: 0;
}

/* استفاده از متغیر محلی برای gap در صورتی که تنظیم شده باشد */
.elementor-widget-product_grid[data-card-gap] .epa-carousel-wrapper {
  gap: var(--this-card-gap, 20px);
}

.epa-carousel-wrapper::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* استایل هر اسلاید در کروسل */
.epa-carousel .epa-product-wrapper,
.epa-carousel .epa-portfolio-wrapper {
  flex: 0 0 288px;
  max-width: 288px;
  padding: 0;
  margin: 0;
}

/* استایل کارت محصول در کروسل - انتقال همه استایل‌های کارت محصول باید در اینجا منتقل شود */
.epa-carousel .epa-product-item,
.epa-carousel .epa-portfolio-item {
  height: 100%;
  /* مهم: ما margin را صفر نمی‌کنیم تا تنظیمات margin از ویجت المنتور کار کند */
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  /* همه استایل‌های کارت محصول باید در اینجا منتقل شود */
}

/* حفظ رنگ پس‌زمینه از تنظیمات */
.elementor-widget-product_grid .epa-carousel .epa-product-item {
  background-color: inherit;
  border-radius: inherit;
  box-shadow: inherit;
  border: inherit;
  padding: inherit;
  box-sizing: border-box;
}

/* استایل وضوح تصاویر در کروسل */
.epa-carousel .epa-product-image,
.epa-carousel .epa-portfolio-image {
  object-fit: cover;
  width: 100%;
  height: 200px;
  display: block;
}

/* اعمال استایل‌های محصول برای کارت در کروسل */
.epa-carousel .epa-product-title,
.epa-carousel .epa-product-price,
.epa-carousel .epa-product-specs-group1,
.epa-carousel .epa-product-specs-group2,
.epa-carousel .epa-portfolio-title,
.epa-carousel .epa-portfolio-categories,
.epa-carousel .epa-portfolio-date,
.epa-carousel .epa-content-title,
.epa-carousel .epa-product-excerpt {
  /* اطمینان از اینکه استایل‌های این المنت‌ها در کروسل هم اعمال می‌شود */
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  margin: inherit;
  padding: inherit;
}

/* اضافه کردن استایل مشترک برای لینک‌های عنوان پورتفولیو و بلاگ در کاروسل */
.epa-carousel .epa-portfolio-title a, 
.epa-carousel .epa-content-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
  height: auto !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 3.6em;
}

/* دکمه‌های ناوبری */
.epa-carousel-prev,
.epa-carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

.epa-carousel-prev:hover,
.epa-carousel-next:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

.epa-carousel-prev {
  left: -20px;
}

.epa-carousel-next {
  right: -20px;
}

.epa-carousel-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none; /* اضافه شده برای غیرفعال کردن کامل */
}

/* استایل نقاط ناوبری (در صورت نیاز) */
.epa-carousel-dots {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.epa-carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--gray-200, rgba(202, 197, 197, 1));
  margin: 0 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.epa-carousel-dot.active {
  background-color: var(--primary-400, rgba(238, 37, 41, 1));
}

/* اطمینان از اینکه فاصله بین کارت‌ها هم در حالت گرید و هم در حالت کروسل یکسان است */
.elementor-widget-product_grid[data-card-gap] .epa-carousel .epa-product-wrapper,
.elementor-widget-product_grid[data-card-gap] .epa-carousel .epa-portfolio-wrapper {
  padding: var(--card-padding, 10px);
}

/* هنگامی که mixin carousel_item_margin صفر است، از card_gap استفاده کنیم */
.elementor-widget-product_grid .epa-carousel .epa-product-wrapper[style*="padding: 0px"],
.elementor-widget-product_grid .epa-carousel .epa-portfolio-wrapper[style*="padding: 0px"] {
  padding: var(--card-padding, 10px) !important;
}

/* نگهداری نسبت در تصاویر محصول */
.epa-carousel .epa-product-image-link,
.epa-carousel .epa-portfolio-image-link {
  width: 100%;
  display: block;
  overflow: hidden;
}

/* واکنش‌گرایی برای کروسل - استفاده از data attributes */
@media screen and (max-width: 1024px) {
  /* تنظیمات تبلت */
  .epa-carousel .epa-product-wrapper,
  .epa-carousel .epa-portfolio-wrapper {
    flex: 0 0 calc(100% / var(--tablet-slides, 2));
    max-width: calc(100% / var(--tablet-slides, 2));
    padding: 0;
    margin: 0;
  }
}

@media screen and (max-width: 767px) {
  /* تنظیمات موبایل */
  .epa-carousel-prev,
  .epa-carousel-next {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
  
  /* تنظیم عرض ثابت برای کارت‌ها در کروسل در حالت موبایل */
  .epa-carousel .epa-product-wrapper,
  .epa-carousel .epa-portfolio-wrapper {
    width: 155px !important;
    flex: 0 0 155px;
    padding: 0;
    margin: 0;
  }
  
  /* اضافه کردن فاصله 9px بین کارت‌ها */
  .epa-carousel-wrapper {
    gap: 9px 9px; /* فاصله عمودی و افقی هر دو 9px */
    row-gap: 9px;
    column-gap: 9px;
    padding: 0;
    margin: 0;
  }
  
  /* تنظیم برای دو ستون در حالت موبایل اگر mobile-slides برابر 2 باشد */
  .elementor-widget-product_grid[style*="--mobile-slides: 2"] .epa-carousel .epa-product-wrapper,
  .elementor-widget-product_grid[style*="--mobile-slides: 2"] .epa-carousel .epa-portfolio-wrapper {
    width: calc(50% - 4.5px) !important; /* 50% منهای نصف فاصله بین ستون‌ها */
    flex: 0 0 calc(50% - 4.5px);
    padding: 0;
    margin: 0;
  }
  
  /* تنظیم ارتفاع عکس و کارت در حالت موبایل برای کروسل */
  .epa-carousel .epa-product-item > a:first-child,
  .epa-carousel .epa-product-wrapper .epa-product-item > a:first-child,
  .epa-carousel .epa-portfolio-item > a:first-child,
  .epa-carousel .epa-portfolio-wrapper .epa-portfolio-item > a:first-child,
  .epa-carousel .epa-product-image-link,
  .epa-carousel .epa-portfolio-image-link {
    height: 107px !important;
  }
  
  .epa-carousel .epa-product-image,
  .epa-carousel .epa-portfolio-image,
  .epa-carousel .epa-product-item img,
  .epa-carousel .epa-portfolio-item img {
    height: 107px !important;
  }
  
  .epa-carousel .epa-product-item,
  .epa-carousel .epa-portfolio-item {
    height: 140px;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  .epa-carousel .epa-product-info {
    padding: 5px 5px 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #EFEEEE;
  }
  
  /* استایل‌های جدید برای عنوان و اطلاعات پورتفولیو در کروسل */
  .epa-carousel .epa-portfolio-title {
    margin: 5px 0 5px; /* همسان با مارجین محصول */
    direction: rtl;
    text-align: center;
  }
  
  .epa-carousel .epa-portfolio-info {
    padding: 5px 5px 5px; /* همسان با پدینگ محصول */
    background: #EFEEEE;
  }
  
  /* استایل‌های جدید برای عنوان بلاگ پست‌ها در کروسل */
  .epa-carousel .epa-content-title {
    margin: 5px 0 5px !important; /* همسان با مارجین محصول */
    direction: rtl;
    text-align: center;
  }
  
  .epa-carousel .epa-content-title a, .epa-carousel .epa-portfolio-title a {
    line-height: 1.4em !important;
    -webkit-line-clamp: 1;
    max-height: 1.4em;
    /* اضافه کردن خصوصیت‌های مشترک برای محدود کردن متن */
    display: -webkit-box !important; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ویژگی‌های دیگر اسلاید با توجه به تنظیمات نمایش */
@media screen and (min-width: 1025px) {
  .epa-carousel[data-slides-to-show="1"] .epa-product-wrapper,
  .epa-carousel[data-slides-to-show="1"] .epa-portfolio-wrapper {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  .epa-carousel[data-slides-to-show="2"] .epa-product-wrapper,
  .epa-carousel[data-slides-to-show="2"] .epa-portfolio-wrapper {
    flex: 0 0 calc(50% - 10px);
    max-width: calc(50% - 10px);
  }
  
  .epa-carousel[data-slides-to-show="3"] .epa-product-wrapper,
  .epa-carousel[data-slides-to-show="3"] .epa-portfolio-wrapper {
    flex: 0 0 calc(33.333% - 14px);
    max-width: calc(33.333% - 14px);
  }
  
  .epa-carousel[data-slides-to-show="4"] .epa-product-wrapper,
  .epa-carousel[data-slides-to-show="4"] .epa-portfolio-wrapper {
    flex: 0 0 288px;
    max-width: 288px;
  }
  
  .epa-carousel[data-slides-to-show="5"] .epa-product-wrapper,
  .epa-carousel[data-slides-to-show="5"] .epa-portfolio-wrapper {
    flex: 0 0 calc(20% - 16px);
    max-width: calc(20% - 16px);
  }
  
  .epa-carousel[data-slides-to-show="6"] .epa-product-wrapper,
  .epa-carousel[data-slides-to-show="6"] .epa-portfolio-wrapper {
    flex: 0 0 calc(16.666% - 17px);
    max-width: calc(16.666% - 17px);
  }
  
  .epa-carousel .epa-product-image,
  .epa-carousel .epa-portfolio-image {
    height: 200px;
  }
} 