<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>IP Display & Copy</title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        body {
            margin: 0;
            font-family: 'Poppins', sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background: linear-gradient(135deg, #4CAF50, #2E7D32, #1B5E20);
            color: #fff;
            animation: gradientBG 10s ease infinite;
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        #ip-container {
            text-align: center;
            padding: 40px;
            border-radius: 20px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        #logo {
            width: 120px;
            height: 120px;
            object-fit: cover;
            border-radius: 50%;
            margin-bottom: 20px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        #logo:hover {
            transform: scale(1.1);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
        }

        #ip {
            font-size: 3.5rem;
            font-weight: bold;
            margin: 20px 0;
            color: #fff;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
            cursor: pointer; /* مؤشر يدوي */
            transition: color 0.3s ease; /* تأثير تغيير اللون */
        }

        #ip:hover {
            color: #ffeb3b; /* تغيير لون النص عند التمرير */
        }

        #message {
            font-size: 1.5rem;
            margin-bottom: 20px;
            color: #fff;
        }

        #confirmation {
            margin-top: 20px;
            font-size: 1.2rem;
            opacity: 0;
            transition: opacity 0.3s ease;
            background: rgba(255, 255, 255, 0.2);
            padding: 10px 20px;
            border-radius: 10px;
            color: #fff;
        }

        #confirmation.visible {
            opacity: 1;
        }

        #loading {
            font-size: 1.2rem;
            margin-top: 20px;
            opacity: 1;
            transition: opacity 0.3s ease;
        }

        #loading.hidden {
            opacity: 0;
        }

        @media (max-width: 768px) {
            #ip {
                font-size: 2rem;
            }

            #message {
                font-size: 1rem;
            }

            #ip-container {
                padding: 20px;
                border-radius: 15px;
            }

            #logo {
                width: 80px;
                height: 80px;
            }
        }
    </style>
</head>
<body>
    <div id="ip-container">
        <!-- إضافة اللوغو هنا -->
        <img src="https://i.ibb.co/Z2vSv5m/1-E0401-D9-FCED-4-F9-A-917-C-DA30-BBB99437.jpg" alt="Your Logo" id="logo">
        <div id="message">
            <i class="fas fa-share-alt"></i> SHARE WITH REYZIX FOR ACTIVATION
        </div>
        <div id="ip" onclick="copyToClipboard()">Fetching IP...</div>
        <div id="confirmation"><i class="fas fa-check"></i> Copied to clipboard!</div>
        <div id="loading">
            <i class="fas fa-spinner fa-spin"></i> Fetching your IP...
        </div>
    </div>

    <audio id="copySound" src="click-sound.mp3"></audio>

    <script>
        async function fetchIP() {
            const loadingElement = document.getElementById('loading');
            const ipElement = document.getElementById('ip');

            try {
                loadingElement.classList.remove('hidden');
                const response = await fetch('https://api.ipify.org?format=json');
                const data = await response.json();
                const ip = data.ip;
                ipElement.textContent = ip;
                checkAndAddIP(ip);
            } catch (error) {
                ipElement.textContent = "Error fetching IP";
                console.error('Error fetching IP:', error);
            } finally {
                loadingElement.classList.add('hidden');
            }
        }

        function copyToClipboard() {
            const ipElement = document.getElementById('ip');
            const confirmationElement = document.getElementById('confirmation');
            const ip = ipElement.textContent;
            const sound = document.getElementById('copySound');

            navigator.clipboard.writeText(ip).then(() => {
                confirmationElement.classList.add('visible');
                sound.play();
                setTimeout(() => confirmationElement.classList.remove('visible'), 2000);
            }).catch(err => {
                console.error('Could not copy text:', err);
            });
        }

        async function checkAndAddIP(ip) {
            try {
                const response = await fetch('handle_ip.php', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'text/plain',
                    },
                    body: ip,
                });
                const result = await response.text();
                console.log(result);
            } catch (error) {
                console.error('Error checking or adding IP:', error);
            }
        }

        fetchIP();
    </script>
</body>
</html>