<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ 'Processing payment'|trans({}, 'Modules.Payserapayments.Global') }}</title>
    <style>
        body {
            margin: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            background: #f7f7f7;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        }

        .paysera-popup-loader {
            text-align: center;
            color: #555;
        }

        .paysera-popup-loader__spinner {
            width: 40px;
            height: 40px;
            margin: 0 auto 16px;
            border: 3px solid #e0e0e0;
            border-top-color: #23B9D7;
            border-radius: 50%;
            animation: paysera-spin 0.8s linear infinite;
        }

        @keyframes paysera-spin {
            to { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <div class="paysera-popup-loader">
        <div class="paysera-popup-loader__spinner"></div>
        <p>{{ 'Processing payment'|trans({}, 'Modules.Payserapayments.Global') }}</p>
    </div>

    <script>
        (function () {
            var url = {{ redirectUrl|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }};

            try {
                localStorage.removeItem('paysera_popup_active');
                localStorage.setItem('paysera_payment_result', JSON.stringify({
                    redirectUrl: url,
                    timestamp: Date.now()
                }));
            } catch (e) {}

            if (window.opener) {
                try {
                    window.opener.postMessage({
                        type: 'paysera_payment_complete',
                        redirectUrl: url
                    }, {{ parentOrigin|json_encode(constant('JSON_HEX_TAG'))|raw }});
                } catch (e) {}
            }

            window.close();

            if (!window.closed) {
                window.location.href = url;
            }
        })();
    </script>
</body>
</html>
