<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pay2inr - Secure Payment</title>
    <link rel="stylesheet" href="page/styles.css">
    <style>
        :root {
            --primary-color: #667eea;
            --secondary-color: #764ba2;
            --success-color: #28a745;
            --danger-color: #dc3545;
            --warning-color: #ffc107;
        }
        
        body {
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            min-height: 100vh;
        }
        
        .yanpay-header {
            background: white;
            padding: 20px;
            text-align: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .yanpay-logo {
            font-size: 32px;
            font-weight: 700;
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .yanpay-tagline {
            font-size: 12px;
            color: #666;
            margin-top: 5px;
        }
        
        .payment-container {
            max-width: 500px;
            margin: 30px auto;
            background: white;
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
        }
        
        .payment-header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 30px 20px;
            text-align: center;
        }
        
        .payment-amount {
            font-size: 48px;
            font-weight: 700;
            margin: 10px 0;
        }
        
        .payment-timer {
            font-size: 14px;
            opacity: 0.9;
            margin-top: 10px;
        }
        
        .payment-body {
            padding: 30px 20px;
        }
        
        .payment-info {
            text-align: center;
            margin-bottom: 20px;
        }
        
        .payment-info p {
            color: #666;
            margin: 5px 0;
        }
        
        .payment-button {
            display: block;
            width: 100%;
            padding: 15px;
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            margin: 10px 0;
            transition: transform 0.2s;
        }
        
        .payment-button:hover {
            transform: translateY(-2px);
        }
        
        .payment-button:active {
            transform: translateY(0);
        }
        
        .qr-section {
            text-align: center;
            margin: 20px 0;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 8px;
        }
        
        .qr-code-img {
            max-width: 250px;
            margin: 15px auto;
            border: 3px solid var(--primary-color);
            border-radius: 10px;
            padding: 10px;
            background: white;
        }
        
        .security-badge {
            text-align: center;
            padding: 20px;
            background: #f8f9fa;
            border-top: 1px solid #e0e0e0;
        }
        
        .security-badge img {
            width: 30px;
            vertical-align: middle;
            margin-right: 10px;
        }
        
        .security-badge p {
            color: #666;
            font-size: 13px;
            margin: 10px 0 0 0;
        }
        
        .powered-by {
            text-align: center;
            padding: 15px;
            font-size: 12px;
            color: white;
        }
        
        .powered-by a {
            color: white;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="yanpay-header">
        <div class="yanpay-logo">🚀 pay2inr</div>
        <div class="yanpay-tagline">Secure Payment Gateway</div>
    </div>
    
    <div class="payment-container">
        <div class="payment-header">
            <div>Payment Amount</div>
            <div class="payment-amount">₹<?= number_format($res['amount'], 2) ?></div>
            <div class="payment-timer" id="timer">
                Expires in: <?= htmlspecialchars($res['expiration_time'] ?? '') ?>
            </div>
        </div>
        
        <div class="payment-body">
            <div class="payment-info">
                <p><strong>Order ID:</strong> <?= htmlspecialchars($orderid) ?></p>
                <p><strong>Customer:</strong> <?= htmlspecialchars($customer_name) ?></p>
                <p><strong>Merchant:</strong> pay2inr</p>
            </div>
            
            <?php if ($res['status'] == 'SUCCESS' && isset($res['payment_link'])): ?>
                <a href="<?= htmlspecialchars($res['payment_link']) ?>" class="payment-button" target="_blank">
                    💳 Pay Now with UPI
                </a>
                
                <div class="qr-section">
                    <p style="color: #666; margin-bottom: 10px;">Or Scan QR Code to Pay</p>
                    <?php if (!empty($res['qr_code'])): ?>
                        <img src="<?= htmlspecialchars($res['qr_code']) ?>" alt="QR Code" class="qr-code-img">
                    <?php endif; ?>
                    <p style="font-size: 12px; color: #999; margin-top: 10px;">
                        Scan with any UPI app (GPay, PhonePe, Paytm, etc.)
                    </p>
                </div>
            <?php else: ?>
                <div style="text-align: center; padding: 20px;">
                    <p style="color: var(--danger-color); font-size: 18px; font-weight: 600;">
                        ❌ Payment Failed
                    </p>
                    <p style="color: #666; margin-top: 10px;">
                        <?= htmlspecialchars($res['message'] ?? 'Unknown error occurred') ?>
                    </p>
                </div>
            <?php endif; ?>
        </div>
        
        <div class="security-badge">
            <img src="https://cdn-icons-png.flaticon.com/512/10703/10703030.png" alt="Secure">
            <p>🔒 This payment is secured by pay2inr</p>
            <p style="font-size: 11px; margin-top: 5px;">256-bit SSL Encryption | PCI DSS Compliant</p>
        </div>
    </div>
    
    <div class="powered-by">
        Powered by <strong>pay2inr</strong> | <a href="https://fastpay.us.cc">fastpay.us.cc</a>
    </div>
    
    <script>
        // Timer countdown
        const expirationTimeString = "<?= htmlspecialchars($res['expiration_time'] ?? '') ?>";
        const expirationTimestamp = Date.parse(expirationTimeString) / 1000;
        
        if (!isNaN(expirationTimestamp)) {
            function updateCountdown() {
                const currentTime = Math.floor(Date.now() / 1000);
                const timeRemaining = expirationTimestamp - currentTime;
                
                if (timeRemaining <= 0) {
                    document.getElementById('timer').textContent = "Expired";
                    clearInterval(countdownInterval);
                } else {
                    const minutes = Math.floor(timeRemaining / 60);
                    const seconds = timeRemaining % 60;
                    document.getElementById('timer').textContent = 
                        `Expires in: ${minutes}:${seconds.toString().padStart(2, '0')}`;
                }
            }
            
            updateCountdown();
            const countdownInterval = setInterval(updateCountdown, 1000);
        }
    </script>
</body>
</html>
