{% extends "base.html" %}

{% block title %}{{ page_title }}{% endblock %}

{% block meta %}
<meta name="description" content="{{ page_description }}">
<meta property="og:description" content="{{ page_description }}">
<meta property="twitter:description" content="{{ page_description }}">
{% endblock %}

{% block content %}
<div class="container py-4 py-lg-5">
  <div class="app-shell">
    <nav class="app-nav d-flex flex-column flex-md-row align-items-md-center justify-content-between gap-3">
      <div class="brand-mark">
        <span class="brand-dot"></span>
        HTML Bundle to PDF
      </div>
      <div class="d-flex flex-wrap align-items-center gap-2">
        <a class="ghost-btn" href="{% url 'home' %}">Home</a>
        <a class="ghost-btn" href="/admin/">Admin</a>
      </div>
    </nav>
    <div class="p-4">
      <div class="d-flex flex-column flex-lg-row justify-content-between align-items-lg-center gap-3 mb-4">
        <div>
          <h1 class="mb-1">All bundles</h1>
          <p class="muted-text mb-0">Review and re-download any previously generated bundle.</p>
        </div>
        <a class="primary-btn" href="{% url 'home' %}#upload">Create new bundle</a>
      </div>

      {% if bundles %}
      <div class="row g-3">
        {% for bundle in bundles %}
        <div class="col-lg-6">
          <div class="list-card h-100">
            <div class="d-flex justify-content-between align-items-start gap-2">
              <div>
                <h3 class="h5 mb-1">{{ bundle.title|default:"Untitled bundle" }}</h3>
                <div class="small muted-text">{{ bundle.created_at|date:"M d, Y · H:i" }}</div>
                <div class="small muted-text">{{ bundle.documents.count }} HTML files</div>
              </div>
              <a class="ghost-btn" href="{% url 'bundle_detail' bundle.id %}">Open</a>
            </div>
          </div>
        </div>
        {% endfor %}
      </div>
      {% else %}
      <div class="list-card">
        <p class="muted-text mb-0">No bundles yet. Upload HTML files to create your first bundle.</p>
      </div>
      {% endif %}
    </div>
  </div>
  <div class="app-footer text-center mt-4">Need a quick export? Create a new bundle from the home page.</div>
</div>
{% endblock %}
