{% extends "base.html" %}
{% block title %}Firewall – Alpine 5G Router{% endblock %}
{% block content %}
<h2>Firewall rules (iptables)</h2>
<p style="color: var(--text-muted); margin: 0 0 1rem;">Rules are stored in SQLite. Add rules below, then click Apply to write /etc/iptables/rules.v4 and run iptables-restore.</p>

<div class="table-wrap">
  <table>
    <thead>
      <tr><th>Table</th><th>Rule</th><th>Enabled</th><th>Actions</th></tr>
    </thead>
    <tbody id="firewallTable"></tbody>
  </table>
</div>

<div class="panel-form" style="margin-top: 1rem;">
  <h3 style="font-size: 0.9375rem; margin: 0 0 0.5rem;">Add rule</h3>
  <div class="form-row">
    <select id="firewallTableName">
      <option value="filter">filter</option>
      <option value="nat">nat</option>
    </select>
    <input type="text" id="firewallRuleLine" placeholder="-A FORWARD -i eth0.100 -o eth1 -j ACCEPT" style="flex: 1; min-width: 200px;">
    <button type="button" class="btn btn-primary" id="firewallAddBtn">Add</button>
  </div>
</div>

<div class="actions" style="margin-top: 1rem;">
  <button type="button" class="btn btn-primary" id="firewallApplyBtn">Apply to system</button>
</div>
<div id="firewallMsg" class="msg"></div>
{% endblock %}
