{% extends "base.html" %}
{% block title %}Formations — GMAO{% endblock %}

{% block content %}

<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1><i class="bi bi-mortarboard"></i> Formations</h1>
        {% if current_user.is_admin() %}
        <a href="{{ url_for('trainings.create') }}" class="btn btn-primary"><i class="bi bi-plus-lg"></i> Créer une formation</a>
        {% endif %}
    </div>
    
    <div class="row">
        {% for training in trainings %}
        <div class="col-md-6 col-lg-4 mb-3">
            <div class="card h-100">
                <div class="card-body">
                    <h5 class="card-title">{{ training.name }}</h5>
                    <p class="card-text small text-muted">{{ training.start_date.strftime('%d/%m/%Y') }} - {{ training.end_date.strftime('%d/%m/%Y') }}</p>
                    {% if training.location %}<p class="card-text small"><i class="bi bi-geo-alt"></i> {{ training.location }}</p>{% endif %}
                    {% if training.max_participants %}
                    <p class="card-text small"><i class="bi bi-people"></i> Max: {{ training.max_participants }} participants</p>
                    {% endif %}
                </div>
                <div class="card-footer">
                    <a href="{{ url_for('trainings.detail', id=training.id) }}" class="btn btn-sm btn-primary">Voir détail</a>
                </div>
            </div>
        </div>
        {% else %}
        <p class="text-muted">Aucune formation programmée.</p>
        {% endfor %}
    </div>
</div>

{% endblock %}
