/* =========================================
       1. المتغيرات والأساسيات
    ========================================= */
    :root {
        --primary-color: #f27a1a; 
        --secondary-color: #1a365d;
        --text-color: #333;
        --bg-color: #f4f5f7;
        --border-color: #e6e6e6;
    }

    * {
        box-sizing: border-box;
        font-family: 'Cairo', sans-serif;
        margin: 0;
        padding: 0;
    }

    body, html {
        overflow-x: clip;
        width: 100%;
        background-color: var(--bg-color);
        color: var(--text-color);
    }

    /* =========================================
       2. الهيدر (Header) الأساسي
    ========================================= */
    .sticky-wrapper {
        position: sticky;
        top: 0;
        z-index: 1000;
        background-color: white;
        box-shadow: 0 4px 10px rgba(0,0,0,0.08);
        width: 100%; 
    }

    .main-header {
        background: white;
        border-bottom: 1px solid var(--border-color);
    }

 .header-container {
    max-width: 98%; 
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px !important;
    width: 100%; 
    gap: 15px;
}

    .brand-group {
        display: flex;
        align-items: center;
    }

    .logo {
        font-size: 24px;
        font-weight: 700;
        color: var(--secondary-color);
        letter-spacing: 1px;
    }
    .logo span { color: var(--primary-color); font-size: 14px; margin-right: 5px;}

    /* =========================================
       3. شريط البحث (Search Bar) - تم الإصلاح
    ========================================= */
/* =========================================
   شريط البحث (Search Bar) الأصلي
========================================= */
.search-bar {
    flex: 1;
    width: 100%; 
    margin: 0 20px;
    display: flex;
    position: relative; 
    align-items: center;
}

.search-bar input {
    width: 60%;
    padding: 1px 40px 10px 15px !important; /* مساحة 40 بكسل على اليمين للأيقونة */
    border: 2px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    transition: border 0.2s;
    box-sizing: border-box; 
}

.search-bar input:focus { 
    border-color: var(--primary-color); 
}
.search-bar button {
    position: absolute;
    right: 12px; /* تثبيت الأيقونة على اليمين */
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--primary-color);
    padding: 0;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

    /* =========================================
       4. أزرار الهيدر (حسابي وحول) - تم الإصلاح وتوحيد الحجم
    ========================================= */
    .header-actions, .header-links {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .header-action-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important; /* المسافة بين الأيقونة والنص */
        cursor: pointer;
        padding: 0 15px !important;
        border-radius: 6px !important;
        border: 1px solid var(--border-color) !important;
        color: var(--secondary-color) !important;
        font-weight: 700 !important;
        font-size: 14px !important;
        transition: all 0.3s ease !important;
        background: white !important;
        height: 38px !important; /* الارتفاع الموحد للكمبيوتر */
        white-space: nowrap !important; /* يمنع نزول النص لسطرين */
        text-decoration: none !important;
        box-sizing: border-box;
    }

    .header-action-btn i {
        font-size: 16px !important;
        color: var(--primary-color) !important;
        margin: 0 !important;
    }

    .header-action-btn:hover {
        border-color: var(--primary-color) !important;
        background-color: #fff1e6 !important;
    }

    /* قواعد الإخفاء حسب نوع الشاشة */
    .mobile-only-text { display: none !important; }
    .hide-on-mobile { display: inline !important; }

    /* =========================================
       5. التجاوب للموبايل (Mobile Responsive)
    ========================================= */
 /* التجاوب مع شاشات الموبايل */
   @media (max-width: 768px) {
    .header-container { flex-wrap: wrap !important; }
    .search-bar { order: 3 !important; flex: 0 0 100% !important; margin: 5px 0 0 0 !important; }
  } 
        
        .hide-on-mobile { display: none !important; }
        .desktop-only-text { display: none !important; }
        .mobile-only-text { display: inline !important; }

        .brand-group {
            order: 1 !important;
            flex: 1; /* يدفع الأزرار لليسار */
        }

        .header-actions {
            order: 2 !important;
            gap: 6px !important; /* تقريب الأزرار من بعضها في الموبايل */
        }

        .search-bar {
            order: 3 !important;
            flex: 0 0 100% !important; /* إجبار البحث على أخذ العرض بالكامل */
            margin: 5px 0 0 0 !important; /* مسافة علوية أنيقة */
        }

        /* توحيد الأزرار في الموبايل */
        .header-action-btn {
            padding: 0 10px !important;
            font-size: 12px !important;
            height: 36px !important; /* الارتفاع الموحد للموبايل */
            gap: 4px !important;
        }

        .header-action-btn i {
            font-size: 14px !important;
        }
    
    /* =========================================
       6. شريط التصنيفات (Categories)
    ========================================= */
    .categories-nav {
        display: flex !important;
        flex-wrap: nowrap !important; 
        overflow-x: auto !important;  
        -webkit-overflow-scrolling: touch !important; 
        white-space: nowrap !important; 
        padding: 5px 20px !important;
        width: 100% !important;
        background: white;
        border-bottom: 1px solid var(--border-color);
    }

    .cat-btn {
        background: none;
        border: none;
        padding: 8px 20px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        border-radius: 20px;
        color: #666;
        white-space: nowrap;
        margin-left: 10px;
    }

    .cat-btn.active, .cat-btn:hover {
        background-color: #fff1e6;
        color: var(--primary-color);
    }

    /* =========================================
       7. شبكة المنتجات (Products Grid)
    ========================================= */
    .shop-container {
        max-width: 98%; 
        margin: 30px auto;
        padding: 0 20px;
    }

    .products-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
        gap: 20px;
    }

    .product-card {
        background: white;
        border-radius: 8px;
        border: 1px solid var(--border-color);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        position: relative;
        transition: transform 0.2s, box-shadow 0.2s;
        width: 100%;
        height: 100%;
    }

    .product-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    }

    .image-container {
        width: 100%;
        height: 160px;
        background: #fdfdfd;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
    }

    .image-container img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .product-info {
        padding: 12px 10px 15px 10px; 
        display: flex;
        flex-direction: column;
        justify-content: flex-start; 
        align-items: center;
        text-align: center;
        flex-grow: 1; 
        position: relative;
        gap: 5px; 
    }

    .product-info::before {
        content: "";
        position: absolute;
        top: 5px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 2px;
        background-color: var(--primary-color);
        border-radius: 2px;
    }

    .product-title {
        font-size: 14px;
        font-weight: 600;
        color: #444;
        line-height: 1.3;
        margin-bottom: 5px; 
        display: block;
        width: 100%;
    }
    
    .product-brand {
        font-size: 10px;
        color: var(--primary-color);
        background-color: #fff1e6; 
        padding: 3px 10px;
        border-radius: 10px;
        font-weight: 700;
        margin-top: 5px;
        margin-bottom: 8px;
        display: inline-block;
        letter-spacing: 0.5px;
    }

    .desc-wrapper { display: flex; flex-direction: column; margin-bottom: 5px; width: 100%; }

    .product-description {
        font-size: 11px;
        color: #777;
        line-height: 1.5;
        display: -webkit-box;
        -webkit-line-clamp: 2 !important; 
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 2px;
        min-height: 33px; 
    }

    .read-more {
        color: var(--secondary-color);
        font-weight: 700;
        font-size: 11px;
        cursor: pointer;
        align-self: flex-start;
    }
    .read-more:hover { text-decoration: underline; }

    .price-row {
        color: #f27a1a !important;
        font-weight: 700;
        font-size: 16px;
        margin-top: auto !important; 
        margin-bottom: 10px;
    }

    .btn-add-to-cart {
        width: 100%;
        background-color: var(--secondary-color);
        color: white;
        border: none;
        padding: 10px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.2s;
    }
    .btn-add-to-cart:hover { background-color: var(--primary-color); }

    /* منتجات الموبايل */
    @media (max-width: 768px) {
        html, body { overflow-x: hidden !important; }
        .products-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; padding: 5px !important; }
        .product-card { padding: 0; }
        .image-container { height: 120px !important; padding: 5px !important; }
        .product-info { padding: 8px 5px 10px 5px !important; }
        .product-title { font-size: 11px !important; margin-bottom: 3px !important; }
        .product-description { font-size: 9px !important; margin-bottom: 3px !important; min-height: 27px; -webkit-line-clamp: 2 !important; }
        .price-row { font-size: 11px !important; margin-bottom: 3px !important; }
        .btn-add-to-cart { padding: 4px !important; font-size: 10px !important; }
        .product-info::before { width: 25px !important; }
    }


    /* =========================================
       8. النوافذ المنبثقة والإشعارات والسلة 
    ========================================= */
    .modal-overlay {
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(26, 54, 93, 0.6); 
        backdrop-filter: blur(3px); 
        display: flex; justify-content: center; align-items: center;
        z-index: 9999; opacity: 0; visibility: hidden; transition: all 0.3s ease;
    }
    .modal-overlay.active { opacity: 1; visibility: visible; }
    
    .modal-box {
        background: white; padding: 30px 25px; border-radius: 12px; width: 90%; max-width: 350px;
        text-align: center; box-shadow: 0 15px 30px rgba(0,0,0,0.2);
        transform: translateY(20px) scale(0.95); transition: all 0.3s ease;
    }
    .modal-overlay.active .modal-box { transform: translateY(0) scale(1); }
    .modal-icon i { font-size: 40px; color: var(--primary-color); margin-bottom: 15px; }
    .modal-box h3 { color: var(--secondary-color); margin-bottom: 10px; font-size: 20px; }
    .modal-box p { color: #555; font-size: 15px; line-height: 1.6; margin-bottom: 20px; }
    .modal-actions { display: flex; gap: 10px; }
    .btn-confirm, .btn-cancel { flex: 1; padding: 12px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: background 0.2s; }
    .btn-confirm { background: #25D366; color: white; }
    .btn-confirm:hover { background: #20ba5a; }
    .btn-cancel { background: #eee; color: #333; }
    .btn-cancel:hover { background: #ddd; }

    #toast-container {
        position: fixed; bottom: 40px; left: 110px; z-index: 10000;
        display: flex; flex-direction: column; gap: 10px;
    }
    .toast-message {
        background: white; color: #333; padding: 15px 20px; border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.15); border-right: 5px solid #25D366; 
        display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 14px;
        animation: slideIn 0.4s ease forwards;
    }
    @media (max-width: 768px) {
        #toast-container { bottom: 28px; left: 85px; max-width: calc(100vw - 100px); }
        .toast-message { padding: 8px 12px !important; font-size: 11px !important; gap: 6px !important; white-space: nowrap; width: max-content; }
    }
    .toast-message i { color: #25D366; font-size: 20px; }
    @keyframes slideIn { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
    @keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } }
    .toast-message.fade-out { animation: slideOut 0.4s ease forwards; }

    /* السلة العائمة */
    .floating-cart-btn {
        position: fixed; bottom: 30px; left: 30px; background-color: #f27a1a; color: white;
        width: 65px; height: 65px; border-radius: 50%; display: flex; justify-content: center; align-items: center;
        box-shadow: 0 4px 15px rgba(242, 122, 26, 0.4); z-index: 9999; text-decoration: none; font-size: 26px; transition: transform 0.3s ease, background-color 0.3s;
    }
    .floating-cart-btn:hover { transform: scale(1.1); background-color: #e06912; color: white; }
    .floating-cart-count {
        position: absolute; top: -5px; right: -5px; background-color: #1a365d; color: white;
        font-size: 14px; font-weight: bold; width: 26px; height: 26px; border-radius: 50%;
        display: flex; justify-content: center; align-items: center; border: 2px solid white; 
    }
    @media (max-width: 768px) {
        .floating-cart-btn { bottom: 20px; left: 20px; width: 55px; height: 55px; font-size: 22px; }
        .floating-cart-count { width: 22px; height: 22px; font-size: 12px; }
    }

    /* =========================================
       9. صفحات الحسابات (Auth) ونوافذ سويت أليرت
    ========================================= */
    .auth-page-container {
        display: flex; justify-content: center; align-items: center; min-height: calc(100vh - 80px); padding: 40px 20px;
    }
    .auth-box {
        background: white; width: 100%; max-width: 450px; padding: 40px; border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.08); border: 1px solid var(--border-color);
    }
    .auth-header { text-align: center; margin-bottom: 30px; }
    .auth-header h2 { color: var(--secondary-color); font-size: 26px; margin-bottom: 10px; }
    .auth-header p { color: #777; font-size: 14px; }
    .auth-form { display: flex; flex-direction: column; gap: 20px; }
    .input-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; color: #444; }
    .input-with-icon { position: relative; display: flex; align-items: center; }
    .input-with-icon i { position: absolute; right: 15px; color: #aaa; font-size: 16px; }
    .input-with-icon input { width: 100%; padding: 12px 40px 12px 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; transition: all 0.3s ease; background: #fafafa; }
    .input-with-icon input:focus { border-color: var(--primary-color); background: white; box-shadow: 0 0 0 3px rgba(242, 122, 26, 0.1); }
    .input-with-icon input:focus + i { color: var(--primary-color); }
    .btn-auth { background-color: var(--primary-color); color: white; border: none; padding: 15px; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; transition: background 0.3s ease; margin-top: 10px; }
    .btn-auth:hover { background-color: #e06912; }
    .auth-footer { text-align: center; margin-top: 25px; font-size: 14px; color: #666; }
    .auth-footer a { color: var(--secondary-color); font-weight: bold; text-decoration: none; }
    .auth-footer a:hover { color: var(--primary-color); text-decoration: underline; }

    /* SweetAlert */
    .swal2-popup.my-swal-popup { width: 300px !important; padding: 15px !important; border-radius: 15px !important; }
    .swal2-title.my-swal-title { font-size: 18px !important; color: #1a365d !important; margin-bottom: 5px !important; }
    .swal2-html-container { font-size: 14px !important; color: #555 !important; }
    .swal2-actions { margin-top: 15px !important; }
    .swal2-styled.swal2-confirm, .swal2-styled.swal2-cancel { padding: 8px 20px !important; font-size: 13px !important; border-radius: 8px !important; }
