/* ===== CLEAN PRODUCT CARD STYLES ===== */
/* قالب منتج نظيف وحديث بدون حركات أو ظلال */

.product-card {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid #97755b4f;
}

.product-card:hover {
    border-color: rgba(0, 123, 255, 0.15);
}

/* ===== 1. صورة المنتج الرئيسية ===== */
.product-image-container {
    position: relative;
    height: 50vh;
    min-height: 300px;
    max-height: 500px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px 24px 0 0;
}

/* ===== علامة الخصم فوق الصورة ===== */
.discount-badge-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #ff4757 0%, #ff3742 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    z-index: 15;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
}

.discount-badge-overlay::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ff4757, #ff3742, #ff4757);
    border-radius: 22px;
    z-index: -1;
    opacity: 0.3;
}

.product-gallery {
    position: relative;
    width: 97%;
    height: 97%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    padding: 40px;
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    border-radius: 24px 24px 0 0;
    cursor: pointer;
}

.product-image.active {
    opacity: 1;
    z-index: 2;
}

/* ===== 2. أزرار التصفح (يمين/يسار) ===== */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
}

.product-gallery:hover .gallery-nav {
    opacity: 1;
    visibility: visible;
}

.gallery-nav:hover {
    background: white;
    border-color: rgba(0, 123, 255, 0.3);
}

.gallery-nav i {
    color: #333;
    font-size: 20px;
    font-weight: bold;
}

.gallery-prev {
    left: -2px;
}

.gallery-next {
    right: -2px;
}

/* ===== 3. أيقونة القلب (المفضلة) ===== */
.favorite-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
}

.product-image-container:hover .favorite-btn {
    opacity: 1;
    visibility: visible;
}

.favorite-btn:hover {
    background: #ff4757;
    border-color: #ff4757;
}

.favorite-btn:hover i {
    color: white;
}

.favorite-btn i {
    color: #666;
    font-size: 22px;
}

.favorite-btn.active {
    background: #ff4757;
    border-color: #ff4757;
}

.favorite-btn.active i {
    color: white;
}

/* ===== 4. مؤشرات الصور المصغرة ===== */
.image-indicators {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.indicator {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.indicator.active {
    background: white;
    border-color: rgba(0, 0, 0, 0.3);
}

.indicator:hover {
    background: rgba(255, 255, 255, 0.8);
}

/* ===== 5. معلومات المنتج ===== */
.product-info {
    padding: 17px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #6c757d73;
    gap: 7px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-top-left-radius: 15px;
}

.product-title {
    font-size: 24px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0;
    padding: 0;
    line-height: 1.3;
    letter-spacing: -0.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title a {
    color: inherit;
    text-decoration: none;
}

.product-title a:hover {
    color: #007bff;
}

/* ===== 6. التقييمات ===== */
.product-rating {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stars {
    display: flex;
    gap: 2px;
}

.stars i {
    color: #ffc107;
    font-size: 14px;
}

.rating-text {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

/* ===== 7. السعر + الخصم - محسن للوضوح ===== */
.product-price-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 8px 0;
}

.product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.current-price {
    font-size: 23px;
    font-weight: 900;
    color: #2c3e50;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.5px;
}

.old-price {
    font-size: 18px;
    color: #95a5a6;
    text-decoration: line-through;
    font-weight: 600;
}

.discount-badge {
    background: #27ae60;
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 16px;
    margin-left: auto;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ===== 8. زر الشراء / أضف إلى السلة - محسن للوضوح ===== */
.add-to-cart-container {
    display: flex; 
    align-items: center; 
    justify-content: center;
    width: 100%;
}

.add-to-cart-btn {
    width: 100%;
    height: 60px;
    background: #28a745;
    color: #ffffff;
    border: 2px solid #28a745;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out; /* إضافة انتقال ناعم */
}

.add-to-cart-btn:hover {
    background: #218838; /* لون أغمق قليلاً عند المرور */
    border-color: #1e7e34;
}

/* ==================== الإصلاح الرئيسي هنا ==================== */
/* تم حذف حالة :active التي تسبب الوميض الأبيض */
/* .add-to-cart-btn:active { background: white; } */
/* ========================================================== */

.add-to-cart-btn i {
    font-size: 20px;
    color: #ffffff;
    margin-right: 8px;
}

.add-to-cart-btn.in-cart {
    background: white;
    color: #27ae60;
    border-color: #27ae60;
}

.add-to-cart-btn.in-cart:hover {
    background: white;
}

/* ===== عداد السلة وأزرار التحكم ===== */
.cart-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 60px;
    background: #28a745;
    border: 2px solid #28a745;
    border-radius: 20px;
    padding: 0 16px;
}

.cart-quantity {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    min-width: 24px;
    text-align: center;
    padding: 0 8px;
}

/* ===== 9. شريط المميزات المتحرك العمودي ===== */
.product-features-marquee {
    width: 100%;
    padding: 0;
    height: 24px;
    overflow: hidden;
    position: relative;
    background-color: #6c757d12;
    margin-top: -8px;
    margin-bottom: 2%;
    border-radius: 8px;
    margin-right: 0%;
}

.marquee-content {
    display: flex;
    flex-direction: column;
    animation: marquee-vertical 15s ease-in-out infinite;
}

.feature-tag {
    color: #666;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    padding: 0;
    align-items: center;
    height: 24px;
    text-align: left;
}

.feature-tag i {
    font-size: 10px;
    margin-right: 12px;
}

.product-features-marquee:hover .marquee-content {
    animation-play-state: paused;
}

/* أيقونات ملونة للمميزات */
.feature-tag:nth-child(1) i { color: #28a745; }
.feature-tag:nth-child(2) i { color: #007bff; }
.feature-tag:nth-child(3) i { color: #ffc107; }
.feature-tag:nth-child(4) i { color: #dc3545; }
.feature-tag:nth-child(5) i { color: #6f42c1; }
.feature-tag:nth-child(6) i { color: #fd7e14; }
.feature-tag:nth-child(7) i { color: #20c997; }
.feature-tag:nth-child(8) i { color: #e83e8c; }

/* ===== Horizontal Scroll Layout ===== */
.products-grid {
    display: flex;
    flex-direction: row;
    gap: 24px;
    padding: 20px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #97755b4f #f8f9fa;
    -webkit-overflow-scrolling: touch;
}

.products-grid::-webkit-scrollbar {
    height: 8px;
}

.products-grid::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.products-grid::-webkit-scrollbar-thumb {
    background: #97755b4f;
    border-radius: 4px;
}

.products-grid::-webkit-scrollbar-thumb:hover {
    background: #97755b;
}

/* ===== Responsive Design ===== */

@media (max-width: 1024px) {
    .products-grid {
        gap: 20px;
        padding: 15px 0;
    }
    
    .product-card {
        width: 300px;
        min-width: 300px;
        max-width: 300px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .product-image-container {
        height: 55vh;
        min-height: 400px;
        max-height: 550px;
    }
    
    .product-image {
        padding: 45px;
    }
    
    .product-title {
        font-size: 20px;
    }
    
    .current-price {
        font-size: 32px;
    }
    
    .add-to-cart-btn,
    .cart-controls {
        height: 64px;
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .product-image-container {
        height: 60vh;
        min-height: 450px;
        max-height: 600px;
        border-radius: 20px 20px 0 0;
    }
    
    .product-image {
        padding: 50px;
    }
    
    .gallery-nav, .favorite-btn {
        width: 52px;
        height: 52px;
        opacity: 1;
        visibility: visible;
    }
    
    .gallery-nav i { font-size: 20px; }
    .favorite-btn { top: 20px; left: 20px; }
    .favorite-btn i { font-size: 22px; }
    
    .product-info {
        padding: 24px;
        gap: 16px;
    }
    
    .product-title {
        font-size: 22px;
        font-weight: 700;
        line-height: 1.4;
    }

    .product-price-container {
        gap: 20px;
    }
    
    .current-price {
        font-size: 36px;
        font-weight: 900;
    }
    
    .old-price {
        font-size: 24px;
    }

    .discount-badge {
        font-size: 18px;
        padding: 8px 16px;
    }
    
    .rating-text {
        font-size: 16px;
    }
    
    .stars i {
        font-size: 18px;
    }
    
    .add-to-cart-btn,
    .cart-controls {
        height: 68px;
        font-size: 20px;
    }
    
    .cart-controls {
        gap: 20px;
        padding: 0 24px;
    }
    
    .cart-quantity {
        font-size: 20px;
        font-weight: 800;
    }

    .product-features-marquee {
        height: 28px;
        margin-top: 12px;
    }
    .feature-tag {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .product-card {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    .product-image-container {
        height: 49vh;
        min-height: 346px;
        max-height: 650px;
    }
    
    .product-image {
        padding: 6px;
    }

    .product-info {
        gap: 3px;
    }
    
    .product-title {
        font-size: 26px;
        font-weight: 800;
    }
    
    .current-price {
        font-size: 20px;
        font-weight: 900;
    }
    
    .old-price {
        font-size: 18px;
    }
    
    .rating-text, .stars i {
        font-size: 20px;
    }
    
    .add-to-cart-btn,
    .cart-controls {
        height: 72px;
        font-size: 22px;
    }
    
    .cart-controls {
        gap: 24px;
        padding: 0 28px;
    }
    
    .cart-quantity {
        font-size: 22px;
        min-width: 32px;
    }
    
    .favorite-btn, .gallery-nav {
        width: 56px;
        height: 56px;
    }

    .favorite-btn { top: 8px; left: 8px; }
    .favorite-btn i { font-size: 24px; }
    .gallery-nav i { font-size: 22px; }

    .product-features-marquee {
        height: 24px;
    }

    .feature-tag {
        font-size: 17px;
    }
}

@media (max-width: 360px) {
    .product-card {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }
    
    .product-image-container {
        height: 24vh;
        min-height: 352px;
    }
    
    .product-image {
        padding: 4px;
    }
    
    .product-title {
        font-size: 20px;
    }
    
    .current-price {
        font-size: 23px;
    }
    
    .old-price {
        font-size: 20px;
    }
    
    .rating-text, .stars i {
        font-size: 22px;
    }
    
    .add-to-cart-btn,
    .cart-controls {
        height: 62px;
        font-size: 24px;
    }
    
    .cart-controls {
        height: 80px;
        gap: 28px;
        padding: 0 32px;
    }
    
    .cart-quantity {
        font-size: 24px;
        min-width: 36px;
    }

    .favorite-btn, .gallery-nav {
        width: 50px;
        height: 54px;
    }

    .favorite-btn {
        top: 6px;
        left: 6px;
    }

    .favorite-btn i { font-size: 20px; }
    .gallery-nav i { font-size: 24px; }
}

/* ===== Loading States ===== */
.product-card.loading {
    pointer-events: none;
    opacity: 0.7;
}

.add-to-cart-btn.loading, .cart-controls.updating {
    position: relative;
    border-color: #97b7ad;
}

.add-to-cart-btn.loading *, .cart-controls.updating * { 
    opacity: 0;
    visibility: hidden;
}

.add-to-cart-btn.loading::after, .cart-controls.updating::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #007bff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    z-index: 100;
}

.cart-quantity.updating {
    color: #007bff;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes marquee-vertical {
    0%, 25% { transform: translateY(0); }
    30%, 50% { transform: translateY(-24px); }
    55%, 75% { transform: translateY(-48px); }
    80%, 100% { transform: translateY(-72px); }
}

/* ===== Accessibility & Print ===== */
.product-card:focus-within,
.gallery-nav:focus,
.favorite-btn:focus,
.add-to-cart-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ===== عداد الوقت المتبقي للخصم ===== */
.discount-countdown {
    /* position: absolute; */
    bottom: 15px;
    left: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px;
    z-index: 15;
}

.countdown-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
}

.countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 35px;
}

.countdown-days,
.countdown-hours,
.countdown-minutes,
.countdown-seconds {
    font-size: 18px;
    font-weight: 800;
    color: #ff4757;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.countdown-label-small {
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.countdown-separator {
    font-size: 16px;
    font-weight: 700;
    color: #ff4757;
    margin: 0 2px;
}

/* ===== Responsive للعداد ===== */
@media (max-width: 768px) {
    .discount-badge-overlay {
        top: 12px;
        right: 12px;
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .discount-countdown {
        bottom: 12px;
        left: 12px;
        right: 12px;
        padding: 10px;
    }
    
    .countdown-days,
    .countdown-hours,
    .countdown-minutes,
    .countdown-seconds {
        font-size: 16px;
    }
    
    .countdown-label-small {
        font-size: 9px;
    }
    
    .countdown-separator {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .discount-badge-overlay {
        top: 10px;
        right: 10px;
        padding: 5px 8px;
        font-size: 11px;
    }
    
    .discount-countdown {
        bottom: 10px;
        left: 10px;
        right: 10px;
        padding: 8px;
    }
    
    .countdown-days,
    .countdown-hours,
    .countdown-minutes,
    .countdown-seconds {
        font-size: 14px;
    }
    
    .countdown-label-small {
        font-size: 8px;
    }
    
    .countdown-separator {
        font-size: 12px;
    }
}

@media print {
    .product-card {
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    .gallery-nav,
    .favorite-btn,
    .add-to-cart-btn,
    .cart-controls,
    .product-features-marquee,
    .discount-badge-overlay,
    .discount-countdown {
        display: none;
    }
}


/* ============================================= */
/*  CSS لمؤشر التحميل على أزرار السلة         */
/* ============================================= */

.cart-btnn {
    position: relative;
    transition: background-color 0.2s ease, color 0.2s ease;
    color: #ffffff;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-btnn i {
    font-size: 18px;
}

/* حالة التحميل للزر */
.cart-btnn.loading {
    pointer-events: none;
    color: transparent !important;
}

/* إنشاء المؤشر الدائري باستخدام ::after */
.cart-btnn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3); /* تم تعديل اللون ليتناسب مع الخلفية */
    border-top-color: #ffffff; /* لون الجزء المتحرك من الدائرة */
    border-radius: 50%;
    animation: cart-btn-spinner 0.8s linear infinite;
}

/* حركة دوران المؤشر */
@keyframes cart-btn-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* =================================== */
/*  CSS لمؤشر التحميل الدائري داخل الزر (لزر الإضافة الرئيسي) */
/* =================================== */

/* تنسيق مؤشر التحميل نفسه */
.button-spinner {
  width: 25px;
  height: 25px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: absolute;
}

/* كلاس يضاف للزر عند التحميل */
.btn--loading {
  pointer-events: none;
  cursor: wait;
}

/* إخفاء الأيقونة الأصلية للزر عند التحميل */
.btn--loading > .fas {
  visibility: hidden;
}


/* ============================================= */
/*  إصلاح مشكلة توسيط رقم كمية السلة في الهيدر   */
/* ============================================= */

/* استهداف جميع عدادات السلة في الموقع */
.cart-count, 
.mobile-cart-countt, 
.mobile-cart-badge,
.cart-counter,      /* اسم شائع آخر */
.header-cart-count  /* اسم شائع آخر */
{
    /* 1. استخدام Flexbox للتوسيط المثالي */
    display: inline-flex;  /* يجعل العنصر مرنًا مع الحفاظ على سلوكه السطري */
    align-items: center;   /* يضمن التوسيط العمودي (الأهم) */
    justify-content: center; /* يضمن التوسيط الأفقي */

    /* 2. تحديد أبعاد وشكل ثابت */
    min-width: 22px;      /* حد أدنى للعرض لضمان الشكل الدائري */
    height: 22px;         /* ارتفاع ثابت */
    padding: 2px;         /* حشوة داخلية بسيطة لتجنب التصاق الرقم بالحواف */
    font-size: 12px;      /* حجم خط مناسب */
    font-weight: 700;     /* خط عريض للوضوح */
    line-height: 1;       /* يمنع أي ارتفاع إضافي للسطر قد يفسد التوسيط */
    
    /* 3. الشكل الدائري والمظهر */
    border-radius: 50%;   /* هذا هو السر للحصول على الشكل الدائري */
    background-color: #ff3742; /* لون الخلفية (يمكنك تغييره) */
    color: white;         /* لون الرقم */
    
    /* 4. تحديد الموضع (مهم جدًا) */
    position: absolute;   /* يجعله يطفو فوق أيقونة السلة */
    top: 0;               /* يلتصق بأعلى الحاوية الأب */
    right: 0;             /* يلتصق يمين الحاوية الأب */
    transform: translate(40%, -40%); /* يدفعه للخارج قليلاً لمظهر أفضل */
    
    /* 5. تحسينات إضافية */
    box-sizing: border-box; /* لضمان أن الحشوة لا تزيد من حجم العنصر */
    text-align: center;     /* احتياطي للتوسيط الأفقي */
    z-index: 10;            /* لضمان ظهوره فوق العناصر الأخرى */
}

/* يجب أن يكون العنصر الأب (الحاوي لأيقونة السلة) بهذا الشكل */
/* مثال: .header-cart-icon-wrapper */
.header-cart-icon-wrapper {
    position: relative; /* ضروري لعمل position: absolute للعنصر الابن */
    display: inline-block; /* ليتناسب حجمه مع المحتوى */
}