<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Driving Academy</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background: linear-gradient(180deg, black, #00ff00);
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            flex-direction: column;
        }

        .form-container {
            background-color: rgba(26, 26, 26, 0.9);
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            width: 90%;
            max-width: 400px;
            margin-bottom: 20px;
        }

        h1 {
            text-align: center;
            margin-bottom: 20px;
            color: #00ff00;
        }

        form {
            display: flex;
            flex-direction: column;
        }

        label {
            font-size: 1rem;
            margin-bottom: 5px;
            color: #00ff00;
        }

        input, button {
            padding: 10px;
            margin-bottom: 15px;
            border: none;
            border-radius: 5px;
            font-size: 1rem;
            width: 100%;
        }

        input {
            background-color: #333;
            color: white;
        }

        input::placeholder {
            color: #888;
        }

        button {
            background-color: #00ff00;
            color: black;
            cursor: pointer;
            font-weight: bold;
            transition: background-color 0.3s ease;
        }

        button:disabled {
            background-color: #555;
            cursor: not-allowed;
        }

        button:hover:enabled {
            background-color: white;
            color: black;
        }

        .button-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            margin-top: 20px;
        }

        .custom-button {
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
            font-size: 1rem;
            font-weight: bold;
            color: black;
            background-color: #00ff00;
            transition: background-color 0.3s ease, color 0.3s ease;
            display: inline-block;
            text-align: center;
            width: 90%;
            max-width: 300px;
        }

        .custom-button:hover {
            background-color: white;
            color: black;
        }

        .credits-section {
            display: none;
            background-color: rgba(26, 26, 26, 0.9);
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            text-align: center;
            margin-top: 20px;
        }

        .credits-section img {
            border-radius: 50%;
            width: 150px;
            height: 150px;
            object-fit: cover;
            margin-bottom: 20px;
        }

        .credits-section h2 {
            color: #00ff00;
            font-size: 1.5rem;
        }

        .credits-section p {
            color: #888;
            font-size: 1rem;
        }

    </style>
</head>
<body>
    <div class="form-container">
        <h1>Driving Academy</h1>
        <form id="testRequestForm">
            <label for="username">Roblox Username:</label>
            <input type="text" id="username" name="username" placeholder="Enter your username" required>

            <label for="test">What would you like to be tested for?</label>
            <input type="text" id="test" name="test" placeholder="Enter your test request" required>

            <button id="submitButton" type="submit">Submit</button>
        </form>

        <p id="status" style="display: none;">✅ Request Sent Successfully!</p>
        <p id="error" style="display: none;">❌ Failed to send request. Please try again.</p>

        <div class="button-container">
            <a href="https://discord.gg/zXexMjxX9P" target="_blank" class="custom-button">Join Discord</a>
            <a href="https://www.roblox.com/communities/35274634/Driving-Academy#!/about" target="_blank" class="custom-button">Roblox Community</a>
            <button id="creditsButton" class="custom-button">Credits</button>
        </div>
    </div>

    <div class="credits-section" id="creditsSection">
        <img src="https://cdn.discordapp.com/attachments/1136034163523334285/1313243639517806632/Screenshot_2024-12-02_153225.png?ex=674f6cf2&is=674e1b72&hm=1b7ef6aee50681c0c07354d90315ab1a2e6157e3d1dd6fd4572877010addfada&" alt="Creator Image">
        <h2>Creator of Website & Developer</h2>
        <p>Outspoken</p>
    </div>

    <script>
        const webhookUrl = 'https://discord.com/api/webhooks/1312670115258695750/Qo6hWHvi2MgeHL29-CBBf0O3TpsyK9bxD3GcCzh1YXH-LTm1dQZ4vCE7saFopaZJT8HZ';
        const submitButton = document.getElementById('submitButton');
        const form = document.getElementById('testRequestForm');
        const creditsButton = document.getElementById('creditsButton');
        const creditsSection = document.getElementById('creditsSection');

        const cooldownEnd = localStorage.getItem('cooldownEnd');
        const now = Date.now();
        if (cooldownEnd && now < cooldownEnd) {
            const remainingTime = Math.ceil((cooldownEnd - now) / 1000);
            submitButton.disabled = true;
            submitButton.textContent = `Please wait ${remainingTime} seconds`;
        } else {
            submitButton.disabled = false;
            submitButton.textContent = "Submit";
        }

        form.addEventListener('submit', function (event) {
            event.preventDefault();

            const username = document.getElementById('username').value;
            const testRequest = document.getElementById('test').value;

            const payload = {
                content: `
📋 New Driving Test Request!
Username: **${username}**
Requested Test: **${testRequest}**
🎯 Status: Awaiting scheduling. 🚦

<@&1312896621704384512>
                `
            };

            submitButton.disabled = true;

            const cooldownDuration = 30000;
            const cooldownTime = Date.now() + cooldownDuration;
            localStorage.setItem('cooldownEnd', cooldownTime);

            submitButton.textContent = `Please wait ${Math.ceil(cooldownDuration / 1000)} seconds`;

            setTimeout(() => {
                submitButton.disabled = false;
                submitButton.textContent = "Submit";
            }, cooldownDuration);

            fetch(webhookUrl, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(payload)
            })
            .then(response => {
                if (response.ok) {
                    document.getElementById('status').style.display = 'block';
                    document.getElementById('error').style.display = 'none';
                    form.reset();
                } else {
                    throw new Error('Failed to send request');
                }
            })
            .catch(error => {
                console.error(error);
                document.getElementById('status').style.display = 'none';
                document.getElementById('error').style.display = 'block';
                submitButton.disabled = false;
                submitButton.textContent = "Submit";
            });
        });

        creditsButton.addEventListener('click', () => {
            creditsSection.style.display = creditsSection.style.display === 'block' ? 'none' : 'block';
        });
    </script>
</body>
</html>
