// Layout.jsx — Nav + Footer + WhatsApp Float

const WA_LINK = "https://wa.me/556282585529?text=Ol%C3%A1!%20Gostaria%20de%20agendar%20um%20hor%C3%A1rio%20na%20Essenza%20Glow.";
const LOGO = "https://imagedelivery.net/mYdfeAeRRdkIXG5w7XJhtQ/95afd9ef-45d9-459d-dbdd-e1ab31607300/public";

const NAV_LINKS = [
  { label: "Serviços",    href: "#services" },
  { label: "Resultados",  href: "resultados.html" },
  { label: "Sobre",       href: "sobre.html" },
  { label: "Blog",        href: "blog.html" },
  { label: "FAQ",         href: "#faq" },
];

function Nav() {
  const [scrolled, setScrolled] = React.useState(false);
  const [open, setOpen] = React.useState(false);

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

  const close = () => setOpen(false);

  return (
    <>
      <nav className={`nav${scrolled ? " scrolled" : ""}`}>
        <div className="nav-inner">
          <a href="index.html" className="nav-logo">
            <img src={LOGO} alt="Essenza Glow" />
          </a>
          <ul className="nav-links">
            {NAV_LINKS.map(l => (
              <li key={l.label}>
                <a href={l.href}>{l.label}</a>
              </li>
            ))}
            <li>
              <a href={WA_LINK} target="_blank" rel="noopener" className="nav-cta">
                Agendar
              </a>
            </li>
          </ul>
          <button className={`nav-hamburger${open ? " active" : ""}`} onClick={() => setOpen(o => !o)} aria-label="Menu">
            <span /><span /><span />
          </button>
        </div>
      </nav>

      {/* Mobile menu */}
      <div className={`nav-mobile${open ? " open" : ""}`}>
        <div className="nav-mobile-bg">
          <div className="nav-mobile-leaf" style={{ top: "-10%", right: "-10%", transform: "rotate(200deg)" }}>
             <svg width="300" height="300" viewBox="0 0 120 120" fill="currentColor"><path d="M60 10 C90 10, 110 40, 60 110 C10 40, 30 10, 60 10 Z" /></svg>
          </div>
          <div className="nav-mobile-leaf" style={{ bottom: "-10%", left: "-10%", transform: "rotate(30deg)" }}>
             <svg width="250" height="250" viewBox="0 0 120 120" fill="currentColor"><path d="M60 10 C90 10, 110 40, 60 110 C10 40, 30 10, 60 10 Z" /></svg>
          </div>
        </div>
        
        <div className="nav-mobile-content">
          <div className="nav-mobile-header">
            <img src={LOGO} alt="Essenza Glow" style={{ height: 38 }} />
            <button onClick={close} className="nav-mobile-close">×</button>
          </div>
          
          <div className="nav-mobile-links">
            {NAV_LINKS.map((l, i) => (
              <a 
                key={l.label} 
                href={l.href} 
                onClick={close}
                style={{ transitionDelay: `${i * 0.1}s` }}
                className={open ? "revealed" : ""}
              >
                {l.label}
              </a>
            ))}
          </div>
          
          <div className={`nav-mobile-footer${open ? " revealed" : ""}`} style={{ transitionDelay: `${NAV_LINKS.length * 0.1}s` }}>
            <p>Realce sua beleza natural.</p>
            <a href={WA_LINK} target="_blank" rel="noopener" onClick={close} className="btn-primary">
              Agendar pelo WhatsApp
            </a>
            <div className="nav-mobile-social">
              <a href="https://instagram.com/essenzaglowbs" target="_blank" rel="noopener">Instagram</a>
            </div>
          </div>
        </div>
      </div>
    </>
  );
}

function Footer() {
  return (
    <footer>
      <div className="container">
        <div className="footer-grid">
          <div className="footer-brand">
            <img src={LOGO} alt="Essenza Glow" />
            <p>Studio de design de sobrancelhas focado em naturalidade, harmonia e resultados personalizados.</p>
            <div style={{ marginTop: 20 }}>
              <a href="https://instagram.com/essenzaglowbs" target="_blank" rel="noopener" className="footer-insta">
                <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
                  <path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z" />
                </svg>
                @essenzaglowbs
              </a>
            </div>
          </div>
          <div>
            <p className="footer-col-title">Serviços</p>
            <ul className="footer-links">
              {["Design de Sobrancelhas", "Brow Lamination", "Henna", "Tintura", "Mapeamento Facial", "Lash Lifting"].map(s => (
                <li key={s}><a href="#services">{s}</a></li>
              ))}
            </ul>
          </div>
          <div>
            <p className="footer-col-title">Contato</p>
            <ul className="footer-links">
              <li><a href={WA_LINK} target="_blank" rel="noopener">WhatsApp</a></li>
              <li><a href="https://instagram.com/essenzaglowbs" target="_blank" rel="noopener">Instagram</a></li>
              <li><a href="https://essenzaglowbs.com" target="_blank" rel="noopener">essenzaglowbs.com</a></li>
            </ul>
            <div style={{ marginTop: 28 }}>
              <a href={WA_LINK} target="_blank" rel="noopener" className="btn-primary" style={{ fontSize: 12 }}>
                Agendar Horário →
              </a>
            </div>
          </div>
        </div>
        <div className="footer-bottom">
          <span>© 2026 Essenza Glow · Todos os direitos reservados</span>
          <span>Studio de design de sobrancelhas</span>
        </div>
      </div>
    </footer>
  );
}

function WAFloat() {
  return (
    <a href={WA_LINK} target="_blank" rel="noopener" className="wa-float" aria-label="Contato via WhatsApp">
      <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
        <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z" />
      </svg>
    </a>
  );
}

Object.assign(window, { Nav, Footer, WAFloat, WA_LINK });
