/* استدعاء خط تجوال العربي الاحترافي */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: #f3f0f8; /* خلفية هادئة مائلة للبنفسجي الفاتح جداً */
    direction: rtl;
    color: #333;
    overflow-x: hidden;
}

/* ==================== توزيعة الـ CSS Grid الأساسية للأعمدة الثلاثة ==================== */
.main-layout {
    display: grid;
    /* السلة يسار (320px)، المحتوى وسط (1fr)، القائمة يمين (260px) */
    grid-template-columns: 260px 1fr 320px;
    gap: 20px;
    padding: 20px;
    min-height: 100vh;
}

/* ==================== 1. تنسيق العمود الأيمن (القائمة البنفسجية) ==================== */
.sidebar {
    background: linear-gradient(180deg, #7b39ca 0%, #511c91 100%); /* التدرج البنفسجي الظاهر في الصورة */
    border-radius: 24px;
    padding: 25px 15px;
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: all 0.4s ease;
}

.sidebar-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

.brand-title h2 {
    font-size: 20px;
    text-align: center;
    margin-bottom: 35px;
    font-weight: 700;
}

.side-nav ul {
    list-style: none;
}

.side-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 14px 20px;
    border-radius: 16px;
    margin-bottom: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.side-nav li a i {
    font-size: 18px;
}

/* حالة العنصر النشط أو عند التمرير بالماوس */
.side-nav li a:hover, .side-nav li a.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: bold;
}

/* كارت الحساب بالأسفل */
.user-card-footer {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px;
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #fff;
    object-fit: cover;
}

.user-info h4 {
    font-size: 15px;
    margin-bottom: 2px;
}

.user-info span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* ==================== 2. تنسيق العمود الأوسط (المحتوى) ==================== */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* شريط البحث العلوي */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 12px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

/* زر القائمة للموبايل (مخفي افتراضياً) */
.mobile-menu-btn {
    display: none;
    background: #7b39ca;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.search-box {
    position: relative;
    width: 50%;
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background-color: #f8fafc;
    outline: none;
    font-size: 14px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-icons {
    display: flex;
    gap: 12px;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
}

.mini-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* البنر الإعلاني العريض */
.hero-banner {
    width: 100%;
    height: 180px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.hero-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* تصميم الأقسام المصغرة */
.section-title {
    font-size: 18px;
    color: #475569;
    margin-bottom: 12px;
    font-weight: 700;
}

.categories-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.categories-list::-webkit-scrollbar {
    height: 5px;
}
.categories-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.cat-item {
    background: #fff;
    padding: 12px 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-width: 95px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.cat-icon {
    width: 45px;
    height: 45px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7b39ca;
    font-size: 18px;
}

.cat-item.active {
    background: #7b39ca;
    color: #fff;
}

.cat-item.active .cat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* شبكة المنتجات */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.product-card {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    transition: transform 0.3s;
}

.product-card:hover {
    transform: translateY(-5px);
}

.img-container {
    width: 100%;
    height: 160px;
    background: #f8fafc;
}

.img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prod-details {
    padding: 15px;
}

.prod-details h4 {
    font-size: 15px;
    margin-bottom: 8px;
    color: #1e293b;
}

.stars {
    font-size: 12px;
    margin-bottom: 12px;
}

.price-row {
    margin-top: 10px;
}

.price {
    display: block;
    font-weight: 700;
    color: #7b39ca;
    font-size: 16px;
    margin-bottom: 10px;
}

/* الـ Flexbox الأفقي للأزرار بنسب التحكم المحددة */
.card-buttons-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}

.add-to-cart-btn {
    flex: 0 0 75%; /* نسبة الـ 75% لزر السلة */
    background: #7b39ca;
    color: #fff;
    border: none;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: 0.3s;
}

.add-to-cart-btn:hover {
    background: #511c91;
}

.wishlist-btn {
    flex: 0 0 20%; /* نسبة الـ 20-25% لأيقونة القلب الجانبية */
    background: #f1f5f9;
    color: #ef4444;
    border: none;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
}

/* ==================== 3. تنسيق العمود الأيسر (السلة والفاتورة) ==================== */
.cart-panel {
    background: #fff;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    transition: all 0.4s ease;
}

.cart-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

.cart-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

/* زر إغلاق السلة للموبايل */
.close-cart-btn {
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
}

.cart-items-list {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
    max-height: 400px;
}

.empty-state {
    color: #94a3b8;
    font-size: 14px;
    text-align: center;
    padding: 40px 0;
}

.invoice-summary {
    border-top: 1px solid #f1f5f9;
    padding-top: 15px;
}

.invoice-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 15px;
}

.checkout-submit-btn {
    width: 100%;
    background: #7b39ca;
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
}

.checkout-submit-btn:hover {
    background: #511c91;
}

/* الزر الطائر العائم للسلة في الموبايل */
.floating-cart-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #7b39ca;
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(123, 57, 202, 0.4);
    cursor: pointer;
    z-index: 999;
    align-items: center;
    gap: 10px;
    direction: ltr;
}

.floating-cart-badge {
    background: #ef4444;
    color: white;
    font-size: 12px;
    padding: 2px 7px;
    border-radius: 50%;
}

/* طبقة الحماية الخلفية الشفافة للموبايل */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 990;
}

/* ==================== 📱 الميديا كوير لمتجاوب الموبايل والتابلت ==================== */

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 220px 1fr 280px;
        gap: 15px;
        padding: 15px;
    }
    .side-nav li a { padding: 10px 12px; font-size: 15px; }
}

@media (max-width: 992px) {
    /* تحويل النظام الكلي إلى عمود واحد لشاشات الموبايل والتابلت */
    .main-layout {
        grid-template-columns: 1fr;
        padding-bottom: 90px; /* لترك مساحة للزر الطائر السفلي */
    }

    /* إخفاء القائمة الجانبية وتحويلها لـ Drawer من اليمين */
    .sidebar {
        position: fixed;
        top: 0;
        right: -280px; /* مخفية في اليمين */
        width: 260px;
        height: 100vh;
        z-index: 1000;
        border-radius: 0;
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    }
    .sidebar.open {
        right: 0; /* تظهر عند إضافة كلاس open */
    }

    /* إخفاء سلة المشتريات وتحويلها لـ Drawer من اليسار */
    .cart-panel {
        position: fixed;
        top: 0;
        left: -340px; /* مخفية في اليسار */
        width: 320px;
        height: 100vh;
        z-index: 1000;
        border-radius: 0;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    .cart-panel.open {
        left: 0; /* تظهر عند إضافة كلاس open */
    }

    /* إظهار عناصر وأزرار الموبايل */
    .mobile-menu-btn, .close-cart-btn, .floating-cart-btn {
        display: flex;
    }

    .top-bar {
        flex-direction: row; /* ضبط شريط البحث في الموبايل */
    }
    .search-box {
        width: 70%;
    }
}

@media (max-width: 576px) {
    .search-box { width: 60%; }
    .hero-banner { height: 130px; }
    .products-grid { grid-template-columns: 1fr; } /* كارت واحد بعرض الشاشة في الموبايل الصغير */
    .top-icons { display: none; } /* إخفاء الايقونات الفرعية لزيادة المساحة للبحث */
}