{% extends "base.html" %}
{% block title %}Catégories d'équipements — GMAO Collège{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1><i class="bi bi-tags"></i> Catégories d'équipements</h1>
    <a href="{{ url_for('equipments.create_category') }}" class="btn btn-primary"><i class="bi bi-plus-lg"></i> Nouvelle catégorie</a>
</div>

<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover table-sm">
                <thead><tr><th>Nom</th><th>Description</th><th>Équipements</th><th>Lots</th></tr></thead>
                <tbody>
                {% for cat in categories %}
                {% set equip_count = cat.equipments|length %}
                {% set lot_count = cat.lots|length %}
                <tr{% if equip_count == 0 %} class="table-warning"{% endif %}>
                    <td>
                        <a href="{{ url_for('equipments.category_detail', id=cat.id) }}">{{ cat.name }}</a>
                        {% if equip_count == 0 %}<span class="badge bg-warning text-dark ms-1">0</span>{% endif %}
                    </td>
                    <td class="text-muted">{{ cat.description or '—' }}</td>
                    <td><span class="badge {% if equip_count == 0 %}bg-warning text-dark{% else %}bg-secondary{% endif %}">{{ equip_count }}</span></td>
                    <td><span class="badge bg-info">{{ lot_count }}</span></td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}