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

<div class="admin-page-head">
  <div>
    <h2>Founder Applications</h2>
    <p style="color: var(--ink-300);"><%= applications.length %> submissions</p>
  </div>
</div>

<div class="table-wrap">
  <table class="data-table">
    <thead><tr><th>Company</th><th>Founder</th><th>Sector</th><th>Stage</th><th>Raise</th><th>Documents</th><th>Status</th><th>Submitted</th></tr></thead>
    <tbody>
      <% if (!applications.length) { %>
        <tr><td class="empty-row" colspan="8">No applications yet.</td></tr>
      <% } %>
      <% applications.forEach(function(a) { %>
        <tr>
          <td class="cell-title"><%= a.company_name %></td>
          <td class="cell-muted"><%= a.founder_name %><br /><span style="font-size:0.75rem;"><%= a.email %></span></td>
          <td class="cell-muted"><%= a.sector || '—' %></td>
          <td class="cell-muted"><%= a.stage || '—' %></td>
          <td class="cell-muted"><%= a.raise_amount_usd ? '$' + Number(a.raise_amount_usd).toLocaleString() : '—' %></td>
          <td class="cell-muted">
            <% if (a.pitch_deck_path) { %><a href="<%= a.pitch_deck_path %>" target="_blank">Deck</a><% } %>
            <% if (a.financials_path) { %> · <a href="<%= a.financials_path %>" target="_blank">Financials</a><% } %>
            <% if (a.business_plan_path) { %> · <a href="<%= a.business_plan_path %>" target="_blank">Plan</a><% } %>
          </td>
          <td>
            <form action="/admin/applications/founders/<%= a.id %>/status" method="POST" data-status-form>
              <input type="hidden" name="_csrf" value="<%= csrfToken %>" />
              <select name="status" class="status-select">
                <% statuses.forEach(function(s) { %>
                  <option value="<%= s %>" <%= a.status === s ? 'selected' : '' %>><%= s.replace('_', ' ') %></option>
                <% }); %>
              </select>
            </form>
          </td>
          <td class="cell-muted"><%= new Date(a.created_at).toLocaleDateString('en-US') %></td>
        </tr>
      <% }); %>
    </tbody>
  </table>
</div>

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