<?php $title='Encomenda Confirmada'; ?>
<div style="max-width:500px;margin:0 auto;padding:36px 16px;text-align:center;">
  <div style="font-size:48px;margin-bottom:12px;">✅</div>
  <h1 style="font-size:22px;font-weight:700;margin-bottom:6px;">Encomenda confirmada!</h1>
  <p style="color:#71717a;font-size:14px;margin-bottom:28px;">
    Obrigado, <?= h($order['customer_name']) ?>.<br>
    O comprovativo foi aberto numa nova janela para guardar como PDF.
  </p>

  <div style="background:#18181b;border-radius:14px;padding:20px;border:1px solid rgba(255,255,255,.07);text-align:left;margin-bottom:16px;">
    <div style="text-align:center;margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid rgba(255,255,255,.08);">
      <div style="font-size:11px;color:#52525b;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px;">Número de encomenda</div>
      <div style="font-size:26px;font-weight:800;font-family:monospace;"><?= h($order['order_number']) ?></div>
    </div>
    <div style="display:flex;flex-direction:column;gap:8px;font-size:14px;">
      <div style="display:flex;justify-content:space-between;">
        <span style="color:#71717a;">Fotografias</span>
        <span><?= count($items) ?><?= $order['photos_free']>0?' (+'.h($order['photos_free']).' grátis)':'' ?></span>
      </div>
      <div style="display:flex;justify-content:space-between;">
        <span style="color:#71717a;">Envio</span>
        <span><?= match($order['shipping_method']){'ctt'=>'Envio CTT','internacional'=>'Internacional',default=>'Entrega aos Noivos'} ?></span>
      </div>
    </div>
  </div>

  <div style="background:rgba(59,130,246,.08);border:1px solid rgba(59,130,246,.2);border-radius:12px;padding:12px 15px;margin-bottom:20px;text-align:left;">
    <div style="font-weight:600;font-size:14px;color:#93c5fd;margin-bottom:3px;">💵 Pagamento junto dos fotógrafos</div>
    <p style="font-size:13px;color:#a1a1aa;">O pagamento é realizado presencialmente no momento da entrega das fotografias.</p>
  </div>

  <div style="display:flex;flex-direction:column;gap:10px;">
    <a href="<?= base_url('recibo/'.$order['order_number'].'?auto=1') ?>" target="_blank"
       style="display:block;background:#fff;color:#18181b;font-weight:700;font-size:14px;padding:12px 20px;border-radius:10px;transition:background .15s;">
      📄 Abrir Comprovativo (PDF)
    </a>
    <a href="<?= base_url() ?>"
       style="display:block;color:#52525b;font-size:14px;padding:10px;transition:color .15s;">
      ← Voltar à galeria
    </a>
  </div>
</div>

<script>
// Abrir recibo automaticamente
window.addEventListener('load', function() {
  setTimeout(function() {
    window.open('<?= base_url('recibo/'.$order['order_number'].'?auto=1') ?>', '_blank');
  }, 500);
});
</script>
