{% extends "base.html" %}
{% block title %}Server Events{% endblock %}
{% block page_title %}<i class="bi bi-server me-2"></i>Server Events{% endblock %}
{% block content %}
<form method="get" class="row g-2 align-items-end mb-3">
    <div class="col-md-3">
        <select name="server" class="form-select form-select-sm">
            <option value="">All Servers</option>
            {% for s in servers %}<option {{ 'selected' if s == server }}>{{ s }}</option>{% endfor %}
        </select>
    </div>
    <div class="col-md-3">
        <select name="type" class="form-select form-select-sm">
            <option value="">All Types</option>
            {% for t in etypes %}<option {{ 'selected' if t == etype }}>{{ t }}</option>{% endfor %}
        </select>
    </div>
    <div class="col-auto">
        <button class="btn btn-success btn-sm">Filter</button>
        <a href="{{ url_for('panel.server_events') }}" class="btn btn-outline-secondary btn-sm ms-1">Reset</a>
    </div>
</form>
<div class="card">
    <div class="card-header">{{ total }} server events</div>
    <div class="card-body p-0">
        <div class="table-responsive">
        <table class="table table-sm table-hover mb-0">
            <thead class="table-dark">
                <tr><th>Time</th><th>Type</th><th>Server</th><th>Message</th></tr>
            </thead>
            <tbody>
            {% for r in rows %}
            {% set badge = {'server_start':'success','server_stop':'danger','player_join':'info','player_quit':'secondary','player_kick':'warning'} %}
            <tr>
                <td class="small text-muted text-nowrap">{{ r.timestamp | fmt_dt }}</td>
                <td><span class="badge bg-{{ badge.get(r.event_type,'secondary') }}">{{ r.event_type }}</span></td>
                <td><span class="badge bg-dark">{{ r.server_name or '—' }}</span></td>
                <td class="small">{{ r.message or '—' }}</td>
            </tr>
            {% else %}
            <tr><td colspan="4" class="text-center text-muted py-4">No events</td></tr>
            {% endfor %}
            </tbody>
        </table>
        </div>
    </div>
</div>
{% include "_pagination.html" %}
{% endblock %}
