<section class="project-form-shell">
  <div class="admin-header">
    <h1>
      <%= message.subject || 'Message from ' + message.name %>
      <% if (message.status === 'spam') { %> <span class="tag" style="font-size:0.65rem; vertical-align:middle; background:#fee2e2; color:#991b1b;">Spam</span><% } %>
    </h1>
    <a class="button button-secondary" href="/admin/messages">Back to Messages</a>
  </div>

  <% if (message.status === 'spam') { %>
    <p class="flash flash-error">This submission was automatically flagged as spam (honeypot, too-fast submit, or too many from the same IP) and no notification email was sent for it.</p>
  <% } %>

  <div class="form-section">
    <p class="admin-table-meta">
      From <strong><%= message.name %></strong>
      <% if (message.email) { %> &middot; <a href="mailto:<%= message.email %>"><%= message.email %></a><% } %>
      <% if (message.phone) { %> &middot; <a href="tel:<%= message.phone.replace(/\s+/g, '') %>"><%= message.phone %></a><% } %>
      &middot; <%= message.createdAt.toLocaleString('en-GB') %>
      <% if (message.ipAddress) { %> &middot; IP: <%= message.ipAddress %><% } %>
    </p>
    <% if (message.serviceInterest) { %>
      <p class="admin-table-meta" style="margin-top: 0.4rem;">Service interest: <strong><%= message.serviceInterest %></strong></p>
    <% } %>
    <p style="white-space: pre-wrap; margin-top: 1.25rem;"><%= message.message || '(no message body)' %></p>
  </div>

  <div class="reorder-actions" style="display:flex; gap:0.75rem; flex-wrap:wrap;">
    <% if (message.status === 'spam') { %>
      <form action="/admin/messages/<%= message.id %>/mark-not-spam" method="POST">
        <button type="submit" class="button button-secondary">Not spam, restore to inbox</button>
      </form>
    <% } else { %>
      <form action="/admin/messages/<%= message.id %>/mark-spam" method="POST">
        <button type="submit" class="button-ghost">Mark as spam</button>
      </form>
    <% } %>
    <form action="/admin/messages/<%= message.id %>?_method=DELETE" method="POST" onsubmit="return confirm('Delete this message?')">
      <button type="submit" class="button-ghost">Delete this message</button>
    </form>
  </div>
</section>
