<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PhonePe Demo Payment</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            margin: 0;
            padding: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .payment-card {
            background: white;
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            text-align: center;
            max-width: 400px;
            width: 100%;
        }
        .phonepe-logo {
            width: 80px;
            height: 80px;
            background: #5f259f;
            border-radius: 50%;
            margin: 0 auto 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 24px;
            font-weight: bold;
        }
        .amount {
            font-size: 36px;
            font-weight: bold;
            color: #333;
            margin: 20px 0;
        }
        .merchant {
            color: #666;
            margin-bottom: 30px;
        }
        .payment-buttons {
            display: flex;
            gap: 15px;
            margin-top: 30px;
        }
        .btn {
            flex: 1;
            padding: 15px;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
        }
        .btn-success {
            background: #4CAF50;
            color: white;
        }
        .btn-success:hover {
            background: #45a049;
        }
        .btn-cancel {
            background: #f44336;
            color: white;
        }
        .btn-cancel:hover {
            background: #da190b;
        }
        .status {
            margin-top: 20px;
            padding: 10px;
            border-radius: 8px;
            display: none;
        }
        .status.success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        .status.failed {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
    </style>
</head>
<body>
    <div class="payment-card">
        <div class="phonepe-logo">PP</div>
        <h2>PhonePe Payment</h2>
        <div class="amount">₹<?php echo htmlspecialchars($_GET['amount'] ?? '100'); ?></div>
        <div class="merchant">AstroSidhi Consultation</div>
        
        <div class="payment-buttons">
            <button class="btn btn-success" onclick="processPayment(true)">Pay Now</button>
            <button class="btn btn-cancel" onclick="processPayment(false)">Cancel</button>
        </div>
        
        <div id="status" class="status"></div>
    </div>

    <script>
        function processPayment(success) {
            const statusDiv = document.getElementById('status');
            
            if (success) {
                statusDiv.className = 'status success';
                statusDiv.innerHTML = '✅ Payment Successful! Redirecting back to app...';
                statusDiv.style.display = 'block';
                
                // Redirect back to app after 2 seconds
                setTimeout(() => {
                    window.location.href = 'astrosidhi://phonepe-callback?mtid=TXN_' + Date.now() + '&status=SUCCESS';
                }, 2000);
            } else {
                statusDiv.className = 'status failed';
                statusDiv.innerHTML = '❌ Payment Cancelled';
                statusDiv.style.display = 'block';
                
                // Redirect back to app after 2 seconds
                setTimeout(() => {
                    window.location.href = 'astrosidhi://phonepe-callback?mtid=TXN_' + Date.now() + '&status=FAILED';
                }, 2000);
            }
        }
    </script>
</body>
</html>
