/* نمایش گرید محصولات */
.epa-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--desktop-columns, 4), 1fr);
    grid-gap: 20px;
    margin: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

/* استایل wrapper برای تمام آیتم‌ها */
.epa-product-wrapper, .epa-portfolio-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
    transition: all 0.3s ease !important;
    background-color: transparent;
    width: 100%;
    box-sizing: border-box;
}

/* آیتم محصول */
.epa-product-item, .epa-portfolio-item {
    border: 1px solid #eee;
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.3s ease !important;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05) !important;
    text-align: center;
    position: relative;
    width: 100%; /* تغییر عرض به نسبی بجای ثابت */
    height: 100%; /* اضافه کردن ارتفاع 100% برای پر کردن کل فضا */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* اصلاح رفتار hover برای همه آیتم‌ها */
.epa-product-wrapper:hover .epa-product-item,
.epa-portfolio-wrapper:hover .epa-portfolio-item,
.epa-product-item:hover,
.epa-portfolio-item:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-3px) !important;
}

/* محدوده تصویر */
.epa-product-item > a:first-child,
.epa-product-wrapper .epa-product-item > a:first-child,
.epa-portfolio-item > a:first-child,
.epa-portfolio-wrapper .epa-portfolio-item > a:first-child,
.epa-product-image-link {
    display: block !important;
    width: 100% !important;
    height: 200px !important; /* تنظیم ارتفاع ثابت برای کانتینر تصویر */
    overflow: hidden !important;
    line-height: 0 !important; /* حذف فضای اضافی زیر تصویر */
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    box-sizing: border-box !important;
}

/* تصویر محصول */
.epa-product-image, 
.epa-product-item img,
.epa-product-item > a:first-child img,
.epa-product-wrapper .epa-product-item > a:first-child img,
.epa-portfolio-image,
.epa-portfolio-item img,
.epa-portfolio-item > a:first-child img,
.epa-portfolio-wrapper .epa-portfolio-item > a:first-child img {
    width: 100% !important;
    height: 200px !important; /* تنظیم ارتفاع ثابت برای تصویر */
    object-fit: cover !important;
    transition: transform 0.5s ease !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* محتوای محصول */
.epa-product-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
}

.epa-product-item a:hover img,
.epa-product-image:hover,
.epa-portfolio-item a:hover img,
.epa-portfolio-image:hover {
    transform: scale(1.05) !important;
}

/* عنوان محصول */
.epa-product-title {
    margin: 0px 10px 26px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.epa-product-title a,
.epa-product-info a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    height: auto !important; /* لغو ارتفاع ثابت برای لینک‌های عنوان */
    display: inline-block !important; /* تغییر نمایش از block به inline-block برای عنوان‌ها */
}

.epa-product-title a:hover {
    color: #4285f4;
}

/* قیمت محصول */
.epa-product-price {
    margin: 10px;
    font-weight: 600;
    color: #23a455;
}

/* عنوان محتوای بلاگ و پورتفولیو - کلاس کاملاً مجزا */
.epa-content-title, .epa-portfolio-title {
    margin: 0px 10px 16px !important;
    font-size: 1.1rem;
    font-weight: 600;
}

.epa-content-title a, .epa-portfolio-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    line-height: 1.8em !important; /* افزایش ارتفاع خط برای عناوین چند خطی */
    display: inline-block !important;
    height: auto !important;
    
    /* محدود کردن نمایش عنوان به حداکثر دو خط */
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3.6em; /* 1.8em * 2 خط */
}

.epa-content-title a:hover, .epa-portfolio-title a:hover {
    color: #4285f4;
}

/* فیلد ACF */
.epa-product-acf-field {
    margin: 15px 10px;
    font-size: 0.9rem;
    padding: 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.epa-product-acf-field img {
    max-width: 100%;
    height: auto !important; /* لغو ارتفاع ثابت برای تصاویر داخل فیلدهای ACF */
    display: block;
    margin: 0 auto;
}

/* خلاصه مطلب برای بلاگ */
.epa-product-excerpt {
    text-align: justify;
    line-height: 1.6;
    color: #666;
    font-size: 0.85rem;
    margin: 10px;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 4px;
    border-right: 3px solid #ddd;
}

/* استایل‌های پیش‌فرض برای واکنش‌گرایی - از طریق CSS Variables */
@media screen and (max-width: 1024px) {
    .epa-products-grid {
        grid-template-columns: repeat(var(--tablet-columns, 2), 1fr) !important;
        grid-gap: 15px;
    }
}

@media screen and (max-width: 767px) {
    .epa-products-grid {
        grid-template-columns: repeat(var(--mobile-columns, 1), 1fr) !important;
        grid-gap: 0px;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 9px 9px; /* فاصله عمودی و افقی هر دو 9px */
        row-gap: 9px;
        column-gap: 9px;
        padding: 0;
        margin: 0;
    }
    
    /* تنظیم عرض ثابت برای کارت‌ها در حالت موبایل */
    .epa-product-wrapper, .epa-portfolio-wrapper {
        width: 155px !important;
        margin-bottom: 9px;
        flex: 0 0 155px;
        padding: 0;
    }
    
    /* تنظیم برای دو ستون در حالت موبایل */
    .epa-products-grid[style*="grid-template-columns: repeat(2, 1fr)"] {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 0;
        margin: 0;
    }
    
    .epa-products-grid[style*="grid-template-columns: repeat(2, 1fr)"] .epa-product-wrapper,
    .epa-products-grid[style*="grid-template-columns: repeat(2, 1fr)"] .epa-portfolio-wrapper {
        width: calc(50% - 4.5px) !important; /* 50% منهای نصف فاصله بین ستون‌ها */
        flex: 0 0 calc(50% - 4.5px);
        margin: 0 0 9px 0;
        padding: 0;
    }
    
    /* تنظیم ارتفاع عکس و کارت در حالت موبایل */
    .epa-product-item > a:first-child,
    .epa-product-wrapper .epa-product-item > a:first-child,
    .epa-portfolio-item > a:first-child,
    .epa-portfolio-wrapper .epa-portfolio-item > a:first-child,
    .epa-product-image-link {
        height: 107px !important;
    }
    
    .epa-product-image, 
    .epa-product-item img,
    .epa-product-item > a:first-child img,
    .epa-product-wrapper .epa-product-item > a:first-child img,
    .epa-portfolio-image,
    .epa-portfolio-item img,
    .epa-portfolio-item > a:first-child img,
    .epa-portfolio-wrapper .epa-portfolio-item > a:first-child img {
        height: 107px !important;
    }
    
    .epa-product-item, .epa-portfolio-item {
        height: 140px;
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .epa-product-info {
        padding: 5px 5px 5px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        background: #EFEEEE;
    }
    
    /* استایل‌های جدید برای عنوان و اطلاعات پورتفولیو */
    .epa-portfolio-title {
        margin: 5px 0 5px; /* همسان با مارجین محصول */
        direction: rtl;
        text-align: center;
    }
    
    .epa-portfolio-info {
        padding: 5px 5px 5px; /* همسان با پدینگ محصول */
        background: #EFEEEE;
    }
    
    /* استایل‌های جدید برای عنوان بلاگ پست‌ها */
    .epa-content-title {
        margin: 5px 0 5px !important; /* همسان با مارجین محصول */
        direction: rtl;
        text-align: center;
    }
    
    .epa-content-title a, .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;
    }
} 