<?php
require_once __DIR__.'/../config/config.php';require_once __DIR__.'/../config/database.php';require_once __DIR__.'/../includes/functions.php';
$cfg=(require __DIR__.'/../config/oauth.php')['google'];
if(!$cfg['client_id']||!$cfg['client_secret']){setFlash('error','Login com Google ainda não foi configurado no servidor.');header('Location: '.SITE_URL.'/auth/login.php');exit;}
$state=bin2hex(random_bytes(24));$_SESSION['oauth_google_state']=$state;
$params=['client_id'=>$cfg['client_id'],'redirect_uri'=>$cfg['redirect_uri'],'response_type'=>'code','scope'=>'openid email profile','state'=>$state,'access_type'=>'offline','prompt'=>'select_account'];
header('Location: https://accounts.google.com/o/oauth2/v2/auth?'.http_build_query($params));exit;
