<?php $__env->startSection('title', 'Products'); ?>
<?php $__env->startSection('page-title', 'Products'); ?>

<?php $__env->startSection('content'); ?>
<div class="mb-4 md:mb-6">
    <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-4">
        <form method="GET" action="<?php echo e(route('admin.products.index')); ?>" class="flex flex-col sm:flex-row flex-wrap gap-3 flex-1 w-full sm:w-auto">
            <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search products..." 
                   class="w-full sm:w-auto px-3 md:px-4 py-2 md:py-3 border-2 border-[#d1d5db] rounded-xl focus:ring-2 focus:ring-black focus:border-black transition-all outline-none text-black text-sm md:text-base">
            <select name="category" class="w-full sm:w-auto px-3 md:px-4 py-2 md:py-3 border-2 border-[#d1d5db] rounded-xl focus:ring-2 focus:ring-black focus:border-black transition-all outline-none text-black bg-white text-sm md:text-base">
                <option value="">All Categories</option>
                <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($category->id); ?>" <?php echo e(request('category') == $category->id ? 'selected' : ''); ?>>
                        <?php echo e($category->name); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <button type="submit" class="w-full sm:w-auto bg-black text-white px-4 md:px-6 py-2 md:py-3 rounded-xl hover:bg-black transition-all font-semibold shadow-md hover:shadow-lg text-sm md:text-base">
                Filter
            </button>
        </form>
        <a href="<?php echo e(route('admin.products.create')); ?>" class="w-full sm:w-auto bg-black text-white px-4 md:px-6 py-2 md:py-3 rounded-xl hover:bg-[#1a1a1a] transition-all font-semibold shadow-md hover:shadow-lg flex items-center justify-center gap-2 text-sm md:text-base">
            <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
            </svg>
            Add New Product
        </a>
    </div>
</div>

<!-- Mobile Card View -->
<div id="products-mobile-container" class="lg:hidden space-y-4">
    <?php echo $__env->make('admin.products.partials.mobile-cards', ['products' => $products], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
</div>

<!-- Desktop Table View -->
<div class="hidden lg:block bg-white rounded-2xl shadow-md border border-[#d1d5db] overflow-x-auto">
    <table class="w-full">
        <thead class="bg-[#f3f4f6] border-b border-[#d1d5db]">
            <tr>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base">Image</th>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base">Name</th>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base">Category</th>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base">Price</th>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base hidden xl:table-cell">Featured</th>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base">Availability</th>
                <th class="px-4 xl:px-6 py-3 md:py-4 text-left text-black font-semibold text-sm md:text-base">Actions</th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr class="border-b border-[#d1d5db] hover:bg-[#f3f4f6] transition-colors">
                    <td class="px-4 xl:px-6 py-3 md:py-4">
                        <?php if($product->primaryImage): ?>
                            <img src="<?php echo e($product->primaryImage->image_data_url); ?>" alt="<?php echo e($product->name); ?>" class="w-12 h-12 md:w-16 md:h-16 object-cover rounded-lg border border-[#d1d5db]">
                        <?php else: ?>
                            <div class="w-12 h-12 md:w-16 md:h-16 bg-gradient-to-br from-[#d1d5db] to-[#e6d5b8] rounded-lg border border-[#d1d5db]"></div>
                        <?php endif; ?>
                    </td>
                    <td class="px-4 xl:px-6 py-3 md:py-4 text-black font-medium text-sm md:text-base"><?php echo e($product->name); ?></td>
                    <td class="px-4 xl:px-6 py-3 md:py-4 text-black text-sm md:text-base"><?php echo e($product->category->name); ?></td>
                    <td class="px-4 xl:px-6 py-3 md:py-4 text-black font-semibold text-sm md:text-base">
                        <?php if($product->is_on_sale): ?>
                            <div class="flex flex-col">
                                <span class="text-black">R<?php echo e(number_format($product->sale_price, 2)); ?></span>
                                <span class="text-xs text-black line-through">R<?php echo e(number_format($product->price, 2)); ?></span>
                            </div>
                        <?php else: ?>
                            R<?php echo e(number_format($product->price, 2)); ?>

                        <?php endif; ?>
                    </td>
                    <td class="px-4 xl:px-6 py-3 md:py-4 hidden xl:table-cell">
                        <?php if($product->featured): ?>
                            <span class="px-2 md:px-3 py-1 rounded-full text-xs font-semibold bg-[#d1fae5] text-[#065f46]">Yes</span>
                        <?php else: ?>
                            <span class="px-2 md:px-3 py-1 rounded-full text-xs font-semibold bg-[#f3f4f6] text-black">No</span>
                        <?php endif; ?>
                    </td>
                    <td class="px-4 xl:px-6 py-3 md:py-4">
                        <?php if($product->availability): ?>
                            <span class="px-2 md:px-3 py-1 rounded-full text-xs font-semibold bg-[#d1fae5] text-[#065f46]">Available</span>
                        <?php else: ?>
                            <span class="px-2 md:px-3 py-1 rounded-full text-xs font-semibold bg-[#fee2e2] text-[#991b1b]">Unavailable</span>
                        <?php endif; ?>
                    </td>
                    <td class="px-4 xl:px-6 py-3 md:py-4">
                        <div class="flex flex-wrap gap-2 md:gap-3">
                            <a href="<?php echo e(route('admin.products.edit', $product->id)); ?>" class="text-black hover:text-black transition-colors font-medium text-xs md:text-sm">Edit</a>
                            <form method="POST" action="<?php echo e(route('admin.products.destroy', $product->id)); ?>" onsubmit="return confirm('Are you sure?')" class="inline">
                                <?php echo csrf_field(); ?>
                                <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="text-black hover:text-[#b86a4f] transition-colors font-medium text-xs md:text-sm">Delete</button>
                            </form>
                        </div>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="7" class="px-4 md:px-6 py-8 md:py-12 text-center text-black text-sm md:text-base">
                        <p class="text-base md:text-lg">No products found.</p>
                        <a href="<?php echo e(route('admin.products.create')); ?>" class="text-black hover:text-black transition-colors mt-2 inline-block text-sm md:text-base">Create your first product</a>
                    </td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>

<div class="mt-4 md:mt-6">
    <?php echo e($products->links()); ?>

</div>
<?php $__env->stopSection(); ?>



<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\catalogue-builder\resources\views/admin/products/index.blade.php ENDPATH**/ ?>