{% load crispy_forms_tags %}
<form
  method="{{ method|default:'post' }}"
  action="{{ action|default:'' }}"
  class="bg-white rounded shadow p-6 space-y-4"
  {% if enctype %}enctype="{{ enctype }}"{% elif form.is_multipart %}enctype="multipart/form-data"{% endif %}
>
  {% if method|default:'post'|lower == 'post' %}{% csrf_token %}{% endif %}

  {% if form.non_field_errors %}
    <div class="error px-3 py-2 rounded mb-3">{{ form.non_field_errors }}</div>
  {% endif %}

  {{ form.media }}
  {{ form|crispy }}

  <div class="flex items-center gap-2">
    <button class="btn">{{ submit_label|default:'Save' }}</button>
    {% if cancel_url %}
      <a href="{{ cancel_url }}" class="btn-outline">Cancel</a>
    {% endif %}
    {% if extra_buttons %}{{ extra_buttons|safe }}{% endif %}
  </div>
</form>
