{% extends "base.html" %}

{% block title %}Tagline Pool{% endblock %}

{% block content %}
<div class="bbs-header">
    <h1><i class="bi bi-chat-quote"></i> Tagline Pool</h1>
    <p>Shared random-tagline pool — anyone composing a message (local boards,
       private messages, netmail, echomail, terminal or web) can opt in to
       append one random active entry. Distinct from a user's own fixed
       profile tagline (Profile &gt; Edit), which is unrelated and always
       appended automatically for netmail/echomail.</p>
</div>

<form method="post" class="card mb-3">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
    <input type="hidden" name="action" value="add">
    <div class="card-body">
        <div class="row g-2 align-items-end">
            <div class="col-md-10">
                <label class="form-label">Tagline text</label>
                <input type="text" name="text" class="form-control" required maxlength="200">
            </div>
            <div class="col-md-2">
                <button class="btn btn-primary w-100">Add</button>
            </div>
        </div>
    </div>
</form>

<div class="card">
    <div class="card-body p-0">
    {% if taglines %}
        <table class="table table-sm mb-0">
            <thead><tr><th>On</th><th>Text</th><th>Added</th><th></th></tr></thead>
            <tbody>
            {% for t in taglines %}
                <tr {% if not t.is_active %}class="text-muted"{% endif %}>
                    <td>{% if t.is_active %}<span class="badge bg-success">on</span>{% else %}<span class="badge bg-secondary">off</span>{% endif %}</td>
                    <td>{{ t.text }}</td>
                    <td><small>{{ t.created_at|eastern('%Y-%m-%d') }}</small></td>
                    <td>
                        <form method="post" style="display:inline;">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                            <input type="hidden" name="action" value="toggle">
                            <input type="hidden" name="tagline_id" value="{{ t.id }}">
                            <button class="btn btn-link btn-sm p-0 me-2">{{ 'pause' if t.is_active else 'enable' }}</button>
                        </form>
                        <form method="post" style="display:inline;">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                            <input type="hidden" name="action" value="delete">
                            <input type="hidden" name="tagline_id" value="{{ t.id }}">
                            <button class="btn btn-link btn-sm text-danger p-0">delete</button>
                        </form>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% else %}<div class="p-3 text-muted">No taglines yet — add one above.</div>{% endif %}
    </div>
</div>
{% endblock %}
