// KASHA website — 쿠키·개인정보 수집 동의 배너
// 동의 시에만 분석/픽셀이 로드돼요(개인정보 보호).
function ConsentBanner() {
  const { Button } = window.DS;
  const [show, setShow] = React.useState(() => { try { return window.localStorage.getItem("kasha_consent") == null; } catch (e) { return false; } });
  if (!show) return null;

  const accept = () => { window.KASHAIntegrations && window.KASHAIntegrations.grantConsent(); setShow(false); };
  const decline = () => { window.KASHAIntegrations && window.KASHAIntegrations.denyConsent(); setShow(false); };

  return (
    <div style={{ position: "fixed", left: 16, right: 16, bottom: 16, zIndex: 1600, maxWidth: 720, margin: "0 auto", background: "var(--ink)", color: "#fff", borderRadius: "var(--radius-lg)", boxShadow: "var(--shadow-xl)", padding: "18px 20px", display: "flex", alignItems: "center", gap: 16, flexWrap: "wrap", fontFamily: "var(--font-sans)" }}>
      <div style={{ flex: 1, minWidth: 220 }}>
        <div style={{ fontSize: 14, fontWeight: 700 }}>쿠키 사용 안내</div>
        <div style={{ fontSize: 13, color: "var(--gray-400)", marginTop: 4, lineHeight: 1.5 }}>
          서비스 개선과 통계 분석을 위해 쿠키를 사용해요. 동의하시면 방문 분석이 활성화됩니다.
        </div>
      </div>
      <div style={{ display: "flex", gap: 8, flexShrink: 0 }}>
        <button onClick={decline} style={{ height: 40, padding: "0 16px", borderRadius: "var(--radius-input)", border: "1px solid rgba(255,255,255,0.25)", background: "transparent", color: "#fff", fontFamily: "var(--font-sans)", fontSize: 14, fontWeight: 600, cursor: "pointer" }}>거부</button>
        <Button variant="accent" onClick={accept}>동의</Button>
      </div>
    </div>
  );
}
window.ConsentBanner = ConsentBanner;
