// PDPA cookie consent banner — fixed bottom, dismissible, persists in localStorage
function CookieBanner() {
  const [show, setShow] = React.useState(false);
  React.useEffect(() => {
    try { if (!localStorage.getItem('bestx-cookie-consent')) setShow(true); } catch (e) { setShow(true); }
  }, []);
  const dismiss = (v) => {
    try { localStorage.setItem('bestx-cookie-consent', v); } catch (e) {}
    setShow(false);
  };
  if (!show) return null;
  return (
    <div style={{
      position: 'fixed', left: 24, right: 24, bottom: 24, zIndex: 750,
      maxWidth: 880, margin: '0 auto',
      background: '#fbfaf5', border: '1px solid rgba(26,43,74,0.12)',
      boxShadow: '0 16px 48px rgba(10,18,38,0.18)',
      padding: '1.8rem 2rem',
      display: 'grid', gridTemplateColumns: '1fr auto', gap: '2rem', alignItems: 'center',
    }}>
      <div>
        <div style={{ fontFamily: "'Jost',sans-serif", fontWeight: 500, fontSize: '0.72rem',
          letterSpacing: '0.32em', textTransform: 'uppercase', color: '#2d6a7a',
          marginBottom: '0.6rem' }}>คุกกี้ · COOKIES (PDPA)</div>
        <p style={{ fontFamily: "'Sarabun',sans-serif", fontWeight: 400, fontSize: '0.95rem',
          color: '#4a5260', lineHeight: 1.7, margin: 0 }}>
          เราใช้คุกกี้เพื่อจดจำการตั้งค่าและวิเคราะห์การใช้เว็บไซต์ การกด "ยอมรับ" ถือว่าท่านยินยอมตาม{' '}
          <a href="Privacy.html" style={{ color: '#2d6a7a', borderBottom: '1px solid currentColor' }}>นโยบายความเป็นส่วนตัว</a>
        </p>
      </div>
      <div style={{ display: 'flex', gap: '1.5rem', alignItems: 'center' }}>
        <button onClick={() => dismiss('declined')} style={{
          fontFamily: "'Jost',sans-serif", fontWeight: 500, fontSize: '0.72rem',
          letterSpacing: '0.25em', textTransform: 'uppercase',
          background: 'transparent', border: 'none', color: '#7a8290',
          padding: '0.5rem 0', cursor: 'pointer',
        }}>ปฏิเสธ</button>
        <button onClick={() => dismiss('accepted')} style={{
          fontFamily: "'Jost',sans-serif", fontWeight: 500, fontSize: '0.78rem',
          letterSpacing: '0.25em', textTransform: 'uppercase',
          background: '#1a2b4a', color: '#fbfaf5', border: 'none',
          padding: '0.9rem 1.8rem', cursor: 'pointer',
        }}>ยอมรับ</button>
      </div>
    </div>
  );
}
window.CookieBanner = CookieBanner;
