{% comment %}
HTMX partial: user search results for the sharing panel.
   Context:
     users          – list of User objects matching the query
     cid_user_exam  – CidUserExam instance
     q              – search query string
{% endcomment %}
{% if users %}
    <ul class="list-group list-group-flush small border rounded">
        {% for u in users %}
            <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center py-1 px-2">
                <span>
                    {{ u.get_full_name|default:u.username }}
                    {% if u.email %}<span class="text-muted">&lt;{{ u.email }}&gt;</span>{% endif %}
                </span>
                <button class="btn btn-sm btn-outline-primary py-0 px-2"
                        hx-post="{% url 'atlas:collection_exam_sharing_panel' cid_user_exam.pk %}"
                        hx-vals='{"action": "add_user", "user_id": "{{ u.pk }}"}'
                        hx-target="#sharing-panel-{{ cid_user_exam.pk }}"
                        hx-swap="outerHTML">
                    Add
                </button>
            </li>
        {% endfor %}
    </ul>
{% elif q|length >= 2 %}
    <div class="small text-muted fst-italic">No matching users found.</div>
{% else %}
    <div class="small text-muted fst-italic">Please enter at least 2 characters to search.</div>
{% endif %}
