// Template preview for add_site_user.html
document.getElementById('templateSlug').addEventListener('change', function() {
    var preview = document.getElementById('templatePreview');
    var selected = this.options[this.selectedIndex];
    if (selected.value) {
        preview.querySelector('.desc').textContent = selected.dataset.desc || '';
        preview.querySelector('.fields').textContent = selected.dataset.fields || '';
        preview.classList.add('active');
    } else {
        preview.classList.remove('active');
    }
});
