
    const selectAll = document.getElementById('selectAll');
    const checkboxes = document.querySelectorAll('.permission-checkbox');

    // Klik Select All
    selectAll.addEventListener('change', function () {
        checkboxes.forEach(cb => {
            cb.checked = selectAll.checked;
        });
    });

    // Kalau user uncheck salah satu, Select All ikut mati
    checkboxes.forEach(cb => {
        cb.addEventListener('change', function () {
            const total = checkboxes.length;
            const checked = document.querySelectorAll('.permission-checkbox:checked').length;
            selectAll.checked = total === checked;
        });
    });

