<?php echo $__env->make('layouts.head', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<body>
<?php echo $__env->make('layouts.topbar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('layouts.navbar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<div class="container py-5">
    <h2 class="mb-4 text-center">Your Cart</h2>

    <?php if(session('cart') && count(session('cart')) > 0): ?>
        <div class="table-responsive">
            <table class="table table-bordered align-middle text-center">
                <thead class="table-light">
                    <tr>
                        <th>Image</th>
                        <th>Product</th>
                        <th>Price</th>
                        <th>Quantity</th>
                        <th>Subtotal</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $total = 0; ?>
                    <?php $__currentLoopData = $cart; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php 
                            $subtotal = $item['price'] * $item['quantity']; 
                            $total += $subtotal; 
                        ?>
                        <tr>
                            <td>
                                <img src="<?php echo e(asset('public_html/img/'.$item['image'])); ?>" 
                                     width="60" 
                                     class="img-fluid rounded" 
                                     alt="<?php echo e($item['name']); ?>">
                            </td>
                            <td class="fw-semibold"><?php echo e($item['name']); ?></td>
                            <td>Tsh <?php echo e(number_format($item['price'],2)); ?></td>
                            <td>
                                <form action="<?php echo e(route('update.cart', $id)); ?>" method="POST" class="d-flex justify-content-center align-items-center gap-2">
                                    <?php echo csrf_field(); ?>
                                    <input type="number" 
                                           name="quantity" 
                                           value="<?php echo e($item['quantity']); ?>" 
                                           min="1" 
                                           class="form-control form-control-sm w-50 text-center">
                                    <button class="btn btn-sm btn-outline-primary" type="submit">
                                        <i class="bi bi-arrow-repeat"></i>
                                    </button>
                                </form>
                            </td>
                            <td>Tsh <?php echo e(number_format($subtotal,2)); ?></td>
                            <td>
                                <a href="<?php echo e(route('remove.from.cart', $id)); ?>" class="btn btn-sm btn-danger">
                                    <i class="bi bi-trash"></i>
                                </a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <tr class="fw-bold">
                        <td colspan="4" class="text-end">Total</td>
                        <td colspan="2">Tsh <?php echo e(number_format($total,2)); ?></td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="d-flex justify-content-between flex-wrap mt-4">
            <a href="<?php echo e(route('products')); ?>" class="btn btn-outline-secondary mb-2">
                <i class="bi bi-arrow-left"></i> Continue Shopping
            </a>
            <a href="<?php echo e(route('checkout')); ?>" class="btn btn-primary px-5 mb-2">
                Proceed to Checkout
            </a>
        </div>
    <?php else: ?>
        <div class="alert alert-info text-center">Your cart is empty.</div>
    <?php endif; ?>
</div>

<?php echo $__env->make('layouts.footer', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
<?php echo $__env->make('layouts.links', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
</body>
</html>
<?php /**PATH /home/u905600066/domains/kauka.medicalsean.com/public_html/resources/views/cart.blade.php ENDPATH**/ ?>