

<?php $__env->startSection('title', 'Search Results - ' . \App\Models\Setting::get('site_name', 'KiyoKart')); ?>

<?php $__env->startPush('styles'); ?>
<link rel="stylesheet" href="<?php echo e(asset('css/homepage.css')); ?>">
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<!-- Page Header -->
<section class="page-header py-4 mb-4" style="background: var(--color-primary); color: white;">
    <div class="container">
        <div class="row align-items-center">
            <div class="col-md-8">
                <h1 class="mb-2" style="font-size: 2.5rem; font-weight: 700;">
                    <?php if(!empty($searchQuery)): ?>
                        SEARCH RESULTS: "<?php echo e($searchQuery); ?>"
                    <?php else: ?>
                        ALL PRODUCTS
                    <?php endif; ?>
                </h1>
                <p class="mb-0" style="font-size: 1.1rem; opacity: 0.9;">
                    <?php if(!empty($searchQuery)): ?>
                        Products matching your search
                    <?php else: ?>
                        Browse all available products
                    <?php endif; ?>
                </p>
            </div>
            <div class="col-md-4 text-end">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb justify-content-end mb-0" style="background: transparent;">
                        <li class="breadcrumb-item"><a href="<?php echo e(route('home')); ?>" style="color: rgba(255,255,255,0.8);">Home</a></li>
                        <li class="breadcrumb-item active" style="color: white;">Search</li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>
</section>

<!-- Search Bar Section -->
<section class="search-bar-section py-3 mb-4" style="background: #f8f9fa; border-bottom: 1px solid #e0e0e0;">
    <div class="container">
        <form method="GET" action="<?php echo e(route('product.search')); ?>" class="row g-2">
            <div class="col-md-8">
                <input type="text" 
                       name="search" 
                       class="form-control form-control-md" 
                       placeholder="Search products by name or keywords..." 
                       value="<?php echo e($searchQuery); ?>"
                       autofocus>
            </div>
            <div class="col-md-2">
                <select name="category" class="form-select form-select-lg">
                    <option value="">All Categories</option>
                    <?php if(isset($categoriesWithCounts)): ?>
                        <?php $__currentLoopData = $categoriesWithCounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($category->slug); ?>" <?php echo e(request('category') == $category->slug ? 'selected' : ''); ?>>
                                <?php echo e($category->name); ?>

                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </select>
            </div>
            <div class="col-md-2">
                <!-- btn-lg -->
                <button type="submit" class="btn btn-primary w-100">
                    <i class="bi bi-search"></i> Search
                </button>
            </div>
        </form>
    </div>
</section>

<!-- Filter Section -->
<section class="filter-section py-3 mb-4" style="background: #f8f9fa; border-bottom: 1px solid #e0e0e0;">
    <div class="container">
        <div class="row align-items-center">
            <div class="col-md-6">
                <p class="mb-0 text-muted">
                    <?php if($products->count() > 0): ?>
                        Showing <strong><?php echo e($products->firstItem() ?? 0); ?></strong> to <strong><?php echo e($products->lastItem() ?? 0); ?></strong> 
                        of <strong><?php echo e($products->total()); ?></strong> 
                        <?php if(!empty($searchQuery)): ?>
                            product<?php echo e($products->total() !== 1 ? 's' : ''); ?> matching "<?php echo e($searchQuery); ?>"
                        <?php else: ?>
                            product<?php echo e($products->total() !== 1 ? 's' : ''); ?>

                        <?php endif; ?>
                    <?php else: ?>
                        No products found
                    <?php endif; ?>
                </p>
            </div>
            <div class="col-md-6 text-end">
                <?php if(!empty($searchQuery)): ?>
                    <a href="<?php echo e(route('product.search')); ?>" class="btn btn-sm btn-outline-secondary">
                        <i class="bi bi-x-circle"></i> Clear Search
                    </a>
                <?php endif; ?>
            </div>
        </div>
    </div>
</section>

<!-- Products Grid -->
<section class="products-section py-5">
    <div class="container product-page-wrapper">
        <div class="products-with-sidebar">
            <!-- Category Filter Sidebar -->
            <?php echo $__env->make('partials.category-filter-sidebar', [
                'categoriesWithCounts' => $categoriesWithCounts,
                'selectedCategoryIds' => $selectedCategoryIds ?? [],
                'formAction' => route('product.search')
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

            <!-- Products Content -->
            <div class="products-content" style="flex: 1;">
                <?php if($products->count() > 0): ?>
                    <div class="row g-4">
                        <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="col-6 col-md-6 col-lg-3">
                                <?php echo $__env->make('partials.product-card', ['product' => $product], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>

                    <!-- Pagination -->
                    <?php if($products->hasPages()): ?>
                    <div class="row mt-3">
                        <div class="col-12 d-flex justify-content-center">
                        <?php echo e($products->links('vendor.pagination.collection')); ?>

                        </div>
                    </div>
                    <?php endif; ?>
                <?php else: ?>
            <div class="text-center py-5">
                <i class="bi bi-search" style="font-size: 4rem; color: #ccc;"></i>
                <h3 class="mt-3 text-muted">
                    <?php if(!empty($searchQuery)): ?>
                        No products found for "<?php echo e($searchQuery); ?>"
                    <?php else: ?>
                        No products available
                    <?php endif; ?>
                </h3>
                <p class="text-muted">
                    <?php if(!empty($searchQuery)): ?>
                        Try searching with different keywords or browse our categories.
                    <?php else: ?>
                        Check back soon for new products!
                    <?php endif; ?>
                </p>
                <div class="mt-4">
                    <a href="<?php echo e(route('product.search')); ?>" class="btn btn-outline-primary me-2">
                        <i class="bi bi-arrow-left"></i> Clear Search
                    </a>
                    <a href="<?php echo e(route('home')); ?>" class="btn btn-primary">
                        <i class="bi bi-house"></i> Back to Home
                    </a>
                </div>
            </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</section>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="<?php echo e(asset('js/category-filter.js')); ?>"></script>
<?php $__env->stopPush(); ?>


<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/shivajewellers_uat/resources/views/product/search.blade.php ENDPATH**/ ?>