{% extends "controlpanel/base.html" %}
{% load lucide %}

{% block heading %}{% if show_archived %}Archived clubs{% else %}Clubs{% endif %}{% endblock heading %}

{% block actions %}
    {% if show_archived %}
        <a class="btn btn-ghost" href="{% url 'controlpanel:club_list' %}">Active clubs</a>
    {% else %}
        <a class="btn btn-ghost" href="{% url 'controlpanel:club_list' %}?archived=1">Archived</a>
    {% endif %}
    <a class="btn btn-primary gap-2" href="{% url 'controlpanel:club_create' %}">{% lucide "plus" size=16 %} New club</a>
{% endblock actions %}

{% block panel %}
    <form method="get" class="mb-4 flex gap-2">
        {% if show_archived %}<input type="hidden" name="archived" value="1">{% endif %}
        <input type="search"
               name="q"
               value="{{ search }}"
               placeholder="Search clubs…"
               class="input input-bordered w-full max-w-xs">
        <button class="btn gap-2" type="submit">{% lucide "search" size=16 %} Search</button>
    </form>
    <div class="card bg-base-100 shadow">
        <div class="card-body">
            <div class="overflow-x-auto">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Club</th>
                            <th>Members</th>
                            <th>Teams</th>
                            <th>Events</th>
                            <th>Admins</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for club in clubs %}
                            <tr>
                                <td>
                                    <a class="link link-hover font-medium" href="{% url 'controlpanel:club_detail' club.pk %}">{{ club.name }}</a>
                                    <div class="text-xs opacity-60">{{ club.slug }}</div>
                                </td>
                                <td>{{ club.member_count }}</td>
                                <td>{{ club.team_count }}</td>
                                <td>{{ club.event_count }}</td>
                                <td>{{ club.admin_count }}</td>
                            </tr>
                        {% empty %}
                            <tr>
                                <td colspan="5" class="text-center opacity-60">
                                    {% if show_archived %}No archived clubs.{% else %}No clubs yet.{% endif %}
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock panel %}
