<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Secure Checkout - PayFast</title>
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
    
    <style>
        :root {
            --payfast-red: #e32e2e;
            --payfast-dark: #1a1a1a;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            padding: 40px 0;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

        .checkout-container {
            max-width: 700px;
            margin: 0 auto;
        }

        .payment-card {
            background: white;
            border-radius: 20px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            animation: slideUp 0.5s ease-out;
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .payment-header {
            background: linear-gradient(135deg, var(--payfast-red) 0%, #c02525 100%);
            color: white;
            padding: 2.5rem;
            text-align: center;
            position: relative;
        }

        .payment-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: 
                radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%);
        }

        .payment-header h1 {
            font-weight: 800;
            margin: 0;
            font-size: 2rem;
            position: relative;
        }

        .lock-icon {
            width: 60px;
            height: 60px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 1rem;
            backdrop-filter: blur(10px);
        }

        .payment-body {
            padding: 2.5rem;
        }

        .payment-details {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            border-radius: 15px;
            padding: 2rem;
            margin-bottom: 2rem;
            border-left: 4px solid var(--payfast-red);
        }

        .payment-details h2 {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--payfast-dark);
            margin-bottom: 0.5rem;
        }

        .payment-details p {
            color: #6c757d;
            margin-bottom: 1rem;
        }

        .amount-display {
            background: white;
            border-radius: 10px;
            padding: 1.5rem;
            text-align: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        }

        .amount-label {
            font-size: 0.9rem;
            color: #6c757d;
            margin-bottom: 0.5rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 600;
        }

        .amount-value {
            font-size: 2.5rem;
            font-weight: 900;
            color: var(--payfast-red);
            margin: 0;
        }

        .currency {
            font-size: 1.5rem;
            vertical-align: super;
        }

        .payment-info {
            background: #fff3cd;
            border-left: 4px solid #ffc107;
            border-radius: 10px;
            padding: 1.5rem;
            margin-bottom: 2rem;
        }

        .payment-info i {
            color: #ffc107;
            margin-right: 0.5rem;
        }

        .btn-pay {
            background: linear-gradient(135deg, var(--payfast-red) 0%, #c02525 100%);
            border: none;
            color: white;
            padding: 1.25rem 3rem;
            font-size: 1.2rem;
            font-weight: 700;
            border-radius: 12px;
            width: 100%;
            transition: all 0.3s;
            box-shadow: 0 4px 15px rgba(227, 46, 46, 0.3);
            position: relative;
            overflow: hidden;
        }

        .btn-pay::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            transform: translate(-50%, -50%);
            transition: width 0.6s, height 0.6s;
        }

        .btn-pay:hover::before {
            width: 300px;
            height: 300px;
        }

        .btn-pay:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 25px rgba(227, 46, 46, 0.4);
        }

        .btn-pay:active {
            transform: translateY(0);
        }

        .btn-pay i {
            margin-right: 0.5rem;
        }

        .security-badges {
            display: flex;
            justify-content: center;
            gap: 1.5rem;
            margin-top: 2rem;
            padding-top: 2rem;
            border-top: 1px solid #dee2e6;
        }

        .security-badge {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: #6c757d;
            font-size: 0.9rem;
        }

        .security-badge i {
            color: var(--payfast-red);
            font-size: 1.2rem;
        }

        .powered-by {
            text-align: center;
            margin-top: 2rem;
            padding-top: 2rem;
            border-top: 1px solid #dee2e6;
            color: #6c757d;
        }

        .payfast-logo {
            color: var(--payfast-red);
            font-weight: 800;
            font-size: 1.2rem;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .checkout-container {
                padding: 0 15px;
            }

            .payment-body {
                padding: 1.5rem;
            }

            .amount-value {
                font-size: 2rem;
            }

            .security-badges {
                flex-direction: column;
                gap: 1rem;
            }
        }

        /* Loading Animation */
        .btn-pay.loading {
            pointer-events: none;
            opacity: 0.7;
        }

        .btn-pay.loading::after {
            content: '';
            position: absolute;
            width: 20px;
            height: 20px;
            top: 50%;
            left: 50%;
            margin-left: -10px;
            margin-top: -10px;
            border: 3px solid rgba(255,255,255,0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 0.6s linear infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <div class="checkout-container">
        <div class="payment-card">
            <!-- Header -->
            <div class="payment-header">
                <div class="lock-icon">
                    <i class="bi bi-shield-lock-fill" style="font-size: 2rem;"></i>
                </div>
                <h1>Secure Checkout</h1>
                <p class="mb-0">Complete your payment securely with PayFast</p>
            </div>

            <!-- Body -->
            <div class="payment-body">
                <!-- Payment Details -->
                <div class="payment-details">
                    <h2>
                        <i class="bi bi-cart-check-fill me-2" style="color: var(--payfast-red);"></i>
                        {{ payment.item_name }}
                    </h2>
                    <p class="mb-3">{{ payment.item_description }}</p>
                    
                    <div class="amount-display">
                        <div class="amount-label">Total Amount</div>
                        <h3 class="amount-value">
                            <span class="currency">R</span>{{ payment.amount }}
                        </h3>
                    </div>
                </div>

                <!-- Security Info -->
                <div class="payment-info">
                    <i class="bi bi-info-circle-fill"></i>
                    <strong>Secure Payment:</strong> You will be redirected to PayFast to complete your payment securely. Your payment details are protected with industry-standard encryption.
                </div>

                <!-- Payment Form -->
                 {{ htmlForm|safe }}
                {% comment %} <form action="{{ form.get_action_url }}" method="post" id="payment-form"> {% endcomment %}
                    <!-- Hidden form fields -->
                    {% comment %} {{ form.as_p }} {% endcomment %}
                    
                    
                    <!-- Submit Button -->
                    {% comment %} <button type="submit" class="btn btn-pay" id="pay-btn">
                        <i class="bi bi-lock-fill"></i>
                        <span>Pay R{{ payment.amount }} with PayFast</span>
                    </button> {% endcomment %}
                {% comment %} </form> {% endcomment %}

                <!-- Security Badges -->
                <div class="security-badges">
                    <div class="security-badge">
                        <i class="bi bi-shield-check"></i>
                        <span>SSL Encrypted</span>
                    </div>
                    <div class="security-badge">
                        <i class="bi bi-lock-fill"></i>
                        <span>PCI Compliant</span>
                    </div>
                    <div class="security-badge">
                        <i class="bi bi-patch-check-fill"></i>
                        <span>Secure Payment</span>
                    </div>
                </div>

                <!-- Powered By -->
                <div class="powered-by">
                    <small>Powered by</small>
                    <div class="payfast-logo">
                        <i class="bi bi-credit-card-2-front-fill"></i> PayFast
                    </div>
                </div>
            </div>
        </div>

        <!-- Additional Info Card -->
        <div class="card mt-4 border-0 shadow-sm">
            <div class="card-body">
                <h5 class="card-title">
                    <i class="bi bi-question-circle-fill text-primary me-2"></i>
                    What happens next?
                </h5>
                <ol class="mb-0">
                    <li>You'll be securely redirected to PayFast</li>
                    <li>Complete your payment with card or instant EFT</li>
                    <li>Return to our site automatically after payment</li>
                    <li>Receive email confirmation of your purchase</li>
                </ol>
            </div>
        </div>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // Add loading state on form submit
        document.getElementById('payment-form').addEventListener('submit', function() {
            const btn = document.getElementById('pay-btn');
            btn.classList.add('loading');
            btn.innerHTML = '<span>Processing...</span>';
        });

        // Hide all form fields (they're hidden inputs)
        document.querySelectorAll('#payment-form p').forEach(p => {
            p.style.display = 'none';
        });
    </script>
</body>
</html>