{% extends "management/base.html" %}
{% load i18n lucide %}

{% block heading %}{% trans "Referee levels" %}{% endblock heading %}
{% block subheading %}{% trans "Which teams' home games each level qualifies a referee for." %}{% endblock subheading %}

{% block actions %}
    {% if is_club_admin %}
        <a class="btn btn-outline gap-2" href="{% url 'management:referee_level_create' %}">{% lucide "plus" size=16 %} {% trans "New level" %}</a>
    {% endif %}
{% endblock actions %}

{% block panel %}
    <div class="card bg-base-100 shadow">
        <div class="card-body">
            <div class="overflow-x-auto">
                <table class="table">
                    <thead>
                        <tr>
                            <th>{% trans "Ordering" %}</th>
                            <th>{% trans "Name" %}</th>
                            <th>{% trans "Qualifies for" %}</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for level in levels %}
                            <tr>
                                <td>{{ level.ordering }}</td>
                                <td>{{ level.name }}</td>
                                <td>
                                    {% for team in level.teams.all %}
                                        <span class="badge badge-outline badge-sm">{{ team.name }}</span>
                                    {% empty %}
                                        <span class="opacity-40">—</span>
                                    {% endfor %}
                                </td>
                                <td class="text-right">
                                    {% if is_club_admin %}
                                        <a class="btn btn-outline btn-sm gap-2" href="{% url 'management:referee_level_update' level.pk %}">{% lucide "pencil" size=14 %} {% trans "Edit" %}</a>
                                    {% endif %}
                                </td>
                            </tr>
                        {% empty %}
                            <tr>
                                <td colspan="4" class="text-center opacity-60">{% trans "No referee levels yet." %}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock panel %}
