{% extends "base.html" %}
{% import "macros/ui.html" as m %}
{% block title %}{{ ws_name }} — Modes{% 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">Reflection Modes
  <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">
  Structured sessions against <code class="font-mono">{{ ws_name }}</code>.
  Each mode executes <code class="font-mono">provisioning run &lt;mode-id&gt;</code> from the workspace root.
</p>

{% if not has_root %}
<div class="alert alert-warning mb-6">
  <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
      d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-2.194-.833-2.964 0L3.232 16.5c-.77.833.192 2.5 1.732 2.5z"/>
  </svg>
  <span>Workspace path not resolved — cannot discover reflection modes.</span>
</div>
{% endif %}

{% if modes %}
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3">
  {% for mode in modes %}
  <div class="card bg-base-200 shadow">
    <div class="card-body p-4">
      <div class="flex items-start justify-between gap-2">
        <span class="font-mono text-sm font-semibold text-primary">{{ mode.id }}</span>
      </div>
      <p class="text-xs text-base-content/40 font-mono truncate mt-1">{{ mode.path }}</p>
      {% if can_operate %}
      <form action="/ui/modes/run" method="post" class="mt-3">
        <input type="hidden" name="mode_id" value="{{ mode.id }}">
        <button type="submit" class="btn btn-xs btn-outline btn-primary w-full">▶ Run</button>
      </form>
      {% else %}
      <div class="mt-3">
        <span class="btn btn-xs btn-disabled w-full cursor-not-allowed opacity-40" title="Requires operator role">▶ Run</span>
      </div>
      {% endif %}
    </div>
  </div>
  {% endfor %}
</div>
{% elif has_root %}
<div class="alert">
  <span class="text-sm">No reflection modes found in <code class="font-mono">reflection/modes/</code>.</span>
</div>
{% endif %}
{% endblock %}
