<h2 class="text-sm font-semibold text-base-content/50 uppercase tracking-wider mb-3">Registered Projects</h2>
{% if projects %}
<div class="overflow-x-auto rounded-lg border border-base-content/10">
  <table class="table table-sm w-full">
    <thead>
      <tr class="text-xs text-base-content/40 uppercase tracking-wider">
        <th>Slug</th>
        <th>Root</th>
        <th>Mode</th>
        <th>Auth</th>
        <th>Persisted</th>
        <th class="text-right">Actions</th>
      </tr>
    </thead>
    <tbody>
      {% for p in projects %}
      <tr class="hover:bg-base-200/50">
        <td class="font-mono font-medium">
          {% if not p.push_only %}
          <a href="/ui/{{ p.slug }}/" class="link link-hover text-primary">{{ p.slug }}</a>
          {% else %}
          <span class="text-base-content/60">{{ p.slug }}</span>
          {% endif %}
        </td>
        <td class="font-mono text-xs text-base-content/60 max-w-xs truncate" title="{{ p.root }}">{{ p.root }}</td>
        <td>
          {% if p.opmode == "daemon" %}
          <span class="badge badge-xs badge-success gap-1">
            <span class="w-1 h-1 rounded-full bg-current inline-block"></span>daemon
          </span>
          {% else %}
          <span class="badge badge-xs badge-info">push</span>
          {% endif %}
        </td>
        <td>
          {% if p.auth %}
          <span class="badge badge-xs badge-warning" title="{{ p.roles | join(sep=', ') }}">
            {{ p.key_count }} key{% if p.key_count != 1 %}s{% endif %}
          </span>
          {% else %}
          <span class="badge badge-xs badge-ghost">open</span>
          {% endif %}
        </td>
        <td>
          {% if p.in_projects_ncl %}
          <span class="badge badge-xs badge-ghost text-success">✓</span>
          {% else %}
          <span class="badge badge-xs badge-warning" title="In memory only — will be lost on restart">memory only</span>
          {% endif %}
        </td>
        <td class="text-right">
          <form hx-post="/ui/manage/remove"
                hx-target="#manage-projects-section"
                hx-swap="innerHTML"
                hx-confirm="Remove project {{ p.slug }}?"
                class="inline">
            <input type="hidden" name="slug" value="{{ p.slug }}">
            <button type="submit" class="btn btn-xs btn-error btn-outline">Remove</button>
          </form>
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% else %}
<div class="text-center py-10 text-base-content/30 text-sm border border-base-content/10 rounded-lg">
  No projects registered. Add one below.
</div>
{% endif %}
{% if manage_error %}
<div id="manage-error" hx-swap-oob="true" class="alert alert-error mb-4 text-sm">
  <svg class="w-5 h-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
  </svg>
  <span>{{ manage_error }}</span>
</div>
{% else %}
<div id="manage-error" hx-swap-oob="true"></div>
{% endif %}
