// GetContent — cookie-/consentbanner (Consent Mode v2).
// Toont alleen bij een eerste bezoek zolang er nog geen keuze is gemaakt. De
// keuze wordt onthouden in localStorage (gc_consent_v1) en doorgegeven aan
// Google Consent Mode via window.gcSetConsent (gedefinieerd in index.html).
// Alleen analytische cookies; geen advertentie-opslag.
function CookieConsent() {
  const NS = window.GetContentDesignSystem_aa0f52;
  const { Button } = NS;
  const [visible, setVisible] = React.useState(false);

  React.useEffect(() => {
    let choice = null;
    try { choice = localStorage.getItem('gc_consent_v1'); } catch (e) {}
    if (!choice) setVisible(true);
  }, []);

  if (!visible) return null;

  const decide = (granted) => {
    if (window.gcSetConsent) window.gcSetConsent(granted);
    setVisible(false);
  };

  return (
    <div role="dialog" aria-label="Cookievoorkeuren" style={{
      position: 'fixed', left: 0, right: 0, bottom: 0, zIndex: 100,
      padding: '0 var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 16px)',
      display: 'flex', justifyContent: 'center', pointerEvents: 'none',
    }}>
      <div style={{
        pointerEvents: 'auto', maxWidth: 720, width: '100%',
        background: 'var(--surface-card)', border: '1px solid var(--border-subtle)',
        borderRadius: 'var(--radius-lg)', boxShadow: 'var(--shadow-lg)',
        padding: 'clamp(16px, 3vw, 22px)',
        display: 'flex', alignItems: 'center', gap: 18, flexWrap: 'wrap',
      }}>
        <p style={{ flex: '1 1 300px', minWidth: 0, fontSize: 14, lineHeight: 1.6, color: 'var(--text-body)', margin: 0 }}>
          We gebruiken analytische cookies om GetContent te verbeteren. Alleen met jouw toestemming.
        </p>
        <div style={{ display: 'flex', gap: 10, flex: 'none', flexWrap: 'wrap' }}>
          <Button variant="ghost" onClick={() => decide(false)}>Weigeren</Button>
          <Button variant="primary" onClick={() => decide(true)}>Accepteren</Button>
        </div>
      </div>
    </div>
  );
}
window.CookieConsent = CookieConsent;
