<!-- Modal Create/Edit Echelle -->
<div class="modal-overlay">
    <div class="modal-content" style="max-width: 600px;">
        <div class="modal-header">
            <h2 id="modalTitle">Nouvelle Échelle</h2>
            <button type="button" class="modal-close" onclick="closeModal()">&times;</button>
        </div>
        <div class="modal-body">
            <form id="echelleForm">
                <input type="hidden" id="echelleId" value="">

                <div class="form-group">
                    <label for="grade_id">Grade <span class="required">*</span></label>
                    <select id="grade_id" name="grade_id" required onchange="onGradeChange()">
                        <option value="">Sélectionner un grade</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: Échelle 10" required
                           oninput="onLibelleEchelleChange()">
                </div>

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

                <div class="form-row">
                    <div class="form-group" style="flex:1;margin-right:10px;">
                        <label for="echellon_depart">Échelon Départ <span class="required">*</span></label>
                        <input type="number" id="echellon_depart" name="echellon_depart" min="1" max="20" placeholder="1" required>
                    </div>
                    <div class="form-group" style="flex:1;">
                        <label for="echellon_fin">Échelon Fin <span class="required">*</span></label>
                        <input type="number" id="echellon_fin" name="echellon_fin" min="1" max="20" placeholder="10" required>
                    </div>
                </div>

                <div class="form-group">
                    <label for="description">Description</label>
                    <textarea id="description" name="description" rows="3" placeholder="Description de l'échelle..."></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="saveEchelle()">
                        <i class="fas fa-save"></i> Enregistrer
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>