/* global React, SHexLogo, Brandmark */
const { useState, useEffect, useRef } = React;

// ============================================================
// useIsMobile hook
// ============================================================
function useIsMobile() {
  const [isMobile, setIsMobile] = useState(
    () => typeof window !== "undefined" && window.matchMedia("(max-width: 900px)").matches
  );
  useEffect(() => {
    const mq = window.matchMedia("(max-width: 900px)");
    const handler = (e) => setIsMobile(e.matches);
    mq.addEventListener("change", handler);
    return () => mq.removeEventListener("change", handler);
  }, []);
  return isMobile;
}
window.useIsMobile = useIsMobile;

// ============================================================
// useReveal — IntersectionObserver fade-up
// ============================================================
function useReveal() {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const obs = new IntersectionObserver(
      (entries) => entries.forEach((e) => e.isIntersecting && e.target.classList.add("in")),
      { threshold: 0.12, rootMargin: "0px 0px -8% 0px" }
    );
    obs.observe(el);
    return () => obs.disconnect();
  }, []);
  return ref;
}
window.useReveal = useReveal;

// Wrapper for staggered reveals
const Reveal = ({ delay = 0, children, as: Tag = "div", className = "", style = {} }) => {
  const ref = useReveal();
  return (
    <Tag
      ref={ref}
      className={`reveal ${className}`}
      style={{ transitionDelay: `${delay}ms`, ...style }}
    >
      {children}
    </Tag>
  );
};
window.Reveal = Reveal;

// ============================================================
// Icon set — minimal inline SVGs
// ============================================================
const Icon = {
  arrow: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" width="16" height="16" {...p}><path d="M5 12h14M13 6l6 6-6 6"/></svg>,
  ext:   (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" width="14" height="14" {...p}><path d="M9 5h10v10M19 5L9 15M19 13v6H5V5h6"/></svg>,
  check: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" width="14" height="14" {...p}><path d="M4 12l5 5L20 6"/></svg>,
  plus:  (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" width="16" height="16" {...p}><path d="M12 5v14M5 12h14"/></svg>,
  globe: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3a14 14 0 010 18M12 3a14 14 0 000 18"/></svg>,
  star:  (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><path d="M12 3l2.7 5.7 6.3.9-4.6 4.4 1.1 6.3L12 17.4 6.5 20.3l1.1-6.3L3 9.6l6.3-.9z"/></svg>,
  bot:   (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><rect x="5" y="8" width="14" height="10" rx="2"/><path d="M12 3v5M8 13v1M16 13v1"/><circle cx="3" cy="12" r="1"/><circle cx="21" cy="12" r="1"/></svg>,
  trend: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><path d="M3 17l6-6 4 4 8-8M14 7h7v7"/></svg>,
  cpu:   (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><rect x="5" y="5" width="14" height="14" rx="2"/><rect x="9" y="9" width="6" height="6"/><path d="M9 2v3M15 2v3M9 19v3M15 19v3M2 9h3M2 15h3M19 9h3M19 15h3"/></svg>,
  rocket:(p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><path d="M14 4c5 0 6 4 6 6 0 0-2 6-9 9l-2-2c3-7 9-9 9-9M4 14l2-2 4 4-2 2c-2 1-4 0-4 0s-1-2 0-4z"/></svg>,
  brief: (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5a2 2 0 012-2h2a2 2 0 012 2v2M3 13h18"/></svg>,
  shield:(p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><path d="M12 3l8 3v5c0 5-4 9-8 10-4-1-8-5-8-10V6z"/></svg>,
  doc:   (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><path d="M14 3H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2V9zM14 3v6h6M8 13h8M8 17h5"/></svg>,
  layers:(p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28" {...p}><path d="M12 2l10 6-10 6L2 8zM2 16l10 6 10-6M2 12l10 6 10-6"/></svg>,
  bars:  (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" width="22" height="22" {...p}><path d="M3 6h18M3 12h18M3 18h18"/></svg>,
  x:     (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" width="22" height="22" {...p}><path d="M6 6l12 12M18 6L6 18"/></svg>,
  in:    (p) => <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" {...p}><path d="M4.98 3.5a2.5 2.5 0 11-.001 5.001A2.5 2.5 0 014.98 3.5zM3 9h4v12H3zM10 9h3.8v1.7h.06c.53-1 1.83-2.07 3.77-2.07 4.03 0 4.77 2.65 4.77 6.1V21h-4v-5.32c0-1.27-.03-2.9-1.77-2.9-1.77 0-2.04 1.38-2.04 2.81V21h-4z"/></svg>,
  ig:    (p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" width="16" height="16" {...p}><rect x="3" y="3" width="18" height="18" rx="5"/><circle cx="12" cy="12" r="4"/><circle cx="17.5" cy="6.5" r="1" fill="currentColor"/></svg>,
  whatsapp:(p) => <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" width="16" height="16" {...p}><path d="M21 12a9 9 0 11-3.6-7.2L21 3l-1.8 3.6A9 9 0 0121 12z"/><path d="M8.5 9c0 4 2.5 6.5 6.5 6.5l1.5-1.5-2-1-1 1c-1.5 0-3-1.5-3-3l1-1-1-2L9 8.5z" fill="currentColor"/></svg>,
};
window.Icon = Icon;

// ============================================================
// Site Header
// ============================================================
function SiteHeader({ current, theme = "group", subnav = null }) {
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  const isMobile = useIsMobile();

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

  const brandVariant = theme === "consult" ? "consult" : theme === "capital" ? "capital" : "group";

  // route Contact link to the matching division page
  const contactHref = theme === "consult"
    ? "/consulting/contact"
    : theme === "capital"
      ? "/capital/contact"
      : "/contact";

  const links = [
    { href: "#/", label: "Home", id: "home" },
    { href: "#/consulting", label: "Sinux Consulting", id: "consulting" },
    { href: "#/capital", label: "Sinux Capital", id: "capital" },
    { href: contactHref, label: "Contact", id: "contact" },
  ];

  return (
    <React.Fragment>
      <header className={`site-header ${scrolled ? "scrolled" : ""}`}>
        <div className="inner">
          <a href="/" className="brand">
            <SHexLogo size={30} variant={brandVariant} />
            <span className="brand-text">
              {theme === "consult" ? "SINUX CONSULTING"
                : theme === "capital" ? "SINUX CAPITAL"
                : "SINUX GROUP"}
            </span>
          </a>
          {!isMobile && (
            <nav className="nav-center">
              {links.map((l) => (
                <a key={l.id}
                   href={l.href}
                   className={`nav-link ${current === l.id ? "active" : ""}`}>
                  {l.label}
                </a>
              ))}
            </nav>
          )}
          <div className="nav-right">
            <a href={contactHref} className="btn btn-outline">Get in Touch</a>
            {isMobile && (
              <button className="hamburger" aria-label="Open menu" onClick={() => setOpen(true)}>
                <Icon.bars />
              </button>
            )}
          </div>
        </div>
      </header>

      {subnav}

      {open && (
        <MobileDrawer
          onClose={() => setOpen(false)}
          links={links}
          current={current}
        />
      )}
    </React.Fragment>
  );
}

function MobileDrawer({ onClose, links, current }) {
  // portal alternative — render at top-level via fixed positioning is OK since header doesn't apply backdrop-filter when drawer is rendered as sibling outside header.
  // To be safe, render to document.body via ReactDOM.createPortal:
  return ReactDOM.createPortal(
    <div className="mobile-drawer">
      <button className="close-x" onClick={onClose} aria-label="Close menu">
        <Icon.x />
      </button>
      <div className="links">
        {links.map((l) => (
          <a key={l.id} href={l.href} onClick={onClose}
             style={{ color: current === l.id ? "var(--accent)" : undefined }}>
            {l.label}
          </a>
        ))}
        <a href="/contact" onClick={onClose} className="btn btn-primary" style={{ marginTop: 24, alignSelf: "flex-start" }}>
          Get in Touch
        </a>
      </div>
      <div className="socials">
        <a className="social-btn" href="https://www.linkedin.com/company/sinuxindustries/" target="_blank" rel="noreferrer"><Icon.in /></a>
        <a className="social-btn" href="https://www.instagram.com/sinuxconsulting/" target="_blank" rel="noreferrer"><Icon.ig /></a>
      </div>
    </div>,
    document.body
  );
}
window.SiteHeader = SiteHeader;

// ============================================================
// Sub Nav
// ============================================================
function SubNav({ items = [], active }) {
  return (
    <div className="sub-nav">
      <div className="inner">
        {items.map((it) => (
          <a key={it.id} href={it.href} className={active === it.id ? "active" : ""}>{it.label}</a>
        ))}
      </div>
    </div>
  );
}
window.SubNav = SubNav;

// ============================================================
// Hero Background — orbs + hex grid + dot grid
// ============================================================
function HeroBg({ theme = "group", showMesh = true }) {
  // hex pattern as inline SVG
  return (
    <div className="hero-bg">
      {showMesh && (
        <React.Fragment>
          {/* orbs */}
          <div className="orb"
            style={{
              width: "44vw", height: "44vw", maxWidth: 700, maxHeight: 700,
              top: "-10%", left: "-6%",
              background: `radial-gradient(circle, color-mix(in oklab, var(--accent) 60%, transparent), transparent 70%)`,
            }}
          />
          <div className="orb"
            style={{
              width: "38vw", height: "38vw", maxWidth: 600, maxHeight: 600,
              bottom: "-12%", right: "-4%",
              background: `radial-gradient(circle, color-mix(in oklab, var(--accent-dark) 80%, transparent), transparent 70%)`,
              animationDelay: "-6s",
            }}
          />
          <div className="orb"
            style={{
              width: "26vw", height: "26vw", maxWidth: 420, maxHeight: 420,
              top: "40%", left: "55%",
              background: `radial-gradient(circle, color-mix(in oklab, var(--accent) 25%, transparent), transparent 70%)`,
              animationDelay: "-10s",
            }}
          />
        </React.Fragment>
      )}
      {/* hex grid */}
      <svg className="hexgrid" width="100%" height="100%" preserveAspectRatio="xMidYMid slice">
        <defs>
          <pattern id="hexpat" width="60" height="69.28" patternUnits="userSpaceOnUse" patternTransform="scale(1)">
            <path d="M30 0 L60 17.32 L60 51.96 L30 69.28 L0 51.96 L0 17.32 Z" fill="none" stroke="currentColor" strokeWidth="0.5" strokeOpacity="0.3"/>
            <path d="M60 17.32 L90 0 M0 17.32 L-30 0 M60 51.96 L90 69.28 M0 51.96 L-30 69.28" stroke="currentColor" strokeWidth="0.5" strokeOpacity="0.15"/>
          </pattern>
        </defs>
        <rect width="100%" height="100%" fill="url(#hexpat)" style={{ color: "var(--accent)" }}/>
      </svg>
      <div className="dotgrid" />
      {/* corner watermark hex */}
      <svg className="hero-watermark" viewBox="0 0 100 100">
        <polygon points="50,4 92,28 92,72 50,96 8,72 8,28" fill="none" stroke="var(--accent)" strokeWidth="0.5"/>
        <polygon points="50,18 78,34 78,66 50,82 22,66 22,34" fill="none" stroke="var(--accent)" strokeWidth="0.3"/>
        <polygon points="50,32 64,40 64,60 50,68 36,60 36,40" fill="var(--accent)" opacity="0.4"/>
      </svg>
    </div>
  );
}
window.HeroBg = HeroBg;

// ============================================================
// Animated Stat Counter
// ============================================================
function CountUp({ to, label, suffix = "", duration = 1500 }) {
  const [val, setVal] = useState(0);
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    let raf;
    const obs = new IntersectionObserver(([entry]) => {
      if (entry.isIntersecting) {
        const start = performance.now();
        const tick = (t) => {
          const p = Math.min(1, (t - start) / duration);
          const eased = 1 - Math.pow(1 - p, 3);
          setVal(Math.round(to * eased));
          if (p < 1) raf = requestAnimationFrame(tick);
        };
        raf = requestAnimationFrame(tick);
        obs.disconnect();
      }
    }, { threshold: 0.4 });
    obs.observe(el);
    return () => { obs.disconnect(); if (raf) cancelAnimationFrame(raf); };
  }, [to, duration]);
  return (
    <div className="stat" ref={ref}>
      <div className="stat-num">{val}{suffix}</div>
      <div className="stat-label">{label}</div>
    </div>
  );
}
window.CountUp = CountUp;

// ============================================================
// Footer
// ============================================================
function Footer({ variant = "group" }) {
  const isGroup = variant === "group";
  const isConsult = variant === "consult";
  const tagline = isGroup
    ? "Building the future through scalable ventures."
    : isConsult
      ? "Digital Growth + Technology Consulting. Powered by AI. Trusted Worldwide."
      : "Strategic investments and ventures for long-term value.";

  const contactHref = isConsult
    ? "/consulting/contact"
    : (variant === "capital" ? "/capital/contact" : "/contact");

  const email = isConsult
    ? "info@sinuxconsulting.com"
    : (variant === "capital" ? "info@sinuxcapital.com" : "info@sinuxgroup.com");

  const websiteName = isGroup ? "Sinux Group" : isConsult ? "Sinux Consulting" : "Sinux Capital";

  return (
    <footer className="site-footer">
      <div className="footer-inner">
        <div className="footer-grid">
          <div>
            <Brandmark variant={variant} size={32} />
            <p style={{ color: "var(--ink-2)", marginTop: 16, maxWidth: 380, fontSize: 14, lineHeight: 1.65 }}>
              {tagline}
            </p>
            <div className="socials">
              <a className="social-btn" href="https://www.linkedin.com/company/sinuxindustries/" target="_blank" rel="noreferrer" aria-label="LinkedIn"><Icon.in /></a>
              <a className="social-btn" href="https://www.instagram.com/sinuxconsulting/" target="_blank" rel="noreferrer" aria-label="Instagram"><Icon.ig /></a>
            </div>
          </div>
          <div>
            <div className="footer-h">Quick Links</div>
            <div className="footer-links">
              <a href="/">Sinux Group</a>
              <a href="/consulting">Sinux Consulting</a>
              <a href="/capital">Sinux Capital</a>
              <a href={contactHref}>Contact</a>
              <a href="/terms">Terms & Conditions</a>
              <a href="/privacy">Privacy Policy</a>
            </div>
          </div>
          <div>
            <div className="footer-h">Get In Touch</div>
            <div className="footer-links">
              <a href={`mailto:${email}`}>{email}</a>
              <a href="tel:+60126187256">+60 12-618 7256</a>
              <a href="tel:+12293746725">+1 (229) 374-6725</a>
              <span style={{ color: "var(--ink-3)", fontSize: 13 }}>Kuala Lumpur, Malaysia</span>
              <span style={{ color: "var(--ink-3)", fontSize: 13 }}>Mon–Fri · 10:00am – 9:00pm</span>
              {isConsult && (
                <div style={{
                  marginTop: 16, paddingTop: 16,
                  borderTop: "1px solid var(--line-2)",
                  display: "flex", flexDirection: "column", gap: 4,
                }}>
                  <span style={{ color: "var(--ink-4)", fontSize: 10, letterSpacing: "0.14em", textTransform: "uppercase", fontFamily: "'Michroma',sans-serif" }}>
                    Registered Entity
                  </span>
                  <span style={{ color: "var(--ink-2)", fontSize: 13 }}>
                    Sinux Consulting (PLT)
                  </span>
                  <span style={{ color: "var(--ink-3)", fontSize: 12, fontFamily: "'JetBrains Mono', monospace", letterSpacing: "0.04em" }}>
                    SSM: 202503207573
                  </span>
                </div>
              )}
            </div>
          </div>
        </div>
        <div className="footer-bottom">
          <div>© 2025 {websiteName}. All rights reserved.</div>
          <div>
            {isGroup
              ? "Sinux Consulting and Sinux Capital are subsidiaries of Sinux Group."
              : isConsult
                ? "A subsidiary of Sinux Group · Registered in Malaysia (SSM: 202503207573)"
                : "A member of the Sinux Group."}
          </div>
          <div><a href="/terms" style={{ color: "inherit", textDecoration: "none" }}>Terms</a> · <a href="/privacy" style={{ color: "inherit", textDecoration: "none" }}>Privacy</a></div>
        </div>
      </div>
    </footer>
  );
}
window.Footer = Footer;

// ============================================================
// Contact Section (shared) — wired to /api/send-email (Resend)
// theme prop maps to a routing variant so the inquiry lands in the right inbox.
// ============================================================
function ContactSection({ theme = "group" }) {
  const variant = theme === "consult" ? "consult" : theme === "capital" ? "capital" : "group";
  const fallbackEmail = variant === "consult"
    ? "info@sinuxconsulting.com"
    : variant === "capital" ? "info@sinuxcapital.com" : "info@sinuxgroup.com";
  const [status, setStatus] = useState("idle");
  const [errorMsg, setErrorMsg] = useState("");

  async function handleSubmit(e) {
    e.preventDefault();
    if (status === "sending") return;
    setStatus("sending");
    setErrorMsg("");
    const form = e.target;
    const fd = new FormData(form);
    const payload = { variant };
    fd.forEach((val, key) => { payload[key] = val; });
    try {
      const r = await fetch("/api/send-email", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(payload),
      });
      if (!r.ok) {
        const data = await r.json().catch(() => ({}));
        throw new Error(data.error || `Server returned ${r.status}`);
      }
      setStatus("sent");
      form.reset();
    } catch (err) {
      setStatus("error");
      setErrorMsg(
        err.message?.includes("Failed to fetch")
          ? "Couldn't reach the server. The form needs to be deployed to Vercel first."
          : err.message || "Something went wrong. Please email us directly."
      );
    }
  }

  return (
    <section id="contact" className="section-py" style={{ borderTop: "1px solid var(--line-2)" }}>
      <div className="container">
        <div style={{ display: "grid", gridTemplateColumns: "minmax(0,1fr) minmax(0,1.2fr)", gap: "clamp(32px, 5vw, 80px)", alignItems: "start" }}
             className="contact-grid">
          <div>
            <div className="eyebrow">Contact</div>
            <h2 className="h2" style={{ marginTop: 16, marginBottom: 20 }}>Let's start a conversation.</h2>
            <p className="lede" style={{ maxWidth: 480 }}>
              Tell us about your project, ambition, or inquiry. We respond within one business day.
            </p>
            <div style={{ marginTop: 32, display: "flex", flexDirection: "column", gap: 12, color: "var(--ink-2)", fontSize: 15 }}>
              <div><span style={{ color: "var(--ink-3)", fontSize: 12, letterSpacing: "0.12em", textTransform: "uppercase", marginRight: 12 }}>EMAIL</span>{fallbackEmail}</div>
              <div><span style={{ color: "var(--ink-3)", fontSize: 12, letterSpacing: "0.12em", textTransform: "uppercase", marginRight: 12 }}>MY</span>+60 12-618 7256</div>
              <div><span style={{ color: "var(--ink-3)", fontSize: 12, letterSpacing: "0.12em", textTransform: "uppercase", marginRight: 12 }}>US</span>+1 (229) 374-6725</div>
              <div><span style={{ color: "var(--ink-3)", fontSize: 12, letterSpacing: "0.12em", textTransform: "uppercase", marginRight: 12 }}>HRS</span>Mon–Fri 10:00am – 9:00pm</div>
            </div>
          </div>
          {status === "sent" ? (
            <div className="card" style={{ textAlign: "center", padding: "clamp(28px, 4vw, 48px)" }}>
              <h3 className="h3" style={{ marginBottom: 12 }}>Message received.</h3>
              <p className="text-muted" style={{ maxWidth: 460, marginInline: "auto", fontSize: 14, lineHeight: 1.65 }}>
                Thank you — we'll be in touch within one business day. For urgent matters, email us directly at{" "}
                <a href={`mailto:${fallbackEmail}`} style={{ color: "var(--accent)" }}>{fallbackEmail}</a>.
              </p>
              <button type="button" onClick={() => setStatus("idle")} className="btn btn-ghost" style={{ marginTop: 20 }}>Send another message</button>
            </div>
          ) : (
            <form className="card" onSubmit={handleSubmit}>
              <input type="text" name="_hp" tabIndex="-1" autoComplete="off" aria-hidden="true" style={{ position: "absolute", left: "-9999px", width: 1, height: 1 }} />
              <div className="auto-grid" style={{ "--min": "200px" }}>
                <div className="field"><label>Name</label><input name="name" required placeholder="Your full name" /></div>
                <div className="field"><label>Email</label><input name="email" required type="email" placeholder="you@company.com" /></div>
              </div>
              <div className="auto-grid" style={{ "--min": "200px", marginTop: 20 }}>
                <div className="field"><label>Phone</label><input name="phone" placeholder="+60 …" /></div>
                <div className="field">
                  <label>Service Interest</label>
                  <select name="inquiryType" defaultValue="">
                    <option value="" disabled>Select…</option>
                    <option>Digital Growth — Websites</option>
                    <option>Tech Consulting</option>
                    <option>ReviewFlow Inquiry</option>
                    <option>General Inquiry</option>
                    <option>Capital Inquiry</option>
                  </select>
                </div>
              </div>
              <div className="field" style={{ marginTop: 20 }}>
                <label>Message</label>
                <textarea name="message" required rows="5" placeholder="Tell us about your project, timeline, and goals." />
              </div>
              {status === "error" && (
                <div style={{ marginTop: 16, padding: "12px 16px", background: "rgba(220, 38, 38, 0.08)", border: "1px solid rgba(220, 38, 38, 0.3)", borderRadius: 10, color: "#fca5a5", fontSize: 13, lineHeight: 1.5 }}>
                  <strong style={{ color: "#fecaca" }}>Couldn't send:</strong> {errorMsg}{" "}
                  You can email us directly at <a href={`mailto:${fallbackEmail}`} style={{ color: "#fecaca", textDecoration: "underline" }}>{fallbackEmail}</a>.
                </div>
              )}
              <div style={{ marginTop: 24, display: "flex", gap: 12, flexWrap: "wrap" }}>
                <button type="submit" className="btn btn-primary" disabled={status === "sending"} style={status === "sending" ? { opacity: 0.6, cursor: "wait" } : {}}>
                  {status === "sending" ? "Sending…" : "Send Message"}
                </button>
                <a href="https://wa.me/60126187256" target="_blank" rel="noreferrer" className="btn btn-ghost">WhatsApp Us</a>
              </div>
            </form>
          )}
        </div>
      </div>
    </section>
  );
}
window.ContactSection = ContactSection;
