/* أنماط الاقتراحات التلقائية */
.search-bar {
    position: relative;
    flex-grow: 1;
    max-width: 600px;
    margin: 0 20px;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

.search-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.search-suggestion:hover {
    background-color: #f8f9fa;
}

.search-suggestion img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    margin-left: 10px;
    border-radius: 3px;
}

.search-suggestion .product-info {
    flex-grow: 1;
}

.search-suggestion .product-name {
    font-weight: 500;
    margin-bottom: 3px;
}

.search-suggestion .product-price {
    color: #ff6b8b;
    font-size: 14px;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    font-weight: bold;
}

.close-suggestions {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    display: none;
}

/* أنماط خاصة للجوال */
@media (max-width: 768px) {
    .search-bar { 
        order: 2;
        width: 50%;
        max-width: 50%;
        margin: 10px 0;
        margin-right: 20px;
        position: relative;
    }

    /* التعديل الرئيسي: إبقاء الاقتراحات تحت شريط البحث مباشرة */
    .search-suggestions {
        position: absolute;
        /* البقاء كعنصر مطلق وليس ثابت */
        top: 100%;
        /* تحت شريط البحث مباشرة */
        left: 0;
        right: 0;
        max-height: 50vh;
        /* ارتفاع معقول */
        border-radius: 0 0 8px 8px;
        z-index: 1100;
        transform: none;
        /* إزالة التحويلات */
        transition: none;
        /* إزالة الانتقالات */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    /* إزالة النمط الذي يجعلها تملأ الصفحة */
    .search-suggestions.active {
        position: absolute;
        /* البقاء مطلقًا وليس ثابتًا */
        top: 100%;
        /* تحت شريط البحث مباشرة */
        bottom: auto;
        /* إزالة التثبيت في الأسفل */
        max-height: 50vh;
        /* ارتفاع محدود */
        border-radius: 0 0 8px 8px;
        transform: none;
    }

    .search-suggestion {
        padding: 12px 15px;
    }

    .search-suggestion img {
        width: 50px;
        height: 50px;
    }

    .close-suggestions {
        display: block;
    }

    /* محتوى الاقتراحات */
    .suggestions-content {
        max-height: 45vh;
        /* ارتفاع أقل بقليل من الحاوية */
        overflow-y: auto;
    }

    /* إزالة تأثير منع التمرير */
    body.search-suggestions-open {
        overflow: auto;
        position: static;
        width: auto;
        height: auto;
    }

    /* تحسين مظهر شريط الإغلاق */
    .suggestions-header {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 8px 15px;
    }

    /* تحسين مظهر الزر */
    .close-suggestions {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 50%;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* تحسين مظهر الاقتراحات */
    .search-suggestion {
        border-bottom: 1px solid #f0f0f0;
    }

    .search-suggestion:last-child {
        border-bottom: none;
    }

    /* تخصيص شريط التمرير */
    .suggestions-content::-webkit-scrollbar {
        width: 4px;
    }

    .suggestions-content::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
}

/* تحسينات إضافية للشاشات الصغيرة جدًا */
@media (max-width: 480px) {
    .search-suggestions {
        max-height: 55vh;
        /* ارتفاع أكبر قليلاً على الشاشات الصغيرة */
    }

    .suggestions-content {
        max-height: 50vh;
    }

    .search-suggestion {
        padding: 10px 12px;
    }

    .search-suggestion img {
        width: 45px;
        height: 45px;
    }
}