


/* منع تمرير الصفحة الخلفية عند فتح المودال */
    body.modal-open {
      overflow: hidden;
    }
    
    /* --------------------- زر العودة --------------------- */
    #back_button {
      background: #f44336;
      color: #fff;
      border: none;
      padding: 10px 15px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 14px;
      margin-bottom: 15px;
    }
    #back_button:hover {
      background: #d32f2f;
    }
    
    /* --------------------- مودال احترافي --------------------- */
    .modal {
      display: none;
      position: fixed;
      z-index: 10000;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.8);
      animation: fadeIn 0.3s;
      overflow: hidden;
    }
    
    /* محتوى المودال على سطح المكتب */
    @media (min-width: 768px) {
      .modal-content {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80%;
        max-width: 500px;
        max-height: 85vh;
        background: #fff;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        animation: slideIn 0.3s;
        z-index: 10001;
      }
    }
    
    /* محتوى المودال على الجوال (شاشة كاملة) */
    @media (max-width: 767px) {
      .modal-content {
        position: relative;
        margin: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        background: #fff;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        animation: slideInMobile 0.3s;
      }
    }
    
    /* --------------------- رأس المودال --------------------- */
    .modal-header {
      position: sticky;
      top: 0;
      left: 0;
      width: 100%;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      padding: 15px 20px;
      display: flex;
      align-items: center;
      z-index: 101;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    .modal-back {
      background: rgba(255, 255, 255, 0.2);
      border: 2px solid rgba(255, 255, 255, 0.3);
      font-size: 16px;
      color: #fff;
      padding: 10px 20px;
      border-radius: 25px;
      cursor: pointer;
      transition: all 0.3s;
      backdrop-filter: blur(10px);
      font-weight: 600;
    }
    
    .modal-back:hover {
      background: rgba(255, 255, 255, 0.3);
      border-color: rgba(255, 255, 255, 0.5);
      transform: translateY(-2px);
    }
    
    /* --------------------- جسم المودال --------------------- */
    .modal-body {
      flex: 1;
      padding: 20px;
      overflow-y: auto;
      text-align: center;
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    }
    
    /* صورة المودال الرئيسية */
    #modalImage {
      width: 100%;
      max-height: 350px;
      object-fit: contain;
      margin-bottom: 20px;
      border-radius: 12px;
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
      transition: transform 0.3s ease;
    }
    
    #modalImage:hover {
      transform: scale(1.02);
    }
    
    /* عناوين ونصوص المودال */
    #modalTitle {
      font-size: 1.8rem;
      margin-bottom: 15px;
      font-weight: 700;
      color: #2c3e50;
      text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    #modalPrice {
      font-size: 1.4rem;
      color: #e74c3c;
      margin-bottom: 20px;
      font-weight: 700;
      background: linear-gradient(45deg, #ff6b6b, #ee5a24);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    
    #modalDescription, #modalShortDescription {
      font-size: 1rem;
      margin-bottom: 20px;
      line-height: 1.6;
      color: #34495e;
      background: rgba(255, 255, 255, 0.8);
      padding: 15px;
      border-radius: 8px;
      backdrop-filter: blur(5px);
    }
    
    /* تنسيق الفيديو في المودال */
    #modalDescription video, #modalShortDescription video {
      width: 100% !important;
      max-width: 400px !important;
      height: auto;
      border-radius: 8px;
      box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
      margin: 10px 0;
    }
    
    /* زر الإضافة أو الإجراء في المودال */
    #modalAddButton {
      display: block;
      margin: 30px auto 0;
      width: 100%;
      max-width: 300px;
      padding: 15px 20px;
      font-size: 1.2rem;
      font-weight: 700;
      background: linear-gradient(45deg, #28a745, #20c997);
      color: #fff;
      border: none;
      border-radius: 50px;
      cursor: pointer;
      transition: all 0.3s;
      box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
      text-transform: uppercase;
      letter-spacing: 1px;
    }
    
    #modalAddButton:hover {
      background: linear-gradient(45deg, #218838, #1ea085);
      transform: translateY(-3px);
      box-shadow: 0 8px 25px rgba(40, 167, 69, 0.6);
    }
    
    #modalAddButton:active {
      transform: translateY(-1px);
    }
    
    /* --------------------- تأثيرات --------------------- */
    @keyframes fadeIn {
      from { 
        opacity: 0; 
        backdrop-filter: blur(0px);
      }
      to { 
        opacity: 1; 
        backdrop-filter: blur(3px);
      }
    }
    
    @keyframes slideIn {
      from { 
        transform: translateY(-100px) scale(0.9); 
        opacity: 0; 
      }
      to { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
      }
    }
    
    @keyframes slideInMobile {
      from { 
        transform: translateX(100%); 
        opacity: 0; 
      }
      to { 
        transform: translateX(0); 
        opacity: 1; 
      }
    }
        /* تخصيص التصميم في الموبايل: تغطية كاملة مع زر عودة بارز */
        @media (max-width: 767px) {
            #customer_info_container {
                width: 100%;
                right: -100%;
                height: 100vh;
                border-radius: 0;
            }
            #customer_info_container.active {
                right: 0;
            }
            #back_button {
                font-size: 16px;
                width: 100%;
                padding: 15px;
            }
        }
/* تنسيق حاوية الفئات */
.category-filter-container {
    display: flex;

    overflow-x: auto; /* تفعيل التمرير الأفقي */
    white-space: nowrap; /* منع النزول لسطر جديد */
    gap: 10px;
    padding: 5px;
    border-radius: 12px;
    scrollbar-width: none; /* إخفاء شريط التمرير على Firefox */
    position: sticky;
    top: 0; /* تثبيت الحاوية عند التمرير */
    z-index: 999;
    background-color: #fff;
    width: 100%;
    -ms-overflow-style: none;  /* إخفاء شريط التمرير على Internet Explorer وEdge */
}

/* إخفاء شريط التمرير في WebKit (Chrome, Safari) */
.category-filter-container::-webkit-scrollbar {
    display: none;
}

/* تنسيق بطاقة التصنيف */
.category-card {
    cursor: pointer;
    background-color: #f3f5f3;
    text-align: center;
    padding: 5px;
    width: 100px;
    border: 2px solid #cfcfcf;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: inline-block;
    min-width: 80px;
    flex: 0 0 auto;
}

.category-card img {
    max-width: 60px;
    max-height: 60px;
    display: block;
    margin: 0 auto;
    border-radius: 50%; /* لجعل الصورة دائرية */
    transition: transform 0.3s ease;
}

.category-card span {
    display: block;
    font-size: 10px;
    margin-top: 5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;

}

.category-card:hover {
    border-color: #ddd;
}

.category-card.selected {
    border-color: #4CAF50;
    background-color: #bffdbf;
}

.category-card.selected img {
    transform: scale(1.1);
}

/* تحسين العرض على الجوال */
@media screen and (max-width: 768px) {
    .category-card {
        width: calc(100% / 4 - 20px); /* عرض 4 بطاقات */
    }
}



/* --- Loading Indicators --- */
        .initial-loading, .modal-loading {
            display: inline-block; position: relative; width: 80px; height: 80px;
            margin: 20px auto; display: block;
        }
        .initial-loading div, .modal-loading div {
            position: absolute; border: 4px solid #007bff; opacity: 1;
            border-radius: 50%; animation: loading-animation 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
        }
        .initial-loading div:nth-child(2), .modal-loading div:nth-child(2) { animation-delay: -0.5s; }
        @keyframes loading-animation {
            0% { top: 36px; left: 36px; width: 0; height: 0; opacity: 0; }
            4.9% { top: 36px; left: 36px; width: 0; height: 0; opacity: 0; }
            5% { top: 36px; left: 36px; width: 0; height: 0; opacity: 1; }
            100% { top: 0px; left: 0px; width: 72px; height: 72px; opacity: 0; }
        }

        /* --- Main Products --- */
        .product-container {
            display: grid; 
            grid-template-columns: repeat(3, 1fr); 
            gap: 6px;
            margin-bottom: 20px;
        }
        .product-card {
            background: #fff; border: 1px solid #ddd; border-radius: 8px; overflow: hidden;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
            position: relative; display: flex; flex-direction: column;
        }
        .product-card:hover { transform: translateY(-5px); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); }
        .product-card img {
            width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover;
            cursor: pointer; border-bottom: 1px solid #eee;
        }
        .product-card-body {
            padding: 8px; text-align: center; flex-grow: 1;
            display: flex; flex-direction: column; justify-content: space-between;
        }
     
        
        .product-card h5 {
    font-size: 0.8rem; 
    margin: 0 0 6px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

        
        .product-card p { font-size: 0.9rem !important; font-weight: 800 !important; text-align: right; color: #555; margin: 0; margin-bottom: 10px; }
        .add_product_card {
            position: absolute; bottom: 10px; left: 5px; width: 36px; height: 36px;
            border-radius: 50%; background-color: #28a745; color: #fff; font-size: 20px;
            text-align: center; line-height: 36px; border: none; cursor: pointer;
            transition: background-color 0.3s ease, transform 0.3s ease; z-index: 10;
        }
        .add_product_card:hover { background-color: #218838; transform: scale(1.1); }
        .add_product_card.added {
            background-color: #5cb85c; color: white; cursor: default;
            pointer-events: none; transform: none;
        }
        
        /* تقليل حجم الصور وتحديد العرض الأقصى لبطاقة المنتج */
.product-card img.product-image {
    max-width: 300px;
    height: auto;
    display: block;
}

/* تنسيق مودال المنتج بحيث لا يتجاوز عرضه 700px */
.modal-content {
    max-width: 700px;
    margin: auto;
}

/* بعض التنسيقات الإضافية لتحسين الأداء والتخطيط */
.initial-loading, .modal-loading {
    display: flex;
    justify-content: center;
    align-items: center;
}
.notification {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    z-index: 10000;
}

        /* --- Added Products (Detailed) --- */
              #additional_product_display_wrapper {
    border: 0px solid #ccc;
    border-radius: 8px;
    padding: 0px;
    max-height: 235px; /* ارتفاع ثابت لتقليل الحيز */
    overflow-y: auto;  /* إضافة تمرير عمودي في حال وجود منتجات كثيرة */
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-top: 10px;
}

        /* Title for Added Products */
        .added-products-title {
          text-align: center;
    font-size: 1.2rem; 
    font-weight: 800; 
    margin-bottom: 12px;
    color: #2c3e50;
    padding-bottom: 6px;
    border-bottom: 2px solid #3498db; 
    display: inline-block;
    width: auto; 
    padding: 20px 10px 6px 10px;
    letter-spacing: 0.4px;
    border-radius: 6px; 
    background: rgba(52, 152, 219, 0.1); 
        }

        #additional_product_display {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
            background: linear-gradient(135deg, #f8f9fa, #e9ecef);
            border-radius: 8px; padding: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            margin-bottom: 0px; /* مساحة للعناصر الثابتة */
        }

        /* تحسينات للهواتف */
        @media (max-width: 768px) {
            #additional_product_display { 
                grid-template-columns: repeat(2, 1fr);
                gap: 5px; padding: 6px;
                margin-bottom: 0px;
            }
            
            .added-product {
                padding: 4px; font-size: 0.85rem;
            }
            
            .added-product img {
                max-width: 60px !important;
                max-height: 60px !important;
            }
        }

        @media (max-width: 480px) {
            #additional_product_display { 
                grid-template-columns: repeat(2, 1fr);
                gap: 4px; padding: 5px;
                margin-bottom: 0px;
            }
            
            .added-product {
                padding: 3px; font-size: 0.75rem;
                border-radius: 4px;
            }
            
            .added-product img {
                max-width: 50px !important;
                max-height: 50px !important;
            }
            
            .qty_controls button {
                padding: 2px 4px; font-size: 0.7rem;
                min-width: 20px; height: 20px;
            }
        }
		/* --- Added Product Container - overflow: hidden; --- */
        .added-product {
            border: 1px solid #ddd;
            padding: 5px;
            border-radius: 6px;
            background-color: #fff;
            position: relative;
            overflow: hidden; /* Add this line */
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        /* Image Styling - Consistent Aspect Ratio and Height */
        .added-product img {
               width: 60px !important;
            height: 60px !important;
            object-fit: cover;
            object-position: center;
            border-radius: 4px;
        }


       .product-name {

	font-size: 0.8rem;
    font-weight: 600;
    margin: 0;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    text-align: center;		
        }

        .product-price {
            font-size: 0.75rem;
            color: #555;
            margin-bottom: 0;
            text-align: center;
            font-weight: 500;
        }

        .quantity-counter {
            display: flex;
            align-items: center;
            gap: 5px;
            margin-top: auto;
        }

        .quantity-counter button {
            background-color: #007bff;
            color: #fff;
            border: none;
            padding: 4px 8px;
            cursor: pointer;
            font-size: 0.9rem;
            border-radius: 4px;
            transition: background-color 0.3s;
        }

        .quantity-counter button:hover {
            background-color: #0056b3;
        }

        .quantity-counter input {
            width: 40px;
            text-align: center;
            border: 1px solid #ddd;
            border-radius: 4px;
            padding: 4px;
            font-size: 0.9rem;
        }

        .remove_added_product {
            position: absolute;
            top: 3px;
            right: 3px;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: rgba(220, 53, 69, 0.8);
            color: #fff;
            font-size: 12px;
            text-align: center;
            line-height: 20px;
            border: none;
            cursor: pointer;
            transition: background-color 0.3s, transform 0.2s;
        }

        .remove_added_product:hover {
            background-color: rgba(220, 53, 69, 1);
            transform: scale(1.1);
        }

        /* --- Fixed Summary List, Fixed Buy Button, Load More, Spinner, Modal, Notification --- */
        /* (Styles remain the same - no changes needed) */
		#fixed_product_list {
            position: fixed; bottom: 70px; left: 0; right: 0;
            background: rgba(255, 255, 255, 0.95); 
            backdrop-filter: blur(10px);
            border-top: 0px solid #ddd; padding: 0px 10px;
            z-index: 9998; display: flex; flex-wrap: nowrap; gap: 10px;
            overflow-x: auto; max-height: 95px; 
            box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
            transition: bottom 0.3s ease;
        }

        /* إخفاء القائمة عندما لا توجد منتجات */
        #fixed_buy_container:not(.has-products) ~ #fixed_product_list {
            display: none;
        }

        /* تحسينات للهواتف */
        @media (max-width: 480px) {
             #fixed_product_list {
                bottom: 60px; 
            }
            
            .fixed-product {
                padding: 1px 3px; font-size: 0.7rem;
                border: 1px solid #e0e0e0;
            }
            
            .fixed-product .fixed_qty {
                font-size: 0.65rem; min-width: 12px;
                padding: 0px 2px;
            }
            
            .remove_fixed {
                width: 12px !important; height: 12px !important;
                font-size: 0.55rem;
            }
        }
        .fixed-product {
            flex: 0 0 auto; display: flex; align-items: center; gap: 5px;
            border: 1px solid #ddd; padding: 3px 5px; border-radius: 4px;
            background-color: #beffef; position: relative; white-space: nowrap;
        }
        .fixed-product img { width: 45px; height: 45px !important; object-fit: cover; border-radius: 4px; }
        .fixed-info { display: flex; flex-direction: column; }
        .fixed-name { font-size: 0.8rem; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; color: #333; }
        .fixed-price { font-size: 0.75rem; color: #555; display: block; margin-top: 2px; }
        .fixed-counter { display: inline-flex; align-items: center; gap: 3px; }
        .fixed-counter button { background-color: #007bff; color: #fff; border: none; padding: 2px 4px; cursor: pointer; border-radius: 4px; }
        .fixed-counter input { width: 30px; text-align: center; border: 1px solid #ddd; border-radius: 4px; font-size: 0.8rem; }
    
        
     .fixed-product .remove_fixed {
    position: absolute;
    top: 2px;
    right: 0px;
    width: 12px;
    height: 12px;
    border-radius: 10%;
    background-color: rgba(220, 53, 69, 0.8);
    color: #fff;
    font-size: 10px;
    text-align: center;
    line-height: 18px;
    border: none;
    padding: 3px 3px;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.3s;
}
        
        
        .fixed-product .remove_fixed:hover { background-color: rgba(220, 53, 69, 1); }

        /* --- Fixed Buy Button - محسن ومخفي افتراضياً --- */
        #fixed_buy_container {
            position: fixed; bottom: -10px; left: 0; right: 0;
            background: linear-gradient(45deg, #28a745, #20c997); 
            color: #fff; border-top: 2px solid #1e7e34;
            display: none; /* مخفي افتراضياً */
            justify-content: space-between; align-items: center;
            padding: 12px 20px; z-index: 9999; 
            box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.15);
            transition: all 0.3s ease;
        }

        /* إظهار الشريط عند وجود منتجات */
        #fixed_buy_container.has-products {
            display: flex;
            animation: slideUpFromBottom 0.4s ease-out;
        }

        /* تأثير الظهور من الأسفل */
        @keyframes slideUpFromBottom {
            from { transform: translateY(100%); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        #fixed_total { 
            font-size: 1.2rem; font-weight: 800; 
            display: flex; align-items: center; gap: 8px;
        }
        
        #fixed_total span { color: #fff; }
        
        #fixed_total span:last-child {
            font-size: 1.3rem; font-weight: 900;
            background: rgba(255,255,255,0.15);
            padding: 4px 12px; border-radius: 20px;
        }
        
        #fixed_buy_button {
            background: linear-gradient(45deg, #fff, #f8f9fa); 
            color: #28a745; border: 3px solid #fff;
            padding: 12px 30px; font-size: 1.1rem; font-weight: 700;
            border-radius: 25px; cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase; letter-spacing: 0.5px;
        }
        
        #fixed_buy_button:hover { 
            background: linear-gradient(45deg, #28a745, #20c997); 
            color: #fff; transform: translateY(-2px);
        }

        /* تحسينات للهواتف */
        @media (max-width: 480px) {
            #fixed_buy_container {
                  padding: 10px 10px; min-height: 50px;
                flex-direction: row; gap: 10px;
            }
            
            #fixed_total { font-size: 0.85rem; gap: 4px; }
            #fixed_total span:first-child { display: none; }
            #fixed_total span:last-child { 
                font-size: 0.95rem; padding: 2px 8px; 
            }
            
            #fixed_buy_button {
                flex: 1; max-width: 140px; padding: 8px 16px;
                font-size: 0.8rem; letter-spacing: 0.2px;
            }
        }

        /* --- Load More Button --- */
        #load_more_products {
            display: block; margin: 30px auto; padding: 15px 30px;
            font-size: 1.1rem; font-weight: 600; background-color: #007bff;
            color: #fff; border: none; border-radius: 8px; cursor: pointer;
            transition: background-color 0.3s, transform 0.2s;
        }
        #load_more_products:hover { background-color: #0056b3; transform: scale(1.05); }

        /* --- Loading Spinner --- */
        .loading-spinner {
            display: none; margin: 15px auto; border: 4px solid #f3f3f3;
            border-top: 4px solid #3498db; border-radius: 50%; width: 30px; height: 30px;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

      
        /* --- Notification --- */
        .notification {
            position: fixed; top: 20px; right: 20px; background: #28a745;
            color: #fff; padding: 12px 18px; border-radius: 8px;
            z-index: 10000; display: none; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        /* --- Responsive Design - محدث --- */
        @media (max-width: 768px) {
            .product-container { grid-template-columns: repeat(3, 1fr); }
            /* تم نقل تحسينات #additional_product_display أعلاه */
       
        }