const menuBtn=document.querySelector('.menu-btn');
const mobileNav=document.querySelector('.mobile-nav');
if(menuBtn&&mobileNav){
  menuBtn.addEventListener('click',()=>{
    mobileNav.classList.toggle('open');
    menuBtn.setAttribute('aria-expanded',mobileNav.classList.contains('open')?'true':'false');
  });
  mobileNav.querySelectorAll('a').forEach(a=>a.addEventListener('click',()=>mobileNav.classList.remove('open')));
}
function encodeMail(value){return encodeURIComponent(value||'');}
function quoteMail(e){
  e.preventDefault();
  const f=e.currentTarget, d=new FormData(f);
  const body=[
    "REQUEST A QUOTE — AL RIF'AH FOODS",'',
    'Name: '+(d.get('name')||''),
    'Company: '+(d.get('company')||''),
    'Email: '+(d.get('email')||''),
    'Phone / WhatsApp: '+(d.get('phone')||''),
    'Country / Market: '+(d.get('market')||''),
    'Brand / Product Required: '+(d.get('product')||''),
    'Quantity: '+(d.get('quantity')||''),
    '',
    'Message / Special Requirements:',
    d.get('message')||''
  ].join('\\n');
  location.href='mailto:sales@alrifahfoods.com?subject='+encodeMail('Quotation Request — '+(d.get('company')||d.get('name')||'Website Enquiry'))+'&body='+encodeMail(body);
}
function contactMail(e){
  e.preventDefault();
  const f=e.currentTarget, d=new FormData(f);
  const body=[
    "GENERAL WEBSITE ENQUIRY — AL RIF'AH FOODS",'',
    'Name: '+(d.get('name')||''),
    'Company: '+(d.get('company')||''),
    'Email: '+(d.get('email')||''),
    'Subject: '+(d.get('subject')||''),
    '',
    'Message:',
    d.get('message')||''
  ].join('\\n');
  location.href='mailto:info@alrifahfoods.com?subject='+encodeMail(d.get('subject')||'Website Enquiry')+'&body='+encodeMail(body);
}

document.querySelectorAll('.mobile-nav a').forEach(a=>a.addEventListener('click',()=>document.querySelector('.mobile-nav')?.classList.remove('open')));