<?php /* filepath: resources\views\AutoGestionCliente\_carrito.blade.php */ ?>

<h5 class="text-muted mb-3">Resumen de tu Pedido</h5>

<?php if(isset($pedido_items) && count($pedido_items) > 0): ?>
    <table class="table table-bordered table-striped text-center align-middle mb-0">
        <thead class="table-dark">
            <tr>
                <th>Producto</th>
                <th style="width: 150px;">Cantidad</th>
                <th>Precio Unit.</th>
                <th>Total</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach($pedido_items as $cart_item_id => $item): ?>
                <tr data-cart-item-id="<?php echo e($cart_item_id); ?>">
                    <td><?php echo e($item['nombre']); ?></td>
                    <td>
                        <div class="input-group input-group-sm justify-content-center">
                            <button class="btn btn-outline-secondary btn-minus-def" type="button">−</button>
                            <input type="number" class="form-control text-center cantidad-input-def"
                                   value="<?php echo e($item['cantidad']); ?>" min="1" style="width: 50px;">
                            <button class="btn btn-outline-secondary btn-plus-def" type="button">+</button>
                        </div>
                    </td>
                    <td>$<?php echo e(number_format($item['precio'], 0, ',', '.')); ?></td>
                    <td>$<?php echo e(number_format($item['precio'] * $item['cantidad'], 0, ',', '.')); ?></td>
                    <td>
                        <button class="btn btn-danger btn-sm btn-eliminar" title="Eliminar del pedido">
                            <i class="fas fa-trash-alt">Eliminar</i>
                        </button>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
        <tfoot>
            <tr class="table-secondary fw-bold">
                <td colspan="3" class="text-end">Total Pedido:</td>
                <td colspan="2">$<?php echo e(number_format($pedido_total, 0, ',', '.')); ?></td>
            </tr>
        </tfoot>
    </table>
<?php else: ?>
    <div class="alert alert-info mb-0 text-center">
        Tu pedido está vacío.<br>
        Añade productos desde el catálogo de la izquierda.
    </div>
<?php endif; ?>