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

{% block heading %}{% if object %}Edit {{ object }}{% else %}New club{% endif %}{% endblock heading %}

{% block panel %}
    <div class="card w-full bg-base-100 shadow">
        <div class="card-body">
            <form method="post" enctype="multipart/form-data">
                {% csrf_token %}

                {% for error in form.non_field_errors %}
                    <div class="alert alert-error my-2">
                        <span>{{ error }}</span>
                    </div>
                {% endfor %}

                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    {% form_field form.name %}
                    {% form_field form.legal_name %}
                    {% form_field form.slug %}
                    {% form_field form.sport_type %}
                </div>

                <div class="divider"></div>

                <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                    {% form_field form.logo %}
                    {% form_field form.primary_color %}
                    {% form_field form.secondary_color %}
                </div>

                <div class="divider"></div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    {% form_field form.season_start %}
                    {% form_field form.season_duration_months %}
                </div>

                <div class="card-actions justify-start pt-2 mt-2">
                    <a class="btn btn-outline gap-2" href="{% if update_view %}{% url "controlpanel:club_detail" object.pk %}{% else %}{% url "controlpanel:club_list" %}{% endif %}">{% lucide "arrow-left" size=16 %} Cancel</a>
                    <button class="btn btn-primary gap-2" type="submit">{% lucide "save" size=16 %} Save</button>
                </div>
            </form>
        </div>
    </div>
{% endblock panel %}
