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

        /* Base styling for body */
        body {
            font-family: 'Poppins', sans-serif;
            background: linear-gradient(to bottom right, #00aaff, #1e88e5); /* Lighter blue gradient */
            color: #ffffff;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }

        /* Container styling */
        .container {
            background: rgba(255, 255, 255, 0.2); /* Transparent background */
            backdrop-filter: blur(10px);
            padding: 30px;
            border-radius: 15px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            text-align: center;
            max-width: 450px;
            width: 100%;
        }

        /* Header styling */
        .container h1 {
            font-size: 36px;
            margin-bottom: 20px;
            color: #ffffff; /* White for contrast */
            text-transform: uppercase;
            letter-spacing: 3px;
            font-weight: bold;
            animation: fadeInName 2s ease-out;
        }

        @keyframes fadeInName {
            0% { opacity: 0; transform: translateY(-20px); }
            100% { opacity: 1; transform: translateY(0); }
        }

        /* Input and button styling */
        input[type="text"], button {
            width: 100%;
            padding: 12px;
            font-size: 16px;
            border: none;
            border-radius: 8px;
            outline: none;
            margin-bottom: 20px;
        }

        input[type="text"] {
            background-color: #2a3c58; /* Lighter dark blue */
            color: #ffffff;
            transition: box-shadow 0.3s ease;
        }

        input[type="text"]:focus {
            box-shadow: 0 0 10px #ffffff; /* White glow for focus */
        }

        button {
            background: linear-gradient(90deg, #00aaff, #1e88e5);
            color: #ffffff;
            font-weight: bold;
            cursor: pointer;
            transition: transform 0.3s, box-shadow 0.3s;
        }

        button:hover {
            transform: scale(1.05);
            box-shadow: 0 5px 15px rgba(0, 170, 255, 0.5);
        }

        /* Image styling */
        img {
            max-width: 100%;
            border-radius: 12px;
            margin-top: 20px;
            display: none;
        }

        /* Spinner styling */
        .spinner {
            width: 50px;
            height: 50px;
            border: 5px solid rgba(255, 255, 255, 0.3);
            border-top: 5px solid #ffffff; /* White spinner */
            border-radius: 50%;
            margin: 20px auto;
            animation: spin 1s linear infinite;
            display: none;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Telegram button */
        .telegram-link {
            display: none;
            margin-top: 20px;
            text-decoration: none;
            background: linear-gradient(90deg, #00aaff, #1e88e5);
            padding: 12px 20px;
            color: white;
            border-radius: 8px;
            font-weight: bold;
            transition: transform 0.3s, background-color 0.3s;
        }

        .telegram-link:hover {
            transform: scale(1.05);
            background-color: #00aaff;
        }

        /* Regenerate button */
        #regenerateButton {
            display: none;
            background: none;
            border: 2px solid #ffffff;
            color: #ffffff;
            font-weight: bold;
            margin-top: 10px;
        }

        #regenerateButton:hover {
            background: #ffffff;
            color: #00aaff;
        }

        /* Footer styling */
        .footer {
            margin-top: 20px;
            font-size: 14px;
            color: #ffffff;
            text-align: center;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>ROMEK Image Generator</h1>
        <input type="text" id="promptInput" placeholder="Enter your creative prompt" />
        <button onclick="generateImage()">Generate Image</button>
        <div class="spinner" id="loadingSpinner"></div>
        <img id="generatedImage" src="" alt="Generated Image" />
        <button id="regenerateButton" onclick="regenerateImage()">Regenerate</button>
        <a href="https://whatsapp.com/channel/0029VakaPzeD38CV78dbGf0e" target="_blank" class="telegram-link" id="telegramLink">
            Join Our WhatsApp
        </a>
        <div class="footer">
            MADE BY ROMEK-XD
        </div>
    </div>

    <script>
        // Function to generate or regenerate the image
        function generateImage() {
            const prompt = document.getElementById("promptInput").value.trim();
            if (!prompt) {
                alert("Please enter a prompt.");
                return;
            }
            displayImage(prompt);
        }

        function regenerateImage() {
            const prompt = document.getElementById("promptInput").value.trim();
            if (!prompt) {
                alert("Please enter a prompt.");
                return;
            }
            displayImage(prompt);
        }

        // Helper function to display the image with loading animation
        function displayImage(prompt) {
            const imageUrl = `https://img.hazex.workers.dev/?prompt=${encodeURIComponent(prompt)}&improve=true&format=square&random=${Math.random()}`;
            const imageElement = document.getElementById("generatedImage");
            const spinner = document.getElementById("loadingSpinner");
            const regenerateButton = document.getElementById("regenerateButton");
            const telegramLink = document.getElementById("telegramLink");

            // Show the loading spinner and hide other elements
            spinner.style.display = "block";
            imageElement.style.display = "none";
            regenerateButton.style.display = "none";
            telegramLink.style.display = "none";

            // Set the image source immediately
            imageElement.src = imageUrl;

            // Show the image once it's ready (skip onload to make it faster)
            setTimeout(() => {
                spinner.style.display = "none";
                imageElement.style.display = "block";
                regenerateButton.style.display = "inline-block";
                telegramLink.style.display = "inline-block";
            }, 1000); // 1 second delay to simulate image loading
        }
    </script>
</body>
</html>