/* ========================================================
   GanjehKala - Dynamic Product Grid (Premium UI Update)
======================================================== */

.gk-product-grid {
    position: relative;
    width: 100%;
    /* استفاده از عرض کلی سایت طبق استاندارد */
    max-width: var(--gk-site-width, 100%);
    margin: 0 auto;
}

/* --- Header Section --- */
.gk-product-grid__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.gk-product-grid__header-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--gk-text, #333);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* استفاده اجباری از رنگ برند برای آیکن‌های شاخص */
.gk-product-grid__header-icon {
    color: var(--gk-primary);
    font-size: 1.2rem;
}

.gk-product-grid__header-link {
    font-size: 0.85rem;
    color: var(--gk-secondary, #666);
    text-decoration: none;
    transition: color var(--gk-duration-fast, 0.3s) ease;
}

.gk-product-grid__header-link:hover {
    color: var(--gk-primary);
}

/* --- Grid System --- */
.gk-product-grid__items {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns-desktop, 6), 1fr);
    /* استفاده از متغیرهای گرید در صورت وجود */
    gap: var(--gk-grid-gap-y, 20px) var(--gk-grid-gap-x, 20px);
}

/* --- Product Card (Modern Surface) --- */
.gk-product-grid__item {
    background-color: var(--gk-surface, #ffffff);
    border-radius: var(--gk-radius, 16px);
    box-shadow: var(--gk-shadow-sm, 0 2px 10px rgba(0,0,0,0.03));
    overflow: hidden;
    transition: transform var(--gk-duration, 0.4s) cubic-bezier(0.165, 0.84, 0.44, 1),
    box-shadow var(--gk-duration, 0.4s) cubic-bezier(0.165, 0.84, 0.44, 1);
    height: 100%; /* برای هم‌اندازه شدن ردیف‌ها */
    border: 1px solid rgba(0,0,0,0.04);
}

.gk-product-grid__item:hover {
    transform: translateY(-5px);
    box-shadow: var(--gk-shadow-lg, 0 15px 30px rgba(0,0,0,0.08));
}

.gk-product-grid__item-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* --- Image Wrapper & Hover Effects --- */
.gk-product-grid__image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f9f9f9;
}

.gk-product-grid__image {
    display: block;
    width: 100%;
    height: 100%;
}

.gk-product-grid__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--gk-duration, 0.4s) ease,
    transform var(--gk-duration-slow, 0.6s) ease;
}

.gk-hover-img {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

/* افکت جذاب تغییر عکس با زوم ظریف */
.gk-product-grid__item:hover .gk-main-img {
    opacity: 0;
    transform: scale(1.05);
}

.gk-product-grid__item:hover .gk-hover-img {
    opacity: 1;
    transform: scale(1.05);
}

/* --- Discount Badge (Floating) --- */
.gk-product-grid__discount-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    /* استفاده از رنگ تاکید (اکسنت) طبق مستندات برای المان‌های فروش */
    background-color: var(--gk-accent, #ef4444);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 50px; /* شکل Pill مدرن */
    z-index: 2;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

/* --- Content Area --- */
.gk-product-grid__content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* هل دادن قیمت به پایین */
}

/* --- Title --- */
.gk-product-grid__title {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 12px 0;
    font-weight: 600;
}

.gk-product-grid__title a {
    color: var(--gk-text, #2d3748);
    text-decoration: none;
    transition: color var(--gk-duration-fast, 0.3s) ease;

    /* محدود کردن عنوان به دو خط برای جلوگیری از به هم ریختگی ارتفاع کارت‌ها */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* خط قرمز: لینک‌های مهم باید به رنگ اصلی در بیایند */
.gk-product-grid__title a:hover {
    color: var(--gk-primary);
}

/* --- Price Block (WooCommerce Standard UI) --- */
.gk-product-grid__price-block {
    margin-top: auto; /* قیمت همیشه در انتهای کارت می‌چسبد */
}

.gk-product-grid__price-block .price {
    display: flex;
    align-items: center;
    flex-direction: row-reverse; /* برای فارسی (چپ به راست قیمت) */
    justify-content: flex-end;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gk-text, #1a202c);
    margin: 0;
}

/* استایل قیمت خط خورده */
.gk-product-grid__price-block .price del {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--gk-secondary, #a0aec0);
    opacity: 0.7;
}

/* استایل قیمت تخفیف خورده */
.gk-product-grid__price-block .price ins {
    text-decoration: none;
    color: var(--gk-primary); /* خط قرمز: قیمت مهم باید برجسته و ترجیحا رنگ برند باشد */
}

/* --- Pagination --- */
.gk-product-grid__pagination {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    gap: 8px;
}

.gk-product-grid__pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--gk-radius-sm, 8px);
    background-color: var(--gk-surface, #fff);
    color: var(--gk-text, #333);
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(0,0,0,0.08);
    transition: all var(--gk-duration-fast, 0.3s) ease;
}

/* خط قرمز: وضعیت فعال/هاور باید رنگ اصلی برند باشد */
.gk-product-grid__pagination .page-numbers:hover,
.gk-product-grid__pagination .page-numbers.current {
    background-color: var(--gk-primary);
    color: #fff;
    border-color: var(--gk-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* --- Responsive Layout --- */
@media (max-width: 1024px) {
    .gk-product-grid__items {
        grid-template-columns: repeat(var(--grid-columns-tablet, 3), 1fr);
    }
}

@media (max-width: 768px) {
    .gk-product-grid__items {
        grid-template-columns: repeat(var(--grid-columns-mobile, 2), 1fr);
        gap: 12px;
    }
    .gk-product-grid__content {
        padding: 12px;
    }
    .gk-product-grid__title {
        font-size: 0.85rem;
    }
    .gk-product-grid__price-block .price {
        font-size: 1rem;
        flex-direction: column; /* در موبایل قیمت‌ها زیر هم می‌روند */
        align-items: flex-end;
        gap: 2px;
    }
}


/* GK v1.8.9: deeper content/style controls */
.gk-product-grid__button{display:inline-flex;align-items:center;justify-content:center;margin-top:12px;min-height:38px;padding:9px 14px;border-radius:12px;background:var(--gk-primary,#ef4056);color:#fff;text-decoration:none;font-weight:800;font-size:13px;transition:.2s ease;}
.gk-product-grid__button:hover{transform:translateY(-1px);filter:brightness(.96);color:#fff;}
.gk-product-grid__content{display:flex;flex-direction:column;flex:1;min-width:0;}
.gk-product-grid__title{min-width:0;}
.gk-product-grid__title a{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
.gk-product-grid__price-block{margin-top:auto;min-width:0;overflow-wrap:anywhere;}


/* GK v1.9.4: product grid hover image must be same box size and only work when a real hover image exists */
.gk-product-grid__image {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: inherit;
    background: transparent !important;
}

.gk-product-grid__image img,
.gk-product-grid__image .gk-main-img,
.gk-product-grid__image .gk-hover-img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center center !important;
    border-radius: inherit;
    transform: none !important;
}

.gk-product-grid__image .gk-main-img {
    opacity: 1 !important;
    z-index: 1;
}

.gk-product-grid__image .gk-hover-img {
    opacity: 0 !important;
    z-index: 2;
    pointer-events: none;
}

.gk-product-grid__item:hover .gk-main-img:not(.gk-main-img--has-hover),
.gk-product-grid__item:focus-within .gk-main-img:not(.gk-main-img--has-hover) {
    opacity: 1 !important;
    transform: none !important;
}

.gk-product-grid__item:hover .gk-main-img--has-hover,
.gk-product-grid__item:focus-within .gk-main-img--has-hover {
    opacity: 0 !important;
    transform: none !important;
}

.gk-product-grid__item:hover .gk-main-img--has-hover + .gk-hover-img,
.gk-product-grid__item:focus-within .gk-main-img--has-hover + .gk-hover-img {
    opacity: 1 !important;
    transform: none !important;
}

@media (hover: none), (pointer: coarse) {
    .gk-product-grid__image .gk-main-img { opacity: 1 !important; }
    .gk-product-grid__image .gk-hover-img { display: none !important; }
}
