<?php


//<----------------------------------------------------------->
//<-------------------COPIA AI BRUXÃO------------------------->
//<-------------CONTATO: https://t.me/eonbry------------------>
//<-------------DEVELOPER: MANIA DE SCRIPT----------------->
//<----------------------------------------------------------->


// Funções para obter IP, login, e manipulação do banco de dados
function getIPAddress() {
    $ip = 'undefined';
    if (isset($_SERVER)) {
        $ip = $_SERVER['REMOTE_ADDR'];
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else if (isset($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        }
    } else {
        $ip = getenv('REMOTE_ADDR');
        if (getenv('HTTP_X_FORWARDED_FOR')) {
            $ip = getenv('HTTP_X_FORWARDED_FOR');
        } else if (getenv('HTTP_CLIENT_IP')) {
            $ip = getenv('HTTP_CLIENT_IP');
        }
    }
    $ip = htmlspecialchars($ip, ENT_QUOTES, 'UTF-8');
    return $ip;
}

session_start();

// Carregar informações do arquivo JSON
$info = json_decode(file_get_contents('./includes/eggzie.json'), true);
$aa = $info['info']['aa'];

// Criar ou abrir banco de dados SQLite
$db = new SQLite3('./a/.eggziepanels.db');
$db->exec('CREATE TABLE IF NOT EXISTS USERS(id INT PRIMARY KEY, NAME TEXT, USERNAME TEXT, PASSWORD TEXT, LOGO TEXT)');

// Verificar se não há usuários e inserir um usuário padrão
$userCountQuery = $db->query('SELECT COUNT(*) as count FROM USERS');
$userCount = $userCountQuery->fetchArray()['count'];
if ($userCount == 0) {
    $db->exec('INSERT INTO USERS(id, NAME, USERNAME, PASSWORD, LOGO) VALUES(\'1\', \'Your Name\', \'maxrebrands29\', \'maxrebrands29\', \'img/logo.png\')');
}

// Obter dados do usuário padrão
$userQuery = $db->query('SELECT * FROM USERS WHERE id=\'1\'');
$user = $userQuery->fetchArray();
$userName = $user['NAME'];
$userLogo = $user['LOGO'];









// ============================
// ===== FUNÇÃO SUB-REVENDA ===
// ============================
function LoginReseller($usernamee, $password) {
    $db = new SQLite3('./a/.eggziedb.db');
    $query = 'SELECT * FROM sub_revenda WHERE usuario="' . $usernamee . '"';
    $result = $db->query($query);

    while ($row = $result->fetchArray()) {
        $revendaId = $row['id'];
        $name = $row['nome'];
        $usuario = $row['usuario'];
        $passwordFromDB = $row['senha'];
    }

    // === BLOQUEIO DE SUBREVENDA (com design futurista) ===
    $block_file = __DIR__ . '/a/subrevenda_block.json';
    if (file_exists($block_file)) {
        $blocked_data = json_decode(file_get_contents($block_file), true);
        if (isset($blocked_data[$usernamee]) && $blocked_data[$usernamee]['blocked'] === true) {

            echo '
            <!DOCTYPE html>
            <html lang="pt-br">
            <head>
                <meta charset="utf-8">
                <title>Acesso Bloqueado - ULTRA IBO</title>
                <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
                <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
                <style>
                    body {
                        background: radial-gradient(circle at center, #0a0f1c, #000);
                        font-family: "Inter", sans-serif;
                        height: 100vh;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        color: #fff;
                        overflow: hidden;
                    }
                    .blocked-container {
                        background: rgba(10, 15, 28, 0.9);
                        border: 1px solid rgba(255,255,255,0.1);
                        border-radius: 20px;
                        box-shadow: 0 0 40px rgba(0, 212, 255, 0.25);
                        max-width: 480px;
                        width: 90%;
                        padding: 40px 30px;
                        text-align: center;
                        backdrop-filter: blur(20px);
                        animation: fadeIn 0.8s ease-in-out;
                        position: relative;
                        overflow: hidden;
                    }
                    .blocked-container::before {
                        content: "";
                        position: absolute;
                        top: 0;
                        left: 0;
                        right: 0;
                        height: 3px;
                        background: linear-gradient(90deg, #00d4ff, #00ff88, #ff6b9d);
                        animation: glowLine 3s linear infinite;
                    }
                    @keyframes glowLine { 0%,100%{opacity:0.6;} 50%{opacity:1;} }
                    .blocked-icon {
                        font-size: 70px;
                        color: #ff416c;
                        margin-bottom: 20px;
                        text-shadow: 0 0 15px rgba(255,65,108,0.6);
                    }
                    .blocked-title {
                        font-size: 1.8rem;
                        background: linear-gradient(135deg, #00d4ff, #00ff88);
                        -webkit-background-clip: text;
                        -webkit-text-fill-color: transparent;
                        font-weight: 700;
                        margin-bottom: 10px;
                    }
                    .blocked-message {
                        font-size: 1rem;
                        color: #b0b7c3;
                        margin-bottom: 30px;
                        line-height: 1.6;
                    }
                    .blocked-buttons {
                        display: flex;
                        justify-content: center;
                        gap: 15px;
                    }
                    .btn-futuristic {
                        border: none;
                        border-radius: 10px;
                        padding: 12px 22px;
                        font-size: 0.95rem;
                        font-weight: 600;
                        text-transform: uppercase;
                        cursor: pointer;
                        transition: all 0.3s ease;
                        box-shadow: 0 0 20px rgba(0,0,0,0.3);
                    }
                    .btn-ok {
                        background: linear-gradient(135deg, #00d4ff, #0099cc);
                        color: white;
                    }
                    .btn-ok:hover {
                        box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
                        transform: translateY(-2px);
                    }
                    .btn-contact {
                        background: linear-gradient(135deg, #ff6b9d, #ff416c);
                        color: white;
                    }
                    .btn-contact:hover {
                        box-shadow: 0 0 20px rgba(255, 65, 108, 0.6);
                        transform: translateY(-2px);
                    }
                    @keyframes fadeIn {
                        from {opacity: 0; transform: scale(0.95);}
                        to {opacity: 1; transform: scale(1);}
                    }
                    .particle {
                        position: fixed;
                        bottom: 0;
                        width: 2px;
                        height: 2px;
                        background: #00d4ff;
                        opacity: 0.6;
                        animation: moveParticles linear infinite;
                        z-index: -1;
                    }
                    @keyframes moveParticles {
                        from { transform: translateY(0); opacity: 0.8; }
                        to { transform: translateY(-1000px); opacity: 0; }
                    }
                </style>
            </head>
            <body>
                <div class="blocked-container">
                    <i class="fa-solid fa-ban blocked-icon"></i>
                    <div class="blocked-title">Acesso Bloqueado</div>
                    <div class="blocked-message">
                        Sua conta de Subrevenda foi temporariamente bloqueada pelo administrador.<br>
                        Entre em contato com o suporte para mais informações.
                    </div>
                    <div class="blocked-buttons">
                        <button class="btn-futuristic btn-ok" onclick="window.location.href=\'login.php\'">
                            <i class="fa-solid fa-rotate-left"></i> OK
                        </button>
                        <button class="btn-futuristic btn-contact" onclick="window.open(\'https://t.me/eonbry\', \'_blank\')">
                            <i class="fa-brands fa-telegram"></i> Contato
                        </button>
                    </div>
                </div>
                <script>
                    const numParticles = 25;
                    for (let i = 0; i < numParticles; i++) {
                        const p = document.createElement("div");
                        p.className = "particle";
                        p.style.left = Math.random() * 100 + "vw";
                        p.style.animationDuration = (3 + Math.random() * 7) + "s";
                        p.style.animationDelay = Math.random() * 5 + "s";
                        document.body.appendChild(p);
                    }
                </script>
            </body>
            </html>';
            exit;
        }
    }

    // Login normal
    if (empty($revendaId)) {
        $errorMessage = '<div class="alert alert-danger" id="flash-msg"><h4><i class="icon fa fa-times"></i>Não é um usuário válido!</h4></div>';
        echo $errorMessage;
    } else if ($passwordFromDB == $password) {
        $_SESSION['eggzie_iboPlayer3'] = true;
        $_SESSION['reseller_name'] = $usuario;
        $_SESSION['aviso_reseller'] = false;
        $_SESSION['id'] = $revendaId;
        header('Location: sub_revenda/index.php');
    } else {
        $errorMessage = '<div class="alert alert-danger" id="flash-msg"><h4><i class="icon fa fa-times"></i>Senha incorreta!</h4></div>';
        echo $errorMessage;
    }

    $db->close();
}




// ============================
// ===== FUNÇÃO REVENDA =======
// ============================
function LoginSeller($usernamee, $password) {
    $db = new SQLite3('./a/.eggziedb.db');
    $query = 'SELECT * FROM revenda WHERE usuario="' . $usernamee . '"';
    $result = $db->query($query);

    while ($row = $result->fetchArray()) {
        $revendaId = $row['id'];
        $name = $row['nome'];
        $usuario = $row['usuario'];
        $passwordFromDB = $row['senha'];
    }

    // === BLOQUEIO DE REVENDA ===
    $block_file = __DIR__ . '/a/revenda_block.json';
    // === BLOQUEIO DE REVENDA (com design futurista) ===
$block_file = __DIR__ . '/a/revenda_block.json';
if (file_exists($block_file)) {
    $blocked_data = json_decode(file_get_contents($block_file), true);
    if (isset($blocked_data[$usernamee]) && $blocked_data[$usernamee]['blocked'] === true) {

        echo '
        <!DOCTYPE html>
        <html lang="pt-br">
        <head>
            <meta charset="utf-8">
            <title>Acesso Bloqueado - ULTRA IBO</title>
            <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
            <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
            <style>
                body {
                    background: radial-gradient(circle at center, #0a0f1c, #000);
                    font-family: "Inter", sans-serif;
                    height: 100vh;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    color: #fff;
                    overflow: hidden;
                }
                .blocked-container {
                    background: rgba(10, 15, 28, 0.9);
                    border: 1px solid rgba(255,255,255,0.1);
                    border-radius: 20px;
                    box-shadow: 0 0 40px rgba(0, 212, 255, 0.25);
                    max-width: 480px;
                    width: 90%;
                    padding: 40px 30px;
                    text-align: center;
                    backdrop-filter: blur(20px);
                    animation: fadeIn 0.8s ease-in-out;
                    position: relative;
                    overflow: hidden;
                }
                .blocked-container::before {
                    content: "";
                    position: absolute;
                    top: 0;
                    left: 0;
                    right: 0;
                    height: 3px;
                    background: linear-gradient(90deg, #00d4ff, #00ff88, #ff6b9d);
                    animation: glowLine 3s linear infinite;
                }
                @keyframes glowLine {
                    0%, 100% {opacity: 0.6;}
                    50% {opacity: 1;}
                }
                .blocked-icon {
                    font-size: 70px;
                    color: #ff416c;
                    margin-bottom: 20px;
                    text-shadow: 0 0 15px rgba(255, 65, 108, 0.6);
                }
                .blocked-title {
                    font-size: 1.8rem;
                    background: linear-gradient(135deg, #00d4ff, #00ff88);
                    -webkit-background-clip: text;
                    -webkit-text-fill-color: transparent;
                    font-weight: 700;
                    margin-bottom: 10px;
                }
                .blocked-message {
                    font-size: 1rem;
                    color: #b0b7c3;
                    margin-bottom: 30px;
                    line-height: 1.6;
                }
                .blocked-buttons {
                    display: flex;
                    justify-content: center;
                    gap: 15px;
                }
                .btn-futuristic {
                    border: none;
                    border-radius: 10px;
                    padding: 12px 22px;
                    font-size: 0.95rem;
                    font-weight: 600;
                    text-transform: uppercase;
                    cursor: pointer;
                    transition: all 0.3s ease;
                    box-shadow: 0 0 20px rgba(0,0,0,0.3);
                }
                .btn-ok {
                    background: linear-gradient(135deg, #00d4ff, #0099cc);
                    color: white;
                }
                .btn-ok:hover {
                    box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
                    transform: translateY(-2px);
                }
                .btn-contact {
                    background: linear-gradient(135deg, #ff6b9d, #ff416c);
                    color: white;
                }
                .btn-contact:hover {
                    box-shadow: 0 0 20px rgba(255, 65, 108, 0.6);
                    transform: translateY(-2px);
                }
                @keyframes fadeIn {
                    from {opacity: 0; transform: scale(0.95);}
                    to {opacity: 1; transform: scale(1);}
                }
                /* Efeito de partículas leves */
                .particle {
                    position: fixed;
                    bottom: 0;
                    width: 2px;
                    height: 2px;
                    background: #00d4ff;
                    opacity: 0.6;
                    animation: moveParticles linear infinite;
                    z-index: -1;
                }
                @keyframes moveParticles {
                    from { transform: translateY(0); opacity: 0.8; }
                    to { transform: translateY(-1000px); opacity: 0; }
                }
            </style>
        </head>
        <body>
            <div class="blocked-container">
                <i class="fa-solid fa-ban blocked-icon"></i>
                <div class="blocked-title">Acesso Bloqueado</div>
                <div class="blocked-message">
                    Sua conta foi temporariamente bloqueada pelo administrador.<br>
                    Entre em contato com o suporte para mais informações.
                </div>
                <div class="blocked-buttons">
                    <button class="btn-futuristic btn-ok" onclick="window.location.href=\'login.php\'">
                        <i class="fa-solid fa-rotate-left"></i> OK
                    </button>
                    <button class="btn-futuristic btn-contact" onclick="window.open(\'https://t.me/eonbry\', \'_blank\')">
                        <i class="fa-brands fa-telegram"></i> Contato
                    </button>
                </div>
            </div>
            <script>
                // Criar partículas de fundo
                const numParticles = 25;
                for (let i = 0; i < numParticles; i++) {
                    const p = document.createElement("div");
                    p.className = "particle";
                    p.style.left = Math.random() * 100 + "vw";
                    p.style.animationDuration = (3 + Math.random() * 7) + "s";
                    p.style.animationDelay = Math.random() * 5 + "s";
                    document.body.appendChild(p);
                }
            </script>
        </body>
        </html>';
        exit;
    }
}


    if (empty($revendaId)) {
        LoginReseller($usernamee, $password);
    } else if ($passwordFromDB == $password) {
        $_SESSION['eggzie_iboPlayer2'] = true;
        $_SESSION['seller_name'] = $usuario;
        $_SESSION['aviso_seller'] = false;
        $_SESSION['id'] = $revendaId;
        header('Location: revenda/index.php');
    } else {
        LoginReseller($usernamee, $password);
    }

    $db->close();
}



// ============================
// ===== LOGIN ADMIN =========
// ============================
if (isset($_POST['login'])) {
    $usernamee = $_POST['username'];
    $password = $_POST['password'];

    $query = 'SELECT * FROM USERS WHERE USERNAME="' . $usernamee . '"';
    $result = $db->query($query);

    while ($row = $result->fetchArray()) {
        $userId = $row['id'];
        $name = $row['NAME'];
        $username = $row['USERNAME'];
        $passwordFromDB = $row['PASSWORD'];
        $logo = $row['LOGO'];
    }

    if (empty($userId)) {
        LoginSeller($usernamee, $password);
    } else if ($passwordFromDB == $password) {
        $_SESSION['eggzie_iboPlayer'] = true;
        $_SESSION['N'] = $userId;
        $_SESSION['admin_name'] = $username;
        $_SESSION['id'] = $userId;
        header('Location: users.php');
    } else {
        LoginSeller($usernamee, $password);
    }

    $db->close();
}


// ============================
// ===== LOG DE ACESSOS =======
// ============================
$date = date('d-m-Y H:i:s');
$ipAddress = getIPAddress();
$logDb = new SQLite3('./a/.logs.db');
$logDb->exec('CREATE TABLE IF NOT EXISTS logs(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, date TEXT, ipaddress TEXT)');
$logDb->exec('INSERT INTO logs(date, ipaddress) VALUES(\'' . $date . '\', \'' . $ipAddress . '\')');

// Criar ou abrir outro banco de dados SQLite
$dataDb = new SQLite3('./a/.eggziedb.db');
$dataDb->exec('CREATE TABLE IF NOT EXISTS ibo(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, mac_address VARCHAR(100), username VARCHAR(100), password VARCHAR(100), expire_date VARCHAR(100), url VARCHAR(100), title VARCHAR(100), created_at VARCHAR(100))');
$dataDb->exec('CREATE TABLE IF NOT EXISTS theme(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(100), url VARCHAR(100))');

?>


<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>IBO REVENDA ULTRA</title>
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Round" rel="stylesheet">
    <link href="css/sb-admin-<?php echo $aa; ?>.css" rel="stylesheet">
    <link rel="shortcut icon" href="ibo1.gif" type="image/x-icon">
    <link rel="icon" href="ibo1.gif" type="image/x-icon">
    <style>
    /* === DESIGN FUTURISTA MODERNO === */
    :root {
        --primary: #00D4FF;
        --primary-dark: #0099CC;
        --secondary: #FF6B9D;
        --tertiary: #ba4c50;
        --tertiary-dark: #a81d23;
        --accent: #00FF88;
        --surface: #0A0F1C;
        --surface-light: #1A1F2C;
        --surface-lighter: #2A2F3C;
        --text-primary: #FFFFFF;
        --text-secondary: #B0B7C3;
        --text-muted: #6B7280;
        --border: rgba(255,255,255,0.1);
        --glow: 0 0 20px rgba(0, 212, 255, 0.3);
        --glow-accent: 0 0 20px rgba(0, 255, 136, 0.3);
        --glow-pink: 0 0 20px rgba(255, 107, 157, 0.3);
    }

    /* === LAYOUT PRINCIPAL === */
    .login-main-container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        padding: 20px;
        position: relative;
    }

    /* === FUNDO FUTURISTA COM ANIMAÇÃO === */
    body {
        background: radial-gradient(circle at center, #0a0a0f, #000);
        font-family: 'Inter', sans-serif;
        min-height: 100vh;
        margin: 0;
        overflow-x: hidden;
        position: relative;
    }

    /* Efeito de partículas futuristas */
    @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: #4e73df;
        opacity: 0.5;
        animation: moveParticles linear infinite;
        z-index: -1;
    }

    .particle:nth-child(odd) {
        background: #6b8cff;
    }

    /* Gradientes animados no fundo */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.15) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255, 107, 157, 0.15) 0%, transparent 50%),
                    radial-gradient(circle at 40% 40%, rgba(0, 255, 136, 0.1) 0%, transparent 50%);
        pointer-events: none;
        z-index: -1;
        animation: gradientShift 8s ease-in-out infinite;
    }

    @keyframes gradientShift {
        0%, 100% { transform: scale(1) rotate(0deg); }
        50% { transform: scale(1.1) rotate(180deg); }
    }

    /* === CONTAINER DE LOGIN FUTURISTA === */
    .login-container-futuristic {
        background: rgba(10, 15, 28, 0.85);
        backdrop-filter: blur(20px);
        border: 1px solid var(--border);
        border-radius: 24px;
        padding: 40px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
        max-width: 480px;
        width: 100%;
        text-align: center;
        position: relative;
        overflow: hidden;
        animation: containerFloat 6s ease-in-out infinite;
        z-index: 10;
    }

    @keyframes containerFloat {
        0%, 100% { transform: translateY(0px) scale(1); }
        50% { transform: translateY(-10px) scale(1.02); }
    }

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

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

    /* === CONTAINER DE RECUPERAÇÃO (SOBREPOSTO) === */
    .recovery-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(10px);
        z-index: 100;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .recovery-container-futuristic {
        background: rgba(10, 15, 28, 0.95);
        border: 1px solid var(--border);
        border-radius: 24px;
        padding: 40px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), var(--glow-pink), inset 0 1px 0 rgba(255, 255, 255, 0.1);
        max-width: 480px;
        width: 100%;
        text-align: center;
        position: relative;
        overflow: hidden;
        animation: modalSlideIn 0.4s ease-out;
    }

    @keyframes modalSlideIn {
        from { opacity: 0; transform: scale(0.8); }
        to { opacity: 1; transform: scale(1); }
    }

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

    /* Logo futurista */
    .login-logo {
        width: 140px;
        height: 140px;
        margin: 0 auto 20px;
        border-radius: 20px;
        background: linear-gradient(135deg, var(--surface-light), var(--surface-lighter));
        padding: 12px;
        border: 2px solid transparent;
        background-clip: padding-box;
        position: relative;
        box-shadow: var(--glow);
        transition: all 0.3s ease;
    }

    .login-logo:hover {
        transform: scale(1.05);
        box-shadow: 0 0 40px rgba(0, 212, 255, 0.5);
    }

    .login-logo::before {
        content: '';
        position: absolute;
        inset: -2px;
        border-radius: 22px;
        padding: 2px;
        background: linear-gradient(135deg, var(--primary), var(--accent), var(--secondary));
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        animation: rotate 3s linear infinite;
    }

    @keyframes rotate {
        100% { transform: rotate(1turn); }
    }

    .login-logo img {
        width: 100%;
        height: 100%;
        border-radius: 16px;
        object-fit: cover;
    }

    /* Títulos futuristas */
    .login-title {
        background: linear-gradient(135deg, var(--primary), var(--accent));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 8px;
        text-transform: uppercase;
        letter-spacing: 2px;
        text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    }

    .recovery-title {
        background: linear-gradient(135deg, var(--secondary), var(--primary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-size: 1.8rem;
        font-weight: 700;
        margin-bottom: 8px;
        text-transform: uppercase;
        letter-spacing: 2px;
        text-shadow: 0 0 20px rgba(255, 107, 157, 0.5);
    }

    .login-subtitle {
        color: var(--text-secondary);
        font-size: 1.1rem;
        font-weight: 500;
        margin-bottom: 30px;
        letter-spacing: 1px;
    }

    .recovery-subtitle {
        color: var(--text-secondary);
        font-size: 1rem;
        font-weight: 500;
        margin-bottom: 25px;
        line-height: 1.5;
    }

    /* Formulário futurista */
    .login-form, .recovery-form {
        text-align: left;
    }

    .form-group-futuristic {
        margin-bottom: 20px;
        position: relative;
    }

    .form-label {
        display: block;
        color: var(--text-primary);
        font-weight: 600;
        margin-bottom: 8px;
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .input-futuristic {
        width: 100%;
        background: var(--surface-lighter);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px 20px;
        color: var(--text-primary);
        font-size: 1rem;
        transition: all 0.3s ease;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .input-futuristic:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(0, 212, 255, 0.1), var(--glow);
        background: var(--surface-light);
    }

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

    /* Botão futurista principal */
    .btn-futuristic {
        width: 100%;
        background: linear-gradient(135deg, var(--tertiary), var(--tertiary-dark));
        border: none;
        border-radius: 12px;
        padding: 16px 20px;
        color: white;
        font-size: 1.1rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 2px;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        box-shadow: var(--glow);
        margin-bottom: 15px;
    }

    /* Botão de recuperação (secundário) */
    .btn-recovery-secondary {
        background: transparent;
        border: 2px solid var(--secondary);
        color: var(--secondary);
        padding: 12px 20px;
        font-size: 0.95rem;
        box-shadow: none;
        margin-bottom: 0;
    }

    .btn-recovery-secondary:hover {
        background: var(--secondary);
        color: white;
        box-shadow: var(--glow-pink);
    }

    /* Botão de recuperação (primário) */
    .btn-recovery {
        background: linear-gradient(135deg, var(--secondary), #ff416c);
        box-shadow: var(--glow-pink);
    }

    /* Botão para fechar */
    .btn-close {
        background: transparent;
        border: 2px solid var(--text-muted);
        color: var(--text-muted);
        padding: 12px 20px;
        font-size: 0.95rem;
        width: auto;
        margin-top: 10px;
    }

    .btn-close:hover {
        background: var(--text-muted);
        color: var(--surface);
        border-color: var(--text-muted);
    }

    .btn-futuristic::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(23, 101, 153, 0.6), transparent);
        transition: left 0.5s;
    }

    .btn-futuristic:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4), var(--glow);
    }

    .btn-recovery:hover {
        box-shadow: 0 8px 25px rgba(255, 107, 157, 0.4), var(--glow-pink);
    }

    .btn-futuristic:hover::before {
        left: 100%;
    }

    .btn-futuristic:active {
        transform: translateY(0);
    }

    /* Links e informações adicionais */
    .login-footer, .recovery-footer {
        margin-top: 25px;
        color: var(--text-muted);
        font-size: 0.9rem;
    }

    .developer-credit {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid var(--border);
        color: var(--text-muted);
        font-size: 0.9rem;
    }

    .developer-credit a {
        color: var(--primary);
        text-decoration: none;
        font-weight: 600;
        transition: all 0.3s ease;
    }

    .developer-credit a:hover {
        color: var(--accent);
        text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    }

    /* Efeitos de brilho nos textos */
    .glow-text {
        text-shadow: 0 0 10px currentColor;
    }

    /* === MODAL DE INFORMAÇÕES FUTURISTA === */
    .info-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(10px);
        z-index: 1000;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .info-modal-content {
        background: rgba(10, 15, 28, 0.95);
        border: 1px solid var(--border);
        border-radius: 24px;
        padding: 30px;
        max-width: 500px;
        width: 100%;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), var(--glow);
        position: relative;
        animation: modalSlideIn 0.4s ease-out;
    }

    .info-modal-header {
        border-bottom: 1px solid var(--border);
        padding-bottom: 15px;
        margin-bottom: 20px;
        text-align: center;
    }

    .info-modal-title {
        background: linear-gradient(135deg, var(--accent), var(--primary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-size: 1.5rem;
        font-weight: 700;
        margin: 0;
    }

    .info-modal-body {
        color: var(--text-secondary);
    }

    .user-info-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    .user-info-label {
        font-weight: 600;
        color: var(--text-primary);
        text-transform: uppercase;
        font-size: 0.85rem;
        letter-spacing: 0.5px;
    }

    .user-info-value {
        color: var(--accent);
        font-weight: 600;
        text-align: right;
    }

    .password-display {
        background: rgba(0, 212, 255, 0.1);
        border: 1px solid var(--primary);
        border-radius: 8px;
        padding: 10px 15px;
        margin: 10px 0;
        font-family: 'Courier New', monospace;
        font-size: 1.1rem;
        font-weight: bold;
        text-align: center;
        color: var(--accent);
        letter-spacing: 2px;
    }

    .no-results {
        text-align: center;
        color: var(--text-muted);
        padding: 20px;
        font-style: italic;
    }

    /* Botão de copiar senha */
    .btn-copy {
        background: rgba(0, 212, 255, 0.1);
        border: 1px solid var(--primary);
        color: var(--primary);
        padding: 8px 16px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 0.8rem;
        margin-left: 10px;
        transition: all 0.3s ease;
    }

    .btn-copy:hover {
        background: var(--primary);
        color: white;
    }

    /* Responsividade */
    @media (max-width: 768px) {
        .login-main-container {
            padding: 10px;
        }
        
        .login-container-futuristic,
        .recovery-container-futuristic,
        .info-modal-content {
            padding: 30px 20px;
        }
        
        .login-title, .recovery-title {
            font-size: 1.6rem;
        }
        
        .login-subtitle, .recovery-subtitle {
            font-size: 1rem;
        }
        
        .login-logo {
            width: 120px;
            height: 120px;
        }
    }

    /* Animações de entrada */
    @keyframes fadeInUp {
        from { opacity: 0; transform: translateY(30px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .login-container-futuristic {
        animation: fadeInUp 0.8s ease-out;
    }
    
    
    
    .login-container-futuristic .developer-credit {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.login-container-futuristic .developer-credit a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.login-container-futuristic .developer-credit a:hover {
    color: var(--accent);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}
    </style>
</head>
<body>
    <!-- Partículas animadas -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const numParticles = 50;
            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 = (2 + Math.random() * 8) + 's';
                particle.style.animationDelay = Math.random() * 10 + 's';
                particle.style.width = particle.style.height = (1 + Math.random() * 4) + 'px';
                particle.style.background = `hsl(${Math.random() * 360}, 70%, 60%)`;
                particlesContainer.appendChild(particle);
            }
            
            document.body.appendChild(particlesContainer);
        });
    </script>

  <!-- Container Principal de Login -->
<div class="login-main-container">
    <div class="login-container-futuristic">
        <!-- Logo -->
        <div class="login-logo">
            <img src="<?php echo $userLogo; ?>" alt="ULTRA IBO">
        </div>

        <!-- Títulos -->
        <h1 class="login-title">ULTRA IBO</h1>
        <div class="login-subtitle">SISTEMA DE GERENCIAMENTO</div>
        <div class="login-subtitle glow-text" style="color: var(--primary);"><?php echo $userName; ?></div>

        <!-- Formulário -->
        <form method="post" class="login-form">
            <div class="form-group-futuristic">
                <label class="form-label">
                    <i class="fas fa-user" style="margin-right: 8px;"></i>
                    USUÁRIO
                </label>
                <input type="text" class="input-futuristic" name="username" placeholder="Digite seu usuário" required autofocus>
            </div>

            <div class="form-group-futuristic">
                <label class="form-label">
                    <i class="fas fa-lock" style="margin-right: 8px;"></i>
                    SENHA
                </label>
                <input type="password" class="input-futuristic" name="password" placeholder="Digite sua senha" required>
            </div>

            <button class="btn-futuristic" name="login" type="submit">
                <i class="fas fa-sign-in-alt" style="margin-right: 10px;"></i>
                ACESSAR SISTEMA
            </button>

            <!-- Botão para abrir recuperação -->
            <button type="button" class="btn-futuristic btn-recovery-secondary" onclick="openRecovery()">
                <i class="fas fa-key" style="margin-right: 8px;"></i>
                RECUPERAR ACESSO
            </button>
        </form>

        <!-- Footer -->
        <div class="login-footer">
            <i class="fas fa-shield-alt" style="margin-right: 8px;"></i>
            Sistema Seguro & Protegido
        </div>

        <!-- Developer Credit DENTRO do container -->
        
    </div>
</div>

            

    <!-- Overlay de Recuperação (Sobreposto) -->
    <div class="recovery-overlay" id="recoveryOverlay">
        <div class="recovery-container-futuristic">
            <!-- Títulos -->
            <h2 class="recovery-title">RECUPERAR ACESSO</h2>
            <div class="recovery-subtitle">
                Informe seu email Nepster para recuperar suas credenciais de acesso ao painel.
            </div>

            <!-- Formulário de Recuperação -->
            <form class="recovery-form" id="recoveryForm">
                <div class="form-group-futuristic">
                    <label class="form-label">
                        <i class="fas fa-envelope" style="margin-right: 8px;"></i>
                        EMAIL NEPSTER
                    </label>
                    <input type="email" class="input-futuristic" id="recoveryEmail" 
                           placeholder="seuemail@nepster.xyz" required>
                </div>

                <button type="submit" class="btn-futuristic btn-recovery">
                    <i class="fas fa-search" style="margin-right: 10px;"></i>
                    BUSCAR INFORMAÇÕES
                </button>

          

            <!-- Footer -->
            <div class="recovery-footer">
                <i class="fas fa-info-circle" style="margin-right: 8px;"></i>
                Sistema irá buscar suas credenciais no banco de dados
            </div>
        </div>
    </div>

    <!-- Modal de Informações -->
    <div class="info-modal" id="infoModal">
        <div class="info-modal-content">
            <div class="info-modal-header">
                <h3 class="info-modal-title">INFORMAÇÕES DA CONTA</h3>
            </div>
            
            <div class="info-modal-body" id="modalContent">
                <!-- Conteúdo será preenchido via JavaScript -->
            </div>

            <!-- Botão Fechar no final -->
            <button class="btn-futuristic btn-close" onclick="closeAllModals()" style="margin-top: 20px;">
                <i class="fas fa-times" style="margin-right: 8px;"></i>
                FECHAR
            </button>
        </div>
        
    </div>

   

    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <script src="js/sb-admin-2.min.js"></script>

    <script>
    // Função para abrir o overlay de recuperação
    function openRecovery() {
        document.getElementById('recoveryOverlay').style.display = 'flex';
    }

    // Função para fechar o overlay de recuperação
    function closeRecovery() {
        document.getElementById('recoveryOverlay').style.display = 'none';
        // Limpar o campo de email
        document.getElementById('recoveryEmail').value = '';
    }

    // Função para fechar todos os modais e voltar ao login
    function closeAllModals() {
        document.getElementById('infoModal').style.display = 'none';
        document.getElementById('recoveryOverlay').style.display = 'none';
        document.getElementById('recoveryEmail').value = '';
    }

    // Função para buscar informações do usuário
    document.getElementById('recoveryForm').addEventListener('submit', function(e) {
        e.preventDefault();
        
        const email = document.getElementById('recoveryEmail').value.trim();
        
        if (!email) {
            alert('Por favor, insira um email válido.');
            return;
        }

        buscarInformacoesUsuario(email);
    });

   function buscarInformacoesUsuario(email) {
    const modalContent = document.getElementById('modalContent');
    modalContent.innerHTML = '<div style="text-align: center; padding: 20px;"><i class="fas fa-spinner fa-spin" style="font-size: 2rem; color: var(--primary);"></i><p style="margin-top: 10px;">Buscando informações...</p></div>';
    
    document.getElementById('infoModal').style.display = 'flex';
    document.getElementById('recoveryOverlay').style.display = 'none';

    // Fazer requisição AJAX REAL para o PHP
    fetch('buscar_usuario.php', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: 'email=' + encodeURIComponent(email)
    })
    .then(response => response.json())
    .then(data => {
        if (data.success) {
            exibirInformacoesUsuario(data.user);
        } else {
            modalContent.innerHTML = `
                <div class="no-results">
                    <i class="fas fa-exclamation-triangle" style="font-size: 3rem; color: var(--secondary); margin-bottom: 15px;"></i>
                    <h4 style="color: var(--text-primary); margin-bottom: 10px;">Nenhuma conta encontrada</h4>
                    <p style="color: var(--text-muted);">O email <strong>${email}</strong> não foi encontrado em nosso sistema.</p>
                    <p style="color: var(--text-muted); font-size: 0.9rem; margin-top: 10px;">Verifique se o email está correto ou entre em contato com o suporte.</p>
                </div>
            `;
        }
    })
    .catch(error => {
        modalContent.innerHTML = `
            <div class="no-results">
                <i class="fas fa-exclamation-circle" style="font-size: 3rem; color: var(--secondary); margin-bottom: 15px;"></i>
                <h4 style="color: var(--text-primary); margin-bottom: 10px;">Erro na busca</h4>
                <p style="color: var(--text-muted);">Ocorreu um erro ao buscar as informações. Tente novamente.</p>
            </div>
        `;
        console.error('Erro:', error);
    });
}

    function exibirInformacoesUsuario(data) {
        const modalContent = document.getElementById('modalContent');
        
        modalContent.innerHTML = `
            <div class="user-info-item">
                <span class="user-info-label">Usuário:</span>
                <span class="user-info-value">${data.usuario}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">Nome:</span>
                <span class="user-info-value">${data.nome}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">Senha:</span>
                <div style="display: flex; align-items: center; justify-content: space-between;">
                    <span class="password-display">${data.senha}</span>
                    <button class="btn-copy" onclick="copyToClipboard('${data.senha}')">
                        <i class="fas fa-copy"></i> Copiar
                    </button>
                </div>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">Tipo:</span>
                <span class="user-info-value">${data.tipo}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">Email:</span>
                <span class="user-info-value">${data.email}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">ID Referência:</span>
                <span class="user-info-value">${data.id_ref}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">Data de Registro:</span>
                <span class="user-info-value">${data.data_registro}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">MACs Disponíveis:</span>
                <span class="user-info-value">${data.macs_disponiveis}</span>
            </div>
            <div class="user-info-item">
                <span class="user-info-label">Status:</span>
                <span class="user-info-value" style="color: var(--accent);">${data.status}</span>
            </div>
            <div style="margin-top: 20px; padding: 15px; background: rgba(0,212,255,0.1); border-radius: 10px; border-left: 4px solid var(--primary);">
                <small style="color: var(--text-secondary);">
                    <i class="fas fa-info-circle" style="margin-right: 5px;"></i>
                    Use as credenciais acima para fazer login no sistema.
                </small>
            </div>
        `;
    }

    // Função para copiar senha para área de transferência
    function copyToClipboard(text) {
        navigator.clipboard.writeText(text).then(function() {
            // Feedback visual
            const btn = event.target.closest('.btn-copy');
            const originalHtml = btn.innerHTML;
            btn.innerHTML = '<i class="fas fa-check"></i> Copiado!';
            btn.style.background = 'var(--accent)';
            btn.style.color = 'white';
            btn.style.borderColor = 'var(--accent)';
            
            setTimeout(() => {
                btn.innerHTML = originalHtml;
                btn.style.background = 'rgba(0, 212, 255, 0.1)';
                btn.style.color = 'var(--primary)';
                btn.style.borderColor = 'var(--primary)';
            }, 2000);
        }).catch(function(err) {
            console.error('Erro ao copiar: ', err);
            alert('Erro ao copiar a senha. Tente novamente.');
        });
    }

    // Fechar modais clicando fora
    window.onclick = function(event) {
        const recoveryOverlay = document.getElementById('recoveryOverlay');
        const infoModal = document.getElementById('infoModal');
        
        if (event.target === recoveryOverlay) {
            closeRecovery();
        }
        if (event.target === infoModal) {
            closeAllModals();
        }
    }

    // Fechar modais com ESC
    document.addEventListener('keydown', function(event) {
        if (event.key === 'Escape') {
            closeAllModals();
        }
    });
    </script>
</body>
</html>