/* Comportamentos exclusivos da página teste.php */

document.addEventListener('DOMContentLoaded',function(){
    const pills=[...document.querySelectorAll('.provider-pill')];
    const sigma=document.getElementById('paneSigma');
    const fastplay=document.getElementById('paneFastplay');
    const sigmaUrl=document.getElementById('apiUrlSigma');
    const fastplayUrl=document.getElementById('apiUrlFastplay');
    const enabled=document.getElementById('enabledSwitch');
    const enabledText=document.getElementById('enabledText');
    function selected(){const r=document.querySelector('input[name="provider"]:checked');return r?r.value:'sigma'}
    function sync(){const p=selected();pills.forEach(x=>x.classList.toggle('active',x.dataset.provider===p));sigma.classList.toggle('active',p==='sigma');fastplay.classList.toggle('active',p==='fastplay')}
    pills.forEach(p=>p.addEventListener('click',function(){const r=p.querySelector('input');if(r)r.checked=true;sync()}));
    enabled.addEventListener('change',function(){enabledText.textContent=enabled.checked?'Teste ativo no aplicativo':'Teste desativado no aplicativo'});
    document.getElementById('formConfigTeste').addEventListener('submit',sync);
    sync();
});
