/* =====================================================================
   کارت محصول — تک‌منبعِ استایل (قالبش: woocommerce/content-product.php)
   همه‌جا یکسان: فروشگاه، دسته، کاروسل‌ها، مرتبط، ۴۰۴، علاقه‌مندی‌ها.

   چرا سلکتورها بلند و !important دارن؟ custom.css ده‌ها قانونِ قدیمیِ
   «li.product ...» با !important داره. این فایل بعد از اون لود می‌شه و با
   پیشوندِ html body … .sg-card.sg-card از همه‌شون قوی‌تره، تا کارت فقط از
   همین‌جا شکل بگیره. عرضِ کارت در کاروسل همچنان از قوانینِ کاروسل میاد.
   ===================================================================== */

html body ul.products li.product.sg-card.sg-card {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    border: 1px solid var(--sg-border-light, #E8DFCE) !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    box-shadow: none !important;
    transform: none !important;
    text-align: right !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}
html body ul.products li.product.sg-card.sg-card::before,
html body ul.products li.product.sg-card.sg-card::after {
    content: none !important;
    display: none !important;
}
html body ul.products li.product.sg-card.sg-card:hover {
    border-color: var(--sg-gold, #C5A059) !important;
    box-shadow: 0 6px 18px rgba(31, 38, 45, 0.08) !important;
}

/* ---------- تصویر ---------- */
html body ul.products li.product.sg-card.sg-card .sg-card__media {
    position: relative !important;
    aspect-ratio: 1 / 1;
    margin: 0 !important;
    background: #F6F4F0;
    overflow: hidden !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__media img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    object-fit: cover !important;
    aspect-ratio: auto !important;
    box-shadow: none !important;
    transition: transform 0.25s ease !important;
}
html body ul.products li.product.sg-card.sg-card:hover .sg-card__media img {
    transform: scale(1.04) !important;
}
html body ul.products li.product.sg-card.sg-card.sg-card--out .sg-card__media img {
    opacity: 0.55;
    filter: grayscale(0.4);
}

/* برچسبِ تخفیف / ناموجود — گوشه‌ی راستِ عکس */
html body ul.products li.product.sg-card.sg-card .sg-card__badge {
    position: absolute !important;
    top: 10px;
    right: 10px;
    z-index: 2;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--sg-price-old, #C84B31);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1;
}
html body ul.products li.product.sg-card.sg-card .sg-card__badge--out {
    background: rgba(26, 26, 26, 0.75);
}

/* قلب — گوشه‌ی چپِ عکس */
html body ul.products li.product.sg-card.sg-card .sg-card__wish {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    right: auto !important;
    z-index: 3 !important;
    margin: 0 !important;
    padding: 0 !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__wish .sg-wish-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 34px !important;
    height: 34px !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.92) !important;
    color: var(--sg-text-body, #333) !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: color 0.2s ease !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__wish .sg-wish-btn svg {
    width: 18px !important;
    height: 18px !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__wish .sg-wish-btn:hover,
html body ul.products li.product.sg-card.sg-card .sg-card__wish .sg-wish-btn.is-active {
    color: var(--sg-price-old, #C84B31) !important;
}

/* ---------- متن ---------- */
html body ul.products li.product.sg-card.sg-card .sg-card__body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    gap: 8px;
    padding: 12px 14px 14px !important;
    margin: 0 !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__title {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
    min-height: 3.1em;
    margin: 0 !important;
    padding: 0 !important;
    font-family: var(--sg-font-body, inherit) !important;
    font-size: 0.92rem !important;
    font-weight: 400 !important;
    line-height: 1.55 !important;
    text-align: right !important;
    color: var(--sg-black, #1A1A1A) !important;
    white-space: normal !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__link {
    color: inherit !important;
    text-decoration: none !important;
    background: none !important;
}
/* کلِ کارت کلیک‌پذیر، با یک لینکِ واحد (دسترس‌پذیرتر از چند لینکِ تکراری) */
html body ul.products li.product.sg-card.sg-card .sg-card__link::after {
    content: "" !important;
    position: absolute !important;
    inset: 0;
    z-index: 1;
}
html body ul.products li.product.sg-card.sg-card .sg-card__link:focus-visible {
    outline: none;
}
html body ul.products li.product.sg-card.sg-card:focus-within {
    border-color: var(--sg-gold, #C5A059) !important;
}

/* ---------- قیمت ----------
   ارتفاعِ ثابتِ دو خط (قیمتِ خط‌خورده + قیمت نهایی) تا کارتِ بی‌تخفیف هم هم‌قد بمونه */
html body ul.products li.product.sg-card.sg-card .sg-card__price {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-end !important;
    align-items: flex-start !important;
    min-width: 0;
    min-height: 2.55em;
    margin: auto 0 0 !important;
    padding: 0 !important;
    color: var(--sg-black, #1A1A1A) !important;
    font-size: 1.05rem !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    text-align: right !important;
    background: none !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__price del {
    display: block !important;
    margin: 0 !important;
    font-size: 0.72rem !important;
    font-weight: 400 !important;
    color: var(--sg-text-muted, #767676) !important;
    opacity: 1 !important;
    background: none !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__price ins {
    display: block !important;
    text-decoration: none !important;
    background: none !important;
    font-weight: 500 !important;
}
/* قیمتِ خط‌خورده فقط عدد — «تومان» یک‌بار، کنار قیمتِ نهایی */
html body ul.products li.product.sg-card.sg-card .sg-card__price del .woocommerce-Price-currencySymbol {
    display: none !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__price .woocommerce-Price-currencySymbol {
    font-size: 0.7rem !important;
    font-weight: 400 !important;
    color: var(--sg-text-muted, #767676) !important;
}
/* دکمه‌ی سبد: گوشه‌ی پایین-چپِ عکس — در هیچ عرضی روی قیمت یا متن نمی‌افته */
html body ul.products li.product.sg-card.sg-card .sg-card__cart {
    position: absolute !important;
    left: 8px;
    bottom: 8px;
    z-index: 3;
    margin: 0 !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button:not(:hover):not(.added) {
    background: rgba(255, 255, 255, 0.94) !important;
}
/* دکمه‌ی سبدِ خودِ ووکامرس → دکمه‌ی گردِ آیکونی (متن برای صفحه‌خوان با aria-label می‌مونه) */
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid var(--sg-gold, #C5A059) !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--sg-gold-dark, #9E7B3B) !important;
    font-size: 0 !important;
    line-height: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button::before {
    content: "" !important;
    display: block !important;
    width: 20px;
    height: 20px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.3'/%3E%3Ccircle cx='18' cy='20' r='1.3'/%3E%3Cpath d='M2.5 3h3l2.4 12.2a1.6 1.6 0 0 0 1.6 1.3h8.4a1.6 1.6 0 0 0 1.6-1.3L22 7H6.2'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.3'/%3E%3Ccircle cx='18' cy='20' r='1.3'/%3E%3Cpath d='M2.5 3h3l2.4 12.2a1.6 1.6 0 0 0 1.6 1.3h8.4a1.6 1.6 0 0 0 1.6-1.3L22 7H6.2'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* محصولی که مستقیم به سبد نمی‌ره (چندوزنی/متغیر/قفل خرید) → فلش «مشاهده» */
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button:not(.add_to_cart_button)::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E");
}
/* بعد از افزودن → تیک */
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button.added::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button::after {
    content: none !important;
    display: none !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button:hover,
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button:focus-visible,
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button.added {
    background: var(--sg-gold, #C5A059) !important;
    color: #fff !important;
}
html body ul.products li.product.sg-card.sg-card .sg-card__cart .button.loading {
    opacity: 0.55 !important;
    pointer-events: none;
}
/* لینکِ «مشاهده سبد» که ووکامرس کنار دکمه اضافه می‌کنه — توستِ سایت همین کار رو می‌کنه */
html body ul.products li.product.sg-card.sg-card .sg-card__cart .added_to_cart {
    display: none !important;
}

/* ---------- ارسال سریع · ۴ قسط ---------- */
/* همیشه هست (حتی خالی) با ارتفاعِ ثابتِ دو خط: خط جداکننده در همه‌ی کارت‌ها هم‌تراز */
html body ul.products li.product.sg-card.sg-card .sg-card__meta {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0;
    height: calc(2 * 1.6em + 8px);
    margin: 0 !important;
    padding: 8px 0 0 !important;
    border-top: 1px solid var(--sg-champagne, #F2EEE9);
    font-size: 0.75rem !important;
    line-height: 1.6 !important;
    color: var(--sg-text-muted, #767676) !important;
    overflow: hidden;
}
html body ul.products li.product.sg-card.sg-card .sg-card__meta > span {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
html body ul.products li.product.sg-card.sg-card .sg-card__fast {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--sg-gold-dark, #9E7B3B);
}
html body ul.products li.product.sg-card.sg-card .sg-card__inst .sg-installment-btn__number {
    color: var(--sg-text-body, #333);
}

/* همه‌ی کاروسل‌ها (صفحه اصلی، محصولات مرتبط، ۴۰۴) یک عرضِ کارت */
html body .sg-carousel-row ul.products li.product.sg-card.sg-card {
    flex: 0 0 266px !important;
    width: 266px !important;
    min-width: 266px !important;
    max-width: 266px !important;
}

/* ---------- موبایل ---------- */
@media (max-width: 600px) {
    html body ul.products li.product.sg-card.sg-card {
        border-radius: 12px !important;
    }
    html body ul.products li.product.sg-card.sg-card .sg-card__body {
        gap: 6px;
        padding: 10px 10px 12px !important;
    }
    html body ul.products li.product.sg-card.sg-card .sg-card__title {
        font-size: 0.84rem !important;
    }
    html body ul.products li.product.sg-card.sg-card .sg-card__price {
        font-size: 0.95rem !important;
    }
    html body ul.products li.product.sg-card.sg-card .sg-card__cart .button {
        width: 36px !important;
        height: 36px !important;
    }
    html body ul.products li.product.sg-card.sg-card .sg-card__cart .button::before {
        width: 18px;
        height: 18px;
    }
    html body ul.products li.product.sg-card.sg-card .sg-card__wish .sg-wish-btn {
        width: 30px !important;
        height: 30px !important;
    }
}

/* فروشگاه/دسته روی موبایل: دو ستون (کارتِ جدید برای دو ستون جمع‌وجوره) */
@media (max-width: 500px) {
    /* #main/#primary: یک قانونِ قدیمی با ID (#main ul.products.columns-3 → 1fr) رو خنثی می‌کنه */
    html body.woocommerce-shop #main ul.products:not(.sg-carousel-row ul.products),
    html body.tax-product_cat #main ul.products:not(.sg-carousel-row ul.products),
    html body.tax-product_tag #main ul.products:not(.sg-carousel-row ul.products),
    html body.post-type-archive-product #main ul.products:not(.sg-carousel-row ul.products),
    html body.woocommerce-shop #primary ul.products:not(.sg-carousel-row ul.products),
    html body.tax-product_cat #primary ul.products:not(.sg-carousel-row ul.products),
    html body.tax-product_tag #primary ul.products:not(.sg-carousel-row ul.products) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }
}

/* موبایل، همه‌ی شبکه‌های محصول (فروشگاه، دسته، تگ، علاقه‌مندی‌ها):
   قابِ سفیدِ دورِ شبکه و فاصله‌ی داخلیش حذف، و شبکه تا ۶px از لبه‌ی گوشی
   (col-full خودش ۱۶px حاشیه داره → ۱۰px منفی) تا کارت‌ها جا داشته باشن */
@media (max-width: 600px) {
    html body #main ul.products:not(.sg-carousel-row ul.products),
    html body #primary ul.products:not(.sg-carousel-row ul.products) {
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-left: -10px !important;
        margin-right: -10px !important;
        width: auto !important;
    }
    /* علاقه‌مندی‌ها داخلِ محتوای برگه با پدینگِ بیشتره → شبکه نسبت به خودِ صفحه
       تمام‌عرض می‌شه (۶px از لبه)، دو ستون مثل فروشگاه */
    html body #main .sg-wish-page.sg-wish-page ul.products.products {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: calc(var(--sg-vw, 100vw) - 12px) !important;
        max-width: none !important;
        margin-left: calc(50% - var(--sg-vw, 100vw) / 2 + 6px) !important;
        margin-right: calc(50% - var(--sg-vw, 100vw) / 2 + 6px) !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
    }
    /* کاروسلِ «محصولات مرتبط» همون عرضِ کارتِ کاروسل‌های صفحه اصلی رو بگیره */
    html body .sg-carousel-row ul.products li.product.sg-card.sg-card {
        flex: 0 0 200px !important;
        width: 200px !important;
        min-width: 200px !important;
        max-width: 200px !important;
    }
}
