<%- include('../partials/head', { title: 'Admin – Zertifikate' }) %>
<%- include('../partials/topbar', {
  kicker: 'Administration',
  heading: 'Zertifikate',
  actionPrimary: { href: '/admin/certificates/new', label: 'Neues Zertifikat' },
  showLogout: true
}) %>
<main class="main-area">
  <div class="container-inner">
    <section class="content-card content-card--padded">
      <% if (!certificates.length) { %>
      <p class="empty-state">Noch keine Zertifikate vorhanden.</p>
      <% } else { %>
      <div class="table-wrap">
        <table class="data-table">
          <thead>
            <tr>
              <th>Titel</th>
              <th>Name</th>
              <th>Teilnehmernummer</th>
              <th>Gesamtpunkte</th>
              <th>Ausstellung</th>
              <th>Verifizierung (nur Admin)</th>
              <th></th>
            </tr>
          </thead>
          <tbody>
            <% certificates.forEach((c) => { %>
            <tr>
              <td class="cell-strong"><%= c.title %></td>
              <td><%= c.first_name %> <%= c.last_name %></td>
              <td><%= c.participant_number %></td>
              <td><%= c.total_points %></td>
              <td><%= c.issue_date ? new Date(c.issue_date).toLocaleDateString("de-DE") : "–" %></td>
              <td class="cell-verify">
                <a class="verify-link-admin" href="<%= c.certificate_url %>" target="_blank" rel="noopener noreferrer"><%= c.certificate_url %></a>
                <img class="verify-qr-thumb" src="<%= c.qr_code_data %>" alt="" width="72" height="72" />
              </td>
              <td class="cell-actions">
                <a class="btn btn-sm btn-ghost" href="/admin/certificates/<%= c.id %>/edit">Bearbeiten</a>
                <a class="btn btn-sm" target="_blank" rel="noopener noreferrer" href="/certificates/<%= c.public_id %>">Anzeigen</a>
              </td>
            </tr>
            <% }) %>
          </tbody>
        </table>
      </div>
      <% } %>
    </section>
  </div>
</main>
<%- include('../partials/foot') %>
