{# partial: list of cases for HTMX search results #}
<div class="list-group">
{% if cases %}
  {% for case in cases %}
    <a href="{% url 'atlas:case_detail' case.pk %}" class="list-group-item list-group-item-action">
      <div class="d-flex w-100 justify-content-between">
        <h6 class="mb-1">{{ case.title }}</h6>
        <small class="text-muted">{{ case.created_date|date:"Y-m-d" }}</small>
      </div>
      <div class="mb-1">
        <small class="text-muted me-2">{% if case.author.all %}By {{ case.author.all|join:", " }}{% endif %}</small>
        {% if case.condition %}<span class="badge bg-secondary me-1">{{ case.condition.name }}</span>{% endif %}
        {% if case.presentation %}<span class="badge bg-secondary me-1">{{ case.presentation.name }}</span>{% endif %}
        {% if case.subspecialty %}<span class="badge bg-secondary">{{ case.subspecialty.name }}</span>{% endif %}
      </div>

      <div class="mb-1">
        {# show up to three series modalities/examinations if present #}
        {% for s in case.series.all|slice:":3" %}
          <span class="badge bg-light text-dark me-1">
            {% if s.modality %}{{ s.modality.modality }}{% endif %}
            {% if s.examination %} / {{ s.examination.examination }}{% endif %}
          </span>
        {% empty %}
          <small class="text-muted">No series</small>
        {% endfor %}
      </div>

      <p class="mb-1 text-truncate">{{ case.description }}</p>
    </a>
  {% endfor %}
{% else %}
  <div class="list-group-item">No cases found</div>
{% endif %}
</div>
