<section>
  <div class="admin-header">
    <h1>Our Work</h1>
    <a class="button button-primary" href="/admin/work/new">+ New Project</a>
  </div>
  <p class="hint">Each row below is a published case study on the site (zucegroup.com/work/your-slug). Edit one to change its brief, deliverables, gallery and client details.</p>

  <% if (!projects.length) { %>
    <div class="dash-empty-state">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"></rect><path d="M3 9h18"></path><path d="M9 21V9"></path></svg>
      <p>No projects yet.</p>
      <a href="/admin/work/new">Add your first project &rarr;</a>
    </div>
  <% } else { %>
    <table class="admin-table">
      <thead>
        <tr><th>Title</th><th>Client</th><th>Status</th><th>Updated</th><th></th></tr>
      </thead>
      <tbody>
        <% projects.forEach(function(project) { %>
          <tr>
            <td><%= project.title %></td>
            <td><%= project.client || '—' %></td>
            <td><span class="tag"><%= project.status %></span></td>
            <td><%= project.updatedAt.toDateString() %></td>
            <td>
              <a href="/work/<%= project.slug %>" target="_blank" rel="noopener">View</a>
              <a href="/admin/work/<%= project.id %>/edit">Edit</a>
              <form action="/admin/work/<%= project.id %>?_method=DELETE" method="POST" style="display:inline"
                    onsubmit="return confirm('Delete this project?')">
                <button type="submit">Delete</button>
              </form>
            </td>
          </tr>
        <% }) %>
      </tbody>
    </table>
  <% } %>
</section>
