/*
 * Custom Frontend Stylesheet
 * styles for product cards, etc.
 */

/*
 * =============================================
 *   شاشة التحميل (Preloader)
 * =============================================
 */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.75s ease, visibility 0.75s ease;
}

/*
 * =============================================
 *   تخصيص شعار التحميل (Lottie)
 * =============================================
 */
.preloader-lottie {
    width: 250px; /* حجم مناسب للشاشات الكبيرة */
    height: auto;
    /* تطبيق فلتر لتحويل الألوان إلى الأسود */
    filter: grayscale(1) brightness(0);
}

@media (max-width: 768px) {
    .preloader-lottie {
        width: 180px; /* حجم أصغر للشاشات المتوسطة والصغيرة */
    }
}

/* --- إعدادات عامة وخطوط --- */
body {
    font-family: 'Cairo', sans-serif; /* تأكد من استيراد الخط في header.php */
    background-color: #f8f9fa;
}

/* --- حاوية شبكة المنتجات --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

@media (max-width: 576px) {
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}
/* =============================================
   بطاقات المنتجات - نسخة محسنة ومتناسقة
   ============================================= */
.product-card {
    background-color: #ffffff;
    width: 100%;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    padding: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: auto;
    direction: rtl;
    text-align: right;
    margin: 0;
}

.product-card .image-container {
    position: relative;
    background: #f7f8fb;
    border-radius: 14px;
    height: 214px;
    padding: 7px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid #eceff3;
}

.product-card .main-product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    z-index: 2;
    border-radius: 12px;
}

.product-card .product-info {
    display: flex;
    flex-direction: column;
}

.product-card .badge-promo {
    background-color: #ffc107;
    color: #000;
    font-size: 12px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 5px;
}

.product-card .product-title {
    font-size: 16px;
    font-weight: 700;
    color: #000000;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0;
}

.product-card .price-container {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 6px;
    margin: 2px 0;
    line-height: 1;
    min-height: 0;
    flex-wrap: wrap;
    overflow: visible;
    width: auto;
    max-width: 100%;
    direction: rtl;
}

.product-card .current-price {
    color: #b70000;
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
    margin: 0;
    display: inline-block;
    white-space: nowrap;
}

.product-card .old-price {
    color: #9e9e9e;
    text-decoration: line-through;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    margin: 0;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .tags-container {
    display: flex;
    gap: 6px;
    margin: 0;
    flex-wrap: wrap;
    min-height: 0;
    align-items: center;
    overflow: visible;
}

.product-card .badge-stock--img {
    position: absolute;
    bottom: 8px;
    inset-inline-start: 8px;
    z-index: 3;
    margin: 0;
    border-radius: 8px;
}

.product-card .badge-discount {
    background-color: #ff9800;
    color: #000;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .badge-stock {
    background-color: #fb5f66;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .badge-stock.stock-in {
    background-color: #159947;
}

.product-card .badge-stock.stock-low {
    background-color: #f59e0b;
}

.product-card .badge-stock.stock-out {
    background-color: #e53935;
}

.product-card .savings-text {
    color: #00897b;
    font-size: 13.5px;
    font-weight: 500;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 992px) {
    .product-card {
        padding: 10px;
    }

    .product-card .image-container {
        height: 198px;
        margin-bottom: 8px;
        padding: 6px;
    }

    .product-card .product-title {
        font-size: 15px;
        min-height: 36px;
        margin-bottom: 1px;
    }

    .product-card .current-price {
        font-size: 23px;
    }

    .product-card .old-price {
        font-size: 14px;
        max-width: none;
    }

    .product-card .price-container {
        min-height: 0;
        gap: 6px;
        width: auto;
        justify-content: flex-start;
    }

    .product-card .tags-container {
        min-height: 22px;
        margin: 3px 0 4px 0;
    }

    .product-card .badge-discount,
    .product-card .badge-stock,
    .product-card .badge-promo {
        font-size: 11px;
        padding: 1px 6px;
        max-width: 100%;
    }

    .product-card .savings-text {
        font-size: 12px;
        margin-top: 1px;
    }
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .product-card {
        width: 100%;
        padding: 8px;
    }

    .product-card .image-container {
        height: 150px;
        margin-bottom: 8px;
        padding: 8px;
    }

    .product-card .product-title {
        font-size: 14px;
        line-height: 1.15;
        min-height: 32px;
    }

    .product-card .current-price {
        font-size: 18px;
    }

    .product-card .old-price {
        font-size: 12px;
    }

    .product-card .price-container {
        gap: 4px;
        min-height: 22px;
        margin: 1px 0;
    }

    .product-card .tags-container {
        gap: 4px;
        margin: 2px 0 3px 0;
        min-height: 20px;
    }

    .product-card .badge-discount,
    .product-card .badge-stock,
    .product-card .badge-promo {
        font-size: 10px;
        padding: 1px 5px;
    }

    .product-card .savings-text {
        font-size: 11px;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 1px;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .product-card .image-container {
        height: 135px;
        margin-bottom: 6px;
        padding: 6px;
    }

    .product-card {
        padding: 7px;
    }

    .product-card .product-title {
        font-size: 12px;
        min-height: 28px;
    }

    .product-card .current-price {
        font-size: 16px;
    }

    .product-card .old-price {
        font-size: 11px;
    }

    .product-card .price-container {
        min-height: 20px;
    }

    .product-card .tags-container {
        min-height: 18px;
    }

    .product-card .savings-text {
        font-size: 10px;
    }
}

/*
 * =============================================
 *   إصلاح مشكلة bootstrap.rtl.min.css
 * =============================================
 * هذه القاعدة تقوم بتصحيح السلوك الخاطئ للكلاس .text-end
 * وتجبره على محاذاة النص لليمين كما هو متوقع في RTL.
 */
[dir="rtl"] .text-end {
    text-align: right !important;
}

/* إبراز نص التوفير بخط عريض */
.product-card .savings-text {
    font-weight: 700 !important;
}

/*
 * =============================================
 *   تعديل موضع مؤشرات السلايدر
 * =============================================
 * هذا الكود يضع المؤشرات داخل السلايدر في الأسفل.
 */
#mainSlider .carousel-indicators {
    position: absolute;
    bottom: 20px; /* يمكنك تعديل هذه القيمة لضبط المسافة من الأسفل */
}

/* تم حذف ارتفاع ثابت قديم للسلايدر لأنه يتعارض مع نظام aspect-ratio الحالي. */

/*
 * =============================================
 *   توسيط محتوى السلايدر عمودياً
 * =============================================
 */
@media (min-width: 768px) { /* تطبيق النمط على الشاشات المتوسطة وأكبر */
    .slide-content-wrapper .col-md-7 {
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100%;
    }
}

/*
 * =============================================
 *   إصلاح مشكلة ظهور لون فوق خلفية السلايدر
 * =============================================
 * هذا الكود يجعل خلفية أعمدة المحتوى شفافة.
 */
.slide-content-wrapper,
.slide-content-wrapper .row,
.slide-content-wrapper .col-md-7,
.slide-content-wrapper .col-md-5 {
    background-color: transparent !important;
}

/*
 * =============================================
 *   تطبيق تصميم محصور للسلايدر والبطاقات
 * =============================================
 * هذا الكود يطبق الإعدادات المطلوبة على حاوية السلايدر.
 */
.hero-section-container {
    margin-top: 1.5rem;
}