{% comment %}Partial for a single user group card. Rendered by HTMX after archive toggles.{% endcomment %}
<div class="card mb-3" id="group-card-{{ group.pk }}">
  <div class="card-body d-flex justify-content-between align-items-center">
    <div>
      <h5 class="card-title mb-0"><a href="{% url 'generic:user_group_detail' group.pk %}">{{ group.name }}</a></h5>
      {% if group.description %}
        <p class="mb-0 text-muted small">{{ group.description }}</p>
      {% endif %}
    </div>

    <div class="btn-group" role="group" aria-label="Group actions">
      <a class="btn btn-sm btn-outline-primary" href="{% url 'generic:user_group_update' pk=group.pk %}">Edit</a>
      <a class="btn btn-sm btn-outline-danger" href="{% url 'generic:user_group_delete' pk=group.pk %}">Delete</a>

      <form hx-post="{% url 'generic:user_group_toggle_archive' pk=group.pk %}" hx-swap="outerHTML" method="post" class="d-inline-block ms-1">
        {% csrf_token %}
        {% if view_all %}
          <input type="hidden" name="view_all" value="1">
        {% endif %}
        {% if group.archive %}
          <input type="hidden" name="archive" value="false">
          <button class="btn btn-sm btn-outline-success">Unarchive</button>
        {% else %}
          <input type="hidden" name="archive" value="true">
          <button class="btn btn-sm btn-outline-secondary">Archive</button>
        {% endif %}
      </form>
    </div>
  </div>
</div>
