{% if results %}
  <div id="resource-search-results" hx-swap-oob="true">
    <ul class="list-unstyled mb-0" id="resource_search_results_list_{{ field }}">
      {% for item in results %}
        <li class="py-1 d-flex justify-content-between align-items-center" data-resource-id="{{ item.id }}">
          <div class="flex-grow-1">
            <a href="{% url 'atlas:resource_detail' item.pk %}" target="_blank">{{ item.name|escape }}</a>
            <div class="small text-muted">{{ item.get_display|safe }}</div>
          </div>
          <div class="d-flex gap-2">
            <button
              type="button"
              class="btn btn-sm btn-success resource-attach-btn"
              hx-post="{% url 'atlas:case_attach_resource' pk=case_id %}"
              hx-vals='{"resource_id": "{{ item.id }}", "pre_review": "0"}'
              hx-swap="outerHTML"
              hx-target="#case-resources-list">
              Attach
            </button>
            <button
              type="button"
              class="btn btn-sm btn-outline-success resource-attach-pre-btn"
              hx-post="{% url 'atlas:case_attach_resource' pk=case_id %}"
              hx-vals='{"resource_id": "{{ item.id }}", "pre_review": "1"}'
              hx-swap="outerHTML"
              hx-target="#case-resources-list">
              Attach (pre)
            </button>
          </div>
        </li>
      {% endfor %}
    </ul>
    <div class="mt-2 text-end">
      <small class="text-muted">{{ results|length }} results</small>
    </div>
  </div>
{% else %}
  <div id="resource-search-results" hx-swap-oob="true"><em>No resources found</em></div>
{% endif %}
