.elementor-kit-9{--e-global-color-primary:#6EC1E4;--e-global-color-secondary:#54595F;--e-global-color-text:#7A7A7A;--e-global-color-accent:#61CE70;--e-global-typography-primary-font-family:"Roboto";--e-global-typography-primary-font-weight:600;--e-global-typography-secondary-font-family:"Roboto Slab";--e-global-typography-secondary-font-weight:400;--e-global-typography-text-font-family:"Roboto";--e-global-typography-text-font-weight:400;--e-global-typography-accent-font-family:"Roboto";--e-global-typography-accent-font-weight:500;}.elementor-kit-9 e-page-transition{background-color:#FFBC7D;}.elementor-section.elementor-section-boxed > .elementor-container{max-width:1140px;}.e-con{--container-max-width:1140px;}.elementor-widget:not(:last-child){--kit-widget-spacing:20px;}.elementor-element{--widgets-spacing:20px 20px;--widgets-spacing-row:20px;--widgets-spacing-column:20px;}{}h1.entry-title{display:var(--page-title-display);}@media(max-width:1024px){.elementor-section.elementor-section-boxed > .elementor-container{max-width:1024px;}.e-con{--container-max-width:1024px;}}@media(max-width:767px){.elementor-section.elementor-section-boxed > .elementor-container{max-width:767px;}.e-con{--container-max-width:767px;}}
/* Start custom CSS */<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json");

// Insira a chave da OpenAI do seu projeto
$openAiApiKey = 'SUA_OPENAI_API_KEY_AQUI';

$input = json_decode(file_get_contents('php://input'), true);
$userMessage = $input['message'] ?? '';

if (empty($userMessage)) {
    echo json_encode(['reply' => 'Olá! Como posso te ajudar com os cursos do Instituto hoje?']);
    exit;
}

$systemPrompt = "Você é a Secretaria Virtual de Admissão do Instituto. Seu papel é tirar dúvidas sobre cursos, horários e modalidades de forma cortês, objetiva e acolhedora.
SEU OBJETIVO PRINCIPAL: Sanar a dúvida imediata e solicitar o NOME do aluno, o WHATSAPP e O CURSO DE INTERESSE para que a secretaria envie a tabela detalhada de bolsas e descontos.
DIRETRIZES DE RESPOSTA:
1. Máximo de 2 a 3 frases curtas por mensagem.
2. Nunca invente valores fixos ou promessas enganosas. Se perguntarem preço, diga: 'Nossas mensalidades contam com bolsas e descontos conforme o turno. Para eu te enviar a tabela completa atualizada no WhatsApp, qual o seu NOME e o SEU NÚMERO DE WHATSAPP?'";

$payload = [
    'model' => 'gpt-4o-mini',
    'messages' => [
        ['role' => 'system', 'content' => $systemPrompt],
        ['role' => 'user', 'content' => $userMessage]
    ],
    'max_tokens' => 220,
    'temperature' => 0.4
];

$ch = curl_init('https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $openAiApiKey
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
$reply = $data['choices'][0]['message']['content'] ?? 'Obrigado pelo contato! Para informações sobre turmas, informe seu WhatsApp para nossa equipe entrar em contato.';

echo json_encode(['reply' => $reply]);
?>/* End custom CSS */