<div class="modal-overlay" id="candidatModal">
    <!-- الـ modal هو الحاوية الرئيسية -->
    <div class="modal-content">

        <div class="modal-header">
            <h2 id="modalTitle">Modifier Candidat</h2>
            <button class="modal-close" onclick="closeModal()">&times;</button>
        </div>

        <div class="modal-body">
            <form id="candidatForm">
                <input type="hidden" id="candidatId">

                <h3>Informations Personnelles</h3>
                <div class="form-row">
                    <div class="form-group">
                        <label for="nom">Nom *</label>
                        <input type="text" id="nom" required>
                    </div>
                    <div class="form-group">
                        <label for="prenom">Prénom *</label>
                        <input type="text" id="prenom" required>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group">
                        <label for="cin">CIN *</label>
                        <input type="text" id="cin" required>
                    </div>
                    <div class="form-group">
                        <label for="phone">Téléphone</label>
                        <input type="text" id="phone">
                    </div>
                </div>

                <h3>Informations de Connexion</h3>
                <div class="form-group">
                    <label for="email">Email *</label>
                    <input type="email" id="email" name="email" required>
                </div>

                <div class="form-group password-field">
                    <label for="current_password">Mot de passe actuel</label>
                    <div class="input-wrapper" style="display: flex; align-items: center; gap: 5px;">
                        <input type="password" id="current_password" name="current_password" placeholder="********">
                        <i class="fas fa-eye toggle-password" onclick="togglePassword('current_password')"></i>
                        <button type="button" class="btn btn-sm btn-outline" onclick="enablePasswordChange()" title="Modifier le mot de passe">
                            <i class="fas fa-key"></i>
                        </button>
                    </div>
                </div>

                <div class="form-row">
                    <div class="form-group password-field">
                        <label for="new_password">Nouveau mot de passe</label>
                        <div class="input-wrapper">
                            <input type="password" id="new_password" name="new_password">
                            <i class="fas fa-eye toggle-password" onclick="togglePassword('new_password')"></i>
                        </div>
                    </div>
                    <div class="form-group password-field">
                        <label for="confirm_password">Confirmer nouveau mot de passe</label>
                        <div class="input-wrapper">
                            <input type="password" id="confirm_password" name="confirm_password">
                            <i class="fas fa-eye toggle-password" onclick="togglePassword('confirm_password')"></i>
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <!-- الـ footer موجود الآن داخل الـ modal-content وسيظهر في الأسفل -->
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" onclick="closeModal()">Annuler</button>
            <button type="button" class="btn btn-primary" onclick="saveCandidat()">💾 Enregistrer</button>
        </div>
    </div>
</div>