{% extends "base.html" %}

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

{% block content %}
<div class="subpage-shell">
  <div class="container py-5">
    <div class="subpage-header glass-panel mb-4">
      <div>
        <span class="eyebrow">History</span>
        <h1>All momentum entries</h1>
        <p>Filter by category and open any check-in for its confirmation/detail view.</p>
      </div>
      <div class="d-flex flex-wrap gap-2">
        <a class="btn btn-ghost" href="{% url 'home' %}">Back to dashboard</a>
        <a class="btn btn-accent" href="{% url 'home' %}#check-in">New check-in</a>
      </div>
    </div>

    <div class="filter-row mb-4">
      <a class="filter-chip {% if not selected_slug %}active{% endif %}" href="{% url 'entry_list' %}">All categories</a>
      {% for category in categories %}
      <a class="filter-chip {% if selected_slug == category.slug %}active{% endif %}" href="{% url 'entry_list' %}?category={{ category.slug }}">{{ category.name }} · {{ category.entry_total }}</a>
      {% endfor %}
    </div>

    {% if entries %}
    <div class="row g-4">
      {% for entry in entries %}
      <div class="col-lg-4 col-md-6">
        <article class="glass-panel entry-card h-100">
          <div class="entry-card-top">
            <span class="category-badge">{{ entry.category.name }}</span>
            <span class="entry-date">{{ entry.entry_date|date:"M j, Y" }}</span>
          </div>
          <h2 class="h4"><a href="{% url 'entry_detail' entry.pk %}">{{ entry.title }}</a></h2>
          <p>{{ entry.takeaway }}</p>
          <div class="entry-stats">
            <span>Focus {{ entry.focus_score }}/10</span>
            <span>Energy {{ entry.energy_score }}/10</span>
            <span>{{ entry.deep_work_minutes }} min</span>
          </div>
        </article>
      </div>
      {% endfor %}
    </div>
    {% else %}
    <div class="glass-panel empty-state">
      <h2>No entries for this filter</h2>
      <p>Try a different category or create a new check-in from the dashboard.</p>
      <a class="btn btn-accent mt-3" href="{% url 'home' %}#check-in">Create an entry</a>
    </div>
    {% endif %}
  </div>
</div>
{% endblock %}
