/* Foto Neon — shared site chrome for the multi-page prototype.
   SiteNav (page-aware top bar), SiteFooter, and the GSAP animation hook.
   Everything is attached to window so the per-page babel scripts can use it. */

const FNC = window.FotoNeonDesignSystem_0a5c5f;

const FN_BRAND = {
  phone: "+381 61 160 4669",
  phoneHref: "tel:+381611604669",
  instagram: "@foto_neon_",
  instagramHref: "https://www.instagram.com/foto_neon_/",
  logo: (typeof window !== "undefined" && window.FN_LOGO) || "assets/logo.jpg",
};

const FN_NAV = [
  { id: "home", label: "Početna" },
  { id: "shop", label: "Shop" },
  { id: "gallery", label: "Galerija" },
  { id: "about", label: "O nama" },
];

/* Reveal helper: add .fn-in to a [data-reveal] element, or to each child of a
   [data-reveal-stagger] container (with a per-child transition delay). Adding the
   class to CHILDREN means React re-applying a container's className can't strip it.
   Exposed on window so pages can re-reveal after a filter change. */
function fnRevealEl(el) {
  if (!el) return;
  const targets = el.hasAttribute("data-reveal-stagger") ? el.children : [el];
  Array.prototype.forEach.call(targets, (t, i) => {
    if (t.classList.contains("fn-in")) return;
    t.style.animationDelay = Math.min(i, 8) * 0.06 + "s";
    t.classList.add("fn-in");
  });
}

/* ---------- SiteNav ---------- */
function NavTab({ active, children, onClick }) {
  const [hover, setHover] = React.useState(false);
  return (
    <button
      onClick={onClick}
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        background: "none", border: "none", cursor: "pointer",
        fontFamily: "var(--font-body)", fontSize: "0.875rem", fontWeight: 500,
        textTransform: "uppercase", letterSpacing: "0.1em", padding: "0.35rem 0",
        color: active ? "var(--neon-cyan)" : hover ? "var(--text-primary)" : "var(--text-secondary)",
        textShadow: active ? "0 0 10px var(--neon-cyan)" : "none",
        borderBottom: active ? "2px solid var(--neon-cyan)" : "2px solid transparent",
        transition: "color 0.3s ease, text-shadow 0.3s ease",
      }}
    >
      {children}
    </button>
  );
}

function SiteNav({ page, onNav, cart = 0, onCartClick }) {
  const [scrolled, setScrolled] = React.useState(false);
  const [open, setOpen] = React.useState(false);
  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 40);
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  const go = (id) => { onNav(id); setOpen(false); };

  return (
    <nav style={{
      position: "fixed", top: 0, left: 0, right: 0, zIndex: 50,
      padding: scrolled ? "0.75rem 0" : "1.25rem 0",
      background: scrolled ? "rgba(5,5,8,0.92)" : "rgba(5,5,8,0.35)",
      backdropFilter: "blur(12px)", WebkitBackdropFilter: "blur(12px)",
      borderBottom: `1px solid ${scrolled ? "rgba(255,16,240,0.18)" : "transparent"}`,
      transition: "all 0.4s ease",
    }}>
      <div style={{ maxWidth: "80rem", margin: "0 auto", padding: "0 1.5rem", display: "flex", alignItems: "center", justifyContent: "space-between", gap: "1rem" }}>
        {/* Brand */}
        <button onClick={() => go("home")} style={{ display: "flex", alignItems: "center", gap: "0.6rem", background: "none", border: "none", cursor: "pointer", padding: 0 }}>
          <img src={FN_BRAND.logo} alt="" style={{ width: 36, height: 36, borderRadius: "50%", boxShadow: "0 0 14px rgba(0,255,240,0.3)" }} />
          <span style={{ fontFamily: "var(--font-display)", fontSize: "1.35rem", color: "var(--neon-pink)", textShadow: "0 0 10px var(--neon-pink), 0 0 20px var(--neon-pink)", lineHeight: 1 }}>FOTO&nbsp;NEON</span>
        </button>

        {/* Desktop tabs */}
        <div className="fn-nav-tabs" style={{ display: "flex", alignItems: "center", gap: "2rem" }}>
          {FN_NAV.map((n) => <NavTab key={n.id} active={page === n.id} onClick={() => go(n.id)}>{n.label}</NavTab>)}
        </div>

        {/* Right cluster */}
        <div style={{ display: "flex", alignItems: "center", gap: "1rem" }}>
          <button onClick={onCartClick} title="Korpa" style={{ position: "relative", background: "none", border: "none", cursor: "pointer", fontSize: "1.25rem", lineHeight: 1, filter: "drop-shadow(0 0 6px rgba(0,255,240,0.5))" }}>
            🛒
            {cart > 0 && (
              <span style={{ position: "absolute", top: -8, right: -10, minWidth: 18, height: 18, padding: "0 4px", borderRadius: 9999, background: "var(--neon-pink)", color: "#050508", fontSize: 11, fontWeight: 700, fontFamily: "var(--font-body)", display: "grid", placeItems: "center", boxShadow: "0 0 10px var(--neon-pink)" }}>{cart}</span>
            )}
          </button>
          <div className="fn-nav-cta">
            <FNC.NeonButton color="cyan" size="sm" onClick={() => go("shop")}>Naruči</FNC.NeonButton>
          </div>
          <button className="fn-nav-burger" onClick={() => setOpen((o) => !o)} aria-label="Meni" style={{ display: "none", flexDirection: "column", gap: 5, background: "none", border: "none", cursor: "pointer", padding: 6 }}>
            {[0, 1, 2].map((i) => (
              <span key={i} style={{ width: 24, height: 2, background: "var(--neon-pink)", boxShadow: "0 0 5px var(--neon-pink)", transition: "all 0.3s ease",
                transform: open && i === 0 ? "translateY(7px) rotate(45deg)" : open && i === 2 ? "translateY(-7px) rotate(-45deg)" : "none",
                opacity: open && i === 1 ? 0 : 1 }} />
            ))}
          </button>
        </div>
      </div>

      {/* Mobile dropdown */}
      <div className="fn-nav-mobile" style={{ display: "none", overflow: "hidden", maxHeight: open ? 320 : 0, transition: "max-height 0.4s ease", background: "rgba(5,5,8,0.97)" }}>
        <div style={{ padding: "1rem 1.5rem", display: "flex", flexDirection: "column", gap: "1rem" }}>
          {FN_NAV.map((n) => <NavTab key={n.id} active={page === n.id} onClick={() => go(n.id)}>{n.label}</NavTab>)}
        </div>
      </div>

      <style>{`
        @media (max-width: 820px) {
          .fn-nav-tabs { display: none !important; }
          .fn-nav-cta { display: none !important; }
          .fn-nav-burger { display: flex !important; }
          .fn-nav-mobile { display: block !important; }
        }
      `}</style>
    </nav>
  );
}

/* ---------- SiteFooter ---------- */
function FooterLink({ children, onClick, href }) {
  const [hover, setHover] = React.useState(false);
  const style = {
    background: "none", border: "none", padding: 0, textAlign: "left", cursor: "pointer",
    fontFamily: "var(--font-body)", fontSize: "0.9rem", textDecoration: "none",
    color: hover ? "var(--neon-cyan)" : "var(--text-secondary)",
    textShadow: hover ? "0 0 8px var(--neon-cyan)" : "none", transition: "color 0.25s ease",
  };
  if (href) return <a href={href} target="_blank" rel="noopener noreferrer" onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)} style={style}>{children}</a>;
  return <button onClick={onClick} onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)} style={style}>{children}</button>;
}

function FooterCol({ title, children }) {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: "0.8rem" }}>
      <h4 style={{ margin: 0, fontSize: "0.8rem", textTransform: "uppercase", letterSpacing: "0.16em", color: "var(--text-muted)", fontWeight: 600 }}>{title}</h4>
      {children}
    </div>
  );
}

function SiteFooter({ onNav }) {
  return (
    <footer style={{ position: "relative", zIndex: 10, borderTop: "1px solid var(--border-hairline)", background: "rgba(5,5,8,0.85)", backdropFilter: "blur(12px)" }}>
      <div style={{ maxWidth: "80rem", margin: "0 auto", padding: "4rem 1.5rem 2rem", display: "grid", gridTemplateColumns: "1.6fr 1fr 1fr 1.2fr", gap: "2.5rem" }} className="fn-footer-grid">
        <div>
          <div style={{ fontFamily: "var(--font-display)", fontSize: "1.6rem", color: "var(--neon-pink)", textShadow: "0 0 10px var(--neon-pink), 0 0 22px var(--neon-pink)", marginBottom: "1rem" }}>FOTO NEON</div>
          <p style={{ color: "var(--text-secondary)", lineHeight: 1.6, maxWidth: "22rem", margin: 0, fontSize: "0.95rem" }}>
            Ručno izrađeni neon znakovi, LED reklame i alu-bond signalizacija. Niš i okolina — od ideje do sjaja.
          </p>
        </div>
        <FooterCol title="Stranice">
          {FN_NAV.map((n) => <FooterLink key={n.id} onClick={() => onNav(n.id)}>{n.label}</FooterLink>)}
        </FooterCol>
        <FooterCol title="Usluge">
          <FooterLink onClick={() => onNav("home")}>Neon znakovi</FooterLink>
          <FooterLink onClick={() => onNav("home")}>LED reklame</FooterLink>
          <FooterLink onClick={() => onNav("home")}>Alu-bond table</FooterLink>
          <FooterLink onClick={() => onNav("home")}>Svetleća slova</FooterLink>
        </FooterCol>
        <FooterCol title="Kontakt">
          <FooterLink href={FN_BRAND.phoneHref}>{FN_BRAND.phone}</FooterLink>
          <FooterLink href={FN_BRAND.instagramHref}>Instagram · {FN_BRAND.instagram}</FooterLink>
          <span style={{ color: "var(--text-secondary)", fontSize: "0.9rem" }}>Niš, Srbija</span>
        </FooterCol>
      </div>
      <div style={{ borderTop: "1px solid var(--border-hairline)", padding: "1.25rem 1.5rem", textAlign: "center", color: "var(--text-muted)", fontSize: "0.8rem" }}>
        © 2026 Foto Neon. Sva prava zadržana.
      </div>
      <style>{`@media (max-width: 820px){ .fn-footer-grid{ grid-template-columns: 1fr 1fr !important; } }
        @media (max-width: 520px){ .fn-footer-grid{ grid-template-columns: 1fr !important; } }`}</style>
    </footer>
  );
}

/* ---------- Shared GSAP hook: hero entrance, scroll reveals, parallax, cursor glow ---------- */
function useFotoNeonAnimations(deps) {
  React.useEffect(() => {
    const g = window.gsap, ST = window.ScrollTrigger;
    const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;

    let moveHandler = null;
    const glow = document.querySelector(".cursor-glow");
    if (g && glow && !reduce) {
      document.body.classList.add("glow-on");
      g.set(glow, { x: window.innerWidth / 2, y: window.innerHeight * 0.4 });
      const xTo = g.quickTo(glow, "x", { duration: 0.6, ease: "power3" });
      const yTo = g.quickTo(glow, "y", { duration: 0.6, ease: "power3" });
      moveHandler = (e) => { xTo(e.clientX); yTo(e.clientY); };
      window.addEventListener("pointermove", moveHandler, { passive: true });
    }

    if (!g || !ST || reduce) {
      document.documentElement.classList.remove("js-anim");
      return () => {
        if (moveHandler) window.removeEventListener("pointermove", moveHandler);
        document.body.classList.remove("glow-on");
      };
    }

    g.registerPlugin(ST);
    const ctx = g.context(() => {
      // Hero entrance (only if a hero is present on this page) — plays immediately
      if (document.querySelector('[data-hero="title"]')) {
        g.timeline({ defaults: { ease: "power3.out" } })
          .fromTo('[data-hero="eyebrow"]', { y: 24, opacity: 0 }, { y: 0, opacity: 1, duration: 0.7 })
          .fromTo('[data-hero="title"]', { y: 20, opacity: 0, scale: 0.96 }, { y: 0, opacity: 1, scale: 1, duration: 0.9 }, "-=0.4")
          .fromTo('[data-hero="lead"]', { y: 20, opacity: 0 }, { y: 0, opacity: 1, duration: 0.7 }, "-=0.5")
          .fromTo('[data-hero="cta"]', { y: 20, opacity: 0 }, { y: 0, opacity: 1, duration: 0.6 }, "-=0.4")
          .fromTo('[data-hero="sign"]', { opacity: 0, scale: 0.85 }, { opacity: 1, scale: 1, duration: 1.1, ease: "power2.out" }, "-=1.1");
      }
      // Background-orb parallax (ScrollTrigger is reliable for scrub work)
      g.utils.toArray(".orb").forEach((orb, i) => {
        g.to(orb, { yPercent: i % 2 ? -14 : 14, ease: "none", scrollTrigger: { trigger: document.body, start: "top top", end: "bottom bottom", scrub: 1 } });
      });
      // Per-element scroll parallax (scrub-based — reliable in this preview, like the orbs).
      // Symmetric drift (+sp → -sp) so the element sits at its natural spot when centered.
      g.utils.toArray("[data-parallax]").forEach((el) => {
        const sp = parseFloat(el.getAttribute("data-parallax")) || 6;
        g.fromTo(el, { yPercent: sp }, { yPercent: -sp, ease: "none", scrollTrigger: { trigger: el, start: "top bottom", end: "bottom top", scrub: true } });
      });
    });

    // Scroll reveals via IntersectionObserver. Adds .fn-in per element/child; the
    // hidden state is :not(.fn-in) in CSS, so revealed items fall back to natural
    // styles (survives React re-renders; no !important fighting hover transforms).
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting) { io.unobserve(e.target); fnRevealEl(e.target); } });
    }, { rootMargin: "0px 0px -6% 0px", threshold: 0.04 });
    document.querySelectorAll("[data-reveal], [data-reveal-stagger]").forEach((el) => io.observe(el));

    // Failsafe: if IO timing is flaky after a page switch, add .fn-in to everything
    // shortly after mount so the one-shot reveal animation runs and settles visible.
    const failsafe = setTimeout(() => {
      document.querySelectorAll("[data-reveal], [data-reveal-stagger] > *").forEach((t) => t.classList.add("fn-in"));
    }, 1000);

    const onLoad = () => ST.refresh();
    window.addEventListener("load", onLoad);
    return () => {
      clearTimeout(failsafe);
      window.removeEventListener("load", onLoad);
      io.disconnect();
      if (moveHandler) window.removeEventListener("pointermove", moveHandler);
      document.body.classList.remove("glow-on");
      ctx.revert();
    };
  }, deps || []);
}

/* ---------- Cart helpers + drawer ---------- */
function fnParsePrice(s) { return parseInt(String(s).replace(/[^\d]/g, ""), 10) || 0; }
function fnFormatPrice(n) { return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, "."); }

const qtyBtn = { width: 26, height: 26, display: "grid", placeItems: "center", background: "transparent", border: "1px solid var(--border-hairline)", color: "var(--text-secondary)", cursor: "pointer", borderRadius: 4, fontSize: "0.95rem", lineHeight: 1 };

function CartLine({ it, onQty, onRemove }) {
  const neon = `var(--neon-${it.color})`;
  const tw = String(it.word).length;
  const fs = tw > 6 ? "0.44rem" : tw > 4 ? "0.6rem" : "0.78rem";
  return (
    <div style={{ display: "flex", gap: "0.9rem", alignItems: "center", padding: "0.9rem 0", borderBottom: "1px solid var(--border-hairline)" }}>
      <div style={{ width: 56, height: 56, flexShrink: 0, display: "grid", placeItems: "center", overflow: "hidden", background: "var(--surface-card-alt)", border: `1px solid ${neon}` }}>
        <span style={{ fontFamily: "var(--font-display)", fontSize: fs, lineHeight: 1, whiteSpace: "nowrap", padding: "0 3px", color: neon, textShadow: `0 0 8px ${neon}` }}>{it.word}</span>
      </div>
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{ color: "var(--text-primary)", fontSize: "0.9rem", fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{it.name}</div>
        <div style={{ color: "var(--text-muted)", fontSize: "0.8rem" }}>{fnFormatPrice(fnParsePrice(it.price))} RSD</div>
        <div style={{ display: "flex", alignItems: "center", gap: "0.5rem", marginTop: "0.4rem" }}>
          <button onClick={() => onQty(it.id, -1)} aria-label="Manje" style={qtyBtn}>−</button>
          <span style={{ color: "var(--text-primary)", fontSize: "0.85rem", minWidth: 18, textAlign: "center" }}>{it.qty}</span>
          <button onClick={() => onQty(it.id, 1)} aria-label="Više" style={qtyBtn}>+</button>
          <button onClick={() => onRemove(it.id)} aria-label="Ukloni" style={{ ...qtyBtn, marginLeft: "auto", borderColor: "transparent", color: "var(--text-muted)" }}>✕</button>
        </div>
      </div>
    </div>
  );
}

function PayField({ label, ...rest }) {
  const [f, setF] = React.useState(false);
  return (
    <label style={{ display: "block" }}>
      <span style={{ display: "block", marginBottom: "0.35rem", fontSize: "0.72rem", textTransform: "uppercase", letterSpacing: "0.1em", color: "var(--text-secondary)" }}>{label}</span>
      <input onFocus={() => setF(true)} onBlur={() => setF(false)} style={{ width: "100%", boxSizing: "border-box", background: "rgba(5,5,8,0.7)", color: "var(--text-primary)", border: `1px solid ${f ? "var(--neon-pink)" : "var(--border-hairline)"}`, borderRadius: 0, padding: "0.7rem 0.85rem", fontFamily: "var(--font-body)", fontSize: "0.95rem", outline: "none", boxShadow: f ? "0 0 12px rgba(255,16,240,0.25)" : "none", transition: "border-color .2s, box-shadow .2s" }} {...rest} />
    </label>
  );
}

function PaymentModal({ open, total, onClose, onPay }) {
  const [card, setCard] = React.useState({ num: "", name: "", exp: "", cvc: "" });
  React.useEffect(() => { if (!open) setCard({ num: "", name: "", exp: "", cvc: "" }); }, [open]);
  if (!open) return null;
  const fmtNum = (v) => v.replace(/\D/g, "").slice(0, 16).replace(/(.{4})/g, "$1 ").trim();
  const submit = (e) => { e.preventDefault(); onPay(); };
  return (
    <div onClick={onClose} style={{ position: "fixed", inset: 0, zIndex: 130, background: "rgba(5,5,8,0.82)", backdropFilter: "blur(6px)", display: "grid", placeItems: "center", padding: "1.5rem" }}>
      <div onClick={(e) => e.stopPropagation()} style={{ width: "min(420px, 100%)", background: "rgba(10,10,18,0.98)", border: "1px solid rgba(255,16,240,0.35)", boxShadow: "0 0 44px rgba(255,16,240,0.25)", padding: "1.75rem" }}>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "1.25rem" }}>
          <span style={{ fontFamily: "var(--font-display)", fontSize: "1.15rem", color: "var(--neon-pink)", textShadow: "0 0 10px var(--neon-pink)" }}>Plaćanje</span>
          <button onClick={onClose} aria-label="Zatvori" style={{ background: "none", border: "none", color: "var(--text-secondary)", fontSize: "1.2rem", cursor: "pointer" }}>✕</button>
        </div>
        <div style={{ display: "flex", justifyContent: "space-between", padding: "0.75rem 1rem", marginBottom: "1.25rem", border: "1px solid var(--border-hairline)", background: "var(--surface-card-alt)" }}>
          <span style={{ color: "var(--text-secondary)", fontSize: "0.85rem" }}>Za naplatu</span>
          <span style={{ color: "var(--text-primary)", fontWeight: 700 }}>{total} RSD</span>
        </div>
        <form onSubmit={submit} style={{ display: "grid", gap: "1rem" }}>
          <PayField label="Broj kartice" value={card.num} onChange={(e) => setCard((c) => ({ ...c, num: fmtNum(e.target.value) }))} placeholder="1234 5678 9012 3456" inputMode="numeric" required />
          <PayField label="Ime na kartici" value={card.name} onChange={(e) => setCard((c) => ({ ...c, name: e.target.value }))} placeholder="Petar Petrović" required />
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem" }}>
            <PayField label="MM/GG" value={card.exp} onChange={(e) => setCard((c) => ({ ...c, exp: e.target.value.replace(/[^\d/]/g, "").slice(0, 5) }))} placeholder="08/28" required />
            <PayField label="CVC" value={card.cvc} onChange={(e) => setCard((c) => ({ ...c, cvc: e.target.value.replace(/\D/g, "").slice(0, 4) }))} placeholder="123" inputMode="numeric" required />
          </div>
          <FNC.NeonButton color="pink" type="submit" style={{ width: "100%", textAlign: "center" }}>Plati {total} RSD</FNC.NeonButton>
        </form>
        <p style={{ textAlign: "center", color: "var(--text-muted)", fontSize: "0.72rem", margin: "0.9rem 0 0" }}>🔒 Demo plaćanje — ne unosite prave podatke kartice.</p>
      </div>
    </div>
  );
}

function CartDrawer({ open, items = [], onClose, onQty, onRemove, onCheckout, onNav }) {
  const [done, setDone] = React.useState(false);
  const [pay, setPay] = React.useState(false);
  React.useEffect(() => { if (!open) { setDone(false); setPay(false); } }, [open]);
  const total = items.reduce((s, it) => s + fnParsePrice(it.price) * it.qty, 0);
  const count = items.reduce((s, it) => s + it.qty, 0);
  const finishPay = () => { setPay(false); setDone(true); onCheckout(); };
  return (
    <React.Fragment>
      <div onClick={onClose} style={{ position: "fixed", inset: 0, zIndex: 110, background: "rgba(5,5,8,0.6)", backdropFilter: "blur(4px)", opacity: open ? 1 : 0, pointerEvents: open ? "auto" : "none", transition: "opacity 0.3s ease" }} />
      <aside aria-hidden={!open} style={{ position: "fixed", top: 0, right: 0, bottom: 0, width: "min(420px, 92vw)", zIndex: 120, background: "rgba(10,10,18,0.98)", backdropFilter: "blur(16px)", borderLeft: "1px solid rgba(255,16,240,0.28)", boxShadow: "-20px 0 60px rgba(0,0,0,0.6)", transform: open ? "translateX(0)" : "translateX(100%)", transition: "transform 0.4s cubic-bezier(.16,1,.3,1)", display: "flex", flexDirection: "column" }}>
        <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", padding: "1.5rem", borderBottom: "1px solid var(--border-hairline)" }}>
          <span style={{ fontFamily: "var(--font-display)", fontSize: "1.2rem", color: "var(--neon-pink)", textShadow: "0 0 10px var(--neon-pink)" }}>Korpa</span>
          <button onClick={onClose} aria-label="Zatvori" style={{ background: "none", border: "none", color: "var(--text-secondary)", fontSize: "1.3rem", cursor: "pointer", lineHeight: 1 }}>✕</button>
        </div>
        <div style={{ flex: 1, overflowY: "auto", padding: "0 1.5rem" }}>
          {done ? (
            <div style={{ textAlign: "center", padding: "3rem 0", color: "var(--text-secondary)" }}>
              <div style={{ fontSize: "2.5rem", marginBottom: "1rem" }}>✨</div>
              <p style={{ color: "var(--neon-green)", fontWeight: 600, textShadow: "0 0 10px var(--neon-green)", margin: "0 0 0.5rem" }}>Hvala na porudžbini!</p>
              <p style={{ margin: 0, fontSize: "0.9rem" }}>Javićemo se u roku od 24h da potvrdimo detalje.</p>
            </div>
          ) : items.length === 0 ? (
            <div style={{ textAlign: "center", padding: "3rem 0", color: "var(--text-muted)" }}>
              <div style={{ fontSize: "2rem", marginBottom: "0.75rem", opacity: 0.5 }}>🛒</div>
              <p style={{ margin: "0 0 1.5rem" }}>Vaša korpa je prazna.</p>
              <FNC.NeonButton color="cyan" size="sm" onClick={() => { onClose(); onNav("shop"); }}>Pogledaj shop</FNC.NeonButton>
            </div>
          ) : (
            items.map((it) => <CartLine key={it.id} it={it} onQty={onQty} onRemove={onRemove} />)
          )}
        </div>
        {!done && items.length > 0 && (
          <div style={{ padding: "1.5rem", borderTop: "1px solid var(--border-hairline)" }}>
            <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: "1rem" }}>
              <span style={{ color: "var(--text-secondary)", textTransform: "uppercase", letterSpacing: "0.1em", fontSize: "0.8rem" }}>Ukupno ({count})</span>
              <span style={{ color: "var(--text-primary)", fontSize: "1.35rem", fontWeight: 700 }}>{fnFormatPrice(total)} <span style={{ fontSize: "0.85rem", color: "var(--text-muted)", fontWeight: 500 }}>RSD</span></span>
            </div>
            <FNC.NeonButton color="pink" onClick={() => setPay(true)} style={{ width: "100%", textAlign: "center" }}>Poruči</FNC.NeonButton>
            <p style={{ textAlign: "center", color: "var(--text-muted)", fontSize: "0.75rem", margin: "0.9rem 0 0" }}>Bez online plaćanja — potvrđujemo porudžbinu telefonom.</p>
          </div>
        )}
      </aside>
      <PaymentModal open={pay} total={fnFormatPrice(total)} onClose={() => setPay(false)} onPay={finishPay} />
    </React.Fragment>
  );
}

Object.assign(window, { SiteNav, SiteFooter, CartDrawer, useFotoNeonAnimations, fnRevealEl, FN_BRAND, FN_NAV });
