{% extends "base.html" %}

{% set active_tab = '' %}

{% block title %}{{ title }} - History{% endblock %}

{% block content_class %}reading{% endblock %}

{% block actions %}
<a href="/wiki/{{ slug }}" class="topbar-btn">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
        <path d="M19 12H5M12 19l-7-7 7-7"/>
    </svg>
</a>
{% endblock %}

{% block content %}
<div class="history-page">
    <div class="page-header">
        <h2>Version History</h2>
        <p>{{ title }} · {{ versions | length }} version{{ 's' if versions | length != 1 }}</p>
    </div>

    {% if not versions %}
    <div class="empty-state">
        <svg class="empty-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
            <circle cx="12" cy="12" r="10"/>
            <polyline points="12 6 12 12 16 14"/>
        </svg>
        <h3>No versions yet</h3>
        <p>Versions are automatically saved when you edit a page.</p>
        <a href="/wiki/{{ slug }}" class="btn">Back to Page</a>
    </div>
    {% else %}
    <div class="version-list">
        {% for v in versions %}
        <div class="version-item">
            <div class="version-info">
                <span class="version-date">{{ v.date }}</span>
                <span class="version-size">{{ v.size }} bytes</span>
            </div>
            <form method="POST" action="/wiki/{{ slug }}/restore"
                  onsubmit="return confirm('Restore this version? Current content will be saved.');"
                  class="version-restore">
                <input type="hidden" name="timestamp" value="{{ v.timestamp }}">
                <button type="submit" class="btn">Restore</button>
            </form>
        </div>
        {% endfor %}
    </div>
    {% endif %}
</div>
{% endblock %}