{% extends 'base.html' %}
{% load widget_tweaks %}

{% block content %}
<div class="container mt-5">
  <h2>{{ title }}</h2>
  <form method="post" enctype="multipart/form-data" class="card p-4 shadow-sm">
    {% csrf_token %}

    {% if form.non_field_errors %}
    <div class="alert alert-danger">
      {{ form.non_field_errors }}
    </div>
    {% endif %}
    
    <div class="row g-3">
  {% for field in form %}
    {% if field.name == "is_coach" %}
      <div class="col-md-6">
        <div class="form-check mt-2">
          {% render_field field class="form-check-input" id="id_is_coach" %}
          <label class="form-check-label" for="id_is_coach">{{ field.label }}</label>
        </div>
      </div>
    {% elif field.name in coach_fields %}
      <div class="col-md-6 coach-only">
        <label class="form-label">{{ field.label }}</label>
        {% render_field field class="form-control" %}
        {% if field.errors %}
          <div class="text-danger small mt-1">{{ field.errors|striptags }}</div>
        {% endif %}
      </div>
    {% else %}
      <div class="col-md-6">
        <label class="form-label">{{ field.label }}</label>
        {% render_field field class="form-control" %}
        {% if field.errors %}
          <div class="text-danger small mt-1">{{ field.errors|striptags }}</div>
        {% endif %}
      </div>
    {% endif %}
  {% endfor %}
</div>


    <div class="mt-4 text-end">
      <button type="submit" class="btn btn-success px-4">Save</button>
      <a href="{% url 'club_official_list' %}?status=Approved&request_type=official" class="btn btn-secondary ms-2">Cancel</a>
    </div>
  </form>
</div>
{% endblock %}
