<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Secure Payment Redirection | American Plastics</title>
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap" rel="stylesheet">
    <!-- FontAwesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <style>
        :root {
            --primary-color: #85c226;
            --primary-hover: #72a61e;
            --bg-color: #0b0f19;
            --card-bg: rgba(255, 255, 255, 0.03);
            --text-color: #f3f4f6;
            --text-muted: #9ca3af;
            --border-color: rgba(255, 255, 255, 0.08);
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Outfit', sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            position: relative;
        }

        /* Abstract Background Elements */
        .bg-glow-1 {
            position: absolute;
            width: 400px;
            height: 400px;
            background: radial-gradient(circle, rgba(133, 194, 38, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
            top: -100px;
            left: -100px;
            z-index: 1;
        }

        .bg-glow-2 {
            position: absolute;
            width: 500px;
            height: 500px;
            background: radial-gradient(circle, rgba(133, 194, 38, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
            bottom: -150px;
            right: -150px;
            z-index: 1;
        }

        .payment-container {
            position: relative;
            z-index: 10;
            width: 100%;
            max-width: 480px;
            padding: 40px 30px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 24px;
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
            text-align: center;
            animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }

        @keyframes fadeInScale {
            0% {
                opacity: 0;
                transform: scale(0.95) translateY(10px);
            }

            100% {
                opacity: 1;
                transform: scale(1) translateY(0);
            }
        }

        .logo-section {
            margin-bottom: 30px;
        }

        .logo-icon {
            font-size: 3rem;
            color: var(--primary-color);
            margin-bottom: 10px;
            animation: pulse 2s infinite ease-in-out;
        }

        @keyframes pulse {

            0%,
            100% {
                transform: scale(1);
                opacity: 1;
            }

            50% {
                transform: scale(1.08);
                opacity: 0.8;
            }
        }

        .loader-wrapper {
            margin: 40px auto;
            position: relative;
            width: 90px;
            height: 90px;
        }

        .spinner {
            width: 100%;
            height: 100%;
            border: 4px solid rgba(133, 194, 38, 0.1);
            border-top: 4px solid var(--primary-color);
            border-radius: 50%;
            animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
        }

        .lock-icon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 1.5rem;
            color: var(--primary-color);
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        @keyframes pulse-opacity {

            0%,
            100% {
                opacity: 0.4;
            }

            50% {
                opacity: 1;
            }
        }

        h1 {
            font-size: 1.6rem;
            font-weight: 600;
            margin-bottom: 12px;
            letter-spacing: -0.5px;
        }

        p {
            font-size: 0.95rem;
            color: var(--text-muted);
            line-height: 1.6;
            margin-bottom: 25px;
        }

        .status-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: rgba(133, 194, 38, 0.1);
            color: var(--primary-color);
            padding: 8px 16px;
            border-radius: 30px;
            font-size: 0.85rem;
            font-weight: 600;
            margin-bottom: 30px;
            border: 1px solid rgba(133, 194, 38, 0.15);
        }

        .action-button {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            width: 100%;
            background-color: var(--primary-color);
            color: #ffffff;
            border: none;
            padding: 16px 24px;
            font-size: 1rem;
            font-weight: 600;
            border-radius: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(133, 194, 38, 0.2);
            text-decoration: none;
        }

        .action-button:hover {
            background-color: var(--primary-hover);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(133, 194, 38, 0.3);
        }

        .action-button:active {
            transform: translateY(0);
        }

        .footer-note {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid var(--border-color);
            font-size: 0.8rem;
            color: var(--text-muted);
        }

        .footer-note i {
            margin-right: 5px;
            color: var(--primary-color);
        }
    </style>

    <!-- Mastercard Checkout Library -->
    <script src="https://cbcmpgs.gateway.mastercard.com/static/checkout/checkout.min.js" data-error="errorCallback"
        data-cancel="cancelCallback"></script>

    <script type="text/javascript">
        function errorCallback(error) {
            console.error('Payment Error:', error);
            // Optionally redirect back or show notification
        }

        function cancelCallback() {
            console.log('Payment cancelled');
            window.location.href = '/cart-checkout'; // redirect back if cancelled
        }

        // Configure checkout session
        Checkout.configure({
            session: {
                id: "<?php echo e($session_id); ?>"
            }
        });

        // Automatically trigger payment page once the DOM is ready
        document.addEventListener("DOMContentLoaded", function () {
            setTimeout(function () {
                try {
                    Checkout.showPaymentPage();
                } catch (e) {
                    console.error("Auto-redirect failed, requiring manual click:", e);
                }
            }, 800); // Small delay to let checkout library bind correctly
        });
    </script>
</head>

<body>
    <div class="bg-glow-1"></div>
    <div class="bg-glow-2"></div>

    <div class="payment-container">
        <div class="logo-section">
            <div class="logo-icon">
                <i class="fa-solid fa-shield-halved"></i>
            </div>
            <h1>Secure Checkout</h1>
        </div>

        <div class="status-badge">
            <i class="fa-solid fa-circle"
                style="font-size: 8px; animation: pulse-opacity 1.5s infinite ease-in-out;"></i> Connecting to Gateway
        </div>



        <p>Please wait while we securely redirect you to the payment processing page to complete your transaction.</p>

        <!-- Fallback button in case of blockages or slow loading -->
        <button class="action-button" onclick="Checkout.showPaymentPage();">
            <span>Proceed to Payment</span>
            <i class="fa-solid fa-arrow-right"></i>
        </button>

        <div class="footer-note">
            <i class="fa-solid fa-shield"></i> 3D Secure Encrypted Transaction
        </div>
    </div>
</body>

</html><?php /**PATH /home/amerbofz/public_html/resources/views/web/home/payment/payment.blade.php ENDPATH**/ ?>