/**
 * أزرار المنتج والصور — يعتمد على متغيرات CSS (نفس الأسماء في global-admin.css :root).
 * تُحدَّث القيم من Firestore عبر store-product-display.js على عنصر html.
 */
:root {
    --dedo-buy-now-bg: #ea580c;
    --dedo-buy-now-text: #ffffff;
    --dedo-buy-now-border: #c2410c;
}

.btn-buy-now-store,
a.btn-buy-now-store,
.home-prod-card .btn-buy-now-store,
button.btn-buy-now-store {
    background: var(--dedo-buy-now-bg) !important;
    background-image: none !important;
    color: var(--dedo-buy-now-text) !important;
    border: 2px solid var(--dedo-buy-now-border) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14) !important;
}

/* إخفاء الزر على المتجر فقط (لوحة التحكم تبقى للمعاينة) */
body:not(.merchant-dashboard).dedo-buy-now-off .btn-buy-now-store,
body:not(.merchant-dashboard).dedo-buy-now-off a.btn-buy-now-store {
    display: none !important;
}

/* بطاقات القائمة: إظهار الزر عند التمرير فقط — دون تعطيل النقر (كان pointer-events:none يمنع الضغط المباشر على الزر) */
body:not(.merchant-dashboard).dedo-buy-now-card-hover .card-product:not(:hover) .btn-buy-now-store,
body:not(.merchant-dashboard).dedo-buy-now-card-hover .home-prod-card:not(:hover) .btn-buy-now-store {
    opacity: 0;
    transition: opacity 0.22s ease;
}

body:not(.merchant-dashboard).dedo-buy-now-card-hover .card-product:hover .btn-buy-now-store,
body:not(.merchant-dashboard).dedo-buy-now-card-hover .home-prod-card:hover .btn-buy-now-store {
    opacity: 1;
}

@media (hover: none) {
    body:not(.merchant-dashboard).dedo-buy-now-card-hover .card-product:not(:hover) .btn-buy-now-store,
    body:not(.merchant-dashboard).dedo-buy-now-card-hover .home-prod-card:not(:hover) .btn-buy-now-store {
        opacity: 1;
    }
}

/* أزرار الإجراء فوق أي طبقات ضمن البطاقة */
.product-card-actions,
.home-prod-card-actions {
    position: relative;
    z-index: 2;
}

/* تكبير صورة المنتج عند التمرير */
body.dedo-product-zoom-hover .product-main-img,
body.dedo-product-zoom-hover .home-prod-card-media-link img,
body.dedo-product-zoom-hover .pd-main-img,
body.dedo-product-zoom-hover .pd-related-card img {
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
}

body.dedo-product-zoom-hover a.product-card-hit:hover .product-main-img,
body.dedo-product-zoom-hover .card-product:hover .product-main-img,
body.dedo-product-zoom-hover .home-prod-card:hover .home-prod-card-media-link img,
body.dedo-product-zoom-hover .pd-main-img:hover,
body.dedo-product-zoom-hover .pd-related-card:hover img {
    transform: scale(1.07);
}

/* ——— إعدادات عرض الأقسام (sectionsLayout في appearance) ——— */
body:not(.merchant-dashboard).dedo-sec-layout-grid .home-prod-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
@media (min-width: 480px) {
    body:not(.merchant-dashboard).dedo-sec-layout-grid .home-prod-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

body:not(.merchant-dashboard).dedo-sec-layout-horizontal .home-prod-grid,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal .store-cat-products-block .product-grid,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal #products-area.product-grid,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal #store-featured-inner .product-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 1rem;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    grid-template-columns: unset;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
body:not(.merchant-dashboard).dedo-sec-layout-horizontal .home-prod-grid::-webkit-scrollbar,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal .store-cat-products-block .product-grid::-webkit-scrollbar,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal #products-area.product-grid::-webkit-scrollbar,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal #store-featured-inner .product-grid::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body:not(.merchant-dashboard).dedo-sec-layout-horizontal .home-prod-grid > .home-prod-card,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal .store-cat-products-block .product-grid > .card-product,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal #products-area.product-grid > .card-product,
body:not(.merchant-dashboard).dedo-sec-layout-horizontal #store-featured-inner .product-grid > .card-product {
    flex: 0 0 min(46vw, 200px);
    max-width: min(46vw, 200px);
    height: auto;
    align-self: stretch;
    scroll-snap-align: start;
}

body:not(.merchant-dashboard).dedo-sec-layout-horizontal .home-featured-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 1.15rem;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    grid-template-columns: unset;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
body:not(.merchant-dashboard).dedo-sec-layout-horizontal .home-featured-grid::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body:not(.merchant-dashboard).dedo-sec-layout-horizontal .home-featured-grid > .home-prod-card {
    flex: 0 0 min(46vw, 200px);
    max-width: min(46vw, 200px);
    scroll-snap-align: start;
}

/* غلاف أسهم التنقل بدل شريط السكرول */
.dedo-hscroll-shell {
    position: relative;
    padding-inline: 2.35rem;
}
.dedo-hscroll-btn {
    position: absolute;
    top: 42%;
    transform: translateY(-50%);
    z-index: 6;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.dedo-hscroll-btn:hover {
    background: #f8fafc;
    color: #2563eb;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.18);
}
.dedo-hscroll-btn:disabled,
.dedo-hscroll-btn.is-disabled {
    opacity: 0.28;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
}
.dedo-hscroll-btn--prev { inset-inline-start: 0; }
.dedo-hscroll-btn--next { inset-inline-end: 0; }
.dedo-hscroll-shell.is-no-overflow .dedo-hscroll-btn {
    display: none;
}
@media (max-width: 480px) {
    .dedo-hscroll-shell { padding-inline: 1.85rem; }
    .dedo-hscroll-btn {
        width: 2.15rem;
        height: 2.15rem;
        font-size: 0.85rem;
    }
}

/* محاذاة عنوان القسم (يتجاوز أنماط الصفحة الداخلية) */
body:not(.merchant-dashboard).dedo-sec-title-center #home-sections-root .home-sec-title,
body:not(.merchant-dashboard).dedo-sec-title-center .store-cat-heading {
    text-align: center !important;
}
body:not(.merchant-dashboard).dedo-sec-title-right #home-sections-root .home-sec-title,
body:not(.merchant-dashboard).dedo-sec-title-right .store-cat-heading {
    text-align: right !important;
}
body:not(.merchant-dashboard).dedo-sec-title-left #home-sections-root .home-sec-title,
body:not(.merchant-dashboard).dedo-sec-title-left .store-cat-heading {
    text-align: left !important;
}

body:not(.merchant-dashboard).dedo-sec-title-center .home-featured-head {
    justify-content: center;
}
body:not(.merchant-dashboard).dedo-sec-title-center .home-featured-head .sub {
    text-align: center;
}
body:not(.merchant-dashboard).dedo-sec-title-right .home-featured-head {
    justify-content: flex-end;
}
body:not(.merchant-dashboard).dedo-sec-title-right .home-featured-head .sub {
    text-align: right;
}
body:not(.merchant-dashboard).dedo-sec-title-left .home-featured-head {
    justify-content: flex-start;
}
body:not(.merchant-dashboard).dedo-sec-title-left .home-featured-head .sub {
    text-align: left;
}

.store-cat-more-link {
    display: inline-block;
    margin-top: 0.85rem;
    font-weight: 900;
    font-size: 0.95rem;
    color: var(--primary-color, #2563eb);
    text-decoration: none;
}
.store-cat-more-link:hover {
    text-decoration: underline;
}

/* ——— أشكال بطاقة المنتج (productCardStyle) ——— */
/* إطار موحّد 1:1 لأي صورة (حتى لو الرفع مش مربع) */
.product-card-media-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    flex-shrink: 0;
}
.product-card-media-wrap .product-main-img,
.home-prod-card .product-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}
.pcard-wish,
.pcard-quick-add,
.product-card-bar-elegant {
    display: none;
}

/* أنيق — بطاقة خفيفة + شريط سعر */
body.dedo-pcard-elegant .card-product,
body.dedo-pcard-elegant .home-prod-card {
    border: 1px solid #e8eef5 !important;
    border-radius: 18px !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04) !important;
    padding: 12px 12px 10px !important;
}
body.dedo-pcard-elegant .product-gallery-thumbs,
body.dedo-pcard-elegant .product-card-desc,
body.dedo-pcard-elegant .product-card-attrs,
body.dedo-pcard-elegant .product-card-stock,
body.dedo-pcard-elegant .product-card-actions,
body.dedo-pcard-elegant .home-prod-card-actions,
body.dedo-pcard-elegant .product-card-price,
body.dedo-pcard-elegant .p-price {
    display: none !important;
}
body.dedo-pcard-elegant .product-card-title {
    min-height: calc(1.35em * 2);
    margin-bottom: 0.5rem;
}
body.dedo-pcard-elegant .product-card-bar-elegant {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.35rem;
    flex-shrink: 0;
}
body.dedo-pcard-elegant .pcard-bar-price {
    flex: 1;
    text-align: center;
    font-weight: 900;
    font-size: 0.92rem;
    color: #0f172a;
    min-width: 0;
}
body.dedo-pcard-elegant .pcard-bar-wish,
body.dedo-pcard-elegant .pcard-bar-cart {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}
body.dedo-pcard-elegant .pcard-bar-cart {
    border-color: color-mix(in srgb, var(--primary-color, #84cc16) 45%, #e2e8f0);
    color: var(--primary-color, #65a30d);
}

/* كتالوج — كثيف مثل المتاجر الكبيرة */
body.dedo-pcard-catalog .card-product,
body.dedo-pcard-catalog .home-prod-card {
    border: 1px solid #eef2f7 !important;
    border-radius: 14px !important;
    padding: 10px !important;
    background: #fff !important;
}
body.dedo-pcard-catalog .product-gallery-thumbs,
body.dedo-pcard-catalog .product-card-desc,
body.dedo-pcard-catalog .product-card-attrs,
body.dedo-pcard-catalog .product-card-stock,
body.dedo-pcard-catalog .product-card-actions,
body.dedo-pcard-catalog .home-prod-card-actions {
    display: none !important;
}
body.dedo-pcard-catalog .product-card-media-wrap {
    margin-bottom: 0.35rem;
}
body.dedo-pcard-catalog .pcard-wish {
    display: inline-flex;
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    z-index: 3;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #64748b;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
body.dedo-pcard-catalog .pcard-quick-add {
    display: inline-flex;
    position: absolute;
    bottom: 8px;
    inset-inline-start: 8px;
    z-index: 3;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #0f172a;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 900;
    font-size: 1.15rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
}
body.dedo-pcard-catalog .product-card-title {
    font-size: 0.82rem;
    min-height: calc(1.3em * 2);
    text-align: start;
}
body.dedo-pcard-catalog .product-card-price {
    text-align: start;
    margin-top: 0.35rem;
}
body.dedo-pcard-catalog .product-card-body > a.product-card-hit {
    text-align: start;
}

/* ستوديو — عرض هادئ: بئر صورة + سعر بارز + زر واحد */
body.dedo-pcard-studio .card-product,
body.dedo-pcard-studio .home-prod-card {
    border: 0 !important;
    border-radius: 22px !important;
    padding: 14px 14px 12px !important;
    background: #fff !important;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.07) !important;
}
body.dedo-pcard-studio .product-gallery-thumbs,
body.dedo-pcard-studio .product-card-desc,
body.dedo-pcard-studio .product-card-attrs,
body.dedo-pcard-studio .product-card-stock,
body.dedo-pcard-studio .product-card-bar-elegant,
body.dedo-pcard-studio .btn-add-cart-store,
body.dedo-pcard-studio .btn-add-home {
    display: none !important;
}
body.dedo-pcard-studio .product-card-media-wrap {
    aspect-ratio: 1 / 1;
    height: auto;
    padding: 10px;
    border-radius: 18px;
    background: linear-gradient(165deg, #f1f5f9 0%, #e8eef5 100%);
    box-sizing: border-box;
    margin-bottom: 0.65rem;
}
body.dedo-pcard-studio .product-card-media {
    height: 100%;
    border-radius: 14px;
    background: transparent;
}
body.dedo-pcard-studio .product-main-img {
    object-fit: cover;
}
body.dedo-pcard-studio .product-card-title {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    min-height: calc(1.35em * 2);
    margin-bottom: 0.25rem;
}
body.dedo-pcard-studio .product-card-price {
    margin: 0.15rem 0 0.55rem;
    font-size: 1.05rem;
}
body.dedo-pcard-studio .product-card-price .text-primary {
    color: #0f172a !important;
    font-weight: 900;
}
body.dedo-pcard-studio .product-card-actions {
    flex-wrap: nowrap;
    margin-top: auto;
}
body.dedo-pcard-studio .btn-buy-now-store {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border-radius: 999px !important;
    padding: 0.7rem 0.75rem;
    font-size: 0.82rem;
    background: #0f172a !important;
    background-image: none !important;
    border: 0 !important;
    color: #fff !important;
    box-shadow: none !important;
}
body.dedo-pcard-studio .btn-buy-now-store i {
    display: none;
}
/* لو اشتري الآن مطفي: زر الإضافة يبقى كـ CTA وحيد بنفس روح الستوديو */
body.dedo-pcard-studio.dedo-buy-now-off .btn-add-cart-store {
    display: inline-flex !important;
    flex: 1 1 auto;
    width: 100%;
    border-radius: 999px;
    background: #0f172a;
    font-size: 0.82rem;
    padding: 0.7rem 0.75rem;
}
body.dedo-pcard-studio:not(.dedo-buy-now-off) .btn-add-cart-store {
    display: none !important;
}

/* بدون برواز — صورة ومنتج بدون إطار ولا ظل */
body.dedo-pcard-plain .card-product,
body.dedo-pcard-plain .home-prod-card {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 6px 4px 8px !important;
}
body.dedo-pcard-plain .product-card-bar-elegant {
    display: none !important;
}
body.dedo-pcard-plain .product-card-media-wrap {
    border-radius: 12px;
    overflow: hidden;
}
body.dedo-pcard-plain .product-card-media {
    border-radius: 12px;
    background: #f8fafc;
}
body.dedo-pcard-plain .product-gallery-thumbs.is-empty {
    min-height: 0;
    margin: 0;
}
body.dedo-pcard-plain .product-card-bar-elegant {
    display: none !important;
}
body.dedo-pcard-plain .product-card-title {
    font-size: 0.9rem;
}
body.dedo-pcard-plain .product-card-actions {
    gap: 0.4rem;
}
body.dedo-pcard-plain .btn-add-cart-store,
body.dedo-pcard-plain .btn-buy-now-store {
    border-radius: 10px;
}
