/* =============================================== */
/* == تحسينات التنسيق الشامل للموبايل == */
/* =============================================== */

/* =============================================== */
/* == تحسينات الهيدر == */
/* =============================================== */

@media (max-width: 992px) {
header.main-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9999 !important; /* رفع الترتيب لضمان بقاء الهيدر فوق كل شيء */
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 50%, #e8eaf6 100%) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}
}

.header-top {
    display: flex !important;
    flex-wrap: nowrap !important; /* الوضع الافتراضي سطر واحد */
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    gap: 8px !important;
}

@media (max-width: 992px) {
    .header-top {
        flex-wrap: wrap !important; /* الموبايل فقط يسمح بالالتفاف */
    }
    .header-search-container {
        order: 3 !important;
        flex: 1 0 100% !important;
    }
    .auth-nav {
        order: 2 !important;
    }
}

.header-bottom {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    flex-direction: row !important; 
    flex-wrap: nowrap !important; 
    justify-content: flex-start !important; 
    gap: 8px !important; /* تقليل الفجوة قليلاً بين زر الفئات وحاوية الأقسام */
    overflow: visible !important; /* السماح للعناصر الداخلية (الأسهم) بالتموضع المطلق */
    overflow-y: hidden !important; /* منع التمرير العمودي غير المرغوب فيه */
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 60px !important; 
    width: 100% !important; /* فرض العرض الكامل */
    background: #ffffff !important; 
    border-top: 1px solid #eee !important;
    border-bottom: 1px solid #ddd !important;
}

/* ضمان عدم انكماش حاوية الأقسام */
.sections-wrapper {
    flex: 1 1 auto !important; /* السماح بالتمدد مع الحفاظ على الهيكل */
    min-width: 0 !important; /* ضروري لعمل التمرير داخل flexbox */
    display: flex !important;
    align-items: center !important; /* محاذاة العناصر عمودياً */
    gap: 0 !important; /* إزالة الفجوة هنا، ستكون داخل sections-scroll-container */
    position: relative !important; /* لتمكين التموضع المطلق للأسهم */
    padding: 0 40px !important; /* مساحة للأسهم على الجانبين */
}

.sections-scroll-container {
    overflow-x: auto !important;
    display: flex !important;
    gap: 10px !important; /* مسافة بين الروابط */
    padding: 5px 0 !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    flex: 1 !important; /* السماح للحاوية بالتمدد */
    min-width: 0 !important; /* ضروري لعمل التمرير داخل flexbox */
    white-space: nowrap !important; /* منع الروابط من الالتفاف */
}

/* إعادة تموضع الأسهم لتكون فوق حاوية التمرير */
.sections-wrapper .scroll-arrow,
.sections-wrapper .subheader-scroll-arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10 !important; /* لضمان ظهورها فوق الروابط */
    display: none; /* إخفاء افتراضي للسماح لـ JavaScript بالتحكم بالظهور */
    width: 36px !important;
    height: 36px !important;
    background: linear-gradient(135deg, #3f51b5 0%, #e91e63 100%) !important;
}

.sections-wrapper .scroll-arrow-left {
    left: 5px !important;
}

.sections-wrapper .scroll-arrow-right {
    right: 5px !important;
}

/* =============================================== */
/* == تحسينات الشعار == */
/* =============================================== */

.logo-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
    order: 1 !important;
}

.logo-link {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    text-decoration: none !important;
    color: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
}

.logo-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.brand-badge-e {
    width: 34px !important;
    height: 34px !important;
    font-size: 18px !important;
    border-radius: 8px !important;
    font-family: 'Permanent Marker', cursive !important; /* تطبيق الخط الجديد */
}

.logo-text {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
}

.logo-main {
    font-size: 1.25rem !important;
    font-weight: bold !important;
    background: linear-gradient(135deg, #3f51b5, #e91e63) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.logo-sub {
    font-size: 0.7rem !important;
    color: #757575 !important;
    margin: 0 !important;
    padding: 0 !important;
}

@media (max-width: 480px) {
    .map-modal-container {
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }

    .map-modal-header { padding: 10px 12px !important; }
    .map-modal-header h3 { font-size: 1rem !important; }
    .map-modal-close { font-size: 1.5rem !important; }
    .map-modal-body { padding: 10px !important; }
    .map-search-box { height: 36px !important; }
    .map-search-box input { font-size: 0.85rem !important; }
    .map-view-wrapper { height: 220px !important; min-height: 220px !important; }

    .current-location-btn { width: 32px !important; height: 32px !important; bottom: 8px !important; right: 8px !important; }
    html[dir="rtl"] .current-location-btn { left: 8px !important; }
    .current-location-btn svg { width: 16px !important; height: 16px !important; }
    .confirm-btn { padding: 8px 12px !important; font-size: 0.9rem !important; }

    .form-container.delivery-info-page {
        margin-top: 220px !important;
    }
}

@media (max-width: 360px) {
    .form-container.delivery-info-page {
        margin-top: 200px !important;
    }
}

/* Ensure map modal is centered vertically on mobile */
.map-modal-overlay { align-items: center !important; }

/* تحسين زر X (الإغلاق) في Modal */
.map-modal-close,
#close-map-btn {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.95) !important;
    color: #333 !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
    z-index: 100000 !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important;
    cursor: pointer !important;
    font-size: 1.8rem !important;
    line-height: 1 !important;
}

.map-modal-close:hover,
#close-map-btn:hover {
    background: #e91e63 !important;
    color: #fff !important;
    transform: rotate(90deg) scale(1.05) !important;
}

html[dir="rtl"] .map-modal-close,
html[dir="rtl"] #close-map-btn {
    left: 12px !important;
    right: auto !important;
}


/* Leaflet inside modal: force stable height so map renders correctly */

.map-modal-body #map {
    height: 100% !important;
    min-height: 380px !important;
}

.map-modal-body .map-view-wrapper {
    height: 100% !important;
    min-height: 420px !important;
    display: block !important;
}

.map-modal-body .leaflet-container {
    height: 100% !important;
    width: 100% !important;
}


/* =============================================== */
/* == تحسينات شريط البحث == */
/* =============================================== */

/* =============================================== */
/* == تحسينات صفحة إنشاء الحساب وتسجيل الدخول == */
/* =============================================== */

.form-container {
    background: #ffffff !important;
    border-radius: 28px !important; /* حواف أكثر انسيابية */
    box-shadow: 0 20px 60px rgba(63, 81, 181, 0.1), 0 10px 30px rgba(0, 0, 0, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    position: relative !important;
    width: 92% !important;
    max-width: 480px !important; /* تقليل العرض الأقصى ليكون أكثر تناسقاً */
    margin-left: auto !important;
    margin-right: auto !important;
    margin-bottom: 50px !important;
    margin-top: 40px !important;
    padding: 30px 30px !important; /* تقليل الحشو الداخلي للبطاقة */
    box-sizing: border-box !important;
    overflow: visible !important;
    background: linear-gradient(165deg, #ffffff 0%, #fdfdff 100%) !important;
    transition: transform 0.4s ease, box-shadow 0.4s ease !important;
    animation: cardFadeIn 0.6s cubic-bezier(0.23, 1, 0.32, 1) !important;
}

/* ضمان عدم اختفاء النماذج تحت الهيدر في الصفحات المستقلة */
main.form-container:not(.container) {
    margin-top: 220px !important;
}
@media (max-width: 992px) {
    main.form-container:not(.container) { margin-top: 280px !important; }
}

/* هندسة العرض للحقول: تملأ المساحة المتاحة مع احترام حشو البطاقة */
.form-container form,
.modal-content form {
    max-width: 100% !important; 
    margin-left: auto !important;
    margin-right: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important; /* توحيد المسافات الرأسية بين المجموعات */
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 !important; /* إلغاء أي حشو داخلي للفورم لضمان الاعتماد على حشو الحاوية */
}

/* تطبيق الشريط العلوي الملون على البطاقة والنافذة المنبثقة */
.form-container::before,
.modal-content::before {
    content: '';
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 6px !important; /* شريط علوي أكثر بروزاً */
    background: linear-gradient(90deg, #3f51b5, #e91e63) !important;
    border-radius: 24px 24px 0 0 !important;
    z-index: 5 !important;
}

/* تحسين الطبقة الشفافة لضمان عدم قص النافذة المنبثقة */
.modal-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    justify-content: center !important;
    align-items: flex-start !important; /* البدء من الأعلى لضمان ظهور الرأس */
    overflow-y: auto !important; /* السماح بالتمرير إذا كانت النافذة طويلة */
    padding: 30px 0 !important; /* مسافة أمان علوية وسفلية */
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 100001 !important; /* Ensure it's on top */
}

/* تحسين مظهر النافذة المنبثقة لتطابق البطاقة */
.modal-content {
    border-radius: 24px !important;
    border: none !important;
    max-width: 480px !important; /* مطابقة العرض الجديد لضمان التناسق */
    width: 95% !important;
    margin-top: 20px !important; /* إزاحة بسيطة لعدم الالتصاق بالحافة العلوية */
    margin-bottom: 20px !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2) !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%) !important;
    position: relative !important;
}

/* تنسيق form-container داخل modal */
.modal-content .form-container {
    padding: 25px 30px !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

/* تطبيق نفس الحشو على النموذج داخل النافذة المنبثقة */
.modal-content form { 
    padding: 20px 0 !important; /* إلغاء الحشو الجانبي الكبير والاعتماد على العرض المحدد أعلاه */
}

.form-container h2 {
    font-size: 1.75rem !important; /* تصغير حجم العنوان */
    font-weight: 800 !important;
    margin-bottom: 25px !important;
    background: linear-gradient(135deg, #3f51b5 0%, #e91e63 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    letter-spacing: -1px !important;
    text-align: center !important;
}

/* تحسين أزرار تسجيل الدخول لتكون بارزة */
.login-button {
    background: linear-gradient(135deg, #3f51b5 0%, #303f9f 100%) !important;
    min-height: 52px !important;
    border-radius: 12px !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    box-shadow: 0 6px 20px rgba(63, 81, 181, 0.25) !important;
    transition: all 0.3s ease !important;
    padding: 14px 24px !important;
}

.login-button:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 25px rgba(63, 81, 181, 0.4) !important;
}

.login-button:active {
    transform: scale(0.98) !important;
}

/* Map Modal Responsiveness */
.map-modal-overlay {
    align-items: center !important; /* Ensure map modal is centered vertically on mobile */
}

@media (max-width: 768px) {
    .map-modal-container {
        width: 98% !important;
        max-width: none !important;
        margin-top: 20px !important;
        margin-bottom: 20px !important;
        border-radius: 10px !important;
    }

    .map-modal-header { padding: 12px 15px !important; }
    .map-modal-header h3 { font-size: 1.1rem !important; }
    .map-modal-close { font-size: 1.8rem !important; }
    .map-modal-body { padding: 15px !important; gap: 10px !important; }
    .map-search-box { height: 40px !important; }
    .map-search-box input { font-size: 0.9rem !important; }
    .map-search-box button { padding: 0 10px !important; }
    .map-view-wrapper { height: 250px !important; }
    .current-location-btn { width: 36px !important; height: 36px !important; bottom: 10px !important; right: 10px !important; }
    html[dir="rtl"] .current-location-btn { left: 10px !important; }
    .current-location-btn svg { width: 18px !important; height: 18px !important; }
    .confirm-btn { padding: 10px 15px !important; font-size: 1rem !important; }

    .form-container.delivery-info-page {
        margin-top: 250px !important; /* Adjust as needed based on header height */
    }
}

.back-arrow {
    position: absolute !important;
    top: 25px !important;
    left: 25px !important;
    font-size: 1.8rem !important;
    color: #3f51b5 !important;
    z-index: 10 !important;
    transition: transform 0.3s ease !important;
}

html[dir="rtl"] .back-arrow {
    left: auto !important;
    right: 25px !important;
    transform: scaleX(-1) !important;
}
html[dir="rtl"] .back-arrow:hover { transform: scaleX(-1) scale(1.1) !important; }

.form-group label {
    font-weight: 600 !important;
    color: #4a5568 !important;
    font-size: 0.95rem !important;
    margin-bottom: 6px !important; /* تقليل المسافة بين التسمية والحقل */
    display: block !important;
}

/* تنسيق خيارات تسجيل الدخول (تذكرني / نسيت) */
.login-options {
    display: flex !important;
    align-items: center !important;
    justify-content: space-around !important; /* توزيع أفضل داخل البطاقة */
    margin-bottom: 20px !important;
    margin-top: 0 !important;
    font-size: 0.95rem !important;
    background: rgba(248, 250, 252, 0.5) !important;
    padding: 12px !important;
    border-radius: 12px !important;
    width: 100% !important;
}

.remember-me {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.remember-me input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    accent-color: #3f51b5 !important;
    cursor: pointer !important;
}

.remember-me label {
    color: #555 !important;
    cursor: pointer !important;
    user-select: none !important;
    font-size: 0.95rem !important;
}

.forgot-password-link {
    color: #3f51b5 !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    font-size: 0.95rem !important;
    transition: color 0.3s ease !important;
}

.forgot-password-link:hover {
    color: #303f9f !important;
    text-decoration: underline !important;
}

html[dir="rtl"] .login-options { flex-direction: row !important; }

/* تحسينات للموبايل */
@media (max-width: 768px) {
    .form-container {
        padding: 40px 40px !important;
        margin-top: 15px !important;
        max-width: 420px !important;
        width: 95% !important;
    }
    
    .form-container h2 {
        font-size: 1.75rem !important;
        margin-bottom: 20px !important;
    }
    
    .input-with-icon,
    .password-wrapper.modern-password {
        height: 48px !important;
    }
    
    .input-with-icon .field-icon,
    .password-wrapper.modern-password .field-icon,
    .password-wrapper.modern-password .toggle-password {
        width: 42px !important;
        height: 48px !important;
    }
    
    .input-with-icon input,
    .password-wrapper.modern-password input {
        font-size: 0.95rem !important;
        height: 48px !important;
    }
    
    .login-button {
        min-height: 50px !important;
        font-size: 1.1rem !important;
        padding: 12px 20px !important;
    }
    
    .login-options {
        font-size: 0.9rem !important;
    }
    
    .form-links a {
        font-size: 0.95rem !important;
    }
}

@media (max-width: 480px) {
    .form-container {
        padding: 35px 25px !important; /* حشو متناسق للهواتف */
        width: 95% !important;
        max-width: 100% !important;
    }
    
    .form-container h2 {
        font-size: 1.6rem !important;
    }
    
    .input-with-icon,
    .password-wrapper.modern-password {
        height: 46px !important;
    }
    
    .input-with-icon .field-icon,
    .password-wrapper.modern-password .field-icon,
    .password-wrapper.modern-password .toggle-password {
        width: 40px !important;
        height: 46px !important;
    }
    
    .input-with-icon input,
    .password-wrapper.modern-password input {
        font-size: 0.9rem !important;
        height: 46px !important;
    }
    
    .login-button {
        min-height: 48px !important;
        font-size: 1.05rem !important;
    }
    
    .login-options {
        font-size: 0.85rem !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    .form-links a {
        font-size: 0.9rem !important;
    }
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
html[dir="rtl"] .form-container { animation: cardFadeInRTL 0.6s ease; }

/* تحسين اختيار تاريخ الميلاد */
.birthdate-selects {
    display: flex !important;
    gap: 10px !important;
    margin-top: 0 !important; /* Let form-group handle top margin */
}

.birthdate-selects select {
    flex: 1 !important;
    height: 48px !important; /* توحيد الارتفاع مع حقول الإدخال */
    border-radius: 10px !important;
    background-color: #f7fafc !important;
    border: 2px solid #e2e8f0 !important;
}

/* تحسين اختيار الجنس */
.gender-options {
    display: flex !important;
    gap: 10px !important; /* Consistent gap with birthdate selects */
    margin-top: 0 !important; /* Let form-group handle top margin */
}

.gender-item {
    flex: 1 !important;
    width: 100% !important;
    box-sizing: border-box !important; /* Ensure padding/border are included */
}

.gender-item label {
    width: 100% !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    height: 48px !important; /* توحيد الارتفاع مع بقية الحقول */
    border-radius: 12px !important;
    margin-bottom: 0 !important;
    cursor: pointer !important;
    background-color: #f8fafc !important;
    border: 2px solid #e2e8f0 !important;
    transition: all 0.3s ease !important;
}

/* بناء علامة الراديو (الدائرة) بشكل يدوي لتظهر بجانب النص */
.gender-item label::before {
    content: "" !important;
    width: 20px !important; /* Slightly larger radio button */
    height: 20px !important;
    border: 2px solid #cbd5e0 !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
}

/* شكل الدائرة عند تحديد الخيار */
.gender-item input[type="radio"]:checked + label::before {
    border-color: #3f51b5 !important;
    background-color: #3f51b5 !important;
    box-shadow: inset 0 0 0 4px #ffffff !important; /* Larger white dot */
}

.gender-item input[type="radio"]:checked + label {
    border-color: #3f51b5 !important;
    background-color: rgba(63, 81, 181, 0.05) !important;
    color: #3f51b5 !important;
}

.form-links {
    margin-top: 25px !important;
    padding-top: 20px !important;
    border-top: 1px solid #edf2f7 !important;
}

@media (max-width: 576px) {
    .form-container {
        padding: 30px 30px !important; 
        margin-bottom: 20px !important;
        border-radius: 15px !important;
    }

    .birthdate-selects {
        flex-wrap: wrap !important; /* Allow wrapping on very small screens */
        gap: 5px !important; /* تقليل الفجوة بين حقول التاريخ في الموبايل */
    }
    .birthdate-selects select {
        flex-basis: calc(33.33% - 5px) !important; /* Distribute evenly */
        min-width: 80px !important; /* Ensure minimum width for each select */
    }
    .birthdate-selects select {
        font-size: 0.85rem !important; /* تصغير الخط قليلاً ليناسب العرض */
        padding: 8px 5px !important;
    }

    .modal-content .form-container {
        padding: 25px 25px !important; /* زيادة الحشو في الموبايل لضمان ظهور كافة العناصر */
    }

    .form-container h2 {
        font-size: 1.5rem !important;
    }

    .gender-options {
        flex-direction: column !important;
    }

    .back-arrow {
        top: 15px !important;
        left: 15px !important;
        font-size: 1.5rem !important;
    }
    html[dir="rtl"] .back-arrow { right: 15px !important; }
}

/* تنسيق إضافي للهواتف الصغيرة جداً لضمان عدم تداخل العناصر */
@media (max-width: 360px) {
    .form-container {
        padding: 25px 20px !important; 
        width: 98% !important;
    }
}

/* =============================================== */
/* == تحسين مربع الموافقة على الشروط == */
/* =============================================== */

.form-group:has(#terms-checkbox) {
    display: block !important;
    margin: 20px 0 !important;
    width: 100% !important;
}

.form-container label[for="terms-checkbox"] {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important; /* السماح بالتفاف النص في الشاشات الصغيرة لمنع التداخل */
    align-items: flex-start !important;
    gap: 10px !important;
    margin: 0 !important;
    font-size: 0.95rem !important;
    line-height: 1.6 !important;
    color: #333 !important;
    cursor: pointer !important;
    text-align: start !important;
    width: 100% !important;
}

#terms-checkbox {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    accent-color: #3f51b5 !important;
    cursor: pointer !important;
    margin: 0 !important;
    margin-top: 3px !important;
    flex-shrink: 0 !important;
}

/* زر الإرسال الرئيسي */
.form-container button[type="submit"] {
    min-height: 44px !important; /* تصغير ارتفاع الزر */
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.25) !important;
    margin-top: 15px !important;
}

/* ضمان تمدد الحقول داخل مجموعات الفورم */
.form-group {
    width: 100% !important; /* الحقل يأخذ كامل العرض المتاح داخل البطاقة */
    flex-direction: column !important; /* التأكد من أن التسمية فوق الحقل لضمان عرض 100% */
    display: flex !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 18px !important; /* مسافة متناسقة بين الحقول */
}

/* ضمان تقليل العرض وتوسيط العناصر في صفحة معلومات التوصيل */
.delivery-info-page .form-group,
.delivery-info-page .btn-locate-trigger,
.delivery-info-page .login-button {
    max-width: 360px !important;
    margin-inline: auto !important;
}

/* تصغير حقول الإدخال النصية والأيقونات المصاحبة */
.input-with-icon, 
.password-wrapper.modern-password {
    min-height: 44px !important; /* توحيد الارتفاع ليكون أقل ضخامة */
    margin-bottom: 12px !important;
    border: 2px solid #e2e8f0 !important;
    background-color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    transition: all 0.3s ease !important;
    border-radius: 10px !important;
}

/* إزالة أي حدود داخلية أو فواصل بين الأيقونة ونص الإدخال لمنع ظهور خطوط غير مرغوب فيها */
.input-with-icon input, 
.password-wrapper.modern-password input,
.input-with-icon .field-icon,
.password-wrapper.modern-password .field-icon,
.password-wrapper.modern-password .toggle-password {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
}

.input-with-icon .field-icon, 
.password-wrapper.modern-password .field-icon,
.password-wrapper.modern-password .toggle-password {
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.input-with-icon input, 
.password-wrapper.modern-password input {
    font-size: 0.95rem !important;
    height: 44px !important;
    padding: 0 14px !important;
    width: 100% !important;
    box-sizing: border-box !important; /* Ensure padding is included in width */
}
.header-search-container {
    display: flex !important;
    align-items: stretch !important;
    order: 2 !important; /* المركز في الديسكتوب */
    height: 46px !important; /* توحيد الارتفاع مع الديسكتوب للتناسق */
    padding: 0 !important;
    border: 2px solid #e0e4e9; /* إزالة !important للسماح بتأثير hover */
    border-radius: 10px !important;
    overflow: hidden !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
    transition: all 0.3s ease !important;
}

.header-search-container:hover {
    border-color: #3f51b5 !important;
    box-shadow: 0 4px 12px rgba(63, 81, 181, 0.1) !important;
}

.header-search-container select,
.header-search-container input,
.header-search-container button {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    height: 100% !important;
}

.header-search-container select {
    width: 130px !important; /* زيادة العرض قليلاً لاستيعاب النصوص */
    padding: 0 10px !important;
    font-size: 12px !important;
    background: #f6f8fa !important;
    border-right: 1px solid #d0d7de !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
}

html[dir="rtl"] .header-search-container select {
    border-right: none !important;
    border-left: 1px solid #d0d7de !important;
    padding: 0 10px !important;
}

.header-search-container input {
    flex: 1 !important;
    padding: 0 10px !important;
    font-size: 13px !important;
    background: transparent !important;
}

.header-search-container button {
    width: 44px !important; /* تكبير منطقة الضغط للبحث */
    padding: 0 !important;
    background: transparent !important;
    color: #5f6368 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
}

@media (hover: hover) {
.header-search-container button:hover {
    background: #f8f9fa !important;
    color: #202124 !important;
}
}

/* =================================================================== */
/* == أنماط مدمجة لصفحة البروفايل داخل النافذة المنبثقة (Modal) == */
/* =================================================================== */

.modal-content .form-container.profile-modal-form {
    padding: 20px 25px 30px !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.profile-modal-form .form-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 15px !important;
    width: 100% !important;
}

.modal-content .form-container.profile-modal-form h2 {
    font-size: 1.5rem !important;
    margin-bottom: 20px !important;
    text-align: center !important;
    background: linear-gradient(135deg, #3f51b5 0%, #e91e63 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* تصغير الصورة الشخصية */
.modal-content .form-container.profile-modal-form #profile-image-preview {
    width: 110px !important;
    height: 110px !important;
    border: 4px solid #fff !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12) !important;
    border-radius: 50% !important;
    object-fit: cover !important;
}

.modal-content .form-container.profile-modal-form .profile-picture-section {
    margin-bottom: 25px !important;
    display: flex !important;
    justify-content: center !important;
    position: relative !important;
    width: 110px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* تقليل المسافات بين حقول النموذج */
.modal-content .form-container.profile-modal-form .form-group {
    margin-bottom: 18px !important;
    text-align: start !important;
}

.profile-modal-form .disabled-field {
    background-color: #f8f9fa !important;
    border-color: #e2e8f0 !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
}

.profile-modal-form .disabled-field input {
    color: #718096 !important;
    cursor: not-allowed !important;
    font-style: italic !important;
}

/* تصغير زر التحديث */
.modal-content .form-container.profile-modal-form button[type="submit"] {
    margin-top: 15px !important;
    background: linear-gradient(135deg, #3f51b5 0%, #303f9f 100%) !important;
    border-radius: 12px !important;
    min-height: 48px !important;
}

/* تحسين أزرار التعديل والحذف في البروفايل (Modal) */
.profile-modal-form .edit-icon {
    position: absolute !important;
    bottom: 5px !important;
    right: 5px !important;
    background-color: #3f51b5 !important;
    color: white !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    border: 3px solid white !important;
    transition: transform 0.3s ease !important;
    z-index: 10 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

html[dir="rtl"] .profile-modal-form .edit-icon {
    right: auto !important;
    left: 5px !important;
}

.profile-modal-form .delete-icon {
    position: absolute !important;
    bottom: 5px !important;
    left: 5px !important;
    background-color: #e91e63 !important;
    color: white !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    border: 3px solid white !important;
    transition: transform 0.3s ease !important;
    cursor: pointer !important;
    z-index: 10 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.modal-content .form-container.profile-modal-form .delete-icon:hover {
    transform: scale(1.1) !important;
    background-color: #c2185b !important;
}

html[dir="rtl"] .profile-modal-form .delete-icon {
    left: auto !important;
    right: 5px !important;
}

@media (max-width: 576px) {
    .profile-modal-form .form-row {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }
}

/* =============================================== */
/* == تحسينات قائمة المستخدم == */
/* =============================================== */

.auth-nav {
    display: flex !important;
    align-items: center !important;
    order: 3 !important; /* اليسار في الديسكتوب */
    gap: 6px !important;
    flex-wrap: wrap !important;
    padding: 0 !important;
}

.cart-icon-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #333 !important;
    text-decoration: none !important;
    border-radius: 12px !important;
    background: #ffffff !important;
    border: 1.5px solid #eee !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    flex-shrink: 0 !important;
}

@media (hover: hover) {
.cart-icon-link:hover {
    background: #f0f2f5 !important;
    color: #3f51b5 !important;
}
}

.cart-icon-link svg {
    width: 22px !important;
    height: 22px !important;
    stroke-width: 1.8 !important;
}

.cart-item-count {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    background: linear-gradient(135deg, #ff4081 0%, #e91e63 100%) !important;
    color: white !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    font-size: 0.7rem !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px solid white !important;
    z-index: 1 !important;
}

.lang-switcher-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    background: linear-gradient(135deg, #3f51b5 0%, #e91e63 100%) !important;
    border-radius: 50% !important;
    text-decoration: none !important;
    color: white !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: 0 4px 10px rgba(63, 81, 181, 0.25) !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    flex-shrink: 0 !important;
}

@media (hover: hover) {
.lang-switcher-link:hover {
    background: #303f9f !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 10px rgba(63, 81, 181, 0.3) !important;
}
}

.btn-login, .btn-register {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 8px 10px !important;
    min-height: 38px !important;
    min-width: 38px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    border: none !important;
    cursor: pointer !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    transition: all 0.2s ease !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

.btn-login {
    background: #3f51b5 !important;
    color: white !important;
}

.btn-login:hover {
    background: #303f9f !important;
    transform: translateY(-1px) !important;
}

.btn-register {
    background: #4CAF50 !important;
    color: white !important;
}

.btn-register:hover {
    background: #45a049 !important;
    transform: translateY(-1px) !important;
}

/* =============================================== */
/* == تحسينات القائمة الجانبية == */
/* =============================================== */

.category-sidebar {
    position: fixed !important;
    top: 0 !important;
    width: 85vw !important;
    max-width: 300px !important;
    height: 100vh !important;
    z-index: 10001 !important; /* رفع الترتيب ليكون فوق الهيدر (9999) */
    padding: 15px !important;
    overflow-y: auto !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    box-shadow: 0 0 20px rgba(0,0,0,0.1) !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
}

.category-sidebar h3 {
    font-size: 1.1rem !important;
    color: #3f51b5 !important;
    margin: 15px 0 10px 0 !important;
    padding: 0 0 10px 0 !important;
    border-bottom: 1px solid #ddd !important;
}

.category-list {
    flex: 1 !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.category-sidebar ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.category-sidebar ul li a {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important; /* مسافة ثابتة وموحدة */
    padding: 10px 12px !important;
    border-radius: 8px !important;
    color: #333 !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    margin: 0 !important;
}

@media (hover: hover) {
.category-sidebar ul li a:hover {
    background: rgba(63, 81, 181, 0.1) !important;
    color: #3f51b5 !important;
    transform: translateX(5px) !important;
}
}

.category-icon {
    width: 32px !important; /* عرض ثابت للأيقونة في الموبايل */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

#overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0,0,0,0.5) !important;
    z-index: 10000 !important; /* خلف القائمة الجانبية مباشرة وفوق الهيدر */
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.3s ease !important;
    margin: 0 !important;
    padding: 0 !important;
}

#overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* =============================================== */
/* == تحسينات بطاقات المنتجات == */
/* =============================================== */

.products-grid {
    display: grid !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: stretch !important; /* لضمان تساوي ارتفاع البطاقات في الصف الواحد */
}

@media (max-width: 479px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* تغيير للموبايل الصغير لعرض منتجين */
        gap: 10px !important;
        padding: 0 8px !important;
    }
    /* للهواتف الصغيرة جداً (أقل من 340px) نعود لعمود واحد */
    @media (max-width: 340px) {
        .products-grid { grid-template-columns: 1fr !important; }
    }
}

@media (min-width: 480px) and (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
        padding: 0 10px !important;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px !important;
        padding: 0 15px !important;
    }
}

@media (min-width: 1025px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 25px !important;
        padding: 0 20px !important;
    }
}

.product-card {
    display: flex !important;
    flex-direction: column !important;
    background: white !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    transition: all 0.3s ease !important;
    border: 1px solid #eee !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    height: 100% !important; /* تجعل البطاقة تأخذ كامل ارتفاع الصف */
}

.product-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: 0 12px 24px rgba(63,81,181,0.12) !important;
}

.product-image-wrapper {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important; /* ضمان شكل مربع متناسق يمنع قص النقاط */
    overflow: hidden !important; /* حماية الحواف الدائرية للصورة */
    background: #f8f9fa !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

.product-image-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    padding: 8px !important;
}

.product-info h3 {
    font-size: 0.95rem !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    min-height: 2.4em !important;
    height: auto !important;
    overflow: hidden !important;
    text-align: start !important; /* المحاذاة حسب اتجاه اللغة */
    line-height: 1.2 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    color: #333 !important;
}

/* تم نقل كافة تنسيقات البطاقة إلى product-improvements.css لضمان التناسق بين الديسكتوب والموبايل */
@media (max-width: 480px) {
    .product-info h3 { font-size: 0.9rem !important; }
    .product-description-snippet { font-size: 0.8rem !important; }
    .price-current { font-size: 1.2rem !important; }
    .price-original { font-size: 0.85rem !important; }
    .discount-pill { font-size: 0.9rem !important; padding: 4px 10px !important; }
}

.product-card-stock {
    display: flex !important;
    gap: 6px !important;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
}

.stock-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 3px 6px !important;
    border-radius: 8px !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
}

.stock-badge.stock-available {
    background: rgba(76, 175, 80, 0.1) !important;
    color: #4CAF50 !important;
    border: 1px solid rgba(76, 175, 80, 0.2) !important;
}

.stock-badge.stock-sold {
    background: rgba(63, 81, 181, 0.1) !important;
    color: #3f51b5 !important;
    border: 1px solid rgba(63, 81, 181, 0.2) !important;
}

.product-actions {
    display: flex !important;
    flex-direction: row !important; /* إجبار الترتيب الأفقي */
    gap: 5px !important; /* تقليل المسافة لتناسب الشاشات الصغيرة */
    margin: 10px 0 0 0 !important;
    padding: 0 !important;
    align-items: stretch !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
}

.btn-view-details,
.btn-favorites,
.btn-add-to-cart-quick {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 38px !important;
    height: 38px !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.btn-view-details {
    background: #f0f2f5 !important;
    color: #3f51b5 !important;
    flex: 1 1 auto !important; /* يأخذ باقي المساحة */
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    padding: 0 10px !important;
    white-space: nowrap !important;
}

.btn-favorites {
    background: #fff0f3 !important; /* خلفية وردية فاتحة جداً لتمييز الزر */
    color: #e91e63 !important;
    flex: 0 0 38px !important; /* عرض ثابت ليظهر بشكل مربع */
    width: 38px !important;
    padding: 0 !important;
    border: 1px solid rgba(233, 30, 99, 0.1) !important;
    z-index: 99 !important; /* رفع الزر لأعلى طبقة ممكنة */
    position: relative !important;
    cursor: pointer !important;
    pointer-events: all !important; /* التأكد من استقبال النقرات بشكل صريح */
    overflow: hidden !important;
}

.product-actions {
    position: relative !important;
    z-index: 20 !important; /* ضمان ظهور الأزرار فوق خلفية البطاقة */
}

.btn-favorites:hover {
    background: #e91e63 !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 5px 15px rgba(233, 30, 99, 0.3) !important;
}

.btn-add-to-cart-quick {
    background: #e8f5e9 !important;
    color: #4CAF50 !important;
    flex: 0 0 38px !important; /* عرض ثابت ليظهر بشكل مربع */
    width: 38px !important;
    padding: 0 !important;
}

.btn-add-to-cart-quick:hover {
    background: #4CAF50 !important;
    color: white !important;
}

.btn-view-details svg,
.btn-favorites svg,
.btn-add-to-cart-quick svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
    transition: all 0.3s ease !important;
}

/* ضمان ظهور شكل القلب بوضوح */
.btn-favorites svg, 
.btn-add-to-wishlist svg, 
.btn-wishlist svg, 
.btn-add-to-favorites svg {
    fill: transparent !important; /* القلب مفرغ افتراضياً لتمييز الحالة */
    stroke: #e91e63 !important; /* إطار القلب باللون الأحمر */
    stroke-width: 2px !important;
    display: block !important;
    transition: fill 0.3s ease, transform 0.3s ease !important;
}

/* الحالة النشطة للقلب (عند الإضافة للمفضلة) */
.btn-favorites.active svg, 
.btn-favorites.in-favorites svg,
.btn-add-to-wishlist.active svg, 
.btn-add-to-wishlist.in-wishlist svg,
.btn-wishlist.active svg, 
.btn-wishlist.in-wishlist svg,
.btn-add-to-favorites.active svg,
.btn-add-to-favorites.in-favorites svg {
    fill: #e91e63 !important;
    transform: scale(1.2) !important;
}

/* تغيير لون القلب إلى الأبيض عند تمرير الماوس */
.btn-favorites:hover svg,
.btn-add-to-wishlist:hover svg,
.btn-wishlist:hover svg,
.btn-add-to-favorites:hover svg {
    fill: #ffffff !important;
    stroke: #ffffff !important;
}

/* =============================================== */
/* == تحسينات الفوتر == */
/* =============================================== */

footer {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 50px 20px 20px !important;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important;
    color: #e0e0e0 !important;
    margin-top: 60px !important;
    border-top: 4px solid #3f51b5 !important;
}

.footer-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 30px !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
}

@media (max-width: 991px) {
    .footer-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 576px) {
    .footer-grid { 
        grid-template-columns: 1fr !important; 
        text-align: center !important;
    }
    .social-icons { justify-content: center !important; }
}

.footer-section h4 {
    color: #ffffff !important;
    font-size: 1.1rem !important;
    margin-bottom: 20px !important;
    position: relative !important;
    padding-bottom: 10px !important;
    font-weight: 700 !important;
}

.footer-section h4::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background: #e91e63;
}

html[dir="rtl"] .footer-section h4::after {
    left: auto;
    right: 0;
}

.social-icons {
    display: flex !important;
    gap: 10px !important;
    margin: 20px 0 !important;
    padding: 0 !important;
}

.social-icons a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    overflow: hidden !important; /* لمنع أي بروز للأيقونات */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    text-decoration: none !important;
}

.social-icons a img, 
.social-icons a svg { 
    width: 20px !important; /* حجم متناسق داخل الدائرة (40px) */
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    display: block !important;
    transition: all 0.3s ease !important;
    pointer-events: none !important;
    object-fit: contain !important;
    background: transparent !important;
    background-color: transparent !important; /* ضمان عدم وجود خلفية بيضاء موروثة */
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important; /* إلغاء أي انحناء موروث قد يشوه الصورة */
    filter: none !important; /* إظهار الألوان الأصلية (Facebook Blue, WhatsApp Green, etc.) */
}

.social-icons a svg {
    fill: currentColor !important; /* السماح للألوان الأصلية للـ SVG بالظهور */
}

.social-icons a:hover {
    background: rgba(255, 255, 255, 0.2) !important; /* تفتيح الدائرة عند التمرير بدلاً من تغيير لونها بالكامل */
    transform: translateY(-5px) !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}
 
.footer-bottom {
    margin-top: 40px !important;
    padding-top: 20px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    text-align: center !important;
}

.footer-bottom p {
    font-size: 0.85rem !important;
    color: #999 !important;
    margin: 0 !important;
}

/* =============================================== */
/* == تحسينات المحتوى الرئيسي == */
/* =============================================== */

main.container {
    width: 100% !important;
    box-sizing: border-box !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 0 !important;
    margin-top: 0 !important; /* Handled by body padding-top in sticky-header.css */
    display: flow-root !important; /* منع Margin Collapsing لضمان احتساب مسافة البطاقة بشكل مستقل */
}

.section-title {
    text-align: start !important; /* محاذاة تلقائية: يمين للعربي ويسار للإنجليزي */
    margin: 20px 0 15px 0 !important;
    padding: 0 15px !important;
    font-size: 1.1rem !important;
    background: linear-gradient(135deg, #3f51b5 0%, #e91e63 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    font-weight: 700 !important;
    position: relative !important;
}

/* =============================================== */
/* == تحسينات الإعلانات == */
/* =============================================== */

.announcements-section {
    width: 100% !important;
    margin: 0 auto 2.5rem auto !important;
    padding: 0 15px !important;
    box-sizing: border-box !important;
    display: flex !important;
    justify-content: center !important;
    max-width: 1200px !important; /* تقييد العرض لضمان التمركز في الشاشات الكبيرة */
}

.main-page-carousel {
    width: 100% !important;
    aspect-ratio: 16/9 !important; /* نسبة ذهبية للهواتف لضمان وضوح المحتوى */
    max-height: 220px !important;
    min-height: 120px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* =============================================== */
/* == تحسين أزرار التنقل (Carousel Arrows) == */
/* =============================================== */

.main-page-carousel .carousel-control {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 48px !important;
    height: 48px !important;
    background-color: rgba(255, 255, 255, 0.9) !important; /* خلفية بيضاء زجاجية واضحة */
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    color: #444 !important; /* لون السهم الافتراضي غامق وواضح */
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    opacity: 1 !important; /* ضمان الظهور الكامل */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 20 !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 24px !important;
}

/* أيقونة السهم "السابق" (SVG مدمج لضمان الظهور) */
.main-page-carousel .carousel-control.prev {
    left: 15px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233f51b5' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

/* أيقونة السهم "التالي" (SVG مدمج لضمان الظهور) */
.main-page-carousel .carousel-control.next {
    right: 15px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%233f51b5' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

/* دعم اتجاه الأسهم في وضع اللغة العربية RTL */
[dir="rtl"] .main-page-carousel .carousel-control.prev { left: auto !important; right: 15px !important; transform: translateY(-50%) rotate(180deg) !important; }
[dir="rtl"] .main-page-carousel .carousel-control.next { right: auto !important; left: 15px !important; transform: translateY(-50%) rotate(180deg) !important; }

.main-page-carousel .carousel-control:hover {
    background-color: #ffffff !important; /* يصبح أبيض ناصع عند التمرير */
    color: #3f51b5 !important; /* السهم نفسه فقط يصبح أزرق */
    opacity: 1 !important;
    transform: translateY(-50%) scale(1.1) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
    border-color: rgba(63, 81, 181, 0.2) !important;
}

/* الحفاظ على تأثير التمرير في وضع RTL */
[dir="rtl"] .main-page-carousel .carousel-control:hover { 
    transform: translateY(-50%) rotate(180deg) scale(1.1) !important; 
}

.main-page-carousel .carousel-control svg {
    display: none !important; /* إخفاء أي SVG داخلي قديم لضمان استخدام الأيقونة الجديدة الموحدة */
}

/* =============================================== */
/* == التنسيق الموحد للنقاط - شكل حبة الدواء == */
/* =============================================== */

/* =============================================== */
/* == الحل النهائي والجذري للنقاط (Pill Shape) == */
/* =============================================== */

/* 1. الحاوية: فرض التصميم الموحد ومنع الالتفاف */
.main-page-carousel .carousel-dots, 
.announcement-carousel .carousel-dots, 
.product-carousel .carousel-dots,
.carousel-dots {
    position: absolute !important;
    bottom: 15px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 6px 14px !important;
    background: rgba(0, 0, 0, 0.3) !important; /* خلفية شبه شفافة أنيقة */
    border-radius: 20px !important; 
    z-index: 999 !important; /* رفع الطبقة لأقصى حد لضمان الظهور */
    width: auto !important;
    min-width: 40px !important;
    min-height: 18px !important; /* زيادة طفيفة لراحة العين */
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    pointer-events: auto !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}

/* 2. النقطة العادية: تحسين الأبعاد لضمان التفاعل */
.carousel-dots .dot,
.carousel-dots button.dot,
.product-carousel .carousel-dots .dot {
    display: block !important;
    visibility: visible !important;
    width: 8px !important;
    height: 8px !important;
    min-width: 8px !important;
    min-height: 8px !important; 
    max-width: 8px !important;
    max-height: 8px !important;
    padding: 0 !important; /* إزالة الحشو الذي يسبب تضخم الحجم */
    background: rgba(255, 255, 255, 0.45) !important;
    border-radius: 50% !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    cursor: pointer !important; /* جعلها قابلة للنقر */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}

/* 3. النقطة النشطة: فرض شكل حبة الدواء بقوة الأبعاد */
.carousel-dots .dot.active,
.carousel-dots button.dot.active,
.product-carousel .carousel-dots .dot.active {
    display: inline-block !important;
    visibility: visible !important;
    width: 24px !important; /* الطول المطلوب لشكل حبة الدواء */
    height: 8px !important;
    min-width: 24px !important;
    min-height: 8px !important;
    border-radius: 20px !important; /* انحناء كامل */
    background: #3f51b5 !important; /* لون الهوية البصرية Indigo */
    transform: none !important; /* منع أي تكبير يشوه الشكل */
    box-shadow: 0 0 10px rgba(63, 81, 181, 0.6) !important;
    border: none !important;
    opacity: 1 !important;
}

/* =============================================== */
/* == تحسينات الأجهزة المتوسطة والكبيرة == */
/* =============================================== */

@media (min-width: 600px) and (max-width: 991px) { /* Tablets */
    .main-page-carousel {
        aspect-ratio: 16/6 !important;
        max-height: 280px !important;
        border-radius: 15px !important;
    }
}

@media (min-width: 992px) { /* Desktop */
    .main-page-carousel {
        aspect-ratio: 16/5 !important;
        max-height: 350px !important;
        border-radius: 20px !important;
    }
}

/* =============================================== */
/* == تحسينات الفئات والعلامات التجارية == */
/* =============================================== */

.shop-by-category-banner,
.shop-by-brand-section {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.category-items-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 12px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* تحسين شريط الماركات ليصبح في صف واحد قابل للتمرير */
.shop-by-brand-banner {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important; /* إخفاء شريط التمرير في Firefox */
    -ms-overflow-style: none !important; /* إخفاء شريط التمرير في IE */
    display: block !important;
    width: 100% !important;
    -webkit-overflow-scrolling: touch !important; /* تمرير سلس جداً على iOS */
}

.shop-by-brand-banner::-webkit-scrollbar {
    display: none !important; /* إخفاء شريط التمرير في Chrome/Safari */
}

.brand-items-wrapper {
    display: flex !important;
    flex-wrap: nowrap !important; /* إجبار العناصر على البقاء في صف واحد */
    justify-content: flex-start !important; /* البدء من اليمين/اليسار للسماح بالتمرير */
    gap: 20px !important; /* مسافة متناسقة بين الشعارات */
    padding: 15px !important;
    width: max-content !important; /* السماح للحاوية بالتمدد حسب محتواها */
}

.category-item,
.brand-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    padding: 8px !important;
    margin: 0 !important;
}

.category-item:hover,
.brand-item:hover {
    transform: translateY(-4px) !important;
}

.category-item img,
.brand-item img {
    width: 80px !important;
    height: 80px !important;
    object-fit: contain !important;
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
}

@media (max-width: 479px) {
    .category-item img,
    .brand-item img {
        width: 60px !important;
        height: 60px !important;
    }
}

/* إضافة قاعدة لضمان ظهور عناصر الفئات في قسم "تسوق حسب الفئة" */
.shop-by-category-banner .category-item {
    display: flex !important;    /* التأكد من أنها مرئية كـ flex item */
    visibility: visible !important; /* التأكد من أنها مرئية */
    opacity: 1 !important;       /* التأكد من أنها غير شفافة */
}

.category-item span,
.brand-name {
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    color: #555 !important;
    text-align: center !important;
    transition: color 0.3s ease !important;
}

.category-item:hover span,
.brand-item:hover .brand-name {
    color: #3f51b5 !important;
}

/* =============================================== */
/* == تحسينات عامة == */
/* =============================================== */

* {
    box-sizing: border-box !important;
}

body {
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Tajawal', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* إخفاء شريط التمرير الافتراضي */
::-webkit-scrollbar {
    width: 6px !important;
    height: 6px !important;
}

::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
}

::-webkit-scrollbar-thumb {
    background: #888 !important;
    border-radius: 3px !important;
}

::-webkit-scrollbar-thumb:hover {
    background: #555 !important;
}
