{% extends "base.html" %}
{% block title %}Block-Events{% endblock %}
{% block page_title %}<i class="bi bi-bricks me-2"></i>Block-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 ['break','place','ignite','burn','explode','fade','grow','dispense'] %}
            <option {{ 'selected' if t == event_type }}>{{ t }}</option>
            {% endfor %}
        </select>
    </div>
    <div class="col-md-2">
        <input type="text" name="player" class="form-control form-control-sm" placeholder="Spieler…" value="{{ player }}">
    </div>
    <div class="col-md-2">
        <input type="text" name="block" class="form-control form-control-sm" placeholder="Block-Typ…" value="{{ block }}">
    </div>
    <div class="col-md-2">
        <select name="world" class="form-select form-select-sm">
            <option value="">All Worlds</option>
            {% for w in worlds %}<option {{ 'selected' if w == world }}>{{ w }}</option>{% endfor %}
        </select>
    </div>
    <div class="col-md-2">
        <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-auto">
        <button class="btn btn-success btn-sm">Filter</button>
        <a href="{{ url_for('blocks') }}" class="btn btn-outline-secondary btn-sm ms-1">Reset</a>
    </div>
</form>
<div class="card">
    <div class="card-header">{{ total }} block 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>Block</th><th>World</th><th>Position</th><th>Tool</th><th>Silk</th></tr>
            </thead>
            <tbody>
            {% for r in rows %}
            <tr>
                <td class="small text-muted text-nowrap">{{ r.timestamp | fmt_dt }}</td>
                <td>
                    {% set colors = {'break':'danger','place':'success','ignite':'warning','burn':'orange','explode':'dark'} %}
                    <span class="badge bg-{{ colors.get(r.event_type,'secondary') }}">{{ r.event_type }}</span>
                </td>
                <td class="small">{{ r.player_name or '—' }}</td>
                <td class="small font-monospace">{{ r.block_type }}</td>
                <td><span class="badge bg-secondary">{{ r.world }}</span></td>
                <td class="small text-muted">{{ r.x }}, {{ r.y }}, {{ r.z }}</td>
                <td class="small">{{ r.tool or '—' }}</td>
                <td>{% if r.is_silk %}<i class="bi bi-check-circle-fill text-success"></i>{% else %}—{% endif %}</td>
            </tr>
            {% else %}
            <tr><td colspan="8" class="text-center text-muted py-4">No block events</td></tr>
            {% endfor %}
            </tbody>
        </table>
        </div>
    </div>
</div>
{% include "_pagination.html" %}
{% endblock %}
