/* ================= إعدادات عامة ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent; /* إزالة المربع الأزرق عند الضغط في الجوال */
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-bottom: 80px; /* ترك مساحة لشريط التنقل السفلي */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ================= الرأس (Header) ================= */
.app-header {
    background-color: var(--card-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.cart-icon {
    position: relative;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* تأثير النبض لعداد السلة */
.cart-badge.pop {
    animation: popAnimation 0.3s ease;
}

@keyframes popAnimation {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* ================= قسم الهيرو (Hero Section) ================= */
.hero-section {
    position: relative;
    width: 100%;
    height: 220px;
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.hero-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); /* تظليل داكن ليبرز النص */
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 0 20px;
}

.hero-logo {
    height: 70px;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.hero-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.hero-desc {
    font-size: 0.9rem;
    color: #f1f2f6;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    max-width: 400px;
    margin: 0 auto;
}


/* ================= شريط الأقسام (Categories) ================= */
.categories-slider {
    display: flex;
    overflow-x: auto;
    padding: 15px 20px;
    gap: 10px;
    scrollbar-width: none; /* إخفاء شريط التمرير للفايرفوكس */
}

.categories-slider::-webkit-scrollbar {
    display: none; /* إخفاء شريط التمرير لكروم وسفاري */
}

.category-btn {
    white-space: nowrap;
    padding: 8px 20px;
    border: none;
    background-color: var(--card-bg);
    color: var(--text-main);
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    transition: all 0.3s ease;
}

.category-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* ================= شبكة المنتجات (Products Grid) ================= */
.products-grid {
    display: grid;
    /* جعلها بطاقة واحدة في السطر على الجوال */
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 0 15px 20px 15px;
}

.product-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--primary-color); /* تحديد خفيف يفصل الكروت */
    height: 100%; /* إجبار الكروت في نفس الصف على أخذ نفس الطول */
}

.product-image {
    width: 100%;
    height: 250px; /* تقليل ارتفاع الصورة قليلاً لإعطاء مساحة للنص */
    background-size: cover;
    background-position: center;
}

/* ================= بادج الخصم النابض (Discount Badge) ================= */
.product-image-wrapper {
    position: relative;
    width: 100%;
    height: 180px; /* زيادة الارتفاع ليتناسب مع عرض البطاقة الكامل على الجوال */
}

.product-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.discount-badge {
    position: absolute;
    top: 10px;
    right: 10px; /* في العربية سيكون يمين، في الإنجليزية سنعكسه */
    background-color: var(--danger); /* أحمر صارخ */
    color: white;
    font-weight: bold;
    font-size: 0.85rem;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4);
    z-index: 2;
    animation: pulse-discount 1.5s infinite; /* حركة النبض */
    display: flex;
    align-items: center;
    gap: 4px;
}

[dir="ltr"] .discount-badge {
    right: auto;
    left: 10px;
}

/* حركة النبض السحرية */
@keyframes pulse-discount {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}


.product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* لجعل الزر والسعر دائماً في الأسفل */
}

.product-title {
    font-size: 0.95rem;
    margin-bottom: 5px;
    font-weight: 700;
    line-height: 1.3;
    /* إخفاء النص الزائد إذا كان طويلاً جداً (سطرين كحد أقصى) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
    flex-grow: 1; /* لدفع منطقة السعر للأسفل */
    /* إخفاء الوصف الزائد (سطرين كحد أقصى) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* ضمان البقاء في الأسفل */
    gap: 5px; /* مسافة أمان بين السعر والزر */
}

.product-price {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap; /* منع السعر من النزول لسطر جديد */
}

.product-price small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.add-to-cart-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap; /* منع كلمة إضافة من الانقسام */
}

.add-to-cart-btn:active {
    transform: scale(0.95); /* تأثير ضغطة خفيف */
}

/* ================= تحسينات الشاشات الكبيرة للبطاقات (Desktop/Tablet) ================= */
@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* كروت أكبر */
        gap: 25px; /* مسافة أكبر بين الكروت */
    }
    .product-image-wrapper {
        height: 220px; /* صورة أكبر بشكل طولي يتناسب مع الكارت */
    }
    .product-title {
        font-size: 1.2rem; /* تكبير اسم المنتج */
    }
    .product-price {
        font-size: 1.35rem; /* تكبير السعر */
    }
    .add-to-cart-btn {
        font-size: 1.05rem;
        padding: 10px 18px; /* تكبير زر الإضافة للسلة */
    }
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    transition: color 0.3s;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item.active {
    color: var(--primary-color);
}

/* ================= تصميم صفحة السلة ================= */
.back-btn {
    color: var(--text-main);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
}

.cart-items-list {
    padding: 15px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.item-details h4 {
    margin-bottom: 5px;
}

.item-price {
    color: var(--primary-color);
    font-weight: bold;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.remove-btn {
    color: #e74c3c;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.cart-summary {
    background: var(--card-bg);
    padding: 20px;
    margin: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
}

.delivery-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
    text-align: center;
}

/* ================= تصميم الخريطة ================= */
.map-section {
    padding: 15px;
    margin-bottom: 100px;
}

.section-title {
    margin-bottom: 5px;
}

.map-instruction {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.location-btn {
    width: 100%;
    padding: 10px;
    background: #ecf0f1;
    border: none;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: inherit;
    font-weight: bold;
    color: #2c3e50;
    cursor: pointer;
}

.map-container {
    height: 250px;
    width: 100%;
    border-radius: var(--border-radius);
    border: 2px solid #ecf0f1;
    z-index: 1; /* مهم لكي لا تغطي الخريطة على القوائم */
}

/* ================= زر الدفع ================= */
.checkout-section {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    padding: 15px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.08);
    z-index: 100;
}

.checkout-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
}

.checkout-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* تصميم أزرار الكمية في السلة */
.qty-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    background: var(--bg-color);
    padding: 5px;
    border-radius: 8px;
    width: fit-content;
}

.qty-btn {
    background: white;
    border: 1px solid #ddd;
    color: var(--text-main);
    width: 25px;
    height: 25px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qty-number {
    font-weight: bold;
    font-size: 1.1rem;
}

/* ================= نافذة الإضافات (Modal) ================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none; /* مخفية افتراضياً */
    align-items: flex-end; /* لدفع المحتوى للأسفل */
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    width: 100%;
    max-width: 500px;
    border-radius: 20px 20px 0 0; /* انحناء من الأعلى فقط */
    animation: slideUp 0.3s ease-out; /* حركة الانزلاق */
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
}

.close-modal-btn {
    background: var(--bg-color);
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    overflow-y: auto; /* السماح بالتمرير إذا كانت الإضافات كثيرة */
    flex-grow: 1;
}

.addon-title {
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--text-muted);
}

.addon-item {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.addon-info label {
    font-weight: 500;
    margin-right: 10px;
    cursor: pointer;
}

.addon-price {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 0.9rem;
}

.modal-footer {
    padding: 20px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-price-summary {
    font-weight: bold;
    font-size: 1.1rem;
}

#modal-total-price {
    color: var(--primary-color);
    font-size: 1.3rem;
}

.confirm-add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    font-weight: bold;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
}

/* تنسيقات مجموعات الإضافات المتقدمة */
.addon-group {
    background: var(--card-bg);
    margin-bottom: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.addon-group-header {
    background: var(--bg-color);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.addon-group-title {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-main);
}

.badge-required {
    background: #ffeaa7;
    color: #e15f41;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: bold;
}

.badge-optional {
    background: var(--bg-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
}

/* تنسيق أزرار الراديو والكميات */
.addon-option {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.addon-option:last-child { border-bottom: none; }

.addon-qty-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-color);
    padding: 3px;
    border-radius: 6px;
}

.addon-qty-btn {
    border: none; background: var(--card-bg); width: 22px; height: 22px;
    border-radius: 4px; cursor: pointer; color: var(--primary-color);
}

.addon-qty-num { font-weight: bold; font-size: 0.9rem; width: 15px; text-align: center; }

/* تحسينات لصفحة السلة في الوضع الداكن */
[data-theme="dark"] .cart-item,
[data-theme="dark"] .cart-summary,
[data-theme="dark"] .checkout-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .qty-btn {
    background: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .location-btn {
    background: var(--border-color);
    color: var(--text-main);
}

/* جعل الخريطة أغمق قليلاً لتناسب الوضع الداكن (خدعة بصرية) */
[data-theme="dark"] .map-container {
    border-color: var(--border-color);
    filter: brightness(0.8) contrast(1.2) invert(0.1); 
}
/* ================= الفوتر والسوشيال ميديا (Footer & Social Media) ================= */
.store-footer {
    padding: 30px 20px 100px 20px; /* 100px من الأسفل لكي لا يغطيه شريط التنقل */
    text-align: center;
    border-top: 1px solid var(--border-color);
    background-color: var(--card-bg);
    margin-top: 20px;
}

.footer-logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.footer-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.social-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    text-decoration: none;
    transition: transform 0.2s, opacity 0.2s;
}

.social-btn:hover {
    transform: translateY(-3px);
    opacity: 0.9;
}

/* ألوان التطبيقات الرسمية */
.social-whatsapp { background-color: #25D366; }
.social-instagram { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }
.social-twitter { background-color: #1DA1F2; } /* يمكن استبداله بأسود لشعار X الجديد */
.social-snapchat { background-color: #FFFC00; color: #333; } /* سناب شات أصفر والنص غامق */
.social-tiktok { background-color: #000000; }
.social-facebook { background-color: #1877F2; }

/* الوضع الداكن للفوتر */
[data-theme="dark"] .store-footer {
    border-color: var(--border-color);
    background-color: var(--bg-color); /* لجعل الفوتر يندمج مع الخلفية السوداء */
}
[data-theme="dark"] .social-snapchat {
    color: #000; /* الحفاظ على لون أيقونة السناب سوداء في الوضع الداكن */
}

/* ================= أزرار اختيار نوع الطلب ================= */
.order-type-container {
    background: var(--card-bg);
    margin: 15px;
    border-radius: var(--border-radius);
    padding: 5px;
    display: flex;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    border: 1px solid var(--border-color);
}

.order-type-btn {
    flex: 1;
    text-align: center;
    padding: 12px;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-muted);
    border-radius: 12px;
    transition: all 0.3s;
}

.order-type-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(255, 94, 20, 0.3);
}

.order-type-btn input {
    display: none; /* إخفاء زر الراديو الافتراضي */
}

/* ================= النوافذ المنبثقة التفاعلية (Custom Alerts) ================= */
.custom-alert-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
    z-index: 3000; display: flex; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s ease;
}

.custom-alert-box {
    background: var(--card-bg); width: 85%; max-width: 350px;
    border-radius: 24px; padding: 25px 20px; text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: scale(0.8); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-alert-overlay.show { opacity: 1; }
.custom-alert-overlay.show .custom-alert-box { transform: scale(1); }

.alert-icon { font-size: 3.5rem; margin-bottom: 15px; }
.alert-icon.warning { color: #f39c12; }
.alert-icon.success { color: #2ecc71; }
.alert-icon.error { color: #e74c3c; }

.alert-title { font-size: 1.3rem; font-weight: bold; color: var(--text-main); margin-bottom: 10px; }
.alert-message { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 25px; line-height: 1.5; }

.alert-buttons { display: flex; gap: 10px; justify-content: center; }
.alert-btn {
    flex: 1; padding: 12px; border: none; border-radius: 12px;
    font-weight: bold; font-size: 1rem; font-family: inherit; cursor: pointer;
}
.alert-btn-confirm { background: var(--primary-color); color: white; }
.alert-btn-cancel { background: var(--bg-color); color: var(--text-main); border: 1px solid var(--border-color); }

/* ================= شريط السلة العائم الذكي (Floating Cart Bar) ================= */
.floating-cart-bar {
    position: fixed;
    bottom: -100px; /* مخفي أسفل الشاشة افتراضياً */
    left: 0;
    width: 100%;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    z-index: 1000;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* حركة انزلاق مطاطية فخمة */
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

/* ================= شريط السلة العائم الذكي ================= */
.floating-cart-bar {
    position: fixed;
    bottom: -120px; /* مخفي أسفل الشاشة افتراضياً */
    left: 0;
    right: 0;
    width: 100%;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    z-index: 9999;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-sizing: border-box;
}

.floating-cart-bar.show {
    bottom: 0; /* يظهر بالكامل في الأسفل عند التفعيل */
}

.floating-cart-info {
    display: flex;
    flex-direction: column;
}

.floating-cart-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: bold;
}

.floating-cart-total {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-main);
}

.floating-checkout-btn {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 12px 25px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s;
}

.floating-checkout-btn:active {
    transform: scale(0.95);
}

[data-theme="dark"] .floating-cart-bar {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}
