'use client';

import { useState, useEffect } from 'react';

export default function CookieBanner() {
  const [showBanner, setShowBanner] = useState(false);

  useEffect(() => {
    const cookieConsent = localStorage.getItem('cookieConsent');
    if (!cookieConsent) {
      setShowBanner(true);
    }
  }, []);

  const handleAccept = () => {
    localStorage.setItem('cookieConsent', 'true');
    setShowBanner(false);
  };

  if (!showBanner) {
    return null;
  }

  return (
    <div className="fixed bottom-0 inset-x-0 bg-flyer-black text-white border-t-4 border-flyer-yellow p-4 flex flex-col items-center z-50">
      <p className="text-center max-w-prose mx-auto">Beim Steinbruchfest gibt es dann frische Mehlspeisen. Hier leider nur technisch notwendige Cookies</p>
      <button onClick={handleAccept} className="bg-flyer-yellow text-black font-bold px-6 py-2 rounded-full mt-3 hover:scale-105 transition-transform">Akzeptieren</button>
    </div>
  );
}
