<div class="admin-page">
  <div class="admin-page-head">
    <h1>Membres</h1>
    <form action="/admin/users" method="get" class="search-form">
      <input type="search" name="q" placeholder="Rechercher (nom, email)" value="<%= search %>" />
      <button type="submit" class="btn btn-ghost btn-sm">Rechercher</button>
    </form>
  </div>

  <div class="admin-panel">
    <% if (!users.length) { %>
      <p class="muted">Aucun membre trouvé.</p>
    <% } else { %>
      <div class="table-wrap">
        <table class="data-table">
          <thead>
            <tr>
              <th>Membre</th>
              <th>Email</th>
              <th>Offre active</th>
              <th>Expire le</th>
              <th>État</th>
              <th></th>
            </tr>
          </thead>
          <tbody>
            <% users.forEach(function(u){ %>
              <tr>
                <td>
                  <strong><%= u.name %></strong>
                  <% if (u.role === 'admin') { %><span class="badge-mini badge-admin">Admin</span><% } %>
                </td>
                <td><%= u.email %></td>
                <td>
                  <% if (u.plan_type) { %>
                    <span class="badge-mini badge-on"><%= planLabels[u.plan_type] || u.plan_type %></span>
                  <% } else { %>
                    <span class="muted">—</span>
                  <% } %>
                </td>
                <td><%= u.expires_at ? fmtDate(u.expires_at) : '—' %></td>
                <td>
                  <% if (u.is_blocked) { %>
                    <span class="badge-mini badge-off">Bloqué</span>
                  <% } else { %>
                    <span class="badge-mini badge-on">Actif</span>
                  <% } %>
                </td>
                <td class="actions-cell">
                  <a href="/admin/users/<%= u.id %>" class="btn btn-ghost btn-xs">Gérer</a>
                </td>
              </tr>
            <% }) %>
          </tbody>
        </table>
      </div>
    <% } %>
  </div>
</div>
