{% extends "base.html" %}
{% block title %}Dashboard{% endblock %}
{% block content %}
<h1>Dashboard</h1>

<div class="stats-grid">
    <div class="stat-card">
        <span class="number">{{ articles_this_week }}</span>
        <span class="label">Articles This Week</span>
    </div>
    <div class="stat-card">
        <span class="number">{{ total_articles }}</span>
        <span class="label">Total Cached</span>
    </div>
    <div class="stat-card">
        <span class="number">{{ total_issues }}</span>
        <span class="label">Issues Published</span>
    </div>
</div>

<hgroup>
    <h3>Scheduler</h3>
    <p>
        Status: <strong>{{ "Enabled" if scheduler_status.running else "Disabled" }}</strong>
        {% if scheduler_status.rss_fetch %}
        &middot; Next fetch: {{ scheduler_status.rss_fetch.next_run }}
        &middot; Interval: {{ scheduler_status.rss_fetch.interval_hours }}h
        {% endif %}
    </p>
</hgroup>

<div class="action-buttons">
    <form method="post" action="/fetch-now">
        <button type="submit">Fetch Now</button>
    </form>
    <a href="/articles" role="button" class="outline">View</a>
    <a href="/publish" role="button" class="outline">Publish New</a>
</div>

{% if latest_issue %}
<h3>Latest Issue</h3>
<p>
    {{ latest_issue.week_start }} – {{ latest_issue.week_end }}
    · <a href="/issues/{{ latest_issue.id }}/download">Download ePub</a>
</p>
{% endif %}
{% endblock %}
