# templates/document_collections/detail.html
{% extends 'base.html' %}

{% block content %}
<div class="row mb-4">
    <div class="col">
        <h1>{{ collection.name }}</h1>
        <p class="text-muted">{{ collection.description }}</p>
    </div>
    <div class="col-auto">
        <a href="{% url 'chat:session' collection.pk %}" class="btn btn-success">Start Chat</a>
        <a href="{% url 'document_collections:delete' collection.pk %}" class="btn btn-danger">Delete Collection</a>
    </div>
</div>

<div class="card mb-4">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h3 class="mb-0">Documents</h3>
        <a href="{% url 'documents:upload' %}?collection={{ collection.pk }}" class="btn btn-primary">Upload Document</a>
    </div>
    <div class="card-body">
        {% if collection.documents.all %}
            <div class="list-group">
                {% for document in collection.documents.all %}
                    <div class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                        <div>
                            <h5 class="mb-1">{{ document.title }}</h5>
                            <small class="text-muted">Uploaded: {{ document.created_at|date:"M d, Y" }}</small>
                        </div>
                        <div>
                            <a href="{% url 'documents:detail' document.pk %}" class="btn btn-sm btn-info">View</a>
                            <a href="{% url 'documents:delete' document.pk %}" class="btn btn-sm btn-danger">Delete</a>
                        </div>
                    </div>
                {% endfor %}
            </div>
        {% else %}
            <p class="text-center text-muted">No documents in this collection yet.</p>
        {% endif %}
    </div>
</div>
{% endblock %}