{% set active_page = "workspaces" %}
{% extends "base.html" %}
{% block title %}Workspaces{% endblock %}
{% block content %}
<div class="page-header animate-in">
    <div class="page-title">Workspaces</div>
    <div class="page-subtitle">{{ workspaces|length }} workspace{{ "s" if workspaces|length != 1 else "" }} configured</div>
</div>

{% if workspaces %}
<div class="grid-2 animate-in delay-1">
    {% for ws in workspaces %}
    <div class="card card-glow" style="padding:20px">
        <div class="flex items-center justify-between mb-3">
            <span class="mono text-white" style="font-weight:600;font-size:15px">{{ ws.name }}</span>
            <span class="text-xs text-faint">{{ ws.repo_count }} repo{{ "s" if ws.repo_count != 1 else "" }}</span>
        </div>
        {% if ws.description %}
        <div class="text-sm text-faint mb-3">{{ ws.description }}</div>
        {% endif %}
        {% if ws.repos %}
        <div class="mb-3">
            {% for repo in ws.repos %}
            <div class="flex items-center justify-between" style="padding:4px 0;border-bottom:1px solid var(--border)">
                <span class="mono text-sm">{{ repo.name }}</span>
                <div class="flex items-center" style="gap:12px">
                    <span class="text-xs text-faint">{{ "{:,}".format(repo.files) }} files</span>
                    <span class="text-xs text-accent">{{ "{:,}".format(repo.symbols) }} sym</span>
                </div>
            </div>
            {% endfor %}
        </div>
        {% endif %}
        <div class="flex items-center justify-between">
            <span class="text-xs text-faint">Total: {{ "{:,}".format(ws.total_files) }} files, {{ "{:,}".format(ws.total_symbols) }} symbols</span>
            {% if ws.created_at %}
            <span class="text-xs text-faint">Created {{ ws.created_at[:10] }}</span>
            {% endif %}
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<div class="empty-state animate-in delay-1">
    <div style="font-size:28px;margin-bottom:12px;opacity:0.3">&#9670;</div>
    No workspaces configured<br>
    <span class="text-faint">Use <span class="mono">sylvan workspace create &lt;name&gt;</span> to create one</span>
</div>
{% endif %}
{% endblock %}
