/* global React, ReactDOM, TRANSLATIONS */
const { useState, useEffect, useRef, useCallback, useMemo } = React;

// Telegram bot configuration — replace BOT_TOKEN/CHAT_ID with real values in production
// In production, the bot send should be proxied through your own backend to keep the token private.
const TG_CONFIG = {
  BOT_TOKEN: "8659768973:AAHWZwHIfOJF-MBhGY_Omu7GyZsKsBBFf90",
  CHAT_ID: "-1003912815046"
};

// ---------------- Decorative Mountain SVG ----------------
function MountainRange({ className = "" }) {
  return (
    <svg viewBox="0 0 1440 420" preserveAspectRatio="none" className={className} aria-hidden="true">
      <defs>
        <linearGradient id="mtnA" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0%" stopColor="#1E5FA8" stopOpacity="0.55" />
          <stop offset="100%" stopColor="#1E5FA8" stopOpacity="0.15" />
        </linearGradient>
        <linearGradient id="mtnB" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0%" stopColor="#0B3F7A" stopOpacity="0.85" />
          <stop offset="100%" stopColor="#0B3F7A" stopOpacity="0.35" />
        </linearGradient>
      </defs>
      {/* Back range */}
      <path fill="url(#mtnA)" d="M0,320 L120,200 L220,260 L340,140 L460,240 L600,160 L740,250 L880,150 L1020,230 L1160,170 L1280,250 L1440,180 L1440,420 L0,420 Z" />
      {/* Front range */}
      <path fill="url(#mtnB)" d="M0,360 L100,280 L200,320 L320,220 L440,300 L580,240 L720,310 L860,230 L1000,300 L1140,250 L1280,320 L1440,260 L1440,420 L0,420 Z" />
      {/* Snow caps */}
      <path fill="#FFFFFF" opacity="0.85" d="M320,220 L350,235 L335,238 L320,232 L310,238 L295,235 Z" />
      <path fill="#FFFFFF" opacity="0.85" d="M580,240 L605,252 L592,256 L580,250 L572,256 L555,253 Z" />
      <path fill="#FFFFFF" opacity="0.85" d="M860,230 L885,245 L872,250 L860,243 L850,250 L835,247 Z" />
      <path fill="#FFFFFF" opacity="0.85" d="M1140,250 L1163,262 L1150,266 L1140,260 L1128,266 L1113,263 Z" />
    </svg>);

}

function WavyDivider({ flip = false, fill = "#ffffff", className = "" }) {
  return (
    <svg viewBox="0 0 1440 80" preserveAspectRatio="none"
    style={{ transform: flip ? "scaleY(-1)" : "none" }}
    className={className} aria-hidden="true">
      <path fill={fill} d="M0,40 C240,80 480,0 720,30 C960,60 1200,20 1440,50 L1440,80 L0,80 Z" />
    </svg>);

}

function DropletIcon({ className = "" }) {
  return (
    <svg viewBox="0 0 24 24" className={className} fill="currentColor" aria-hidden="true">
      <path d="M12 2.5c0 0-7 8-7 13a7 7 0 0 0 14 0c0-5-7-13-7-13z" />
    </svg>);

}

// ---------------- Language hook ----------------
function useLang() {
  const [lang, setLang] = useState(() => {
    try {return localStorage.getItem("safo_lang") || "uz";} catch {return "uz";}
  });
  useEffect(() => {
    try {localStorage.setItem("safo_lang", lang);} catch {}
    document.documentElement.lang = lang;
  }, [lang]);
  const t = TRANSLATIONS[lang];
  return { lang, setLang, t };
}

// ---------------- Navbar ----------------
function Navbar({ lang, setLang, t }) {
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 24);
    window.addEventListener("scroll", onScroll, { passive: true });
    onScroll();
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  useEffect(() => {
    document.body.style.overflow = open ? "hidden" : "";
    return () => {document.body.style.overflow = "";};
  }, [open]);

  const links = [
  { href: "#about", label: t.nav.about },
  { href: "#products", label: t.nav.products },
  { href: "#benefits", label: t.nav.benefits },
  { href: "#delivery", label: t.nav.delivery },
  { href: "#cooperation", label: t.nav.cooperation },
  { href: "#contact", label: t.nav.contact }];


  return (
    <>
    <header className={
      "fixed top-0 inset-x-0 z-50 transition-all duration-300 " + (
      scrolled ? "bg-white/95 backdrop-blur shadow-[0_1px_0_rgba(10,37,64,0.06)]" : "bg-white/80 backdrop-blur-sm")
      }>
      <div className="max-w-7xl mx-auto px-5 md:px-8 h-[68px] md:h-[76px] flex items-center justify-between gap-4">
        <a href="#top" className="flex items-center gap-2.5" aria-label="Safo">
          <img src="assets/logo.webp" alt="Safo" width="512" height="275" className="h-11 md:h-12 w-auto" />
        </a>

        {/* Desktop nav */}
        <nav className="hidden lg:flex items-center gap-1">
          {links.map((l) =>
            <a key={l.href} href={l.href}
            className="px-3 py-2 text-[14.5px] font-medium text-[#0A2540]/80 hover:text-[#0066CC] transition-colors rounded-md">
              {l.label}
            </a>
            )}
        </nav>

        <div className="flex items-center gap-2 md:gap-3">
          {/* Desktop / tablet: lang switch + order */}
          <div className="hidden md:block">
            <LangSwitch lang={lang} setLang={setLang} />
          </div>
          <a href="https://t.me/Safosuvbot" target="_blank" rel="noopener"
            className="hidden md:inline-flex items-center gap-1.5 pl-1.5 pr-4 py-1.5 bg-white border border-[#CFE7F7] hover:border-[#0066CC] text-[#0A2540] text-[13.5px] font-semibold rounded-full shadow-sm hover:shadow transition-all">
            <TgIcon className="w-6 h-6" />
            {t.nav.order}
          </a>

          {/* Mobile hamburger — right */}
          <button
              type="button"
              aria-label="Menu"
              aria-expanded={open}
              onClick={() => setOpen((v) => !v)}
              className="md:hidden inline-flex items-center justify-center w-11 h-11 rounded-full hover:bg-[#E6F4FB] transition-colors">
            <span className="relative w-5 h-3.5">
              <span className={"absolute left-0 right-0 h-[2px] bg-[#0A2540] rounded transition-transform duration-300 " + (open ? "top-1.5 rotate-45" : "top-0")} />
              <span className={"absolute left-0 right-0 top-1.5 h-[2px] bg-[#0A2540] rounded transition-opacity duration-200 " + (open ? "opacity-0" : "opacity-100")} />
              <span className={"absolute left-0 right-0 h-[2px] bg-[#0A2540] rounded transition-transform duration-300 " + (open ? "top-1.5 -rotate-45" : "top-3")} />
            </span>
          </button>
        </div>
      </div>

      {/* (drawer moved outside <header> so fixed positioning is relative to viewport) */}
    </header>

    {/* Mobile drawer — sibling of header so backdrop-filter on <header> doesn't break fixed positioning */}
    <div className="md:hidden">
      <div
          onClick={() => setOpen(false)}
          className={"fixed inset-0 z-[60] bg-[#0A2540]/40 backdrop-blur-sm transition-opacity duration-300 " + (open ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none")}
          aria-hidden={!open} />
      <aside
          {...(!open ? { inert: "" } : {})}
          aria-hidden={!open}
          className={"fixed top-0 right-0 h-full w-[86%] max-w-[360px] bg-white shadow-2xl flex flex-col z-[70] transition-transform duration-300 " + (open ? "translate-x-0" : "translate-x-full")}>
        <div className="h-[68px] px-5 flex items-center justify-between border-b border-[#E6F4FB]">
          <img src="assets/logo.webp" alt="Safo" width="512" height="275" className="h-9 w-auto" />
          <button type="button" onClick={() => setOpen(false)} aria-label="Close"
            className="w-10 h-10 rounded-full hover:bg-[#E6F4FB] flex items-center justify-center">
            <svg viewBox="0 0 24 24" className="w-5 h-5" fill="none" stroke="#0A2540" strokeWidth="2">
              <path d="M6 6l12 12M18 6L6 18" strokeLinecap="round" />
            </svg>
          </button>
        </div>
        <nav className="flex-1 px-3 py-4 overflow-y-auto">
          {links.map((l) =>
            <a key={l.href} href={l.href} onClick={() => setOpen(false)}
            className="block px-4 py-3.5 text-[16px] font-medium text-[#0A2540] rounded-lg hover:bg-[#E6F4FB] transition-colors">
              {l.label}
            </a>
            )}
        </nav>
        <div className="p-5 border-t border-[#E6F4FB] space-y-4">
          <div className="flex items-center justify-end">
            <LangSwitch lang={lang} setLang={setLang} />
          </div>
          <a href="https://t.me/Safosuvbot" target="_blank" rel="noopener" onClick={() => setOpen(false)}
            className="w-full inline-flex items-center justify-center gap-2 pl-2 pr-5 py-2.5 bg-[#0066CC] hover:bg-[#0058B0] text-white text-[15px] font-semibold rounded-full shadow-[0_10px_24px_-10px_rgba(0,102,204,0.55)] transition-all">
            <TgIcon className="w-7 h-7" />
            {t.nav.order}
          </a>
          <a href="tel:+998886661111" onClick={() => setOpen(false)}
            className="w-full inline-flex items-center justify-center gap-2 px-5 py-2.5 bg-[#E6F4FB] hover:bg-[#CFE7F7] text-[#0A2540] text-[15px] font-semibold rounded-full transition-colors">
            <svg viewBox="0 0 24 24" className="w-4 h-4" fill="none" stroke="currentColor" strokeWidth="2">
              <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.72c.13.96.37 1.9.72 2.81a2 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-.45c.91.35 1.85.59 2.81.72A2 2 0 0 1 22 16.92z" strokeLinejoin="round" />
            </svg>
            +998 88 666-11-11
          </a>
        </div>
      </aside>
    </div>
    </>);

}

function BackToTop() {
  const [show, setShow] = useState(false);
  useEffect(() => {
    const onScroll = () => setShow(window.scrollY > 480);
    window.addEventListener("scroll", onScroll, { passive: true });
    onScroll();
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <button
      aria-label="Back to top"
      onClick={() => window.scrollTo({ top: 0, behavior: "smooth" })}
      className={
      "fixed bottom-5 right-5 md:bottom-7 md:right-7 z-40 w-12 h-12 " +
      "rounded-full bg-[#0066CC] hover:bg-[#0058B0] text-white shadow-[0_12px_30px_-10px_rgba(0,102,204,0.55)] " +
      "flex items-center justify-center transition-all duration-300 " + (
      show ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-3 pointer-events-none")
      }>
      <svg viewBox="0 0 24 24" className="w-5 h-5" fill="none" stroke="currentColor" strokeWidth="2.5" aria-hidden="true">
        <path d="M5 14l7-7 7 7" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </button>);

}

function LangSwitch({ lang, setLang }) {
  return (
    <div className="relative bg-[#E6F4FB] rounded-full p-1 flex items-center text-[13px] font-semibold">
      <span
        className="absolute top-1 bottom-1 w-[44px] bg-white rounded-full shadow-sm transition-transform duration-300"
        style={{ transform: lang === "uz" ? "translateX(0)" : "translateX(44px)" }} />
      
      <button onClick={() => setLang("uz")}
      className={"relative z-10 w-[44px] h-7 rounded-full transition-colors " + (lang === "uz" ? "text-[#0066CC]" : "text-[#0A2540]/85")}>
        UZ
      </button>
      <button onClick={() => setLang("ru")}
      className={"relative z-10 w-[44px] h-7 rounded-full transition-colors " + (lang === "ru" ? "text-[#0066CC]" : "text-[#0A2540]/85")}>
        RU
      </button>
    </div>);

}

function TgIcon({ className = "" }) {
  return (
    <svg viewBox="0 0 24 24" className={className} aria-hidden="true">
      <defs>
        <linearGradient id="tgGrad" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0%" stopColor="#37BBFE" />
          <stop offset="100%" stopColor="#007DBB" />
        </linearGradient>
      </defs>
      <circle cx="12" cy="12" r="12" fill="url(#tgGrad)" />
      <path d="M17.8 7.2 5.6 11.9c-.83.32-.82.78-.15.99l3.1.97 1.19 3.61c.15.4.07.56.5.56.32 0 .46-.15.65-.32 0 0 1.27-1.23 1.95-1.9l3.21 2.38c.59.32 1.01.16 1.16-.55l2.1-9.94c.21-.87-.34-1.26-.92-1z" fill="#fff" />
      <path d="M9.7 14.2 9.4 17c.43 0 .61-.18.83-.4l2-1.9-2.07-1.53-.46.93z" fill="#D2E5F1" />
    </svg>);

}

// Monochrome plane (used inside solid colored buttons)
function TgPlane({ className = "" }) {
  return (
    <svg viewBox="0 0 24 24" className={className} fill="currentColor" aria-hidden="true">
      <path d="M21.4 3.2 2.6 10.5c-1.06.4-1.05.97-.18 1.24l4.85 1.5 1.86 5.66c.23.62.12.87.78.87.5 0 .73-.23 1.02-.5l2.47-2.4 5.13 3.79c.94.52 1.62.25 1.86-.87l3.36-15.84c.34-1.37-.55-2-1.47-1.62z" />
      <path d="M9.13 16.3 8.83 19.1c.43 0 .61-.18.83-.4l2-1.9-2.07-1.53-.46 1.03z" opacity="0.85" />
    </svg>);

}

function IgIcon({ className = "" }) {
  return (
    <svg viewBox="0 0 24 24" className={className} fill="currentColor" aria-hidden="true">
      <path d="M12 2.16c3.2 0 3.58.01 4.85.07 1.17.05 1.8.25 2.23.42.56.22.96.48 1.38.9.42.42.68.82.9 1.38.16.43.36 1.06.42 2.23.06 1.27.07 1.65.07 4.85s-.01 3.58-.07 4.85c-.05 1.17-.25 1.8-.42 2.23-.22.56-.48.96-.9 1.38-.42.42-.82.68-1.38.9-.43.16-1.06.36-2.23.42-1.27.06-1.65.07-4.85.07s-3.58-.01-4.85-.07c-1.17-.05-1.8-.25-2.23-.42a3.7 3.7 0 0 1-1.38-.9 3.7 3.7 0 0 1-.9-1.38c-.16-.43-.36-1.06-.42-2.23-.06-1.27-.07-1.65-.07-4.85s.01-3.58.07-4.85c.05-1.17.25-1.8.42-2.23.22-.56.48-.96.9-1.38.42-.42.82-.68 1.38-.9.43-.16 1.06-.36 2.23-.42 1.27-.06 1.65-.07 4.85-.07M12 0C8.74 0 8.33.01 7.05.07 5.77.13 4.9.33 4.14.63a5.85 5.85 0 0 0-2.13 1.38A5.85 5.85 0 0 0 .63 4.14C.33 4.9.13 5.77.07 7.05.01 8.33 0 8.74 0 12s.01 3.67.07 4.95c.06 1.28.26 2.15.56 2.91.32.8.74 1.47 1.38 2.13.66.64 1.33 1.06 2.13 1.38.76.3 1.63.5 2.91.56C8.33 23.99 8.74 24 12 24s3.67-.01 4.95-.07c1.28-.06 2.15-.26 2.91-.56a5.85 5.85 0 0 0 2.13-1.38c.64-.66 1.06-1.33 1.38-2.13.3-.76.5-1.63.56-2.91.06-1.28.07-1.69.07-4.95s-.01-3.67-.07-4.95c-.06-1.28-.26-2.15-.56-2.91a5.85 5.85 0 0 0-1.38-2.13A5.85 5.85 0 0 0 19.86.63C19.1.33 18.23.13 16.95.07 15.67.01 15.26 0 12 0zm0 5.84a6.16 6.16 0 1 0 0 12.32 6.16 6.16 0 0 0 0-12.32zm0 10.16A4 4 0 1 1 12 8a4 4 0 0 1 0 8zm6.4-11.85a1.44 1.44 0 1 0 0 2.88 1.44 1.44 0 0 0 0-2.88z" />
    </svg>);

}

function FbIcon({ className = "" }) {
  return (
    <svg viewBox="0 0 24 24" className={className} fill="currentColor" aria-hidden="true">
      <path d="M22 12.06C22 6.5 17.52 2 12 2S2 6.5 2 12.06c0 5 3.66 9.14 8.44 9.94v-7.03H7.9v-2.9h2.54V9.85c0-2.5 1.49-3.89 3.77-3.89 1.09 0 2.24.2 2.24.2v2.46h-1.26c-1.24 0-1.63.77-1.63 1.56v1.88h2.77l-.44 2.9h-2.33V22c4.78-.8 8.44-4.94 8.44-9.94z" />
    </svg>);

}

// ---------------- Hero ----------------
function Hero({ t }) {
  return (
    <section id="top" className="relative pt-[68px] md:pt-[76px] overflow-hidden min-h-[640px] sm:min-h-[720px] lg:min-h-[88vh] flex flex-col">
      {/* Natural mountain backdrop */}
      <div className="absolute inset-0">
        <img src="assets/hero-mountain.webp" alt="" aria-hidden="true" width="1264" height="842" fetchpriority="high" className="absolute inset-0 w-full h-full object-cover object-bottom hero-zoom" />
        {/* Light vignette for legibility — mobile (top→bottom) + desktop (left→right) */}
        <div className="absolute inset-0 lg:hidden bg-gradient-to-b from-white/55 via-white/20 to-white/0" />
        <div className="absolute inset-0 hidden lg:block bg-gradient-to-r from-white/85 via-white/35 to-white/0" />
        {/* Soft floating orbs */}
        <div className="absolute top-32 -left-10 w-72 h-72 rounded-full bg-[#7AC4ED]/30 blur-3xl float-slow" />
        <div className="absolute bottom-20 right-1/3 w-64 h-64 rounded-full bg-white/50 blur-3xl float-slower" />
        {/* Subtle grain dots */}
        <svg className="absolute inset-0 w-full h-full opacity-[0.06] mix-blend-overlay" aria-hidden="true">
          <filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" /></filter>
          <rect width="100%" height="100%" filter="url(#n)" />
        </svg>
      </div>

      <div className="relative max-w-7xl w-full mx-auto px-5 md:px-8 pt-8 sm:pt-12 md:pt-16 pb-10 md:pb-16 flex-1 flex items-center">
        <div className="grid grid-cols-[1fr_130px] sm:grid-cols-[1.4fr_1fr] lg:grid-cols-[1.05fr_1fr] gap-3 sm:gap-10 lg:gap-14 items-center w-full">
          <div className="relative z-10">
            <div className="inline-flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3 py-1 sm:py-1.5 glass border border-white/60 rounded-full text-[9.5px] sm:text-[12.5px] font-semibold text-[#0066CC] tracking-wide shadow-[0_4px_12px_-4px_rgba(0,102,204,0.25)] whitespace-nowrap">
              <DropletIcon className="w-3 h-3 sm:w-3.5 sm:h-3.5 flex-shrink-0" />
              {t.hero.eyebrow}
            </div>
            <h1 className="mt-4 sm:mt-5 text-[30px] leading-[1.05] sm:text-[52px] md:text-[60px] lg:text-[72px] font-extrabold tracking-tight text-[#0A2540]" style={{ textWrap: "balance" }}>
              {t.hero.title}{" "}
              <span className="relative inline-block">
                <span className="relative z-10 italic font-extrabold bg-gradient-to-br from-[#0066CC] to-[#37BBFE] bg-clip-text text-transparent">{t.hero.titleAccent}</span>
                <svg className="absolute -bottom-2 left-0 w-full" viewBox="0 0 300 14" preserveAspectRatio="none" aria-hidden="true">
                  <path d="M2,8 C 80,2 160,12 298,5" stroke="#7AC4ED" strokeWidth="4" fill="none" strokeLinecap="round" />
                </svg>
              </span>
            </h1>

            <div className="mt-7 sm:mt-8 flex flex-wrap gap-2.5">
              <a href="https://t.me/Safosuvbot" target="_blank" rel="noopener"
              className="group inline-flex items-center gap-2 pl-1.5 pr-5 py-1.5 bg-[#0066CC] hover:bg-[#0058B0] text-white text-[14px] font-semibold rounded-full shadow-[0_10px_24px_-10px_rgba(0,102,204,0.55)] hover:shadow-[0_14px_28px_-10px_rgba(0,102,204,0.65)] hover:-translate-y-0.5 transition-all">
                <TgIcon className="w-7 h-7 transition-transform group-hover:scale-110" />
                {t.hero.ctaOrder}
              </a>
              <a href="tel:+998886661111"
              className="group inline-flex items-center gap-2 px-4 py-2.5 glass border border-white/70 hover:border-[#0066CC] text-[#0A2540] text-[14px] font-semibold rounded-full hover:-translate-y-0.5 transition-all">
                <svg viewBox="0 0 24 24" className="w-4 h-4 transition-transform group-hover:rotate-12" fill="none" stroke="currentColor" strokeWidth="2">
                  <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.72c.13.96.37 1.9.72 2.81a2 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-.45c.91.35 1.85.59 2.81.72A2 2 0 0 1 22 16.92z" strokeLinejoin="round" />
                </svg>
                {t.hero.ctaCall}
              </a>
            </div>

            <dl className="mt-7 sm:mt-10 bg-white/15 backdrop-blur-[2px] border border-white/40 rounded-xl sm:rounded-2xl p-2.5 sm:p-5 grid grid-cols-1 sm:grid-cols-3 gap-2 sm:gap-6 max-w-[130px] sm:max-w-[540px] shadow-[0_10px_30px_-15px_rgba(11,63,122,0.25)]">
              <Stat n={t.hero.stat1} l={t.hero.stat1Label} />
              <Stat n={t.hero.stat2} l={t.hero.stat2Label} />
              <Stat n={t.hero.stat3} l={t.hero.stat3Label} />
            </dl>
          </div>

          {/* Right column — bottle showcase */}
          <div className="relative h-[300px] sm:h-[420px] md:h-[540px] lg:h-[620px]">
            {/* Decorative animated rings */}
            <div className="absolute inset-x-0 top-[18%] mx-auto w-[58%] aspect-square rounded-full border border-white/40 ring-pulse" />
            <div className="absolute inset-x-0 top-[24%] mx-auto w-[44%] aspect-square rounded-full border border-white/30 ring-pulse" style={{ animationDelay: "1.5s" }} />
            {/* Drop sparkles */}
            <Sparkle className="absolute top-[22%] right-[8%] w-5 h-5 text-white opacity-80 sparkle-1" />
            <Sparkle className="absolute top-[50%] left-[6%] w-3.5 h-3.5 text-white opacity-70 sparkle-2" />
            <Sparkle className="absolute top-[36%] right-[18%] w-2.5 h-2.5 text-[#7AC4ED] sparkle-3" />
            {/* Pedestal shadow */}
            <div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-[72%] h-6 bg-[#0A2540]/25 blur-2xl rounded-full" />
            <img
              src="assets/bottle-19l-clean.webp"
              alt="Safo 18.9L"
              width="1200" height="1200" fetchpriority="high"
              className="absolute bottom-[-7rem] sm:bottom-0 left-[-140%] sm:left-1/2 sm:-translate-x-1/2 w-[250%] sm:w-[110%] max-w-none sm:max-w-[520px] object-contain float-bottle"
              style={{ filter: "drop-shadow(0 28px 36px rgba(11,63,122,0.35))" }} />
          </div>
        </div>
      </div>

      {/* Scroll cue — desktop only */}
      <div className="hidden md:flex absolute bottom-6 left-1/2 -translate-x-1/2 flex-col items-center gap-1.5 pointer-events-none">
        <div className="text-[10.5px] font-semibold uppercase tracking-[0.18em] text-[#0A2540]/55">scroll</div>
        <div className="w-6 h-10 rounded-full border-2 border-[#0A2540]/30 flex items-start justify-center pt-1.5">
          <div className="w-1 h-2 rounded-full bg-[#0066CC] scroll-cue" />
        </div>
      </div>

    </section>);

}

function Sparkle({ className }) {
  return (
    <svg viewBox="0 0 24 24" className={className} fill="currentColor" aria-hidden="true">
      <path d="M12 0l2.4 9.6L24 12l-9.6 2.4L12 24l-2.4-9.6L0 12l9.6-2.4L12 0z" />
    </svg>);

}

function Stat({ n, l, className = "" }) {
  return (
    <div className={className}>
      <dd className="text-[22px] sm:text-[30px] md:text-[36px] font-extrabold text-[#0A2540] leading-none">{n}</dd>
      <dt className="mt-1 sm:mt-1.5 text-[10px] sm:text-[11px] uppercase tracking-[0.14em] font-semibold text-[#0A2540]/55">{l}</dt>
    </div>);

}

// ---------------- Footer ----------------
function Footer({ t, lang }) {
  return (
    <footer className="bg-[#0A2540] text-white">
      <div className="max-w-7xl mx-auto px-5 md:px-8 py-14 grid md:grid-cols-[1.4fr_1fr_1.2fr] gap-10">
        <div>
          <div className="flex items-center gap-3">
            <img src="assets/logo.webp" alt="Safo Water" width="512" height="275" className="h-12 w-auto"
            style={{ filter: "brightness(0) invert(1)" }} />
          </div>
          <p className="mt-5 text-[15px] text-white/70 leading-relaxed max-w-[360px]">{t.footer.desc}</p>
          <div className="mt-5 flex gap-2.5">
            <a href="https://t.me/Safosuvbot" target="_blank" rel="noopener"
            className="w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors" aria-label="Telegram">
              <TgIcon className="w-7 h-7" />
            </a>
            <a href="https://www.instagram.com/safo_water/" target="_blank" rel="noopener"
            className="w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors" aria-label="Instagram">
              <IgIcon className="w-4 h-4 text-white" />
            </a>
            <a href="https://www.facebook.com/SafoWater/" target="_blank" rel="noopener"
            className="w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors" aria-label="Facebook">
              <FbIcon className="w-4 h-4 text-white" />
            </a>
          </div>
        </div>

        <div>
          <div className="text-[13px] uppercase tracking-[0.14em] font-semibold text-white/50 mb-4">{t.footer.links}</div>
          <ul className="space-y-2.5 text-[14.5px]">
            <li><a href="#about" className="text-white/80 hover:text-white">{t.nav.about}</a></li>
            <li><a href="#products" className="text-white/80 hover:text-white">{t.nav.products}</a></li>
            <li><a href="#benefits" className="text-white/80 hover:text-white">{t.nav.benefits}</a></li>
            <li><a href="#delivery" className="text-white/80 hover:text-white">{t.nav.delivery}</a></li>
            <li><a href="#cooperation" className="text-white/80 hover:text-white">{t.nav.cooperation}</a></li>
          </ul>
        </div>

        <div>
          <div className="text-[13px] uppercase tracking-[0.14em] font-semibold text-white/50 mb-4">{t.footer.contactsTitle}</div>
          <ul className="space-y-3 text-[14.5px]">
            <li className="flex items-start gap-2.5 text-white/80">
              <svg viewBox="0 0 24 24" className="w-4 h-4 mt-1 text-[#7AC4ED] flex-shrink-0" fill="none" stroke="currentColor" strokeWidth="1.8">
                <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z" /><circle cx="12" cy="10" r="3" />
              </svg>
              <span>{t.contact.address}</span>
            </li>
            <li className="flex items-center gap-2.5">
              <svg viewBox="0 0 24 24" className="w-4 h-4 text-[#7AC4ED] flex-shrink-0" fill="none" stroke="currentColor" strokeWidth="1.8">
                <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.72c.13.96.37 1.9.72 2.81a2 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-.45c.91.35 1.85.59 2.81.72A2 2 0 0 1 22 16.92z" strokeLinejoin="round" />
              </svg>
              <a href="tel:+998886661111" className="text-white hover:text-[#7AC4ED]">+998 88 666-11-11</a>
            </li>
            <li className="flex items-center gap-2.5">
              <TgIcon className="w-5 h-5 flex-shrink-0" />
              <a href="https://t.me/Safosuvbot" target="_blank" rel="noopener" className="text-white hover:text-[#7AC4ED]">t.me/Safosuvbot</a>
            </li>
            <li className="flex items-center gap-2.5">
              <IgIcon className="w-4 h-4 text-[#E1306C] flex-shrink-0" />
              <a href="https://www.instagram.com/safo_water/" target="_blank" rel="noopener" className="text-white hover:text-[#7AC4ED]">@safo_water</a>
            </li>
            <li className="flex items-center gap-2.5">
              <FbIcon className="w-4 h-4 text-[#1877F2] flex-shrink-0" />
              <a href="https://www.facebook.com/SafoWater/" target="_blank" rel="noopener" className="text-white hover:text-[#7AC4ED]">facebook.com/SafoWater</a>
            </li>
          </ul>
        </div>
      </div>
      <div className="border-t border-white/10">
        <div className="max-w-7xl mx-auto px-5 md:px-8 py-5 flex flex-wrap items-center justify-between gap-3 text-[13px] text-white/50">
          <div>© {new Date().getFullYear()} Safo Water. {t.footer.rights}</div>
          <div>UzTR.861-032:2019 · Sugar Business Production MChJ</div>
        </div>
      </div>
    </footer>);

}

// ---------------- App ----------------
function App() {
  const { lang, setLang, t } = useLang();
  return (
    <>
      <Navbar lang={lang} setLang={setLang} t={t} />
      <main>
        <Hero t={t} />
        <About t={t} />
        <Process t={t} />
        <Products t={t} />
        <Benefits t={t} />
        <Delivery t={t} />
        <Cooperation t={t} lang={lang} tgConfig={TG_CONFIG} />
        <Contact t={t} />
      </main>
      <Footer t={t} lang={lang} />
      <BackToTop />
    </>);

}

ReactDOM.createRoot(document.getElementById("root")).render(<App />);