<?php
declare(strict_types=1);
?>
<!DOCTYPE html>
<html lang="ca">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Pagament cancel·lat · Blood Bros Sports</title>
  <link rel="icon" type="image/png" href="/assets/logo/bloodbros-sports-logo.png">
  <style>
    :root{
      --bg-1:#040b16;
      --bg-2:#071425;
      --bg-3:#091a30;
      --text:#f4f7fb;
      --muted:#9fb0ca;
      --shadow:0 16px 44px rgba(0,0,0,.34);
    }

    *{box-sizing:border-box}
    html,body{margin:0;padding:0}
    body{
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      color:var(--text);
      background:
        radial-gradient(circle at 12% 10%, rgba(52,122,255,.18), transparent 24%),
        radial-gradient(circle at 82% 12%, rgba(100,196,255,.12), transparent 24%),
        linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 38%, var(--bg-3) 100%);
      min-height:100vh;
    }

    .wrap{
      max-width:900px;
      margin:0 auto;
      padding:48px 18px;
    }

    .card{
      border-radius:32px;
      border:1px solid rgba(255,255,255,.10);
      background:
        radial-gradient(circle at 75% 15%, rgba(104,133,255,.18), transparent 28%),
        linear-gradient(180deg, rgba(17,29,52,.95), rgba(12,20,36,.98));
      box-shadow:var(--shadow);
      padding:28px;
    }

    .head{
      display:flex;
      align-items:center;
      gap:18px;
      margin-bottom:18px;
    }

    .logo-wrap{
      width:84px;
      height:84px;
      border-radius:24px;
      background:linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
      border:1px solid rgba(255,255,255,.10);
      display:flex;
      align-items:center;
      justify-content:center;
      overflow:hidden;
      flex:0 0 auto;
    }

    .logo-wrap img{
      max-width:82%;
      max-height:82%;
      object-fit:contain;
      display:block;
    }

    h1{
      margin:0 0 6px;
      font-size:24px;
      font-weight:1000;
    }

    p{
      margin:0;
      color:var(--muted);
      font-size:16px;
      line-height:1.5;
    }

    .actions{
      display:flex;
      gap:12px;
      flex-wrap:wrap;
      margin-top:26px;
    }

    .btn{
      min-height:52px;
      padding:0 20px;
      border-radius:999px;
      border:1px solid rgba(255,255,255,.10);
      text-decoration:none;
      display:inline-flex;
      align-items:center;
      justify-content:center;
      font-weight:900;
      color:#fff;
      background:rgba(255,255,255,.05);
    }

    .btn-primary{
      background:linear-gradient(180deg, rgba(93,154,255,.34), rgba(52,115,214,.28));
      border-color:rgba(100,196,255,.24);
    }

    @media (max-width:640px){
      .head{
        align-items:flex-start;
      }
    }
  </style>
</head>
<body>
  <div class="wrap">
    <div class="card">
      <div class="head">
        <div class="logo-wrap">
          <img src="/assets/logo/bloodbros-sports-logo.png" alt="Blood Bros Sports">
        </div>
        <div>
          <h1>Pagament cancel·lat</h1>
          <p>No s'ha completat la compra. Si vols, pots tornar al catàleg i reprendre la comanda quan et vagi bé.</p>
        </div>
      </div>

      <div class="actions">
        <a class="btn btn-primary" href="/">Torna al catàleg</a>
      </div>
    </div>
  </div>
  <script>
    (function () {
      try {
        var key = 'kapvoe_session_id';
        var sessionId = localStorage.getItem(key) || '';
        fetch('/api/track-event.php', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          keepalive: true,
          body: JSON.stringify({
            event_type: 'payment_cancel',
            session_id: sessionId,
            page_url: window.location.href,
            referrer: document.referrer || '',
            user_agent: navigator.userAgent || '',
            device_type: /mobile|android|iphone|ipod/i.test(navigator.userAgent || '') ? 'mobile' : 'desktop',
            page_type: 'checkout'
          })
        });
      } catch (e) {}
    })();
  </script>
</body>
</html>
