{% set active_page = "extensions" %}
{% extends "base.html" %}
{% block title %}Extensions{% endblock %}
{% block content %}
<div class="page-header animate-in">
    <div class="page-title">Extensions</div>
    <div class="page-subtitle">
        {% if enabled %}
            {{ loaded_count }} extension{{ "s" if loaded_count != 1 else "" }} loaded from {{ extensions_path }}
        {% else %}
            Extensions are disabled in config
        {% endif %}
    </div>
</div>

{% if not enabled %}
<div class="empty-state animate-in delay-1">
    <div style="font-size:28px;margin-bottom:12px;opacity:0.3">&#9670;</div>
    Extensions disabled<br>
    <span class="text-faint">Set <span class="mono">extensions.enabled: true</span> in config.yaml</span>
</div>
{% elif tools or languages or parsers or providers %}
<div class="animate-in delay-1">
    {% if tools %}
    <div class="section-header">Custom Tools ({{ tools|length }})</div>
    <div class="table-wrap mb-6">
        <table>
            <thead><tr>
                <th>Name</th>
                <th>Description</th>
            </tr></thead>
            <tbody>
                {% for tool in tools %}
                <tr>
                    <td><span class="mono text-accent">{{ tool.name }}</span></td>
                    <td class="text-faint text-sm">{{ tool.description|truncate(100) }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% endif %}

    {% if languages %}
    <div class="section-header">Custom Languages ({{ languages|length }})</div>
    <div class="grid-4 mb-6">
        {% for lang in languages %}
        <div class="card" style="padding:12px">
            <span class="mono text-sm text-white">{{ lang.name }}</span>
            <div class="text-xs text-faint mt-1">{{ lang.extensions|join(", ") }}</div>
        </div>
        {% endfor %}
    </div>
    {% endif %}

    {% if parsers %}
    <div class="section-header">Custom Parsers ({{ parsers|length }})</div>
    <div class="grid-4 mb-6">
        {% for parser in parsers %}
        <div class="card" style="padding:12px">
            <span class="mono text-sm text-white">{{ parser }}</span>
        </div>
        {% endfor %}
    </div>
    {% endif %}

    {% if providers %}
    <div class="section-header">Custom Providers ({{ providers|length }})</div>
    <div class="grid-4 mb-6">
        {% for prov in providers %}
        <div class="card" style="padding:12px">
            <span class="mono text-sm text-white">{{ prov }}</span>
        </div>
        {% endfor %}
    </div>
    {% endif %}
</div>
{% else %}
<div class="empty-state animate-in delay-1">
    <div style="font-size:28px;margin-bottom:12px;opacity:0.3">&#9670;</div>
    No extensions loaded<br>
    <span class="text-faint">Add Python files to <span class="mono">~/.sylvan/extensions/</span> subdirectories</span>
</div>
{% endif %}
{% endblock %}
