{% load i18n %}
<ul class="anyllm-chat-list">
  {% for c in chats %}
    <li class="{% if c.pk == chat.pk %}active{% endif %}">
      <a href="{% url 'django_anyllm:chat_detail' c.pk %}">
        <span class="anyllm-chat-title">{{ c.title|default:_("Untitled") }}</span>
        <span class="anyllm-chat-date">{{ c.created_at|date:"M j" }}</span>
      </a>
      <button
        class="anyllm-delete-btn"
        title="{% trans 'Delete chat' %}"
        hx-post="{% url 'django_anyllm:chat_delete' c.pk %}"
        hx-target=".anyllm-chat-list"
        hx-swap="outerHTML"
        hx-confirm="{% trans 'Delete this chat?' %}"
        {% if chat and chat.pk == c.pk %}hx-vals='{"from_chat": "{{ chat.pk }}"}'{% endif %}
      >
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
      </button>
    </li>
  {% empty %}
    <li class="anyllm-chat-empty">{% trans "No chats yet." %}</li>
  {% endfor %}
</ul>
