<?php
$status = isset($_GET['payment_status']) ? strtolower($_GET['payment_status']) : 'success';
$isFailed = in_array($status, ['failed', 'failure', 'cancelled', 'canceled']);
$orderId = isset($_GET['order_id']) ? htmlspecialchars($_GET['order_id']) : '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $isFailed ? 'Transaction Failed' : 'Transaction Success' ?></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f9f9f9;
            color: #333;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            background-color: #fff;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            text-align: center;
            max-width: 90%;
        }
        h1 {
            color: <?= $isFailed ? '#dc3545' : '#28a745' ?>;
        }
        p {
            font-size: 18px;
        }
        .order-id {
            font-size: 14px;
            color: #888;
            margin-bottom: 10px;
        }
        .btn {
            background-color: <?= $isFailed ? '#dc3545' : '#28a745' ?>;
            color: #fff;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
        }
        .btn:hover {
            background-color: <?= $isFailed ? '#c82333' : '#218838' ?>;
        }
        .status-icon {
            width: 80px;
            height: 80px;
            margin-bottom: 20px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-left: auto;
            margin-right: auto;
            background-color: <?= $isFailed ? '#fdecea' : '#eafaf1' ?>;
        }
        .status-icon svg { width: 44px; height: 44px; }
    </style>
</head>
<body>
    <div class="container">
        <div class="status-icon">
            <?php if ($isFailed): ?>
                <svg viewBox="0 0 24 24" fill="none" stroke="#dc3545" stroke-width="2.5" stroke-linecap="round">
                    <line x1="6" y1="6" x2="18" y2="18"></line>
                    <line x1="18" y1="6" x2="6" y2="18"></line>
                </svg>
            <?php else: ?>
                <svg viewBox="0 0 24 24" fill="none" stroke="#28a745" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="20 6 9 17 4 12"></polyline>
                </svg>
            <?php endif; ?>
        </div>
        <?php if ($isFailed): ?>
            <h1>Transaction Failed</h1>
            <p>Your payment could not be completed. No successful transaction was recorded.</p>
        <?php else: ?>
            <h1>Transaction Successful!</h1>
            <p>Thank you for your payment.</p>
        <?php endif; ?>
        <?php if ($orderId): ?>
            <p class="order-id">Order ID: <?= $orderId ?></p>
        <?php endif; ?>
        <a href="index.php" class="btn">Go to Homepage</a>
    </div>
</body>
</html>
