        errorAlert.style.display = 'block';
                    showToast("Server error: " + xhr.status, "error");
                }
            });

            // Handle toggle buttons - using pure JavaScript
            document.querySelectorAll('.toggle-btn').forEach(button => {
                button.addEventListener('click', function() {
                    const agent = this.getAttribute('data-agent');
                    const isActive = this.getAttribute('data-active') === 'true';
                 