{% extends "base.html" %}
{% block title %}Types de Salles — 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> Types de Salles</h1>
    <a href="{{ url_for('room_types.new') }}" class="btn btn-primary">
        <i class="bi bi-plus-lg"></i> Nouveau type
    </a>
</div>

{% if room_types %}
<div class="table-responsive">
    <table class="table table-hover" id="tableRoomTypes">
        <thead class="table-light">
            <tr>
                <th>Nom</th>
                <th>Description</th>
                <th>Couleur</th>
                <th>Icône</th>
                <th>Salles</th>
                <th>Enseignement</th>
                <th class="text-end">Actions</th>
            </tr>
        </thead>
        <tbody>
            {% for rt in room_types %}
            <tr>
                <td>
                    <span class="badge" style="background-color: {{ rt.color|hex_color }}; color: {{ rt.color|text_color }};">
                        {% if rt.icon %}<i class="bi bi-{{ rt.icon }}"></i>{% endif %}
                        {{ rt.name }}
                    </span>
                </td>
                <td>{{ rt.description or '-' }}</td>
                <td>
                    <span class="badge" style="background-color: {{ rt.color|hex_color }}; color: {{ rt.color|text_color }};">
                        {{ rt.color or '-' }}
                    </span>
                </td>
                <td>{% if rt.icon %}<i class="bi bi-{{ rt.icon }}"></i> {{ rt.icon }}{% else %}-{% endif %}</td>
                <td>
                    <span class="badge bg-info">{{ rt.rooms|length if rt.rooms else 0 }}</span>
                </td>
                <td>
                    {% if rt.is_teaching %}
                    <span class="badge bg-success"><i class="bi bi-check"></i> Oui</span>
                    {% else %}
                    <span class="badge bg-secondary">Non</span>
                    {% endif %}
                </td>
                <td class="text-end">
                    <a href="{{ url_for('room_types.edit', id=rt.id) }}" class="btn btn-sm btn-outline-primary">
                        <i class="bi bi-pencil"></i>
                    </a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% else %}
<div class="alert alert-info">
    <i class="bi bi-info-circle"></i> Aucun type de salle configuré.
</div>
{% endif %}
{% endblock %}