{% extends "base.html" %}
{% import "macros/ui.html" as m %}
{% block title %}{{ ws_name }} — Config{% 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">Config
  <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">
  Infrastructure settings from <code class="font-mono">infra/&lt;env&gt;/settings.ncl</code>.
</p>

{% if not has_root %}
<div class="alert alert-warning mb-4">
  <span>Workspace path not resolved.</span>
</div>
{% endif %}

{% if env_configs %}
  {% for ec in env_configs %}
  <div class="mb-6">
    <h3 class="font-mono font-semibold text-sm mb-2 flex items-center gap-2">
      <svg class="w-3.5 h-3.5 text-primary/70" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
          d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"/>
      </svg>
      {{ ec.env }}
    </h3>
    <div class="bg-base-200 rounded-box border border-base-300">
      <pre class="p-4 text-xs font-mono overflow-x-auto text-base-content/80 whitespace-pre-wrap">{{ ec.config_pretty }}</pre>
    </div>
  </div>
  {% endfor %}
{% elif has_root %}
<div class="alert">
  <span class="text-sm">No infrastructure environments with <code class="font-mono">settings.ncl</code> found.</span>
</div>
{% endif %}
{% endblock %}
