<?php
include '../includes/header3.php';
?>

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <title>Login via MAC</title>
    <style>
        /* === ESTILO FUTURISTA === */

        body {
            background-image: url('./img/painel/background/background.jpg');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            font-family: "Segoe UI", Arial, sans-serif;
            color: var(--text-primary);
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            min-height: 100vh;
            padding-top: 80px;
            overflow-x: hidden;
        }

        .login-box {
            background: var(--surface-light);
            padding: 40px 60px;
            border-radius: 20px;
            width: 90vw;
            max-width: 850px;
            box-sizing: border-box;
            box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .login-box::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, var(--primary), var(--accent), var(--primary-dark));
            animation: borderGlow 3s ease-in-out infinite;
        }

        @keyframes borderGlow {
            0%, 100% { opacity: 0.6; }
            50% { opacity: 1; }
        }

        h2 {
            font-size: 2.2rem;
            margin-bottom: 30px;
            text-transform: uppercase;
            letter-spacing: 2px;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-weight: 700;
        }

        input {
            display: block;
            width: 70%;
            min-width: 320px;
            max-width: 650px;
            padding: 14px 20px;
            margin: 15px auto;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--surface-lighter);
            color: var(--text-primary);
            font-size: 1.05rem;
            transition: all 0.3s ease;
            box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
        }

        input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
            outline: none;
        }

        input::placeholder {
            color: var(--text-muted);
        }

        button[type="submit"] {
            background: linear-gradient(135deg, var(--accent), #0dbf36);
            color: white;
            padding: 14px 24px;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            width: 75%;
            min-width: 330px;
            max-width: 680px;
            margin-top: 20px;
            font-size: 1.1rem;
            font-weight: 700;
            letter-spacing: 1px;
            box-shadow: var(--glow);
            transition: all 0.3s ease;
            text-transform: uppercase;
        }

        button[type="submit"]:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(49, 255, 3, 0.5);
        }

        /* CAPTCHA */
        .captcha-container {
            margin: 25px 0;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
            flex-wrap: wrap;
        }

        .captcha-image {
            border-radius: 10px;
            border: 1px solid var(--border);
            padding: 10px;
            background: rgba(0, 0, 0, 0.3);
            cursor: pointer;
            transition: all 0.3s ease;
            height: 80px;
        }

        .captcha-image:hover {
            transform: scale(1.05);
            border-color: var(--primary);
            box-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
        }

        .refresh-captcha {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            color: white;
            border: none;
            border-radius: 10px;
            padding: 10px 18px;
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: bold;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 6px;
            height: 50px;
            box-shadow: var(--glow);
        }

        .refresh-captcha:hover {
            background: linear-gradient(135deg, var(--primary-dark), var(--primary));
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 212, 255, 0.5);
        }

        .captcha-text {
            font-size: 0.95rem;
            color: var(--accent);
            margin-top: 5px;
            font-weight: 500;
        }

        /* Partículas */
        @keyframes moveParticles {
            from { transform: translateY(0); opacity: 0.7; }
            to { transform: translateY(-1000px); opacity: 0; }
        }

        .particle {
            position: fixed;
            bottom: 0;
            width: 2px;
            height: 2px;
            background: var(--primary);
            opacity: 0.6;
            animation: moveParticles linear infinite;
            z-index: -1;
        }

        .particle:nth-child(odd) { background: var(--accent); }

        @media (max-width: 768px) {
            .login-box {
                width: 95vw;
                padding: 30px;
            }
            input, button[type="submit"] {
                width: 90%;
                max-width: none;
            }
            .captcha-container {
                flex-direction: column;
                gap: 10px;
            }
        }
    </style>
</head>
<body>
    <div class="login-box">
        <h2><i class="fas fa-microchip"></i> Login via MAC</h2>
        <form method="post">
            <input type="text" name="mac" id="mac" placeholder="Endereço MAC *" maxlength="17" required>
            <input type="text" name="key" placeholder="Digite a Key *" required>

            <div class="captcha-container">
                <img src="captcha.php?<?php echo time(); ?>" alt="Captcha" class="captcha-image" id="captchaImage">
                <button type="button" class="refresh-captcha" id="refreshCaptcha">🔄 Atualizar</button>
            </div>
            <div class="captcha-text">Clique na imagem ou no botão para gerar novo captcha</div>
            
            <input type="text" name="captcha" placeholder="Digite o Captcha *" required>

            <button type="submit"><i class="fas fa-sign-in-alt"></i> Acessar</button>
        </form>
    </div>

    <script>
    // Efeito de partículas
    document.addEventListener("DOMContentLoaded", function() {
        const numParticles = 30;
        const particlesContainer = document.createElement('div');
        particlesContainer.style.position = 'fixed';
        particlesContainer.style.top = '0';
        particlesContainer.style.left = '0';
        particlesContainer.style.width = '100%';
        particlesContainer.style.height = '100%';
        particlesContainer.style.pointerEvents = 'none';
        particlesContainer.style.zIndex = '-1';
        for (let i = 0; i < numParticles; i++) {
            const particle = document.createElement('div');
            particle.classList.add('particle');
            particle.style.left = Math.random() * 100 + 'vw';
            particle.style.animationDuration = (3 + Math.random() * 7) + 's';
            particle.style.animationDelay = Math.random() * 8 + 's';
            particle.style.width = particle.style.height = (1 + Math.random() * 3) + 'px';
            particlesContainer.appendChild(particle);
        }
        document.body.appendChild(particlesContainer);
    });

    // Formatar MAC em tempo real
    document.getElementById('mac').addEventListener('input', function(e) {
        let value = e.target.value.replace(/[^a-fA-F0-9]/g, '');
        let formatted = '';
        for (let i = 0; i < value.length; i++) {
            if (i > 0 && i % 2 === 0 && i < 12) {
                formatted += ':';
            }
            formatted += value[i];
        }
        e.target.value = formatted.toUpperCase();
    });

    // Atualizar captcha
    function refreshCaptcha() {
        const captchaImage = document.getElementById('captchaImage');
        captchaImage.src = 'captcha.php?' + new Date().getTime();
        captchaImage.style.opacity = '0.7';
        setTimeout(() => captchaImage.style.opacity = '1', 300);
    }

    document.getElementById('refreshCaptcha').addEventListener('click', refreshCaptcha);
    document.getElementById('captchaImage').addEventListener('click', refreshCaptcha);
    setInterval(refreshCaptcha, 120000);
    </script>
</body>
</html>
