{% extends "base.html" %}
{% block title %}Memories — MemoTrail{% endblock %}
{% block content %}
<h1>Memories ({{ memories|length }})</h1>

<article>
    <header>Add Memory</header>
    <form method="post" action="/memories/add">
        <label for="content">Content</label>
        <textarea id="content" name="content" placeholder="Enter a fact, decision, or note to remember..." required></textarea>
        <label for="tags">Tags (comma-separated)</label>
        <input type="text" id="tags" name="tags" placeholder="e.g., database, architecture">
        <button type="submit">Save Memory</button>
    </form>
</article>

{% for m in memories %}
<article>
    <header>
        <strong>{{ m.id }}</strong>
        <small>Updated: {{ m.updated_at[:16] }}</small>
    </header>
    <p>{{ m.content }}</p>
    {% if m.tags %}
    <p><small>Tags: {{ m.tags | join(', ') }}</small></p>
    {% endif %}
    <footer>
        <button class="outline secondary" hx-delete="/memories/{{ m.id }}" hx-target="body"
                hx-confirm="Delete this memory?">Delete</button>
    </footer>
</article>
{% endfor %}

{% if not memories %}
<p>No memories saved yet. Add one above!</p>
{% endif %}
{% endblock %}
