

<?php $__env->startSection('title', 'Cart'); ?>
<?php $__env->startSection('meta_description', 'Your cart – ' . ($store_name ?? config('app.name'))); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
    <h1 class="text-2xl font-bold text-gray-800 mb-6">Your Cart</h1>

    <?php if($cart->items->isEmpty()): ?>
    <div class="card p-12 text-center">
        <i class="fas fa-shopping-cart text-5xl text-gray-300 mb-4"></i>
        <p class="text-gray-600 mb-4">Your cart is empty.</p>
        <a href="<?php echo e(route('products.index')); ?>" class="btn-primary inline-block">Continue Shopping</a>
    </div>
    <?php else: ?>
    <div class="space-y-4">
        <?php $__currentLoopData = $cart->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="card p-4 flex flex-col sm:flex-row gap-4">
            <?php
                $img = $item->product->images->sortBy('sort_order')->first();
                $imgUrl = $img && $img->image_path ? asset('storage/'.$img->image_path) : 'https://images.unsplash.com/photo-1542838132-92c53300491e?w=200';
            ?>
            <img src="<?php echo e($imgUrl); ?>" alt="<?php echo e($item->product->name); ?>" class="w-24 h-24 object-cover rounded-xl flex-shrink-0">
            <div class="flex-1 min-w-0">
                <a href="<?php echo e(route('products.show', $item->product->slug)); ?>" class="font-semibold text-gray-800 hover:text-primary"><?php echo e($item->product->name); ?></a>
                <?php if($item->variant): ?>
                <p class="text-sm text-gray-500"><?php echo e($item->variant->name); ?></p>
                <?php endif; ?>
                <p class="text-primary-dark font-bold mt-1"><?php echo e($currency_symbol); ?><?php echo e(number_format($item->price, 0)); ?> each</p>
            </div>
            <div class="flex items-center gap-2">
                <form action="<?php echo e(route('cart.update', $item)); ?>" method="POST" class="flex items-center gap-1">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    <input type="number" name="quantity" value="<?php echo e($item->quantity); ?>" min="1" max="99" class="input w-16 text-center py-1 text-sm">
                    <button type="submit" class="text-primary text-sm font-medium hover:underline">Update</button>
                </form>
                <form action="<?php echo e(route('cart.remove', $item)); ?>" method="POST" class="inline">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('DELETE'); ?>
                    <button type="submit" class="text-red-600 hover:text-red-700 text-sm" title="Remove"><i class="fas fa-trash"></i></button>
                </form>
            </div>
            <div class="font-semibold text-gray-800 sm:text-right"><?php echo e($currency_symbol); ?><?php echo e(number_format($item->subtotal, 0)); ?></div>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>

    <div class="mt-8 card p-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
        <div>
            <p class="text-xl font-bold text-gray-800">Subtotal: <?php echo e($currency_symbol); ?><?php echo e(number_format($cart->subtotal, 0)); ?></p>
            <form action="<?php echo e(route('cart.clear')); ?>" method="POST" class="inline mt-2">
                <?php echo csrf_field(); ?>
                <?php echo method_field('DELETE'); ?>
                <button type="submit" class="text-sm text-red-600 hover:underline">Clear cart</button>
            </form>
        </div>
        <a href="<?php echo e(route('checkout.index')); ?>" class="btn-primary inline-block text-center">
            <?php if(auth()->guard('web')->check()): ?>
            Proceed to Checkout
            <?php else: ?>
            Login to Checkout
            <?php endif; ?>
        </a>
    </div>
    <?php if(auth()->guard('web')->guest()): ?>
    <p class="mt-4 text-sm text-gray-500">You will be asked to log in when you proceed to checkout.</p>
    <?php endif; ?>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('store.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\ReactNative\grocery-api\resources\views/store/cart/show.blade.php ENDPATH**/ ?>