-- Inserir Elton Souza na empresa Leader Tecnologia LTDA
INSERT INTO core_business.users (
    company_id,
    name,
    email,
    password_hash,
    type,
    status,
    phone,
    preferences,
    last_login,
    email_verified,
    phone_verified,
    two_factor_enabled,
    deleted,
    created_at,
    updated_at
) VALUES (
    (SELECT id FROM core_business.companies WHERE name = 'Leader Tecnologia LTDA' ORDER BY id DESC LIMIT 1),
    'Elton Souza',
    'elton.souza2@leadertecnologia.com',
    crypt('Leader@2025!Strong#Pass', gen_salt('bf', 12)),
    'ADMIN',
    'ACTIVE',
    '+55 11 99876-5432',
    '{"language": "pt-BR", "timezone": "America/Sao_Paulo", "profile": {"position": "CTO", "department": "Tecnologia"}}',
    CURRENT_TIMESTAMP,
    true,
    false,
    false,
    false,
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP
);

-- Verificar ambos usuários da Leader Tecnologia LTDA
SELECT 
    u.id,
    u.name,
    u.email,
    u.type,
    u.status,
    c.name as company_name,
    u.phone,
    u.email_verified,
    CASE 
        WHEN u.password_hash = crypt('Leader@2025!Strong#Pass', u.password_hash) 
        THEN 'Senha OK ✅'
        ELSE 'Senha Erro ❌'
    END as password_test
FROM core_business.users u
JOIN core_business.companies c ON u.company_id = c.id
WHERE c.name = 'Leader Tecnologia LTDA'
ORDER BY u.id;
