/* ===== أنيميشن نافذة البحث ===== */

/* الـ overlay */
#searchOverlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#searchOverlay.active {
    opacity: 1;
}

/* محتوى النافذة */
#searchOverlay .modal-content {
    transform: scale(0.7) translateY(-50px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

#searchOverlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* تأثير على حقل البحث */
#searchInput {
    transition: all 0.3s ease;
}

#searchInput:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* أنيميشن ظهور النتائج */
#searchResults .product-card {
    animation: slideInUp 0.4s ease forwards;
    opacity: 0;
}

#searchResults .product-card:nth-child(1) {
    animation-delay: 0.1s;
}

#searchResults .product-card:nth-child(2) {
    animation-delay: 0.15s;
}

#searchResults .product-card:nth-child(3) {
    animation-delay: 0.2s;
}

#searchResults .product-card:nth-child(4) {
    animation-delay: 0.25s;
}

#searchResults .product-card:nth-child(5) {
    animation-delay: 0.3s;
}

#searchResults .product-card:nth-child(6) {
    animation-delay: 0.35s;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* تأثير hover على بطاقات النتائج */
#searchResults .product-card {
    transition: all 0.3s ease;
    cursor: pointer;
}

#searchResults .product-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

/* أنيميشن زر الإغلاق */
#searchOverlay .btn-secondary {
    transition: all 0.3s ease;
}

#searchOverlay .btn-secondary:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#searchOverlay .btn-secondary:active {
    transform: scale(0.95);
}

/* تحسينات للهواتف */
@media (max-width: 768px) {
    #searchOverlay .modal-content {
        max-width: 95%;
        width: 95%;
        padding: 15px;
        max-height: 80vh;
        border-radius: 15px;
    }

    #searchOverlay h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    #searchInput {
        font-size: 16px;
        /* منع التكبير التلقائي في iOS */
        padding: 10px 12px;
        min-height: 44px;
    }

    #searchResults {
        max-height: 50vh;
        overflow-y: auto;
    }

    #searchResults .products-grid {
        grid-template-columns: repeat(2, 1fr);
        /* منتجان في صف واحد */
        gap: 10px;
        max-height: 45vh !important;
    }

    #searchResults .product-card {
        padding: 10px;
        animation-duration: 0.3s;
    }

    #searchResults .product-image {
        height: 100px;
    }

    #searchResults .product-title {
        font-size: 0.9rem;
    }

    #searchResults .product-price {
        font-size: 0.85rem;
    }

    #searchOverlay .btn {
        min-height: 44px;
        font-size: 0.9rem;
        padding: 10px 16px;
    }
}

/* للشاشات الصغيرة جداً */
@media (max-width: 480px) {
    #searchOverlay .modal-content {
        max-width: 98%;
        width: 98%;
        padding: 12px;
        max-height: 85vh;
        border-radius: 12px;
    }

    #searchOverlay h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    #searchInput {
        font-size: 16px;
        padding: 8px 10px;
    }

    #searchResults {
        max-height: 55vh;
    }

    #searchResults .products-grid {
        max-height: 50vh !important;
    }

    #searchResults .product-card {
        padding: 8px;
    }

    #searchResults .product-image {
        height: 80px;
    }

    #searchResults .product-title {
        font-size: 0.85rem;
        line-height: 1.3;
    }

    #searchResults .product-price {
        font-size: 0.8rem;
    }

    #searchResults .btn-small {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}