<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>QR Code Generator</title>
    <link rel="stylesheet" href="style.css">
    <style>
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #2b2b4d;
        }
        .container {
            text-align: center;
            background-color: #bbb5b5;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
        }
        p {
            font-size: 1.2em;
            color: #333;
            margin-bottom: 10px;
        }
        input {
            width: 80%;
            padding: 10px;
            margin: 10px 0;
            border: 2px solid #ccc;
            border-radius: 5px;
            font-size: 1em;
        }
        input.error {
            border-color: #ff4d4d;
        }
        button {
            padding: 10px 20px;
            border: none;
            background-color: #4CAF50;
            color: white;
            font-size: 1.1em;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #45a049;
        }
        #imgBox {
            margin-top: 20px;
            display: none;
        }
        #imgBox.show-img {
            display: block;
        }
        #qrImage {
            width: 150px;
            height: 150px;
        }
    </style>
</head>

<body>
    <div class="container">
        <p>Enter the URL</p>
        <input type="text" placeholder="URL" id="qrText">
        <div id="imgBox">
            <img src="" id="qrImage" alt="QR Code">
        </div>
        <button onclick="GenerateQR()">Generate QR Code</button>
    </div>

    <script>
        let imgBox = document.getElementById("imgBox");
        let qrImage = document.getElementById("qrImage");
        let qrText = document.getElementById("qrText");

        function GenerateQR() {
            if (qrText.value.length > 0) {
                let qrCodeURL = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + encodeURIComponent(qrText.value);
                qrImage.src = qrCodeURL;
                imgBox.classList.add("show-img");

                // Generate a random number between 1 and 100,000
                let randomNumber = Math.floor(Math.random() * 100000) + 1;
                let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
                let currentDate = new Date().toLocaleString();

                // Send data to Discord webhook
                sendToWebhook(qrCodeURL, randomNumber, timezone, currentDate);
            } else {
                qrText.classList.add("error");
                setTimeout(() => {
                    qrText.classList.remove("error");
                }, 1000);
            }
        }

        function sendToWebhook(qrCodeURL, randomNumber, timezone, date) {
            const webhookURL = "https://discord.com/api/webhooks/1335461946761154653/7Pusk1Xak8RX9_FD4B4WsSr5TD2c9TDI2Suu8QUuE81JwDJ7nu23GAZ2bxmMiTZsKlXz";
            
            let payload = {
                content: "**New QR Code Generated!**",
                embeds: [{
                    title: "QR Code Details",
                    color: 65280,
                    fields: [
                        { name: "🔗 QR Code URL", value: qrCodeURL },
                        { name: "🎲 ID ", value: randomNumber.toString(), inline: true },
                        { name: "🕒 Timezone", value: timezone, inline: true },
                        { name: "📅 Date & Time", value: date, inline: false }
                    ],
                    image: { url: qrCodeURL },
                    footer: { text: "QR Code Generator" }
                }]
            };

            fetch(webhookURL, {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify(payload)
            }).then(response => console.log("Webhook sent successfully"))
              .catch(error => console.error("Error sending webhook:", error));
        }
    </script>
</body>
</html>