{% if results %}
<div class="card shadow mb-4 border-primary">
    <div class="card-header bg-primary text-white py-2">
        <span class="small fw-bold">
            <i class="fas fa-search me-2"></i>Live-Suche: „{{ q }}" – {{ results|length }} Treffer
        </span>
    </div>
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-sm table-hover mb-0">
                <tbody>
                    {% for dok in results %}
                    <tr>
                        <td class="align-middle">
                            <a href="{% url 'stiftung:dms_detail' pk=dok.pk %}" class="text-decoration-none fw-semibold">
                                {% if dok.is_pdf %}<i class="fas fa-file-pdf text-danger me-1"></i>{% else %}<i class="fas fa-file text-muted me-1"></i>{% endif %}
                                {{ dok.titel|truncatechars:60 }}
                            </a>
                            {% if dok.beschreibung %}
                            <div class="small text-muted">{{ dok.beschreibung|truncatechars:80 }}</div>
                            {% endif %}
                        </td>
                        <td class="align-middle">
                            <span class="badge bg-secondary small">{{ dok.get_kontext_display }}</span>
                        </td>
                        <td class="align-middle small text-muted text-nowrap">{{ dok.erstellt_am|date:"d.m.Y" }}</td>
                        <td class="align-middle text-end">
                            <a href="{% url 'stiftung:dms_download' pk=dok.pk %}" class="btn btn-xs btn-outline-success" style="font-size:0.7rem;padding:2px 6px;">
                                <i class="fas fa-download"></i>
                            </a>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endif %}
