<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Next-Gen Code Generator</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&family=Fira+Code&display=swap" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.21/vanta.net.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
    <style>
        :root {
            --primary-color: #6C63FF;
            --secondary-color: #4CAF50;
            --background-color: #1A1A2E;
            --text-color: #FFFFFF;
            --card-bg-color: rgba(255, 255, 255, 0.1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Roboto', sans-serif;
            background-color: var(--background-color);
            color: var(--text-color);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow-x: hidden;
        }

        .container {
            width: 90%;
            max-width: 800px;
            padding: 2rem;
            background-color: var(--card-bg-color);
            border-radius: 20px;
            backdrop-filter: blur(10px);
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
            border: 1px solid rgba(255, 255, 255, 0.18);
            transform: translateY(50px);
            opacity: 0;
            transition: all 0.5s ease;
        }

        .container:hover {
            box-shadow: 0 16px 64px 0 rgba(31, 38, 135, 0.6);
        }

        h1 {
            text-align: center;
            margin-bottom: 2rem;
            font-size: 2.5rem;
            background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }

        form {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        .input-group {
            position: relative;
        }

        label {
            position: absolute;
            top: 0;
            left: 1rem;
            transform: translateY(-50%);
            background-color: var(--background-color);
            padding: 0 0.5rem;
            font-size: 0.9rem;
            color: var(--primary-color);
            transition: all 0.3s ease;
            pointer-events: none;
        }

        input[type="text"], select {
            width: 100%;
            padding: 1rem;
            background-color: var(--background-color);
            border: 2px solid transparent;
            border-radius: 10px;
            color: var(--text-color);
            font-size: 1rem;
            transition: all 0.3s ease;
        }

        input[type="text"]:focus, select:focus {
            outline: none;
            border-color: var(--secondary-color);
            box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
        }

        input[type="text"]:focus + label,
        select:focus + label {
            color: var(--secondary-color);
            top: -0.8rem;
            font-size: 0.8rem;
            transform: translateY(0);
        }

        input[type="text"]:not(:placeholder-shown) + label,
        select:not([value=""]) + label {
            top: -0.8rem;
            font-size: 0.8rem;
            transform: translateY(0);
        }

        input[type="submit"] {
            padding: 1rem 2rem;
            background-color: var(--primary-color);
            color: var(--text-color);
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-size: 1rem;
            font-weight: bold;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        input[type="submit"]:hover {
            background-color: var(--secondary-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(46, 204, 113, 0.2);
        }

        .loader {
            display: none;
            width: 50px;
            height: 50px;
            border: 5px solid var(--primary-color);
            border-top: 5px solid var(--secondary-color);
            border-radius: 50%;
            margin: 2rem auto;
            animation: spin 1s linear infinite;
        }

        #output {
            margin-top: 2rem;
            padding: 1.5rem;
            background-color: rgba(0, 0, 0, 0.5);
            border-radius: 10px;
            font-family: 'Fira Code', monospace;
            font-size: 0.9rem;
            line-height: 1.5;
            white-space: pre-wrap;
            overflow-x: auto;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.5s ease;
        }

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

        @media (max-width: 600px) {
            .container {
                width: 95%;
                padding: 1.5rem;
            }

            h1 {
                font-size: 2rem;
            }

            input[type="text"], select, input[type="submit"] {
                font-size: 0.9rem;
            }
        }
    </style>
</head>
<body>
    <div id="vanta-background"></div>
    <div class="container">
        <h1>Next-Gen Code Generator</h1>
        <form id="codeForm">
            <div class="input-group">
                <input type="text" id="codeType" name="codeType" required>
                <label for="codeType">Enter code type</label>
            </div>
            <div class="input-group">
                <select id="language" name="language" required>
                    <option value="" disabled selected>Select language</option>
                    <option value="python">Python</option>
                    <option value="java">Java</option>
                    <option value="javascript">JavaScript</option>
                    <option value="c">C</option>
                    <option value="c++">C++</option>
                    <option value="html">HTML</option>
                    <option value="ruby">Ruby</option>
                </select>
                <label for="language">Programming language</label>
            </div>
            <input type="submit" value="Generate Code">
        </form>
        <div class="loader" id="loader"></div>
        <div id="output"></div>
    </div>

    <script>
        VANTA.NET({
            el: "#vanta-background",
            mouseControls: true,
            touchControls: true,
            gyroControls: false,
            minHeight: 200.00,
            minWidth: 200.00,
            scale: 1.00,
            scaleMobile: 1.00,
            color: 0x6C63FF,
            backgroundColor: 0x1A1A2E,
            points: 10,
            maxDistance: 20.00,
            spacing: 20.00
        });

        gsap.to('.container', {
            opacity: 1,
            y: 0,
            duration: 1,
            ease: 'power3.out'
        });

        gsap.from('#vanta-background', {
            opacity: 0,
            duration: 1.5,
            ease: 'power2.out'
        });

        const form = document.getElementById('codeForm');
        const loader = document.getElementById('loader');
        const output = document.getElementById('output');

        form.addEventListener('submit', async (e) => {
            e.preventDefault();
            const codeType = document.getElementById('codeType').value;
            const language = document.getElementById('language').value;

            gsap.to(form, { opacity: 0.5, pointerEvents: 'none', duration: 0.3 });
            loader.style.display = 'block';
            output.style.display = 'none';

            try {
                const response = await fetch('/code_generation', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                    body: `codeType=${codeType}&language=${language}`
                });
                const data = await response.json();
                output.textContent = data.response;
                
                gsap.to(output, {
                    display: 'block',
                    opacity: 1,
                    y: 0,
                    duration: 0.5,
                    ease: 'power2.out'
                });
            } catch (error) {
                console.error('Error:', error);
                output.textContent = 'Error generating code. Please try again.';
            } finally {
                loader.style.display = 'none';
                gsap.to(form, { opacity: 1, pointerEvents: 'auto', duration: 0.3 });
            }
        });

        // Floating label animation
        const inputs = document.querySelectorAll('input[type="text"], select');
        inputs.forEach(input => {
            input.addEventListener('focus', () => {
                input.previousElementSibling.style.color = '#4CAF50';
            });
            input.addEventListener('blur', () => {
                if (input.value === "") {
                    input.previousElementSibling.style.color = '#6C63FF';
                }
            });
        });
    </script>
</body>
</html>
just enhance styles to get more creative and more animated affects