{% extends "base.html" %}

{% block title %}Default Echo Subscriptions{% endblock %}

{% block content %}
<div class="bbs-header">
    <h1><i class="bi bi-broadcast"></i> Echo Area Subscriptions</h1>
    <p>Toggle which echo areas this BBS receives from the upstream network.</p>
</div>

<form method="post">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
    {% for net in networks %}
    <div class="card mb-3">
        <div class="card-header">
            <strong>{{ net.name }}</strong>
            <small class="text-muted">{{ net.our_address or '' }} → {{ net.binkp_host }}:{{ net.binkp_port }}</small>
        </div>
        <div class="card-body">
            <div class="row">
            {% for area in by_network.get(net.id, []) %}
                <div class="col-md-4 col-lg-3 mb-2">
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" name="area_id"
                               value="{{ area.id }}"
                               id="area_{{ area.id }}"
                               {% if area.is_subscribed %}checked{% endif %}>
                        <label class="form-check-label" for="area_{{ area.id }}">
                            <code>{{ area.tag }}</code>
                            {% if area.total_messages %}
                                <small class="text-muted">({{ area.total_messages }})</small>
                            {% endif %}
                        </label>
                    </div>
                </div>
            {% else %}
                <div class="col-12 text-muted">No areas yet — they'll appear after the first inbound packet.</div>
            {% endfor %}
            </div>
        </div>
    </div>
    {% endfor %}

    <button class="btn btn-primary"><i class="bi bi-check2"></i> Save Subscriptions</button>
</form>
{% endblock %}
