<div class="modal fade" id="editUserModal" tabindex="-1">
    <div class="modal-dialog">
        <form method="POST" action="handlers/update_user.php" class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Edit User</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <input type="hidden" name="user_id" id="edit_user_id">
                
                <div class="mb-3">
                    <label for="edit_username" class="form-label">Username</label>
                    <input type="text" name="username" id="edit_username" class="form-control" required>
                </div>
                
                <div class="mb-3">
                    <label for="edit_email" class="form-label">Email</label>
                    <input type="email" name="email" id="edit_email" class="form-control" required>
                </div>
                
                <div class="mb-3">
                    <label for="edit_role_id" class="form-label">Role</label>
                    <select name="role_id" id="edit_role_id" class="form-select" required>
                        <option value="">Choose role</option>
                        <?php
                        $roles = $conn->query("SELECT id, name FROM roles ORDER BY name");
                        while ($role = $roles->fetch_assoc()) {
                            echo "<option value='{$role['id']}'>{$role['name']}</option>";
                        }
                        ?>
                    </select>
                </div>
                
                <div class="mb-3">
                    <label for="edit_password" class="form-label">New Password (leave blank to keep current)</label>
                    <input type="password" name="password" id="edit_password" class="form-control" placeholder="Enter new password">
                    <small class="form-text text-muted">Only fill this if you want to change the password</small>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                <button type="submit" class="btn btn-primary">Update User</button>
            </div>
        </form>
    </div>
</div>