{% extends "base.html" %}

{% block title %}Registration Attempts - Admin{% endblock %}

{% block content %}
<div class="bbs-header">
    <h1><i class="bi bi-shield-exclamation"></i> Registration Attempts</h1>
    <p>Successful and failed signup attempts (rate-limited per IP).</p>
</div>

<div class="card">
    <div class="card-body p-0">
        <table class="table table-sm table-striped mb-0">
            <thead><tr>
                <th>When</th><th>IP</th><th>Username</th><th>Status</th><th>Reason</th>
            </tr></thead>
            <tbody>
            {% for a in pagination.items %}
                <tr>
                    <td><code>{{ a.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</code></td>
                    <td><code>{{ a.ip_address }}</code></td>
                    <td>{{ a.username_attempted or '—' }}</td>
                    <td>
                        {% if a.success %}
                            <span class="badge bg-success">success</span>
                        {% else %}
                            <span class="badge bg-danger">failed</span>
                        {% endif %}
                    </td>
                    <td>{{ a.error_reason or '' }}</td>
                </tr>
            {% else %}
                <tr><td colspan="5" class="text-muted text-center p-3">No registration attempts yet.</td></tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>

{% if pagination.pages > 1 %}
<nav class="mt-3">
    <ul class="pagination">
        {% if pagination.has_prev %}<li class="page-item"><a class="page-link" href="?page={{ pagination.prev_num }}">Prev</a></li>{% endif %}
        <li class="page-item disabled"><span class="page-link">{{ pagination.page }}/{{ pagination.pages }}</span></li>
        {% if pagination.has_next %}<li class="page-item"><a class="page-link" href="?page={{ pagination.next_num }}">Next</a></li>{% endif %}
    </ul>
</nav>
{% endif %}
{% endblock %}
