<!-- Modal Create/Edit Filiere -->
<div class="modal-overlay">
    <div class="modal-content" style="max-width: 600px;">
        <div class="modal-header">
            <h2 id="modalTitle">Nouvelle Filière</h2>
            <button type="button" class="modal-close" onclick="closeModal()">&times;</button>
        </div>
        <div class="modal-body">
            <form id="filiereForm">
                <input type="hidden" id="filiereId" value="">

                <div class="form-group">
                    <label for="departement_id">Département <span class="required">*</span></label>
                    <select id="departement_id" name="departement_id" required onchange="onDepartementChange()">
                        <option value="">Sélectionner un département</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="libelle">Libellé <span class="required">*</span></label>
                    <input type="text" id="libelle" name="libelle"
                           placeholder="Ex: Génie Informatique" required
                           oninput="onLibelleChange()">
                </div>

                <div class="form-group">
                    <label for="code">Code <span class="required">*</span></label>
                    <input type="text" id="code" name="code"
                           placeholder="Ex: GI" required>
                    <small class="form-text">Généré automatiquement — modifiable</small>
                </div>

                <div class="form-group">
                    <label for="description">Description</label>
                    <textarea id="description" name="description"
                              rows="3" placeholder="Description de la filière..."></textarea>
                </div>

                <div class="form-actions" style="grid-column:span 2;display:flex;flex-direction:row;justify-content:flex-end;gap:10px;">
                    <button type="button" class="btn btn-secondary" onclick="closeModal()">
                        <i class="fas fa-times"></i> Annuler
                    </button>
                    <button type="button" class="btn btn-primary" onclick="saveFiliere()">
                        <i class="fas fa-save"></i> Enregistrer
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>