<section class="section">
  <div class="section-header">
    <p class="eyebrow">Admin</p>
    <h1>Cashless - <%= event.title %></h1>
  </div>
  <form class="panel-grid" method="post" action="/admin/events/<%= event.id %>/cashless/settings">
    <%- include('../partials/csrf-field') %>
    <label><input type="checkbox" name="cashless_enabled" value="1" <%= settings?.cashless_enabled ? 'checked' : '' %>> Cashless activ</label>
    <label><input type="checkbox" name="online_checkin_enabled" value="1" <%= settings?.online_checkin_enabled ? 'checked' : '' %>> Check-in online activ</label>
    <label><input type="checkbox" name="nfc_enabled" value="1" <%= settings?.nfc_enabled ? 'checked' : '' %>> NFC activ</label>
    <label>Refund window ore <input name="refund_window_hours" type="number" min="1" value="<%= settings?.refund_window_hours || 48 %>"></label>
    <button type="submit">Salveaza</button>
  </form>
</section>

<section class="section">
  <div class="section-header"><h2>Walleturi</h2></div>
  <div class="table-wrap">
    <table>
      <thead><tr><th>ID</th><th>Bilet</th><th>Bratara</th><th>Sold</th><th>Status</th><th>Actiuni</th></tr></thead>
      <tbody>
        <% wallets.forEach((wallet) => { %>
          <tr>
            <td><%= wallet.id %></td>
            <td><%= wallet.ticket_code || '-' %></td>
            <td><%= wallet.wristband_code || '-' %></td>
            <td><%= wallet.balance %> <%= wallet.currency %></td>
            <td><%= wallet.status %></td>
            <td class="actions">
              <form method="post" action="/admin/events/<%= event.id %>/cashless/wallet/<%= wallet.id %>/freeze"><%- include('../partials/csrf-field') %><input type="hidden" name="reason" value="Admin freeze"><button>Freeze</button></form>
              <form method="post" action="/admin/events/<%= event.id %>/cashless/wallet/<%= wallet.id %>/unfreeze"><%- include('../partials/csrf-field') %><input type="hidden" name="reason" value="Admin unfreeze"><button>Unfreeze</button></form>
              <form method="post" action="/admin/events/<%= event.id %>/cashless/wallet/<%= wallet.id %>/adjust"><%- include('../partials/csrf-field') %><input name="amount" type="number" step="0.01" placeholder="Suma"><input name="reason" placeholder="Motiv"><button>Ajusteaza</button></form>
            </td>
          </tr>
        <% }) %>
      </tbody>
    </table>
  </div>
</section>

<section class="section">
  <div class="section-header"><h2>Ultimele tranzactii</h2></div>
  <div class="table-wrap">
    <table>
      <thead><tr><th>ID</th><th>Tip</th><th>Suma</th><th>Sold dupa</th><th>Status</th><th>Idempotency</th></tr></thead>
      <tbody>
        <% transactions.forEach((tx) => { %>
          <tr><td><%= tx.id %></td><td><%= tx.type %></td><td><%= tx.amount %></td><td><%= tx.balance_after %></td><td><%= tx.status %></td><td><%= tx.idempotency_key %></td></tr>
        <% }) %>
      </tbody>
    </table>
  </div>
</section>
