/* === SHARED MODULES — icons, hooks, router, Nav, Footer, helpers === */

const { useState, useEffect, useRef, useMemo, useLayoutEffect, useCallback } = React;

/* =================================================================
   ICONS — minimal lucide-style set
   ================================================================= */
const Icon = ({ size = 18, color = "currentColor", strokeWidth = 1.7, children }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round">
    {children}
  </svg>
);
const I = {
  ArrowRight:   (p) => <Icon {...p}><path d="M5 12h14M13 5l7 7-7 7"/></Icon>,
  ArrowUpRight: (p) => <Icon {...p}><path d="M7 17 17 7M7 7h10v10"/></Icon>,
  Chevron:      (p) => <Icon {...p}><path d="m9 18 6-6-6-6"/></Icon>,
  ChevronDown:  (p) => <Icon {...p}><path d="m6 9 6 6 6-6"/></Icon>,
  Check:        (p) => <Icon {...p}><path d="M20 6 9 17l-5-5"/></Icon>,
  Brain:        (p) => <Icon {...p}><path d="M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 4.44-1.04Z"/><path d="M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-4.44-1.04Z"/></Icon>,
  Bot:          (p) => <Icon {...p}><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2M20 14h2M15 13v2M9 13v2"/></Icon>,
  Code:         (p) => <Icon {...p}><path d="m16 18 6-6-6-6M8 6l-6 6 6 6"/></Icon>,
  Globe:        (p) => <Icon {...p}><circle cx="12" cy="12" r="10"/><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10Z"/></Icon>,
  HomeSmart:    (p) => <Icon {...p}><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"/><circle cx="12" cy="14" r="2"/></Icon>,
  Currency:     (p) => <Icon {...p}><circle cx="12" cy="12" r="10"/><path d="M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8M12 6v2m0 8v2"/></Icon>,
  Factory:      (p) => <Icon {...p}><path d="M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"/></Icon>,
  Hotel:        (p) => <Icon {...p}><path d="M18 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2Z"/><circle cx="12" cy="9" r="2"/><path d="M8 22v-4h8v4"/></Icon>,
  Mail:         (p) => <Icon {...p}><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-10 5L2 7"/></Icon>,
  Phone:        (p) => <Icon {...p}><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92Z"/></Icon>,
  MapPin:       (p) => <Icon {...p}><path d="M20 10c0 7-8 12-8 12s-8-5-8-12a8 8 0 1 1 16 0Z"/><circle cx="12" cy="10" r="3"/></Icon>,
  Menu:         (p) => <Icon {...p}><path d="M3 6h18M3 12h18M3 18h18"/></Icon>,
  X:            (p) => <Icon {...p}><path d="M18 6 6 18M6 6l12 12"/></Icon>,
  Linkedin:     (p) => <Icon {...p}><path d="M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-4 0v7h-4v-7a6 6 0 0 1 6-6Z"/><rect width="4" height="12" x="2" y="9"/><circle cx="4" cy="4" r="2"/></Icon>,
  ArrowDown:    (p) => <Icon {...p}><path d="M12 5v14M19 12l-7 7-7-7"/></Icon>,
  Layers:       (p) => <Icon {...p}><path d="m12 2 10 6-10 6L2 8z"/><path d="m2 16 10 6 10-6M2 12l10 6 10-6"/></Icon>,
  Zap:          (p) => <Icon {...p}><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8Z"/></Icon>,
  Sparkle:      (p) => <Icon {...p}><path d="M12 3 14 9l6 2-6 2-2 6-2-6-6-2 6-2z"/></Icon>,
  Shield:       (p) => <Icon {...p}><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z"/></Icon>,
  Server:       (p) => <Icon {...p}><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 6h.01M6 18h.01"/></Icon>,
  Package:      (p) => <Icon {...p}><path d="M16.5 9.4 7.55 4.24M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="M3.27 6.96 12 12.01l8.73-5.05M12 22.08V12"/></Icon>,
  Cpu:          (p) => <Icon {...p}><rect width="16" height="16" x="4" y="4" rx="2"/><rect width="6" height="6" x="9" y="9"/><path d="M15 2v2M9 2v2M15 20v2M9 20v2M2 15h2M2 9h2M20 15h2M20 9h2"/></Icon>,
  TrendingUp:   (p) => <Icon {...p}><path d="m22 7-8.5 8.5-5-5L2 17M16 7h6v6"/></Icon>,
  Truck:        (p) => <Icon {...p}><path d="M5 18H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h13v13"/><path d="M14 9h4l4 4v4a1 1 0 0 1-1 1h-3"/><circle cx="7.5" cy="18.5" r="2.5"/><circle cx="17.5" cy="18.5" r="2.5"/></Icon>,
  Compass:      (p) => <Icon {...p}><circle cx="12" cy="12" r="10"/><path d="m16 8-4 8-4-8h8z" fill="currentColor"/></Icon>,
};
window.I = I;

/* =================================================================
   ROUTER — simple hash-based
   path like "/", "/services", "/services/business-ai-automation"
   ================================================================= */
function parseHash() {
  const h = (window.location.hash || "#/").replace(/^#/, "");
  const norm = h.startsWith("/") ? h : "/" + h;
  const parts = norm.split("/").filter(Boolean);
  if (parts.length === 0) return { name: "home", slug: null, path: "/" };
  return { name: parts[0], slug: parts[1] || null, path: norm };
}

function navigate(path, opts = {}) {
  if (!path.startsWith("/")) path = "/" + path;
  const target = "#" + path;
  if (window.location.hash !== target) {
    window.location.hash = target;
  }
  if (!opts.noScroll) {
    window.scrollTo({ top: 0, behavior: "auto" });
  }
}

function useRoute() {
  const [route, setRoute] = useState(parseHash());
  useEffect(() => {
    const onHash = () => setRoute(parseHash());
    window.addEventListener("hashchange", onHash);
    return () => window.removeEventListener("hashchange", onHash);
  }, []);
  return route;
}

function Link({ to, children, className = "", style = {}, onClick, ...rest }) {
  const onAct = (e) => {
    e.preventDefault();
    onClick && onClick(e);
    navigate(to);
  };
  return (
    <a href={"#" + to} onClick={onAct} className={className} style={style} {...rest}>
      {children}
    </a>
  );
}

window.parseHash = parseHash;
window.navigate = navigate;
window.useRoute = useRoute;
window.Link = Link;

/* =================================================================
   useReveal — opacity+slide on enter viewport
   Falls back to immediate reveal if IntersectionObserver is throttled
   (e.g. when the tab is backgrounded), to avoid invisible pages.
   ================================================================= */
function useReveal(cls = "reveal", delay = 0) {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    el.classList.add(cls);
    let revealed = false;
    const reveal = () => {
      if (revealed) return;
      revealed = true;
      el.classList.add("in");
    };
    const obs = new IntersectionObserver((entries) => {
      entries.forEach((entry) => {
        if (entry.isIntersecting) {
          setTimeout(reveal, delay);
          obs.unobserve(el);
        }
      });
    }, { threshold: 0.12 });
    obs.observe(el);
    // Fallback: if observer hasn't fired within 600ms (hidden tab,
    // throttled, element already onscreen) — reveal anyway.
    const fallback = setTimeout(reveal, 600 + delay);
    return () => { obs.disconnect(); clearTimeout(fallback); };
  }, [cls, delay]);
  return ref;
}
window.useReveal = useReveal;

/* =================================================================
   useInView — fire callback when visible
   ================================================================= */
function useInView(threshold = 0.4) {
  const ref = useRef(null);
  const [inView, setInView] = useState(false);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const obs = new IntersectionObserver(([entry]) => {
      if (entry.isIntersecting) { setInView(true); obs.unobserve(el); }
    }, { threshold });
    obs.observe(el);
    return () => obs.disconnect();
  }, [threshold]);
  return [ref, inView];
}
window.useInView = useInView;

/* =================================================================
   LOGO
   ================================================================= */
function Logo({ white = false }) {
  return (
    <Link to="/" style={{ display: "flex", alignItems: "center", gap: 14 }} aria-label="Allion Group">
      <svg width="40" height="40" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <linearGradient id="allionGradient" x1="0" y1="0" x2="64" y2="64" gradientUnits="userSpaceOnUse">
            <stop offset="0%" stopColor={white ? "#7daefb" : "#0a6ef5"} />
            <stop offset="100%" stopColor={white ? "#5ee0c0" : "#05b89c"} />
          </linearGradient>
        </defs>
        {/* Outer hollow A monogram */}
        <path
          fillRule="evenodd"
          d="M32 6 L58 58 L40 58 L36 48 L28 48 L24 58 L6 58 Z M32 22 L27 38 L37 38 Z"
          fill="url(#allionGradient)"
        />
        {/* "Folded" right slope — orange accent panel */}
        <path d="M40 30 L52 54 L36 54 Z" fill="#e85d00" />
      </svg>

      <div style={{ display: "flex", flexDirection: "column", gap: 4, lineHeight: 1 }}>
        <span style={{
          fontFamily: "Syne, sans-serif",
          fontWeight: 600,
          fontSize: 18,
          letterSpacing: "0.32em",
          color: white ? "#fff" : "#0d0d0d",
        }}>
          ALLION
        </span>
        <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
          <span style={{ width: 10, height: 1, background: "#e85d00" }} />
          <span style={{
            fontFamily: "Inter, sans-serif",
            fontWeight: 600,
            fontSize: 9,
            letterSpacing: "0.46em",
            color: "#e85d00",
            paddingLeft: 2,
          }}>GROUP</span>
          <span style={{ width: 10, height: 1, background: "#e85d00" }} />
        </div>
      </div>
    </Link>
  );
}

/* =================================================================
   NAV — with dropdowns for Services / Industries
   ================================================================= */
const NAV_LINKS = [
  { to: "/services",   key: "nav.services",   hasDropdown: "services" },
  { to: "/work",       key: "nav.work" },
  { to: "/industries", key: "nav.industries", hasDropdown: "industries" },
  { to: "/logistics",  key: "nav.logistics" },
  { to: "/company",    key: "nav.company" },
];

function NavDropdown({ items, accent = "#0a6ef5" }) {
  return (
    <div
      style={{
        position: "absolute",
        top: "100%",
        left: "50%",
        transform: "translateX(-50%) translateY(-4px)",
        marginTop: 14,
        background: "#ffffff",
        border: "1px solid rgba(0,0,0,0.06)",
        borderRadius: 16,
        padding: 8,
        minWidth: 280,
        boxShadow: "0 24px 80px rgba(0,0,0,0.12)",
        zIndex: 100,
        animation: "fade-in-up 0.25s ease both",
      }}
    >
      {items.map((it) => (
        <Link
          key={it.slug}
          to={it.to}
          style={{
            display: "flex",
            alignItems: "center",
            gap: 12,
            padding: "10px 12px",
            borderRadius: 10,
            transition: "background 0.2s ease",
          }}
          onMouseEnter={(e) => (e.currentTarget.style.background = "rgba(10,110,245,0.06)")}
          onMouseLeave={(e) => (e.currentTarget.style.background = "transparent")}
        >
          <span style={{
            width: 32, height: 32, borderRadius: 9,
            background: `${it.accent || accent}12`,
            display: "flex", alignItems: "center", justifyContent: "center",
            flexShrink: 0,
          }}>
            {it.iconNode}
          </span>
          <span style={{
            fontFamily: "Inter, sans-serif",
            fontSize: 13,
            fontWeight: 500,
            color: "#0d0d0d",
          }}>{it.label}</span>
        </Link>
      ))}
    </div>
  );
}

function Nav() {
  const route = useRoute();
  const [scrolled, setScrolled] = useState(false);
  const [openDrop, setOpenDrop] = useState(null);
  const [mobileOpen, setMobileOpen] = useState(false);
  const dropTimerRef = useRef(null);
  const t = window.useT ? window.useT() : (k) => k;

  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 30);
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  useEffect(() => {
    setMobileOpen(false);
  }, [route.path]);

  const SERVICES_DROP = window.SITE_DATA.services.map((s) => ({
    slug: s.slug,
    to: `/services/${s.slug}`,
    label: s.title,
    accent: s.accent,
    iconNode: I[s.icon] ? I[s.icon]({ size: 14, color: s.accent }) : null,
  }));

  const INDUSTRIES_DROP = window.SITE_DATA.industries.map((s) => ({
    slug: s.slug,
    to: `/industries/${s.slug}`,
    label: s.title,
    accent: s.accent,
    iconNode: I[s.icon] ? I[s.icon]({ size: 14, color: s.accent }) : null,
  }));

  const onEnter = (key) => {
    clearTimeout(dropTimerRef.current);
    setOpenDrop(key);
  };
  const onLeave = () => {
    clearTimeout(dropTimerRef.current);
    dropTimerRef.current = setTimeout(() => setOpenDrop(null), 120);
  };

  const isActive = (to) => {
    if (to === "/" && route.name === "home") return true;
    return route.path.startsWith(to);
  };

  return (
    <header style={{
      position: "fixed",
      top: 0, left: 0, right: 0,
      zIndex: 90,
      transition: "all 0.4s cubic-bezier(0.16, 1, 0.3, 1)",
      background: scrolled
        ? "linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(248,247,244,0.35) 100%)"
        : "linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(248,247,244,0.10) 100%)",
      backdropFilter: "blur(28px) saturate(180%)",
      WebkitBackdropFilter: "blur(28px) saturate(180%)",
      borderBottom: scrolled ? "1px solid rgba(255,255,255,0.5)" : "1px solid rgba(255,255,255,0.25)",
      boxShadow: scrolled
        ? "inset 0 1px 0 rgba(255,255,255,0.7), 0 1px 0 rgba(0,0,0,0.04), 0 12px 40px rgba(13,13,13,0.06)"
        : "inset 0 1px 0 rgba(255,255,255,0.5)",
    }}>
      <div style={{ maxWidth: 1680, margin: "0 auto", padding: "0 32px" }}>
        <div style={{
          display: "flex", alignItems: "center", justifyContent: "space-between",
          height: 72,
        }}>
          <Logo />

          {/* Desktop nav */}
          <nav className="nav-desktop" style={{ display: "flex", alignItems: "center", gap: 36 }}>
            {NAV_LINKS.map((l) => {
              const active = isActive(l.to);
              const items =
                l.hasDropdown === "services" ? SERVICES_DROP :
                l.hasDropdown === "industries" ? INDUSTRIES_DROP : null;
              return (
                <div
                  key={l.to}
                  style={{ position: "relative" }}
                  onMouseEnter={() => l.hasDropdown && onEnter(l.hasDropdown)}
                  onMouseLeave={() => l.hasDropdown && onLeave()}
                >
                  <Link to={l.to} style={{
                    display: "inline-flex",
                    alignItems: "center",
                    gap: 6,
                    fontFamily: "Inter, sans-serif",
                    fontSize: 13,
                    fontWeight: active ? 600 : 400,
                    color: active ? "#0a6ef5" : "#3a3a3a",
                    letterSpacing: "0.02em",
                    padding: "8px 0",
                    position: "relative",
                  }}>
                    {t(l.key)}
                    {l.hasDropdown && (
                      <I.ChevronDown size={11} color={active ? "#0a6ef5" : "#7a7a7a"} />
                    )}
                    {active && (
                      <span style={{
                        position: "absolute", bottom: 2, left: 0, right: 0,
                        height: 2, background: "#0a6ef5", borderRadius: 2,
                      }} />
                    )}
                  </Link>
                  {l.hasDropdown && openDrop === l.hasDropdown && items && (
                    <NavDropdown items={items} />
                  )}
                </div>
              );
            })}
            <Link
              to="/contact"
              style={{
                padding: "10px 22px",
                borderRadius: 100,
                background: "#0a6ef5",
                color: "#fff",
                fontFamily: "Inter, sans-serif",
                fontSize: 13, fontWeight: 600,
                letterSpacing: "0.02em",
                boxShadow: "0 6px 20px rgba(10,110,245,0.28)",
                transition: "all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1)",
                display: "inline-flex", alignItems: "center", gap: 8,
              }}
              onMouseEnter={(e) => { e.currentTarget.style.transform = "translateY(-2px)"; e.currentTarget.style.boxShadow = "0 12px 32px rgba(10,110,245,0.4)"; }}
              onMouseLeave={(e) => { e.currentTarget.style.transform = "translateY(0)"; e.currentTarget.style.boxShadow = "0 6px 20px rgba(10,110,245,0.28)"; }}
            >
              {t("nav.contact")}
            </Link>
            {window.LangSwitcher && <window.LangSwitcher />}
          </nav>

          {/* Mobile menu btn */}
          <button
            className="nav-mobile-btn"
            onClick={() => setMobileOpen(!mobileOpen)}
            style={{ display: "none" }}
          >
            {mobileOpen ? <I.X size={22} /> : <I.Menu size={22} />}
          </button>
        </div>
      </div>

      {/* Mobile drawer */}
      {mobileOpen && (
        <div style={{
          background: "rgba(248,247,244,0.98)",
          backdropFilter: "blur(20px)",
          borderTop: "1px solid rgba(0,0,0,0.06)",
          padding: "20px 32px 32px",
        }}>
          {NAV_LINKS.map((l) => (
            <Link key={l.to} to={l.to} style={{
              display: "block",
              padding: "14px 0",
              fontFamily: "Syne, sans-serif",
              fontSize: 22, fontWeight: 700,
              color: isActive(l.to) ? "#0a6ef5" : "#0d0d0d",
              borderBottom: "1px solid rgba(0,0,0,0.05)",
              letterSpacing: "-0.015em",
            }}>{t(l.key)}</Link>
          ))}
          <div style={{ marginTop: 24, display: "flex", alignItems: "center", gap: 16 }}>
            <Link to="/contact" style={{
              padding: "12px 24px",
              borderRadius: 100,
              background: "#0a6ef5", color: "#fff",
              fontSize: 14, fontWeight: 600,
            }}>{t("nav.contact")}</Link>
            {window.LangSwitcher && <window.LangSwitcher />}
          </div>
        </div>
      )}

      <style>{`
        @media (max-width: 880px){
          .nav-desktop{ display:none !important; }
          .nav-mobile-btn{ display:flex !important; }
        }
      `}</style>
    </header>
  );
}
window.Nav = Nav;

/* =================================================================
   FOOTER
   ================================================================= */
function Footer() {
  const services = window.SITE_DATA.services.slice(0, 5);
  const industries = window.SITE_DATA.industries;
  const t = window.useT ? window.useT() : (k) => k;
  return (
    <footer style={{
      background: "#0d0d0d", color: "#fff",
      padding: "80px 32px 40px",
      position: "relative",
      overflow: "hidden",
    }}>
      <div style={{
        position: "absolute",
        top: -200, right: -200,
        width: 600, height: 600, borderRadius: "50%",
        background: "radial-gradient(circle, rgba(10,110,245,0.16), transparent 70%)",
        pointerEvents: "none",
      }} />
      <div style={{
        position: "absolute",
        bottom: -200, left: -100,
        width: 500, height: 500, borderRadius: "50%",
        background: "radial-gradient(circle, rgba(5,184,156,0.10), transparent 70%)",
        pointerEvents: "none",
      }} />
      <div style={{ maxWidth: 1680, margin: "0 auto", position: "relative" }}>
        <div style={{
          display: "grid",
          gridTemplateColumns: "1.6fr 1fr 1fr 1fr",
          gap: 60, marginBottom: 60,
        }} className="footer-grid">
          <div>
            <div style={{ marginBottom: 24 }}><Logo white /></div>
            <p style={{
              fontFamily: "Inter, sans-serif",
              fontSize: 14, lineHeight: 1.75,
              color: "rgba(255,255,255,0.5)",
              maxWidth: 320,
              marginBottom: 28,
            }}>
              {window.tx(window.SITE_DATA.brand.description)}
            </p>
            <div style={{
              display: "inline-flex", alignItems: "center", gap: 8,
              padding: "6px 14px", borderRadius: 100,
              background: "rgba(5,184,156,0.12)",
              border: "1px solid rgba(5,184,156,0.25)",
            }}>
              <span className="pulse-dot" style={{
                width: 6, height: 6, borderRadius: "50%",
                background: "#05b89c",
              }} />
              <span style={{ fontSize: 11, fontWeight: 600, letterSpacing: "0.08em", textTransform: "uppercase", color: "#05b89c" }}>
                {t("footer.accepting")}
              </span>
            </div>
          </div>

          {/* Link columns */}
          <div>
            <div style={{ fontSize: 11, fontWeight: 700, letterSpacing: "0.12em", textTransform: "uppercase", color: "rgba(255,255,255,0.3)", marginBottom: 18 }}>{t("footer.services")}</div>
            <ul style={{ listStyle: "none" }}>
              {services.map((s) => (
                <li key={s.slug} style={{ marginBottom: 10 }}>
                  <Link to={`/services/${s.slug}`} className="link-anim" style={{
                    fontFamily: "Inter, sans-serif", fontSize: 13,
                    color: "rgba(255,255,255,0.55)",
                  }}>{window.tx(s.title)}</Link>
                </li>
              ))}
              <li style={{ marginTop: 4 }}>
                <Link to="/logistics" className="link-anim" style={{
                  fontFamily: "Inter, sans-serif", fontSize: 13,
                  color: "rgba(255,255,255,0.55)",
                }}>{t("footer.logistics")}</Link>
              </li>
            </ul>
          </div>

          <div>
            <div style={{ fontSize: 11, fontWeight: 700, letterSpacing: "0.12em", textTransform: "uppercase", color: "rgba(255,255,255,0.3)", marginBottom: 18 }}>{t("footer.industries")}</div>
            <ul style={{ listStyle: "none" }}>
              {industries.map((s) => (
                <li key={s.slug} style={{ marginBottom: 10 }}>
                  <Link to={`/industries/${s.slug}`} className="link-anim" style={{
                    fontFamily: "Inter, sans-serif", fontSize: 13,
                    color: "rgba(255,255,255,0.55)",
                  }}>{window.tx(s.title)}</Link>
                </li>
              ))}
            </ul>
          </div>

          <div>
            <div style={{ fontSize: 11, fontWeight: 700, letterSpacing: "0.12em", textTransform: "uppercase", color: "rgba(255,255,255,0.3)", marginBottom: 18 }}>{t("footer.company")}</div>
            <ul style={{ listStyle: "none" }}>
              {[
                ["/company", t("footer.about")],
                ["/work",    t("nav.work")],
                ["/contact", t("footer.contacts")],
              ].map(([to, label]) => (
                <li key={to} style={{ marginBottom: 10 }}>
                  <Link to={to} className="link-anim" style={{
                    fontFamily: "Inter, sans-serif", fontSize: 13,
                    color: "rgba(255,255,255,0.55)",
                  }}>{label}</Link>
                </li>
              ))}
            </ul>
          </div>
        </div>

        <div style={{ height: 1, background: "rgba(255,255,255,0.07)", marginBottom: 24 }} />
        <div style={{
          display: "flex", justifyContent: "space-between",
          alignItems: "center", flexWrap: "wrap", gap: 16,
          fontFamily: "Inter, sans-serif", fontSize: 12,
        }}>
          <div style={{ color: "rgba(255,255,255,0.35)" }}>
            © {new Date().getFullYear()} {window.SITE_DATA.brand.name}. {t("footer.rights")}
          </div>
          <div style={{ display: "flex", gap: 24, color: "rgba(255,255,255,0.4)", flexWrap: "wrap" }}>
            <a href={`mailto:${window.SITE_DATA.brand.email}`} style={{ color: "rgba(255,255,255,0.55)" }} className="link-anim">{window.SITE_DATA.brand.email}</a>
            <a href={window.SITE_DATA.brand.instagramUrl} target="_blank" rel="noreferrer" style={{ color: "rgba(255,255,255,0.55)" }} className="link-anim">@{window.SITE_DATA.brand.instagram}</a>
            <span>{window.SITE_DATA.brand.hqCity}, {window.SITE_DATA.brand.hqCountry}</span>
          </div>
        </div>
      </div>
      <style>{`@media (max-width: 880px){ .footer-grid{ grid-template-columns: 1fr 1fr !important; gap: 40px !important; } }`}</style>
    </footer>
  );
}
window.Footer = Footer;

/* =================================================================
   SHARED UI HELPERS — Tag, Breadcrumb, SectionLabel, PageHeader
   ================================================================= */
function Tag({ accent = "#0a6ef5", children }) {
  const content = (children && typeof children === "object" && !Array.isArray(children) && !children.$$typeof)
    ? (window.tx ? window.tx(children) : (children.ru || children.en || ""))
    : children;
  return (
    <span style={{
      padding: "4px 12px", borderRadius: 100,
      background: `${accent}12`,
      color: accent,
      fontSize: 11, fontWeight: 600,
      letterSpacing: "0.04em",
      fontFamily: "Inter, sans-serif",
    }}>{content}</span>
  );
}
window.Tag = Tag;

function Breadcrumb({ items }) {
  return (
    <div style={{
      display: "flex", alignItems: "center", gap: 8,
      fontFamily: "Inter, sans-serif", fontSize: 12,
      color: "#7a7a7a", letterSpacing: "0.04em",
      marginBottom: 36,
    }}>
      {items.map((it, i) => (
        <React.Fragment key={i}>
          {it.to ? (
            <Link to={it.to} className="link-anim" style={{ color: "#7a7a7a" }}>{it.label}</Link>
          ) : (
            <span style={{ color: i === items.length - 1 ? "#0a6ef5" : "#7a7a7a", fontWeight: i === items.length - 1 ? 600 : 400 }}>{it.label}</span>
          )}
          {i < items.length - 1 && <span style={{ color: "#bdb3a3" }}>›</span>}
        </React.Fragment>
      ))}
    </div>
  );
}
window.Breadcrumb = Breadcrumb;

function SectionTag({ tone = "blue", children }) {
  const dotColor = tone === "warm" ? "#e85d00" : tone === "teal" ? "#05b89c" : "#0a6ef5";
  return (
    <div className={`section-tag ${tone !== "blue" ? tone : ""}`}>
      <span style={{ width: 6, height: 6, borderRadius: "50%", background: dotColor, display: "inline-block" }} />
      {children}
    </div>
  );
}
window.SectionTag = SectionTag;
