{% extends "base.html" %}
{% import "macros/ui.html" as m %}
{% block title %}{{ ws_name }} — Notifications{% endblock %}
{% block nav_workspaces %}btn-active{% endblock %}

{% block content %}
{{ m::ws_tabs(ws_name=ws_name, active=ws_active_tab, ws_envs=ws_envs, ws_has_clusters=ws_has_clusters, ws_has_workflows=ws_has_workflows, current_env=current_env) }}

<h2 class="text-xl font-bold font-mono mb-1">Notifications
  <span class="text-base-content/30 font-normal text-sm ml-2">{{ ws_name }}</span>
</h2>
<p class="text-base-content/50 text-sm mb-6">
  Recent audit log entries from the orchestrator.
</p>

{% if audit and audit.items %}
<div class="overflow-x-auto">
  <table class="table table-sm w-full font-mono text-xs">
    <thead>
      <tr>
        <th>Time</th>
        <th>User</th>
        <th>Action</th>
        <th>Resource</th>
        <th>Outcome</th>
      </tr>
    </thead>
    <tbody>
      {% for entry in audit.items %}
      <tr class="hover">
        <td class="text-base-content/40">{{ entry.timestamp | default(value="—") }}</td>
        <td>{{ entry.user_id | default(value="—") }}</td>
        <td>{{ entry.action | default(value="—") }}</td>
        <td class="text-base-content/60">{{ entry.resource | default(value="—") }}</td>
        <td>
          {% if entry.outcome and entry.outcome.status == "ok" %}
            {{ m::outcome_badge(record=entry) }}
          {% elif entry.outcome %}
            {{ m::outcome_badge(record=entry) }}
          {% else %}
            <span class="text-base-content/30">—</span>
          {% endif %}
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% else %}
<div class="alert">
  <span class="text-sm">No recent audit entries found.</span>
</div>
{% endif %}
{% endblock %}
