/**
 * Review notice — dismiss handler.
 * Dismiss buttons share data-action="dismiss"; clicking any of them hides
 * the notice and posts to admin-ajax.php to persist the preference.
 */
(function () {
    var notice = document.querySelector('.vnx-review-notice');
    if (!notice) return;

    var data = window.VunelixReviewNotice || {};
    if (!data.ajaxUrl || !data.nonce) return;

    notice.addEventListener('click', function (e) {
        var btn = e.target.closest('[data-action="dismiss"]');
        if (!btn) return;

        notice.style.display = 'none';

        var body = 'action=vunelix_dismiss_review&_wpnonce=' + encodeURIComponent(data.nonce);
        var xhr = new XMLHttpRequest();
        xhr.open('POST', data.ajaxUrl);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send(body);
    });
})();
