{{define "policies"}}{{template "base" .}}{{end}}
{{define "title"}}Policy Rules — MCIAS{{end}}
{{define "content"}}
<div class="page-header d-flex align-center justify-between">
  <div>
    <h1>Policy Rules</h1>
    <p class="text-muted text-small">{{len .Rules}} operator rules (built-in defaults not shown)</p>
  </div>
  <button class="btn btn-primary" onclick="document.getElementById('create-form').style.display='block';this.style.display='none'">
    Add Rule
  </button>
</div>

<div id="create-form" class="card mt-2" style="display:none">
  <h2 style="font-size:1rem;font-weight:600;margin-bottom:1rem">Create Policy Rule</h2>
  {{template "policy_form" .}}
</div>

<div class="table-wrapper mt-2">
  <table>
    <thead>
      <tr>
        <th>ID</th>
        <th>Priority</th>
        <th>Description</th>
        <th>Effect</th>
        <th>Enabled</th>
        <th>Updated</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody id="policies-tbody">
      {{range .Rules}}{{template "policy_row" .}}{{end}}
    </tbody>
  </table>
</div>
{{end}}
