{% extends "base.html" %}
{% block title %}{{ 'Nouveau type' if not room_type else 'Modifier: ' + room_type.name }} — GMAO Collège{% endblock %}

{% block content %}
<div class="container-fluid">
    <nav aria-label="breadcrumb" class="mb-3">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ url_for('room_types.index') }}">Types de Salles</a></li>
            <li class="breadcrumb-item active">{{ 'Nouveau type' if not room_type else room_type.name }}</li>
        </ol>
    </nav>

    <div class="card">
        <div class="card-body">
            <form method="POST">
                <div class="mb-3">
                    <label for="name" class="form-label">Nom *</label>
                    <input type="text" class="form-control" id="name" name="name" 
                           value="{{ room_type.name if room_type else '' }}" required>
                </div>

                <div class="mb-3">
                    <label for="description" class="form-label">Description</label>
                    <textarea class="form-control" id="description" name="description" rows="2">{{ room_type.description if room_type else '' }}</textarea>
                </div>

                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="color" class="form-label">Couleur</label>
                        <input type="color" class="form-control form-control-color" id="color" name="color" 
                               value="{{ room_type.color if room_type else '#6c757d' }}">
                    </div>

                    <div class="col-md-6 mb-3">
                        <label for="icon" class="form-label">Icône Bootstrap</label>
                        <input type="text" class="form-control" id="icon" name="icon" 
                               value="{{ room_type.icon if room_type else '' }}" 
                               placeholder="Ex: door-open, building, chalkboard">
                        <small class="text-muted">
                            <a href="https://icons.getbootstrap.com/" target="_blank">Voir les icônes disponibles</a>
                        </small>
                    </div>
                </div>

                <div class="mb-3 form-check">
                    <input type="checkbox" class="form-check-input" id="is_teaching" name="is_teaching" value="1"
                           {% if room_type and room_type.is_teaching %}checked{% endif %}>
                    <label for="is_teaching" class="form-check-label">
                        Salle d'enseignement (synchronisée avec PRONOTE)
                    </label>
                </div>

                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-check-lg"></i> Enregistrer
                    </button>
                    <a href="{{ url_for('room_types.index') }}" class="btn btn-outline-secondary">
                        Annuler
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}