

<?php $__env->startSection('title', 'Product Management'); ?>

<?php $__env->startSection('content'); ?>
    <div class="flex flex-col md:flex-row md:items-end justify-between gap-6 mb-8 border-b border-gray-100 pb-6">
        <div class="space-y-1">
            <h1 class="text-3xl font-bold text-gray-900 tracking-tight">Products</h1>
            <p class="text-gray-500 text-sm">Manage pricing, stock and visibility of your items.</p>
        </div>
        <div class="flex items-center gap-3">
            <a href="<?php echo e(route('admin.products.create')); ?>" class="inline-flex items-center px-5 py-3 btn-brand text-white text-xs font-bold rounded-xl shadow-lg shadow-brand/20 transition-all">
                <i class="fas fa-plus mr-2 text-[10px]"></i>
                Add Product
            </a>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div x-data="{ show: true }" x-show="show" x-transition:leave="transition ease-in duration-300" x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-95" class="bg-emerald-50 border border-emerald-100 text-emerald-700 p-5 mb-8 rounded-2xl flex items-center justify-between shadow-sm" role="alert">
            <div class="flex items-center gap-3">
                <div class="h-8 w-8 rounded-lg bg-white flex items-center justify-center shadow-sm">
                    <i class="fas fa-check text-emerald-500 text-xs"></i>
                </div>
                <p class="text-sm font-bold"><?php echo e(session('success')); ?></p>
            </div>
            <button @click="show = false" class="text-emerald-400 hover:text-emerald-600 transition-colors">
                <i class="fas fa-times text-xs"></i>
            </button>
        </div>
    <?php endif; ?>

    <div class="bg-white rounded-3xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="px-6 py-4 border-b border-gray-100 bg-gray-50/60">
            <div class="flex flex-wrap items-center gap-2">
                <a href="<?php echo e(route('admin.products.index')); ?>"
                   class="px-3 py-1.5 rounded-lg text-sm font-medium <?php echo e(request()->has('special_offers') || request()->has('premium') ? 'bg-white border border-gray-200 text-gray-600 hover:bg-gray-50' : 'bg-brand/10 text-brand border border-brand/20'); ?>">
                    All
                </a>
                <a href="<?php echo e(route('admin.products.index', ['special_offers' => 1])); ?>"
                   class="px-3 py-1.5 rounded-lg text-sm font-medium <?php echo e(request()->query('special_offers') == 1 ? 'bg-brand/10 text-brand border border-brand/20' : 'bg-white border border-gray-200 text-gray-600 hover:bg-gray-50'); ?>">
                    Special Offers
                </a>
                <a href="<?php echo e(route('admin.products.index', ['premium' => 1])); ?>"
                   class="px-3 py-1.5 rounded-lg text-sm font-medium <?php echo e(request()->query('premium') == 1 ? 'bg-brand/10 text-brand border border-brand/20' : 'bg-white border border-gray-200 text-gray-600 hover:bg-gray-50'); ?>">
                    Premium Shop
                </a>
                <?php if(request()->query('premium') == 1): ?>
                    <span class="ml-auto inline-flex items-center gap-2 text-sm text-gray-500">
                        <i class="fas fa-gem text-purple-500"></i>
                        Showing premium products
                    </span>
                <?php elseif(request()->query('special_offers') == 1): ?>
                    <span class="ml-auto inline-flex items-center gap-2 text-sm text-gray-500">
                        <i class="fas fa-star text-amber-500"></i>
                        Showing special offers
                    </span>
                <?php endif; ?>
            </div>
        </div>

        <div class="p-6">
            <?php if($products->count()): ?>
            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
                <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if(request()->query('special_offers') == 1): ?>
                        <div class="group border border-gray-100 rounded-2xl overflow-hidden bg-white hover:shadow-md transition-all">
                            <div class="relative aspect-square bg-gray-50 flex items-center justify-center overflow-hidden">
                                <?php if($product->image): ?>
                                    <img class="h-full w-full object-cover group-hover:scale-105 transition-transform duration-500" src="<?php echo e(Str::startsWith($product->image, ['http://', 'https://']) ? $product->image : Storage::url($product->image)); ?>" alt="<?php echo e($product->name); ?>">
                                <?php else: ?>
                                    <i class="fas fa-box text-4xl text-gray-200"></i>
                                <?php endif; ?>
                                <div class="absolute top-3 right-3 h-7 px-2 rounded-lg bg-amber-500 text-white text-[10px] font-bold inline-flex items-center gap-1">
                                    <i class="fas fa-star text-[9px]"></i>
                                    Special
                                </div>
                                <?php if(!$product->is_active): ?>
                                    <div class="absolute bottom-3 left-3 px-2 py-1 text-[10px] font-semibold rounded bg-gray-900 text-white/90">Inactive</div>
                                <?php endif; ?>
                            </div>
                            <div class="p-4">
                                <div class="text-sm font-semibold text-gray-900 line-clamp-2"><?php echo e($product->name); ?></div>
                                <div class="mt-1 text-xs text-gray-500"><?php echo e($product->category->name ?? 'Uncategorized'); ?></div>
                                <div class="mt-2 flex items-baseline gap-2">
                                    <?php if($product->discount_price): ?>
                                        <span class="text-sm font-semibold text-emerald-600"><?php echo e($currencySymbol); ?><?php echo e(number_format($product->discount_price, 2)); ?></span>
                                        <span class="text-xs text-gray-400 line-through"><?php echo e($currencySymbol); ?><?php echo e(number_format($product->price, 2)); ?></span>
                                    <?php else: ?>
                                        <span class="text-sm font-semibold text-gray-900"><?php echo e($currencySymbol); ?><?php echo e(number_format($product->price, 2)); ?></span>
                                    <?php endif; ?>
                                </div>
                                <div class="mt-3 flex items-center justify-between">
                                    <span class="text-xs text-gray-500"><?php echo e($product->stock); ?> <?php echo e($product->unit); ?></span>
                                    <div class="flex items-center gap-2">
                                        <a href="<?php echo e(route('admin.products.edit', $product)); ?>" class="h-9 w-9 flex items-center justify-center text-gray-400 hover:text-brand hover:bg-emerald-50 rounded-xl transition-all" title="Edit">
                                            <i class="fas fa-edit text-sm"></i>
                                        </a>
                                        <form action="<?php echo e(route('admin.products.destroy', $product)); ?>" method="POST" class="inline-block" onsubmit="return confirm('Are you sure you want to delete this product?');">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="h-9 w-9 flex items-center justify-center text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-all" title="Delete">
                                                <i class="fas fa-trash-alt text-sm"></i>
                                            </button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php else: ?>
                        <div class="rounded-2xl border border-gray-200 hover:border-brand/40 transition-colors p-4 bg-white">
                            <div class="relative">
                                <div class="w-full aspect-square rounded-xl overflow-hidden bg-gray-50 border border-gray-100">
                                    <?php if($product->image): ?>
                                        <img class="w-full h-full object-cover" src="<?php echo e(Str::startsWith($product->image, ['http://', 'https://']) ? $product->image : route('public.media', ['path' => $product->image])); ?>" alt="<?php echo e($product->name); ?>">
                                    <?php else: ?>
                                        <div class="w-full h-full flex items-center justify-center text-gray-300">
                                            <i class="fas fa-box text-2xl"></i>
                                        </div>
                                    <?php endif; ?>
                                </div>
                                <?php if($product->is_featured): ?>
                                    <span class="absolute top-2 right-2 px-2 py-0.5 bg-amber-400 text-white rounded-full text-xs">Featured</span>
                                <?php endif; ?>
                                <?php if($product->is_premium): ?>
                                    <span class="absolute top-2 left-2 px-2 py-0.5 bg-purple-500 text-white rounded-full text-xs">Premium</span>
                                <?php endif; ?>
                            </div>
                            <div class="mt-3">
                                <div class="flex items-start justify-between gap-3">
                                    <h4 class="font-semibold text-gray-900 truncate"><?php echo e($product->name); ?></h4>
                                    <?php if($product->is_active): ?>
                                        <span class="px-2 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-xs">Active</span>
                                    <?php else: ?>
                                        <span class="px-2 py-0.5 bg-gray-100 text-gray-500 rounded-full text-xs">Inactive</span>
                                    <?php endif; ?>
                                </div>
                                <p class="text-xs text-gray-500 mt-0.5 truncate">SKU: <?php echo e($product->sku ?? 'N/A'); ?></p>
                                <div class="mt-2 flex items-center gap-2 flex-wrap">
                                    <span class="px-2 py-0.5 bg-gray-100 text-gray-600 rounded text-xs"><?php echo e($product->category->name); ?></span>
                                    <?php if($product->subCategory): ?>
                                        <span class="px-2 py-0.5 bg-gray-100 text-gray-600 rounded text-xs"><?php echo e($product->subCategory->name); ?></span>
                                    <?php endif; ?>
                                </div>
                                <div class="mt-3">
                                    <?php if($product->discount_price): ?>
                                        <div class="flex items-baseline gap-2">
                                            <span class="text-sm font-semibold text-emerald-600"><?php echo e($currencySymbol); ?><?php echo e(number_format($product->discount_price, 2)); ?></span>
                                            <span class="text-xs text-gray-400 line-through"><?php echo e($currencySymbol); ?><?php echo e(number_format($product->price, 2)); ?></span>
                                        </div>
                                    <?php else: ?>
                                        <span class="text-sm font-semibold text-gray-900"><?php echo e($currencySymbol); ?><?php echo e(number_format($product->price, 2)); ?></span>
                                    <?php endif; ?>
                                </div>
                                <div class="mt-3 flex items-center justify-between text-xs text-gray-600">
                                    <span><?php echo e($product->stock); ?> <?php echo e($product->unit); ?></span>
                                    <div class="w-24 bg-gray-100 rounded-full h-1.5 overflow-hidden">
                                        <div class="bg-brand h-full rounded-full" style="width: <?php echo e(min(100, ($product->stock / 100) * 100)); ?>%"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="mt-4 flex items-center justify-end gap-2">
                                <a href="<?php echo e(route('admin.products.edit', $product)); ?>" class="px-3 py-2 bg-gray-50 text-gray-600 rounded-lg hover:bg-brand/10 hover:text-brand transition-colors text-sm">Edit</a>
                                <form action="<?php echo e(route('admin.products.destroy', $product)); ?>" method="POST" onsubmit="return confirm('Are you sure you want to delete this product?');">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="px-3 py-2 bg-red-50 text-red-600 rounded-lg hover:bg-red-100 transition-colors text-sm">Delete</button>
                                </form>
                            </div>
                        </div>
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
            <?php else: ?>
            <?php
                $emptyTitle = 'No products found';
                $emptySubtitle = 'Your inventory is empty. Start adding products to your store to see them listed here.';
                if (request()->query('premium') == 1) {
                    $emptyTitle = 'No premium products';
                    $emptySubtitle = 'Mark products as Premium to include them in this list.';
                } elseif (request()->query('special_offers') == 1) {
                    $emptyTitle = 'No special offers';
                    $emptySubtitle = 'Mark products as Special Offer to include them in this list.';
                }
            ?>
            <div class="px-8 py-20 text-center">
                <div class="flex flex-col items-center justify-center">
                    <div class="w-16 h-16 bg-gray-50 rounded-2xl flex items-center justify-center mb-4">
                        <i class="fas fa-boxes text-gray-200 text-2xl"></i>
                    </div>
                    <h3 class="text-lg font-semibold text-gray-900 mb-1"><?php echo e($emptyTitle); ?></h3>
                    <p class="text-gray-500 text-sm max-w-xs mx-auto"><?php echo e($emptySubtitle); ?></p>
                    <a href="<?php echo e(route('admin.products.create')); ?>" class="mt-6 inline-flex items-center gap-2 bg-emerald-600 !bg-brand text-white !text-white px-5 py-2.5 rounded-xl text-sm hover:bg-emerald-700 hover:!bg-brand/90 transition-colors">
                        <i class="fas fa-plus text-xs"></i>
                        Add product
                    </a>
                </div>
            </div>
            <?php endif; ?>
        </div>
        
        <?php if($products->hasPages()): ?>
        <div class="px-6 py-5 border-t border-gray-100 bg-gray-50/50">
            <?php echo e($products->links()); ?>

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

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/burhjijr/adminprovendorx.burhanstore.online/resources/views/admin/products/index.blade.php ENDPATH**/ ?>