{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">User Management</h1>
</div>

<div class="table-responsive">
    <table class="table table-striped table-sm">
        <thead>
            <tr>
                <th>ID</th>
                <th>Username</th>
                <th>Role</th>
                <th>Created At</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            {% for user in users %}
            <tr>
                <td>{{ user.id }}</td>
                <td>{{ user.username }}</td>
                <td>
                    {% if user.is_admin %}
                        <span class="badge bg-danger">Admin</span>
                    {% elif user.is_guest %}
                        <span class="badge bg-secondary">Guest</span>
                    {% else %}
                        <span class="badge bg-primary">User</span>
                    {% endif %}
                </td>
                <td>{{ user.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                <td>
                    <button class="btn btn-sm btn-outline-danger" {% if user.id == current_user.id %}disabled{% endif %}>Delete</button>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
