<?php
use Livewire\Component;
use App\Models\Product;
?>

<div class="relative w-full max-w-xs sm:max-w-sm" x-data="{ open: true }" @click.away="open = false">
    <div class="relative">
        <input 
            wire:model.live.debounce.300ms="query"
            type="text" 
            placeholder="Search products..." 
            class="w-full text-xs sm:text-sm pl-4 pr-10 py-2 bg-gray-50 border border-gray-250 rounded-xl focus:outline-none focus:ring-1 focus:ring-indigo-650"
            @focus="open = true"
        >
        <span class="absolute inset-y-0 right-3 flex items-center text-gray-400">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(strlen($query) > 0): ?>
                <button wire:click="clearSearch" class="focus:outline-none hover:text-gray-600">
                    <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            <?php else: ?>
                <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                </svg>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </span>
    </div>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(count($results) > 0): ?>
        <div x-show="open" class="absolute left-0 right-0 mt-2 bg-white border border-gray-100 rounded-2xl shadow-xl z-50 overflow-hidden divide-y divide-gray-50" x-cloak>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $results; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                <a 
                    href="/products/<?php echo e($item['id']); ?>" 
                    class="flex items-center p-3 hover:bg-indigo-50/30 transition-colors"
                    wire:click="clearSearch"
                >
                    <img src="<?php echo e($item['image']); ?>" alt="<?php echo e($item['name']); ?>" class="w-10 h-10 object-cover rounded-lg border border-gray-100 flex-shrink-0">
                    <div class="ml-3 flex-grow min-w-0">
                        <p class="text-xs font-semibold text-gray-405 uppercase tracking-wider"><?php echo e($item['category']); ?></p>
                        <h4 class="text-sm font-bold text-gray-900 truncate mt-0.5"><?php echo e($item['name']); ?></h4>
                        <div class="flex items-baseline space-x-1.5 mt-0.5">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($item['sale_price']): ?>
                                <span class="text-xs font-bold text-indigo-650">৳<?php echo e(number_format($item['sale_price'], 2)); ?></span>
                                <span class="text-xxs text-gray-400 line-through">৳<?php echo e(number_format($item['price'], 2)); ?></span>
                            <?php else: ?>
                                <span class="text-xs font-bold text-indigo-650">৳<?php echo e(number_format($item['price'], 2)); ?></span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    </div>
                </a>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
        </div>
    <?php elseif(strlen($query) >= 2 && count($results) === 0): ?>
        <div x-show="open" class="absolute left-0 right-0 mt-2 bg-white border border-gray-100 rounded-2xl shadow-xl z-50 p-4 text-center text-xs text-gray-500" x-cloak>
            No products found matching "<?php echo e($query); ?>"
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div><?php /**PATH storage/framework/views-testing/livewire/views/afbf0c9c.blade.php ENDPATH**/ ?>