<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>User Request System</title>
    <style>
        /* General Reset */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Body and Background */
        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(45deg, #00bcd4, #6200ea, #ff4081); /* More vibrant colors */
            background-size: 400% 400%;
            animation: gradientMove 10s ease infinite;
            color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            overflow: hidden;
            perspective: 1500px; /* Create 3D perspective for the whole page */
            position: relative;
        }

        /* Background Animation */
        @keyframes gradientMove {
            0% { background-position: 0% 0%; }
            50% { background-position: 100% 100%; }
            100% { background-position: 0% 0%; }
        }

        /* Adding Stars */
        .stars {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: -1;
            background: url('https://www.transparenttextures.com/patterns/stardust.png') repeat;
            animation: moveStars 60s linear infinite;
        }

        /* Moving Stars Effect */
        @keyframes moveStars {
            from {
                background-position: 0 0;
            }
            to {
                background-position: 2000px 2000px;
            }
        }

        /* Moon Styling */
        .moon {
            position: absolute;
            top: 10%;
            right: 10%;
            width: 100px;
            height: 100px;
            background-color: #fff;
            border-radius: 50%;
            box-shadow: 0px 0px 30px rgba(255, 255, 255, 0.5);
            animation: moveMoon 20s ease-in-out infinite;
        }

        /* Moving Moon Effect */
        @keyframes moveMoon {
            0% {
                transform: translate(0, 0);
            }
            50% {
                transform: translate(200px, -100px);
            }
            100% {
                transform: translate(0, 0);
            }
        }

        /* Title Styling */
        h1 {
            font-size: 4rem;
            text-transform: uppercase;
            font-weight: bold;
            color: #00bcd4;
            text-align: center;
            margin-bottom: 30px;
            letter-spacing: 6px;
            text-shadow: 0px 0px 20px rgba(0, 255, 255, 0.6);
            animation: glowText 1.5s ease-in-out infinite alternate;
        }

        /* Glowing Text Effect */
        @keyframes glowText {
            0% {
                text-shadow: 0px 0px 20px rgba(0, 255, 255, 0.6), 0px 0px 40px rgba(0, 255, 255, 0.4);
            }
            100% {
                text-shadow: 0px 0px 30px rgba(0, 255, 255, 1), 0px 0px 60px rgba(0, 255, 255, 0.6);
            }
        }

        /* Main Form Container */
        .form-container {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: rgba(0, 0, 0, 0.7);
            padding: 40px;
            border-radius: 20px;
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
            transform-style: preserve-3d;
            position: relative;
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            animation: floatEffect 4s ease-in-out infinite alternate;
            text-align: center; /* Centers the text inside the form */
        }

        /* 3D Floating Effect */
        @keyframes floatEffect {
            0% {
                transform: translateY(-5px) rotateX(5deg) rotateY(5deg);
            }
            100% {
                transform: translateY(10px) rotateX(-5deg) rotateY(-5deg);
            }
        }

        /* Hover Effect for Form */
        .form-container:hover {
            transform: rotateY(15deg) rotateX(10deg);
            box-shadow: 0px 30px 60px rgba(0, 255, 255, 0.6);
        }

        /* Input Styling */
        input[type="text"] {
            padding: 12px 20px;
            margin: 15px 0;
            font-size: 1.1rem;
            border: 2px solid #444;
            border-radius: 10px;
            background-color: #2a2a2a;
            color: #fff;
            width: 100%;
            max-width: 350px;
            transition: 0.3s ease-in-out;
            box-shadow: 0px 0px 10px rgba(0, 255, 255, 0.3);
        }

        /* Input Focus Styling */
        input[type="text"]:focus {
            border-color: #00bcd4;
            outline: none;
            box-shadow: 0px 0px 20px rgba(0, 255, 255, 0.5);
        }

        /* Submit Button Styling */
        button {
            padding: 12px 25px;
            background-color: #00bcd4;
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 1.2rem;
            cursor: pointer;
            width: 70%;
            max-width: 350px;
            transition: 0.3s ease-in-out;
            margin-top: 20px;
            box-shadow: 0px 0px 20px rgba(0, 255, 255, 0.4);
        }

        /* Button Hover Effect */
        button:hover {
            background-color: #0097a7;
            transform: translateY(-5px);
            box-shadow: 0px 0px 30px rgba(0, 255, 255, 0.6);
        }

        button:active {
            transform: translateY(0);
            box-shadow: none;
        }

        /* Loading Message Styling */
        #loadingMessage {
            display: none;
            font-size: 1.1rem;
            color: #00bcd4;
            margin-top: 20px;
            animation: fadeIn 2s ease-in-out infinite;
        }

        /* Fade In Animation */
        @keyframes fadeIn {
            0% { opacity: 0; }
            50% { opacity: 1; }
            100% { opacity: 0; }
        }

        /* Modal Styling */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            justify-content: center;
            align-items: center;
            z-index: 999;
        }

        .modal-content {
            background: #333;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            color: #00bcd4;
        }

       /* Modal Close Button */
.close-btn {
    margin-top: 20px;
    background-color: #ff4040;
    border: none;
    padding: 10px 10px;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    align-self: center;  /* Centers the button horizontally */
    display: inline-block; /* Ensures it behaves like a block-level element but stays inline */
}


        /* Progress Bar */
        .progress-bar {
            width: 100%;
            background: #444;
            height: 5px;
            border-radius: 10px;
            margin-top: 20px;
        }

        .progress-bar-inner {
            width: 0%;
            height: 100%;
            background: #00bcd4;
            border-radius: 10px;
            transition: width 3s ease-in-out;
        }

        /* Smooth Page Load Transition */
        .form-container {
            animation: scaleUp 1s ease-out;
        }

        @keyframes scaleUp {
            0% {
                transform: scale(0.8);
                opacity: 0;
            }
            100% {
                transform: scale(1);
                opacity: 1;
            }
        }

        /* Watermark with Discord Link */
        .watermark {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            text-align: center;
            font-size: 1.2rem;
            color: #fff;
        }

        .watermark a {
            color: #00bcd4;
            text-decoration: none;
            transition: color 0.3s;
        }

        .watermark a:hover {
            color: #ff4081;
        }
    </style>
</head>
<body>
    <div class="stars"></div> <!-- Stars background -->
    <div class="moon"></div> <!-- Moon element -->
    <div class="form-container" id="formContainer">
        <h1>Download Your Game</h1>
        <form id="requestForm">
            <input type="text" id="fileName" placeholder="Enter Game id " required>
            <button type="submit" id="submitButton">Submit</button>
        </form>
        <div id="loadingMessage">
            <p></p>
        </div>
        <div class="progress-bar">
            <div class="progress-bar-inner" id="progressBarInner"></div>
        </div>
    </div>

    <!-- Watermark with Discord Link -->
    <div class="watermark">
        <a href="https://discord.gg/eMs3q29yzK" target="_blank"><span>Join our Discord</span></a>
    </div>

    <!-- Modal -->
    <div class="modal" id="successModal">
        <div class="modal-content">
            <p>file succesful!</p>
            <button class="close-btn" id="closeModal">Close</button>
        </div>
    </div>

    <script>
        // 3D Cursor Effect
        const formContainer = document.getElementById('formContainer');
        document.body.addEventListener('mousemove', (event) => {
            const { clientX: x, clientY: y } = event;
            const centerX = window.innerWidth / 2;
            const centerY = window.innerHeight / 2;
            const deltaX = (x - centerX) / centerX;
            const deltaY = (y - centerY) / centerY;
            const rotateX = deltaY * 10;
            const rotateY = -deltaX * 10;

            formContainer.style.transition = 'transform 0.1s ease-out';  // Improved transition
            formContainer.style.transform = `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
        });

        // Send notification to Discord Webhook when the user downloads the file
        function sendDownloadNotification(fileName) {
            const webhookUrl = 'https://discord.com/api/webhooks/1318206235949924482/LBFyFffhUnKMFKIsVAir92RXD5KAIDGMqmGfQtpafss_vtMDY-APrlrdH_VJMr_7jAZE';
            const payload = {
                content: `A user has downloaded the file: ${fileName}.zip`
            };

            fetch(webhookUrl, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(payload)
            })
            .then(response => response.json())
            .then(data => console.log('Notification sent to Discord:', data))
            .catch(error => console.error('Error sending notification to Discord:', error));
        }

        // Form submission logic
        document.getElementById('requestForm').addEventListener('submit', function(event) {
            event.preventDefault();

            const fileName = document.getElementById('fileName').value.trim();
            if (fileName) {
                const submitButton = document.getElementById('submitButton');
                submitButton.textContent = 'Processing'; // Change button text to 'Processing'
                submitButton.disabled = true; // Disable the button during the processing
                
                // Show the loading message and progress bar
                document.getElementById('loadingMessage').style.display = 'block';
                const progressBar = document.getElementById('progressBarInner');
                progressBar.style.width = '100%';

                // Reset progress bar after 7 seconds
                setTimeout(() => {
                    progressBar.style.width = '0%';
                    progressBar.style.backgroundColor = '#00bcd4'; // Reset to blue after the progress finishes
                }, 6000);

                // Construct the download URL with the user request
                const downloadUrl = `http://fleaks.rf.gd/files/${fileName}.zip`;

                // Check if the file exists before proceeding
                fetch(downloadUrl, { method: 'HEAD' })
                    .then(response => {
                        if (response.ok) {
                            // Show modal after form submission
                            setTimeout(() => {
                                document.getElementById('successModal').style.display = 'flex';
                            }, 3000);

                            // Re-enable the button and reset text after 5 seconds
                            setTimeout(() => {
                                submitButton.textContent = 'Submit'; // Revert button text
                                submitButton.disabled = false; // Re-enable the button
                                // Redirect the user to the download link
                                sendDownloadNotification(fileName); // Send the notification to Discord
                                window.location.href = downloadUrl;
                            }, 5000); // Delay to allow modal to show and progress bar to fill
                        } else {
                            alert('Sorry, the requested file is not available.');
                            progressBar.style.backgroundColor = 'red'; // Change progress bar color to red
                            progressBar.style.width = '0%'; // Reset the progress bar
                            setTimeout(() => {
                                submitButton.textContent = 'Submit'; // Revert button text
                                submitButton.disabled = false; // Re-enable the button
                            }, 2000); // Allow some time before re-enabling the button
                        }
                    })
                    .catch(error => {
                        alert('file not yet available');
                        progressBar.style.backgroundColor = 'red'; // Change progress bar color to red
                        progressBar.style.width = '0%'; // Reset the progress bar
                        setTimeout(() => {
                            submitButton.textContent = 'Submit'; // Revert button text
                            submitButton.disabled = false; // Re-enable the button
                        }, 2000); // Allow some time before re-enabling the button
                    });
            } else {
                alert('Please enter a valid request!');
            }
        });

        // Close modal
        document.getElementById('closeModal').addEventListener('click', function() {
            document.getElementById('successModal').style.display = 'none';
        });
    </script>
</body>
</html>
