{% extends "base.html" %}
{% block title %}Proxy Events{% endblock %}
{% block page_title %}<i class="bi bi-diagram-3-fill me-2"></i>Proxy Events{% endblock %}
{% block content %}
<form method="get" class="row g-2 align-items-end mb-3">
    <div class="col-md-2">
        <select name="type" class="form-select form-select-sm">
            <option value="">All Types</option>
            {% for t in ['login','disconnect','server_switch','command','chat','kick','proxy_start','proxy_stop'] %}
            <option {{ 'selected' if t == event_type }}>{{ t }}</option>
            {% endfor %}
        </select>
    </div>
    <div class="col-md-3">
        <input type="text" name="player" class="form-control form-control-sm" placeholder="Player…" value="{{ player }}">
    </div>
    <div class="col-auto">
        <button class="btn btn-success btn-sm">Filter</button>
        <a href="{{ url_for('panel.proxy') }}" class="btn btn-outline-secondary btn-sm ms-1">Reset</a>
    </div>
</form>
<div class="card">
    <div class="card-header">{{ total }} proxy 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>Player</th><th>Proxy</th><th>From</th><th>To</th><th>IP</th></tr>
            </thead>
            <tbody>
            {% for r in rows %}
            {% set badge = {'login':'success','disconnect':'danger','server_switch':'primary','command':'warning','proxy_start':'info','proxy_stop':'dark'} %}
            <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 class="small fw-semibold">{{ r.player_name or '—' }}</td>
                <td><span class="badge bg-secondary">{{ r.proxy_name or '—' }}</span></td>
                <td class="small">{{ r.from_server or '—' }}</td>
                <td class="small">{{ r.to_server or '—' }}</td>
                <td class="small text-muted">{{ r.ip_address or '—' }}</td>
            </tr>
            {% else %}
            <tr><td colspan="7" class="text-center text-muted py-4">No proxy events</td></tr>
            {% endfor %}
            </tbody>
        </table>
        </div>
    </div>
</div>
{% include "_pagination.html" %}
{% endblock %}
