{% extends "ui/templates/base/layout.html" %}
{% block content %}
<div class="space-y-6">
  <div class="flex flex-wrap items-center justify-between gap-3">
    <div>
      <h2 class="text-xl font-semibold text-slate-900">Employee Registration Requests</h2>
      <p class="text-sm text-slate-500">Approve self-service employee profile requests and create linked employee masters.</p>
    </div>
    <a href="/employees" class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Employees</a>
  </div>

  <form method="get" class="rounded-2xl border border-slate-200 bg-white p-4 shadow-soft">
    <div class="flex flex-wrap items-end gap-3">
      <div><label class="mb-1 block text-xs font-semibold uppercase tracking-wide text-slate-500">Status</label><select name="status" class="rounded-xl border border-slate-300 px-3 py-2 text-sm"><option value="all" {% if status == 'all' %}selected{% endif %}>All</option>{% for st in statuses %}<option value="{{ st }}" {% if status == st %}selected{% endif %}>{{ st.title() }}</option>{% endfor %}</select></div>
      <button class="rounded-xl border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Filter</button>
    </div>
  </form>

  <div class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-soft">
    <table class="min-w-full divide-y divide-slate-200 text-sm">
      <thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500"><tr><th class="px-4 py-3">Request</th><th class="px-4 py-3">User</th><th class="px-4 py-3">Role Details</th><th class="px-4 py-3">Status</th><th class="px-4 py-3 text-right">Action</th></tr></thead>
      <tbody class="divide-y divide-slate-100">
        {% for row in rows %}
        <tr class="hover:bg-slate-50">
          <td class="px-4 py-3"><div class="font-semibold text-slate-900">#{{ row.id }} {{ row.full_name }}</div><div class="text-xs text-slate-500">Requested Code: {{ row.requested_employee_code or 'Auto' }} • {{ row.created_at_utc }}</div></td>
          <td class="px-4 py-3 text-slate-600"><div>{{ row.email or '-' }}</div><div class="text-xs">User #{{ row.user_id }}</div></td>
          <td class="px-4 py-3 text-slate-600"><div>{{ row.department or '-' }}</div><div class="text-xs">{{ row.designation or '-' }}</div></td>
          <td class="px-4 py-3"><span class="rounded-full px-2 py-1 text-xs font-semibold {% if row.status == 'pending' %}bg-amber-50 text-amber-700{% elif row.status == 'approved' %}bg-emerald-50 text-emerald-700{% else %}bg-red-50 text-red-700{% endif %}">{{ row.status.title() }}</span></td>
          <td class="px-4 py-3 text-right"><a href="/employees/registration-requests/{{ row.id }}" class="rounded-lg border border-slate-300 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50">Open</a></td>
        </tr>
        {% else %}<tr><td colspan="5" class="px-4 py-8 text-center text-slate-500">No registration requests found.</td></tr>{% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}
