error, "error");
                        }
                    } catch (e) {
                        // Handle parsing error
                        errorMessage.textContent = "Invalid response format";
                        errorAlert.style.display = 'block';
                        showToast("Invalid response format", "error");
                    }
                } else {
                    // Handle HTTP error
                    errorMessage.textContent = "Server error: " + xhr.status;
            