{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h2">Documenti</h1>
    <a href="{% url 'document_upload' %}" class="btn btn-primary">Carica Documento</a>
</div>

<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th scope="col">Nome</th>
                        <th scope="col">Cliente</th>
                        <th scope="col">Data Caricamento</th>
                        <th scope="col"></th>
                    </tr>
                </thead>
                <tbody>
                    {% for document in documents %}
                    <tr>
                        <td>{{ document.name }}</td>
                        <td><a href="{% url 'client_detail' document.client.pk %}">{{ document.client.name }}</a></td>
                        <td>{{ document.created_at|date:"d/m/Y" }}</td>
                        <td>
                            <a href="{% url 'document_detail' document.pk %}" class="btn btn-sm btn-outline-primary">Dettagli</a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="4" class="text-center">Nessun documento trovato.</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}