<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Pedido Recibido</title>
	<style>
		body { margin:0; font-family:Segoe UI, sans-serif; background:#f6f8fb; color:#0f172a; }
		.wrap { max-width:780px; 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); }
		.ok { 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; }
	</style>
</head>
<body>
	<div class="wrap">
		<div class="card">
			<h1 class="ok">Pedido recibido</h1>
			<p>Gracias, <strong><?php echo html_escape($link['customer_name']); ?></strong>. Tu pedido fue guardado correctamente.</p>
			<p>
				<strong>Folio pedido:</strong> #<?php echo (int) $order_id; ?><br>
				<strong>Venta suspendida:</strong> #<?php echo (int) $sale_id; ?>
			</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>Nota enviada:</strong> <?php echo nl2br(html_escape($note)); ?></p>
			<?php endif; ?>
		</div>
	</div>
</body>
</html>
