{% extends "base.html" %}
{% block title %}Admin — Inquiries{% endblock %}
{% block content %}
<section class="max-w-7xl mx-auto px-6 py-10">
  <h1 class="text-2xl font-bold">Inquiries ({{ total }})</h1>
  <div class="mt-4 overflow-x-auto">
    <table class="min-w-full text-sm">
      <thead class="bg-bh.card/80 border border-bh.ring">
        <tr>
          <th class="p-2 text-left">ID</th>
          <th class="p-2 text-left">Name</th>
          <th class="p-2 text-left">Email</th>
          <th class="p-2 text-left">NDA</th>
          <th class="p-2 text-left">Message</th>
          <th class="p-2 text-left">UA</th>
          <th class="p-2 text-left">IP</th>
          <th class="p-2 text-left">Created</th>
        </tr>
      </thead>
      <tbody>
        {% for r in rows %}
        <tr class="border-b border-bh.ring/50">
          <td class="p-2">{{ r.id }}</td>
          <td class="p-2">{{ r.name }}</td>
          <td class="p-2">{{ r.email }}</td>
          <td class="p-2">{{ r.nda }}</td>
          <td class="p-2">{{ r.message }}</td>
          <td class="p-2">{{ r.meta.ua if r.meta else '' }}</td>
          <td class="p-2">{{ r.meta.ip if r.meta else '' }}</td>
          <td class="p-2 whitespace-nowrap">{{ r.created_at }}</td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <div class="mt-4 flex items-center gap-3">
    {% if page > 1 %}<a class="px-3 py-1 rounded bg-bh.card/80 border border-bh.ring" href="?page={{ page-1 }}">Prev</a>{% endif %}
    <div class="opacity-75">Page {{ page }} / {{ pages }}</div>
    {% if page < pages %}<a class="px-3 py-1 rounded bg-bh.card/80 border border-bh.ring" href="?page={{ page+1 }}">Next</a>{% endif %}
    <a class="ml-auto px-3 py-1 rounded bg-bh-accent/90 text-black font-semibold" href="{{ url_for('admin_inquiries_csv') }}">Export CSV</a>
  </div>
</section>
{% endblock %}

