(function ($) {
    "use strict";

    // Install + Activate button
    $("#install-activate-button").on("click", function (e) {
        e.preventDefault();

        var button = $(this);
        button.prop("disabled", true)
              .text("Installing & Activating recommended plugins…")
              .addClass("processing-spinner");

        $.post(fitness_cardio_localize.ajax_url, {
            action: "fitness_cardio_install_and_activate_plugins",
            nonce: fitness_cardio_localize.nonce
        }, function (response) {
            if (response.success) {
                window.location.href = fitness_cardio_localize.redirect_url;
            } else {
                button.text(response.data?.message || "Installation failed");
            }
        });
    });

})(jQuery);
