<%- include('../partials/header', { title }) %>

<div class="admin-page-head">
  <div>
    <h2>Team</h2>
    <p style="color: var(--ink-300);"><%= team.length %> members</p>
  </div>
  <a href="/admin/team/new" class="btn btn-primary btn-sm"><i data-lucide="plus" width="16" height="16"></i> Add Team Member</a>
</div>

<div class="table-wrap">
  <table class="data-table">
    <thead><tr><th>Name</th><th>Title</th><th>Department</th><th>Active</th><th></th></tr></thead>
    <tbody>
      <% if (!team.length) { %>
        <tr><td class="empty-row" colspan="5">No team members yet. <a href="/admin/team/new">Add your first one</a>.</td></tr>
      <% } %>
      <% team.forEach(function(m) { %>
        <tr>
          <td class="cell-title"><%= m.name %></td>
          <td class="cell-muted"><%= m.title %></td>
          <td class="cell-muted"><%= m.department %></td>
          <td><%= m.is_active ? '✓' : '—' %></td>
          <td class="actions">
            <a class="icon-btn" href="/admin/team/<%= m.id %>/edit" title="Edit"><i data-lucide="pencil" width="15" height="15"></i></a>
            <form action="/admin/team/<%= m.id %>/delete" method="POST" style="display:inline;" data-confirm="Remove <%= m.name.replace(/\"/g, '&quot;') %>?">
              <input type="hidden" name="_csrf" value="<%= csrfToken %>" />
              <button class="icon-btn is-danger" type="submit" title="Delete"><i data-lucide="trash-2" width="15" height="15"></i></button>
            </form>
          </td>
        </tr>
      <% }); %>
    </tbody>
  </table>
</div>

<%- include('../partials/footer') %>
