/**
 *
 * @package GeneratePress_Child
 */

/* ============================================
   الحاوية
   ============================================ */
.products-slider-container {
    width: min(80%, 1600px);
    margin-inline: auto;
    padding: var(--gp-space-5) 0;
    position: relative;
}

/* ============================================
   الرأس
   ============================================ */
.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gp-space-4);
    margin-bottom: var(--gp-space-4);
    padding-bottom: var(--gp-space-3);
}

.slider-header-left {
    display: flex;
    align-items: center;
    gap: var(--gp-space-5);
    flex: 1;
    min-width: 0;
}

.slider-title {
    font-size: clamp(1.1rem, 2.5vw, 1.45rem);
    font-weight: 800;
    color: var(--gp-text);
    margin: 0;
    white-space: nowrap;
    letter-spacing: -.01em;
    flex-shrink: 0;
}

/* ── أزرار التصفية ───────────────────────── */
.filter-buttons-wrapper {
    display: flex;
    gap: var(--gp-space-2);
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-buttons-wrapper::-webkit-scrollbar { display: none; }

.category-btn {
    padding: 6px 18px;
    border-radius: var(--gp-radius-pill);
    border: 1.5px solid var(--gp-border-strong);
    background: transparent;
    color: var(--gp-text-soft);
    font-family: inherit;
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--gp-transition), color var(--gp-transition);
}

.category-btn:hover  { border-color: var(--gp-brand); color: var(--gp-text); }
.category-btn.active { border-color: var(--gp-brand); color: var(--gp-brand); font-weight: 700; }

.view-all-link {
    color: var(--gp-brand);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    transition: opacity var(--gp-transition);
}

.view-all-link:hover { opacity: .75; }

/* ============================================
   المسار — scroll-snap أصلي
   ============================================ */
.slider-controls-wrapper {
    position: relative;
}

.products-carousel-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* مساحة للظل والتكبير عند المرور */
    padding-block: var(--gp-space-1);
    /* overscroll-behavior يمنع سحب السلايدر من تحريك الصفحة كلها */
    overscroll-behavior-x: contain;
}

.products-carousel-wrapper::-webkit-scrollbar { display: none; }

.products-list {
    display: flex;
    /* صريحة عمداً: كل البطاقات بارتفاع أطولها مهما اختلف محتواها */
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    /*
     * min-height يحجز ارتفاع الصف قبل وصول البطاقات، فلا تقفز الصفحة.
     */
    min-height: 280px;
}

/*
 * ⭐ عرض البطاقة — القاعدة الجوهرية في هذا الملف.
 *
 * كانت هذه القاعدة على `.product-slide`، وهو غلاف حذفتُه عند تصحيح
 * تداخل HTML (كان <div> داخل <ul>). فبقيت القاعدة تستهدف عنصراً غير
 * موجود، و<li> بلا أي flex-basis داخل حاوية display:flex → كل البطاقات
 * تنكمش لتتسع في صف واحد مهما كان عددها.
 *
 * الآن القاعدة على العنصر الفعلي، وعدد الأعمدة يأتي من الشورت‌كود عبر
 * متغيّرات CSS على الحاوية:
 *     [my_products_slider cols_desktop="5" cols_tablet="3" cols_mobile="2"]
 *
 * القيم الاحتياطية تعمل لو استُعمل السلايدر بلا إعدادات.
 */
.products-list > li,
.products-list > .product-slide {
    flex: 0 0 calc(100% / var(--cols-mobile, 2));
    max-width: calc(100% / var(--cols-mobile, 2));
    box-sizing: border-box;
    padding-inline: var(--gp-space-2);
    scroll-snap-align: start;
}

@media (min-width: 768px) {
    .products-list > li,
    .products-list > .product-slide {
        flex-basis: calc(100% / var(--cols-tablet, 3));
        max-width:  calc(100% / var(--cols-tablet, 3));
    }
}

@media (min-width: 1024px) {
    .products-list > li,
    .products-list > .product-slide {
        flex-basis: calc(100% / var(--cols-desktop, 4));
        max-width:  calc(100% / var(--cols-desktop, 4));
    }
}

/* رسالة «لا توجد منتجات» تأخذ العرض كاملاً */
.products-list > li.no-products {
    flex-basis: 100%;
    max-width: 100%;
}

/* ============================================
   أزرار التنقل
   ============================================ */
.carousel-btn {
    position: absolute;
    top: 38%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    background-color: var(--gp-surface);
    color: var(--gp-text);
    border: 1px solid var(--gp-border);
    border-radius: 50%;
    box-shadow: var(--gp-shadow-md);
    cursor: pointer;
    z-index: var(--gp-z-badge);
    transition: background-color var(--gp-transition), color var(--gp-transition), opacity var(--gp-transition);
}

.carousel-btn:hover {
    background-color: var(--gp-brand);
    color: var(--gp-text-invert);
    border-color: var(--gp-brand);
}

.carousel-btn:disabled {
    opacity: 0;
    pointer-events: none;
}

/*
 * inset-inline-* تنعكس تلقائياً حسب الاتجاه:
 *   LTR → السابق يسار، التالي يمين
 *   RTL → السابق يمين، التالي يسار   ✓ صحيح
 */
.prev-btn { inset-inline-start: -8px; }
.next-btn { inset-inline-end:   -8px; }

/*
 * ⚠️ لكن الأيقونة نفسها لا تنعكس — تبقى fa-chevron-left مهما كان
 * الاتجاه. في العربية كان زر «السابق» (على اليمين) يعرض سهماً يشير
 * يساراً، أي عكس ما يفعله.
 * نقلبها أفقياً في RTL.
 */
[dir="rtl"] .carousel-btn > i {
    transform: scaleX(-1);
}

/* على الشاشات اللمسية السحب يكفي — نخفي الأزرار */
@media (hover: none) {
    .carousel-btn { display: none; }
}

/* ============================================
   حالات
   ============================================ */
/*
 * ⚠️ [hidden] في ورقة المتصفح ضعيف جداً: أي `display` في ورقة المؤلف
 * يتغلّب عليه. بدون السطر التالي يبقى مؤشر التحميل ظاهراً **دائماً**
 * تحت كل سلايدر رغم وجود hidden في الوسم.
 */
.slider-loader[hidden],
.carousel-btn[hidden] {
    display: none !important;
}

.slider-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gp-space-2);
    padding: var(--gp-space-5);
    color: var(--gp-text-muted);
    font-size: .9rem;
}

.no-products {
    list-style: none;
    width: 100%;
    text-align: center;
    padding: var(--gp-space-7) var(--gp-space-4);
    color: var(--gp-text-muted);
}

/* ============================================
   استجابة
   ============================================ */
@media (max-width: 768px) {
    .products-slider-container { width: 94%; padding: var(--gp-space-4) 0; }

    .slider-header {
        flex-wrap: wrap;
        gap: var(--gp-space-2);
        margin-bottom: var(--gp-space-3);
    }

    .slider-header-left {
        flex-wrap: wrap;
        gap: var(--gp-space-3);
        width: 100%;
    }

    .filter-buttons-wrapper { width: 100%; }

    .category-btn  { padding: 5px 14px; font-size: .82rem; }
    .view-all-link { font-size: .84rem; }
    .products-list { min-height: 240px; }
}
