<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Revisar Pedido</title>
	<style>
		body { margin:0; font-family:Segoe UI, sans-serif; background:#f6f8fb; color:#0f172a; }
		.wrap { max-width:820px; margin:0 auto; padding:32px 16px; }
		.card { background:#fff; border:1px solid #e2e8f0; border-radius:14px; padding:20px; box-shadow:0 10px 25px rgba(15,23,42,.06); }
		h1 { color:#0f766e; font-size:32px; margin:0 0 6px; }
		table { width:100%; border-collapse:collapse; margin-top:12px; }
		th, td { padding:8px; border-bottom:1px solid #e2e8f0; text-align:left; }
		th { font-size:12px; color:#64748b; text-transform:uppercase; }
		.muted { color:#64748b; font-size:13px; }
		.actions { margin-top:14px; display:flex; gap:10px; flex-wrap:wrap; }
		.btn { display:inline-block; text-decoration:none; border:none; border-radius:10px; padding:11px 16px; font:inherit; font-weight:700; cursor:pointer; }
		.btn-outline { background:#fff; border:1px solid #cbd5e1; color:#1e293b; }
		.btn-primary { background:#d62828; color:#fff; }
	</style>
</head>
<body>
	<div class="wrap">
		<div class="card">
			<h1>Revisa tu pedido</h1>
			<p>Cliente: <strong><?php echo html_escape($link['customer_name']); ?></strong></p>

			<table>
				<thead>
					<tr>
						<th>Producto</th>
						<th>Cantidad</th>
						<th>Precio</th>
						<th>Total</th>
					</tr>
				</thead>
				<tbody>
					<?php $grand_total = 0; ?>
					<?php foreach ($items as $item): ?>
						<?php $grand_total += $item['line_total']; ?>
						<tr>
							<td><?php echo html_escape($item['item_name']); ?></td>
							<td><?php echo (float) $item['quantity']; ?></td>
							<td><?php echo html_escape($currency_symbol . number_format((float)$item['unit_price'], 2)); ?></td>
							<td><?php echo html_escape($currency_symbol . number_format((float)$item['line_total'], 2)); ?></td>
						</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
			<p style="margin-top:10px;"><strong>Total:</strong> <?php echo html_escape($currency_symbol . number_format((float)$grand_total, 2)); ?></p>

			<?php if ($note !== ''): ?>
				<p class="muted"><strong>Comentario:</strong> <?php echo nl2br(html_escape($note)); ?></p>
			<?php endif; ?>

			<div class="actions">
				<a class="btn btn-outline" href="<?php echo site_url('catalog/l/'.rawurlencode($link['token'])); ?>">Modificar</a>
				<form method="post" action="<?php echo site_url('catalog/l/'.rawurlencode($link['token']).'/confirm'); ?>" style="margin:0;">
					<button class="btn btn-primary" type="submit">Confirmar pedido</button>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
