
// ──────────────────────────────────────────────
//  Dr. Denerval Carolino – Landing Page Sections
// ──────────────────────────────────────────────

const { useState, useEffect, useRef } = React;

const WA_LINK = "https://wa.me/5511968678888?text=Ol%C3%A1%2C%20gostaria%20de%20agendar%20uma%20consulta!";

// ── Helpers ─────────────────────────────────────
function useInView(threshold = 0.15) {
  const ref = useRef(null);
  const [visible, setVisible] = useState(false);
  useEffect(() => {
    const check = () => {
      if (ref.current) {
        const rect = ref.current.getBoundingClientRect();
        if (rect.top < window.innerHeight && rect.bottom > 0) {
          setVisible(true);
          return true;
        }
      }
      return false;
    };
    // Check immediately after layout
    setTimeout(() => {
      if (!check()) {
        const obs = new IntersectionObserver(([e]) => { if (e.isIntersecting) setVisible(true); }, { threshold });
        if (ref.current) obs.observe(ref.current);
      }
    }, 50);
  }, []);
  return [ref, visible];
}

function useIsMobile(bp = 768) {
  const [mobile, setMobile] = useState(() => typeof window !== 'undefined' && window.innerWidth < bp);
  useEffect(() => {
    const fn = () => setMobile(window.innerWidth < bp);
    window.addEventListener('resize', fn);
    return () => window.removeEventListener('resize', fn);
  }, [bp]);
  return mobile;
}

function Reveal({ children, delay = 0, style = {}, alwaysVisible = false }) {
  const [ref, visible] = useInView();
  const show = alwaysVisible || visible;
  return (
    <div ref={ref} style={{
      opacity: show ? 1 : 0,
      transform: show ? 'translateY(0)' : 'translateY(28px)',
      transition: `opacity .7s ease ${delay}s, transform .7s ease ${delay}s`,
      ...style
    }}>{children}</div>
  );
}

// ── Logo ────────────────────────────────────────
function Logo({ theme, size = 110 }) {
  const dark = theme === 'dark';
  const h = size * 0.7;
  const src = dark ? 'assets/logo_dark.png' : 'assets/logo_nobg.png';
  return (
    <img src={src} alt="The DC Nutricionista"
      style={{ height: h, width: 'auto', display: 'block' }}
    />
  );
}

// ── Navbar ──────────────────────────────────────
function Navbar({ theme }) {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const fn = () => setScrolled(window.scrollY > 40);
    window.addEventListener('scroll', fn);
    return () => window.removeEventListener('scroll', fn);
  }, []);
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  return (
    <nav style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 100,
      padding: '0 5vw',
      height: scrolled ? 64 : 88,
      display: 'flex', alignItems: 'center', justifyContent: 'space-between', overflow: 'visible',
      background: scrolled ? (dark ? 'rgba(13,27,42,.95)' : 'rgba(247,244,239,.95)') : 'transparent',
      backdropFilter: scrolled ? 'blur(12px)' : 'none',
      borderBottom: scrolled ? `1px solid ${dark ? '#c9a96e22' : '#3a6b4a22'}` : 'none',
      transition: 'all .4s ease'
    }}>
      <Logo theme={theme} size={scrolled ? 80 : 95} />
      <div style={{ display: 'flex', gap: mobile ? 12 : 28, alignItems: 'center' }}>
        {!mobile && ['Sobre', 'Método', 'Preços', 'Contato'].map(l => (
          <a key={l} href={`#${l.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'')}`}
            style={{ fontSize: 12.5, letterSpacing: 1.5, textTransform: 'uppercase', color: 'var(--text2)', textDecoration: 'none', fontFamily: 'var(--font-body)', transition: 'color .2s' }}
            onMouseEnter={e => e.target.style.color = 'var(--accent)'}
            onMouseLeave={e => e.target.style.color = 'var(--text2)'}
          >{l}</a>
        ))}
        <a href={WA_LINK} target="_blank" style={{
          padding: mobile ? '8px 16px' : '9px 22px', fontSize: 11, letterSpacing: 1.5, textTransform: 'uppercase',
          background: 'var(--accent)', color: dark ? '#0d1b2a' : '#fff',
          textDecoration: 'none', fontFamily: 'var(--font-body)', fontWeight: 600,
          borderRadius: dark ? 0 : 50, transition: 'opacity .2s', whiteSpace: 'nowrap'
        }}
          onMouseEnter={e => e.target.style.opacity = '.85'}
          onMouseLeave={e => e.target.style.opacity = '1'}
        >Agendar</a>
      </div>
    </nav>
  );
}

// ── Hero ─────────────────────────────────────────
function Hero({ theme }) {
  const dark = theme === 'dark';
  const heroBg = {
    dark:      'radial-gradient(ellipse at 70% 50%, #1a2e45 0%, #0d1b2a 60%)',
    light:     'radial-gradient(ellipse at 30% 60%, #e8f0eb 0%, #f7f4ef 60%)',
    editorial: 'radial-gradient(ellipse at 30% 60%, #f0ecea 0%, #fafafa 70%)',
    terra:     'radial-gradient(ellipse at 30% 60%, #e8d8cc 0%, #f5ede4 70%)',
  }[theme];
  const photoBg = {
    dark:      'linear-gradient(160deg, #1e3550 0%, #0d1b2a 100%)',
    light:     'linear-gradient(160deg, #d4e6d9 0%, #b8d4c0 100%)',
    editorial: 'linear-gradient(160deg, #e8d8d4 0%, #d4beba 100%)',
    terra:     'linear-gradient(160deg, #e8c9b4 0%, #d4a890 100%)',
  }[theme];
  const fadeBg = {
    dark:      'linear-gradient(to top, #0d1b2a 0%, transparent 100%)',
    light:     'linear-gradient(to top, #f7f4ef 0%, transparent 100%)',
    editorial: 'linear-gradient(to top, #fafafa 0%, transparent 100%)',
    terra:     'linear-gradient(to top, #f5ede4 0%, transparent 100%)',
  }[theme];
  const borderRadius = dark ? '8px 8px 0 0' : '240px 240px 0 0';
  const mobile = useIsMobile();
  return (
    <section style={{
      minHeight: '100vh', display: 'flex', alignItems: 'center',
      padding: mobile ? '100px 6vw 60px' : '120px 5vw 80px',
      background: heroBg,
      position: 'relative', overflow: 'hidden'
    }}>
      {!mobile && <>
        <div style={{ position: 'absolute', right: '8vw', top: '15%', width: 420, height: 420, borderRadius: '50%', border: `1px solid ${dark ? '#c9a96e18' : 'var(--accent)18'}`, pointerEvents: 'none' }}/>
        <div style={{ position: 'absolute', right: '6vw', top: '10%', width: 540, height: 540, borderRadius: '50%', border: `1px solid ${dark ? '#c9a96e0c' : 'var(--accent)0c'}`, pointerEvents: 'none' }}/>
      </>}

      {/* Mobile background photo */}
      {mobile && (
        <div style={{ position: 'absolute', inset: 0, zIndex: 0 }}>
          <img src="assets/dr-denerval.png" alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center top', display: 'block', opacity: 0.18 }}/>
        </div>
      )}

      <div style={{ maxWidth: mobile ? '100%' : 760, position: 'relative', zIndex: 2, width: '100%' }}>
        <Reveal delay={0} alwaysVisible>
          <div style={{
            display: 'inline-flex', alignItems: 'center', gap: 10,
            padding: '6px 18px', marginBottom: 32,
            border: `1px solid ${dark ? '#c9a96e50' : '#3a6b4a50'}`,
            borderRadius: dark ? 0 : 50,
            fontSize: 11, letterSpacing: 2, textTransform: 'uppercase',
            color: 'var(--accent)', fontFamily: 'var(--font-body)'
          }}>
            <span style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--accent)' }}/>
            Nutrição Clínica Baseada em Evidências
          </div>
        </Reveal>
        <Reveal delay={0.1} alwaysVisible>
          <h1 style={{
            fontFamily: 'var(--font-display)', fontWeight: 300,
            fontSize: mobile ? 'clamp(2.2rem, 10vw, 3.2rem)' : 'clamp(2.8rem, 6vw, 5rem)', lineHeight: 1.1,
            color: 'var(--text)', margin: '0 0 24px', letterSpacing: '-1px'
          }}>
            O acompanhamento<br/>
            que <em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>transforma</em><br/>
            sua saúde em 3 meses.
          </h1>
        </Reveal>
        <Reveal delay={0.2} alwaysVisible>
          <p style={{
            fontSize: mobile ? 15 : 17, lineHeight: 1.7, color: 'var(--text2)',
            maxWidth: 520, margin: '0 0 44px', fontFamily: 'var(--font-body)', fontWeight: 300
          }}>
            Acompanhamento nutricional individual, baseado em ciência e adaptado à sua vida. Atendimento presencial em São Paulo ou online de onde você estiver.
          </p>
        </Reveal>
        <Reveal delay={0.3} alwaysVisible>
          <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'center' }}>
            <a href={WA_LINK} target="_blank" style={{
              padding: mobile ? '14px 24px' : '16px 38px', fontSize: 13, letterSpacing: 1.5, textTransform: 'uppercase',
              background: 'var(--accent)', color: dark ? '#0d1b2a' : '#fff',
              textDecoration: 'none', fontFamily: 'var(--font-body)', fontWeight: 600,
              borderRadius: dark ? 0 : 50, display: 'flex', alignItems: 'center', gap: 10, transition: 'opacity .2s'
            }}
              onMouseEnter={e => e.currentTarget.style.opacity = '.85'}
              onMouseLeave={e => e.currentTarget.style.opacity = '1'}
            >
              <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><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>
              Agendar Consulta
            </a>
            {!mobile && <a href="#sobre" style={{
              padding: '16px 32px', fontSize: 13, letterSpacing: 1.5, textTransform: 'uppercase',
              border: `1px solid ${dark ? '#c9a96e50' : '#3a6b4a50'}`,
              color: 'var(--text)', textDecoration: 'none',
              fontFamily: 'var(--font-body)', borderRadius: dark ? 0 : 50, transition: 'all .2s'
            }}
              onMouseEnter={e => { e.currentTarget.style.background = 'var(--accent)'; e.currentTarget.style.color = dark ? '#0d1b2a' : '#fff'; e.currentTarget.style.borderColor = 'var(--accent)'; }}
              onMouseLeave={e => { e.currentTarget.style.background = 'transparent'; e.currentTarget.style.color = 'var(--text)'; e.currentTarget.style.borderColor = dark ? '#c9a96e50' : '#3a6b4a50'; }}
            >Conhecer o Dr.</a>}
          </div>
        </Reveal>
      </div>

      {/* Doctor photo — desktop only */}
      {!mobile && (
        <div style={{
          position: 'absolute', right: '6vw', bottom: 0, top: '8%',
          width: 'clamp(200px, 28vw, 420px)',
          borderRadius, overflow: 'hidden', zIndex: 1,
          boxShadow: dark ? '0 32px 80px rgba(0,0,0,.5)' : '0 32px 80px rgba(0,0,0,.15)'
        }}>
          <img src="assets/dr-denerval.png" alt="Dr. Denerval Carolino"
            style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center top', display: 'block' }}
          />
          <div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: '30%', background: fadeBg }}/>
        </div>
      )}
    </section>
  );
}

// ── Sobre ────────────────────────────────────────
function Sobre({ theme }) {
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  const areas = [
    { num: '01', label: 'Clínica Hospitalar', desc: 'Atendimento especializado em ambiente hospitalar' },
    { num: '02', label: 'Ambulatório Primário', desc: 'Cuidado nutricional em nível primário de saúde' },
    { num: '03', label: 'Saúde Coletiva', desc: 'Promoção da saúde em comunidades' },
    { num: '04', label: 'Nutrição Clínica', desc: 'Gestão e planejamento alimentar individualizado' },
  ];
  return (
    <section id="sobre" style={{ padding: '100px 5vw', background: 'var(--bg2)' }}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <Reveal>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: 'var(--accent)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>Formação & Experiência</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2rem, 4vw, 3.2rem)', color: 'var(--text)', margin: '0 0 60px', letterSpacing: '-0.5px' }}>
            Quem é o<br/><em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>Dr. Dener?</em>
          </h2>
        </Reveal>
        <div style={{ display: 'grid', gridTemplateColumns: mobile ? '1fr' : '1fr 1fr', gap: mobile ? 40 : 60, alignItems: 'start' }}>
          <Reveal delay={0.1}>
            <p style={{ fontSize: 16.5, lineHeight: 1.8, color: 'var(--text2)', fontFamily: 'var(--font-body)', fontWeight: 300, marginBottom: 32 }}>
              Nutricionista graduado pela Universidade Uninove com Pós-graduação em Nutrição Clínica e Hospitalar, o Dr. Denerval Carolino combina formação acadêmica sólida com experiência prática em diferentes contextos clínicos.
            </p>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
              {[['Graduação em Nutrição', 'Universidade Uninove'], ['Pós-graduação', 'Nutrição Clínica e Hospitalar'], ['Registro Profissional', 'CRN3 93164']].map(([t, d]) => (
                <div key={t} style={{
                  display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                  padding: '14px 20px',
                  border: `1px solid ${dark ? '#ffffff0f' : '#1a2c1e0f'}`,
                  borderLeft: `3px solid var(--accent)`,
                  background: dark ? '#ffffff05' : '#1a2c1e04'
                }}>
                  <span style={{ fontSize: 13, fontFamily: 'var(--font-body)', color: 'var(--text)', fontWeight: 500 }}>{t}</span>
                  <span style={{ fontSize: 12, fontFamily: 'var(--font-body)', color: 'var(--text2)' }}>{d}</span>
                </div>
              ))}
            </div>
          </Reveal>
          <Reveal delay={0.2}>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
              {areas.map(({ num, label, desc }) => (
                <div key={label} style={{
                  padding: '24px 20px',
                  border: `1px solid ${dark ? '#ffffff0f' : '#1a2c1e0f'}`,
                  background: dark ? '#ffffff05' : '#ffffff60',
                  borderRadius: dark ? 0 : 12, transition: 'all .3s'
                }}
                  onMouseEnter={e => { e.currentTarget.style.borderColor = 'var(--accent)'; e.currentTarget.style.transform = 'translateY(-3px)'; }}
                  onMouseLeave={e => { e.currentTarget.style.borderColor = dark ? '#ffffff0f' : '#1a2c1e0f'; e.currentTarget.style.transform = 'translateY(0)'; }}
                >
                  <div style={{ fontSize: 22, fontFamily: 'var(--font-display)', fontWeight: 300, color: 'var(--accent)', marginBottom: 12, letterSpacing: '-1px' }}>{num}</div>
                  <div style={{ fontSize: 13, fontWeight: 600, color: 'var(--text)', fontFamily: 'var(--font-body)', marginBottom: 6 }}>{label}</div>
                  <div style={{ fontSize: 12, color: 'var(--text2)', fontFamily: 'var(--font-body)', lineHeight: 1.5 }}>{desc}</div>
                </div>
              ))}
            </div>
          </Reveal>
        </div>
      </div>
    </section>
  );
}

// ── Metodologia ──────────────────────────────────
function Metodologia({ theme }) {
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  const pilares = [
    { num: '01', title: 'Individualidade', desc: 'Cada pessoa possui um corpo, uma história e objetivos únicos. O planejamento alimentar é 100% personalizado, nunca genérico.' },
    { num: '02', title: 'Parceria & Confiança', desc: 'Aqui você é ouvido com atenção. Cada decisão é tomada em conjunto, com empatia, transparência e parceria.' },
    { num: '03', title: 'Suporte Contínuo', desc: 'Estamos próximos para ajustar o plano, orientar e motivar no dia a dia, entre uma consulta e outra.' },
    { num: '04', title: 'Autonomia', desc: 'Você participa ativamente das decisões. A longo prazo, conquista conhecimento para manter resultados por conta própria.' },
  ];
  return (
    <section id="metodo" style={{ padding: '100px 5vw', background: 'var(--bg)' }}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <Reveal>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: 'var(--accent)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>Metodologia</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2rem, 4vw, 3.2rem)', color: 'var(--text)', margin: '0 0 16px', letterSpacing: '-0.5px' }}>
            Quatro pilares<br/><em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>fundamentais</em>
          </h2>
          <p style={{ fontSize: 16, color: 'var(--text2)', fontFamily: 'var(--font-body)', maxWidth: 500, margin: '0 0 60px', lineHeight: 1.7, fontWeight: 300 }}>
            Um processo consolidado que une ciência, escuta ativa e acompanhamento próximo.
          </p>
        </Reveal>
        <div style={{ display: 'grid', gridTemplateColumns: mobile ? '1fr 1fr' : 'repeat(4, 1fr)', gap: mobile ? 12 : 2 }}>
          {pilares.map(({ num, title, desc }, i) => (
            <Reveal key={num} delay={i * 0.1}>
              <div style={{
                padding: '40px 28px', height: '100%',
                background: i === 0 ? 'var(--accent)' : (dark ? '#ffffff08' : '#1a2c1e06'),
                borderTop: `2px solid ${i === 0 ? 'var(--accent)' : (dark ? '#ffffff15' : '#1a2c1e15')}`,
                transition: 'all .3s', cursor: 'default'
              }}
                onMouseEnter={e => { if (i !== 0) { e.currentTarget.style.background = 'var(--accent)'; e.currentTarget.style.borderTopColor = 'var(--accent)'; e.currentTarget.querySelector('.pilar-num').style.color = dark ? '#0d1b2a' : '#fff'; e.currentTarget.querySelector('.pilar-title').style.color = dark ? '#0d1b2a' : '#fff'; e.currentTarget.querySelector('.pilar-desc').style.color = dark ? '#0d1b2a99' : '#ffffff99'; }}}
                onMouseLeave={e => { if (i !== 0) { e.currentTarget.style.background = dark ? '#ffffff08' : '#1a2c1e06'; e.currentTarget.style.borderTopColor = dark ? '#ffffff15' : '#1a2c1e15'; e.currentTarget.querySelector('.pilar-num').style.color = 'var(--accent)'; e.currentTarget.querySelector('.pilar-title').style.color = 'var(--text)'; e.currentTarget.querySelector('.pilar-desc').style.color = 'var(--text2)'; }}}
              >
                <div className="pilar-num" style={{ fontSize: 36, fontFamily: 'var(--font-display)', fontWeight: 300, color: i === 0 ? (dark ? '#0d1b2a' : '#fff') : 'var(--accent)', marginBottom: 20, letterSpacing: '-1px', transition: 'color .3s' }}>{num}</div>
                <div className="pilar-title" style={{ fontSize: 17, fontFamily: 'var(--font-display)', fontWeight: 600, color: i === 0 ? (dark ? '#0d1b2a' : '#fff') : 'var(--text)', marginBottom: 12, transition: 'color .3s' }}>{title}</div>
                <div className="pilar-desc" style={{ fontSize: 13.5, fontFamily: 'var(--font-body)', color: i === 0 ? (dark ? '#0d1b2a99' : '#ffffff99') : 'var(--text2)', lineHeight: 1.65, fontWeight: 300, transition: 'color .3s' }}>{desc}</div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── Modalidades ──────────────────────────────────
function Modalidades({ theme }) {
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  const rows = [
    ['Acompanhamento completo', true, true],
    ['Plano alimentar individualizado', true, true],
    ['Monitoramento contínuo', true, true],
    ['WhatsApp e site exclusivo', true, true],
    ['Materiais exclusivos', true, true],
    ['Avaliação corporal', 'Dobras cutâneas', 'Medidas, fotos e peso'],
    ['Local', 'Consultório · Perdizes, SP', 'De onde você estiver'],
  ];
  return (
    <section style={{ padding: mobile ? '70px 5vw' : '100px 5vw', background: 'var(--bg2)' }}>
      <div style={{ maxWidth: 900, margin: '0 auto', overflowX: 'auto' }}>
        <Reveal>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: 'var(--accent)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>Atendimento</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2rem, 4vw, 3.2rem)', color: 'var(--text)', margin: '0 0 16px', letterSpacing: '-0.5px' }}>
            Presencial<br/><em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>&amp; Online</em>
          </h2>
          <p style={{ fontSize: 16, color: 'var(--text2)', fontFamily: 'var(--font-body)', margin: '0 0 48px', lineHeight: 1.7, fontWeight: 300 }}>
            Escolha a modalidade que melhor se adapta à sua rotina. Ambas oferecem o mesmo padrão de excelência clínica.
          </p>
        </Reveal>
        <Reveal delay={0.1}>
          <div style={{ border: `1px solid ${dark ? '#ffffff12' : '#1a2c1e12'}`, overflow: 'hidden', borderRadius: dark ? 0 : 12 }}>
            {/* Header */}
            <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr', background: dark ? '#ffffff08' : '#1a2c1e06' }}>
              <div style={{ padding: '20px 24px', fontSize: 11, letterSpacing: 2, textTransform: 'uppercase', color: 'var(--text2)', fontFamily: 'var(--font-body)' }}>Recurso</div>
              {['Presencial', 'Online'].map(m => (
                <div key={m} style={{ padding: '20px 24px', textAlign: 'center', fontSize: 13, fontWeight: 600, color: m === 'Online' ? 'var(--accent)' : 'var(--text)', fontFamily: 'var(--font-body)', borderLeft: `1px solid ${dark ? '#ffffff12' : '#1a2c1e12'}` }}>{m}</div>
              ))}
            </div>
            {rows.map(([label, a, b], i) => (
              <div key={i} style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr', borderTop: `1px solid ${dark ? '#ffffff08' : '#1a2c1e08'}` }}>
                <div style={{ padding: '16px 24px', fontSize: 13.5, color: 'var(--text)', fontFamily: 'var(--font-body)' }}>{label}</div>
                {[a, b].map((v, j) => (
                  <div key={j} style={{ padding: '16px 24px', textAlign: 'center', fontSize: 13, color: v === true ? 'var(--accent)' : 'var(--text2)', fontFamily: 'var(--font-body)', borderLeft: `1px solid ${dark ? '#ffffff08' : '#1a2c1e08'}` }}>
                    {v === true ? '✓' : v}
                  </div>
                ))}
              </div>
            ))}
          </div>
        </Reveal>
        <Reveal delay={0.2}>
          <div style={{ marginTop: 28, padding: '20px 24px', background: dark ? '#c9a96e12' : '#3a6b4a12', border: `1px solid ${dark ? '#c9a96e30' : '#3a6b4a30'}`, borderRadius: dark ? 0 : 8, display: 'flex', alignItems: 'center', gap: 16 }}>
            <div style={{ width: 32, height: 32, borderRadius: '50%', border: '1.5px solid var(--accent)', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ color: 'var(--accent)' }}><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>
            </div>
            <div>
              <div style={{ fontSize: 13, fontWeight: 600, color: 'var(--text)', fontFamily: 'var(--font-body)', marginBottom: 3 }}>Instituto Atos · Perdizes</div>
              <div style={{ fontSize: 12.5, color: 'var(--text2)', fontFamily: 'var(--font-body)' }}>Av. Francisco Matarazzo, 1752, Água Branca, São Paulo, SP · Conjunto 505</div>
            </div>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

// ── Depoimentos ──────────────────────────────────
function Depoimentos({ theme }) {
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  const deps = [
    { nome: 'Renato Alves', texto: 'Atendimento incrível, fez minha dieta na hora, individualizada e com várias opções. Além de tudo, é a primeira vez que eu consigo falar com um Dr. direto pelo WhatsApp.' },
    { nome: 'Patricia Dias', texto: 'Incrível!!!! Isso que é dinheiro bem investido, profissional experiente e extremamente capacitado. Recomendo de olhos fechados.' },
    { nome: 'Seu depoimento', texto: 'À medida que mais pessoas experimentam os benefícios do atendimento nutricional personalizado, suas histórias de sucesso serão compartilhadas aqui.', placeholder: true },
  ];
  return (
    <section style={{ padding: '100px 5vw', background: 'var(--bg)' }}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <Reveal>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: 'var(--accent)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>Depoimentos</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2rem, 4vw, 3.2rem)', color: 'var(--text)', margin: '0 0 60px', letterSpacing: '-0.5px' }}>
            O que os pacientes<br/><em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>dizem</em>
          </h2>
        </Reveal>
        <div style={{ display: 'grid', gridTemplateColumns: mobile ? '1fr' : 'repeat(3, 1fr)', gap: 20 }}>
          {deps.map(({ nome, texto, placeholder }, i) => (
            <Reveal key={nome} delay={i * 0.1}>
              <div style={{
                padding: '36px 28px', height: '100%',
                border: `1px solid ${placeholder ? (dark ? '#ffffff08' : '#1a2c1e08') : (dark ? '#c9a96e25' : '#3a6b4a25')}`,
                background: placeholder ? 'transparent' : (dark ? '#ffffff05' : '#ffffff70'),
                borderRadius: dark ? 0 : 12,
                opacity: placeholder ? 0.5 : 1
              }}>
                <div style={{ fontSize: 36, color: 'var(--accent)', fontFamily: 'var(--font-display)', marginBottom: 20, lineHeight: 1 }}>"</div>
                <p style={{ fontSize: 14.5, color: 'var(--text2)', fontFamily: 'var(--font-body)', lineHeight: 1.7, margin: '0 0 24px', fontWeight: 300, fontStyle: 'italic' }}>{texto}</p>
                <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                  <div style={{ width: 36, height: 36, borderRadius: '50%', background: 'var(--accent)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 14, fontWeight: 700, color: dark ? '#0d1b2a' : '#fff', fontFamily: 'var(--font-body)' }}>
                    {nome[0]}
                  </div>
                  <span style={{ fontSize: 13, fontWeight: 600, color: 'var(--text)', fontFamily: 'var(--font-body)' }}>{nome}</span>
                </div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── Preços ────────────────────────────────────────
function Precos({ theme }) {
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  const planos = [
    {
      nome: 'Consulta Avulsa',
      preco: 'R$ 250',
      periodo: 'por consulta',
      dest: false,
      itens: ['Avaliação nutricional detalhada', 'Orientações personalizadas', 'Plano alimentar individualizado', 'Online ou presencial'],
    },
    {
      nome: 'Plano Trimestral',
      preco: 'R$ 620',
      periodo: 'ou 3x de R$ 217,15',
      dest: true,
      badge: 'Mais escolhido',
      itens: ['Acompanhamento por 3 meses', 'Consultas regulares', 'Ajustes personalizados', 'Suporte via WhatsApp', 'Site e materiais exclusivos', 'Online ou presencial'],
    },
  ];
  return (
    <section id="precos" style={{ padding: '100px 5vw', background: 'var(--bg2)' }}>
      <div style={{ maxWidth: 800, margin: '0 auto', textAlign: 'center' }}>
        <Reveal>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: 'var(--accent)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>Investimento</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2rem, 4vw, 3.2rem)', color: 'var(--text)', margin: '0 0 16px', letterSpacing: '-0.5px' }}>
            Planos e <em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>preços</em>
          </h2>
          <p style={{ fontSize: 16, color: 'var(--text2)', fontFamily: 'var(--font-body)', margin: '0 0 56px', lineHeight: 1.7, fontWeight: 300 }}>
            Escolha o plano que melhor se encaixa nos seus objetivos e rotina.
          </p>
        </Reveal>
        <div style={{ display: 'grid', gridTemplateColumns: mobile ? '1fr' : '1fr 1fr', gap: 20, textAlign: 'left' }}>
          {planos.map(({ nome, preco, periodo, dest, badge, itens }, i) => (
            <Reveal key={nome} delay={i * 0.15}>
              <div style={{
                padding: '40px 32px', position: 'relative',
                border: dest ? `2px solid var(--accent)` : `1px solid ${dark ? '#ffffff12' : '#1a2c1e12'}`,
                background: dest ? (dark ? '#c9a96e12' : '#3a6b4a0a') : (dark ? '#ffffff05' : '#ffffff70'),
                borderRadius: dark ? 0 : 16, height: '100%'
              }}>
                {badge && <div style={{ position: 'absolute', top: -14, left: '50%', transform: 'translateX(-50%)', background: 'var(--accent)', padding: '4px 16px', fontSize: 11, letterSpacing: 1.5, textTransform: 'uppercase', color: dark ? '#0d1b2a' : '#fff', fontFamily: 'var(--font-body)', fontWeight: 700, borderRadius: 50 }}>{badge}</div>}
                <div style={{ fontSize: 12, letterSpacing: 2, textTransform: 'uppercase', color: 'var(--text2)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>{nome}</div>
                <div style={{ fontFamily: 'var(--font-display)', fontSize: 46, fontWeight: 300, color: 'var(--text)', letterSpacing: '-2px', lineHeight: 1 }}>{preco}</div>
                <div style={{ fontSize: 12, color: 'var(--text2)', fontFamily: 'var(--font-body)', marginTop: 6, marginBottom: 32 }}>{periodo}</div>
                <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginBottom: 32 }}>
                  {itens.map(item => (
                    <div key={item} style={{ display: 'flex', alignItems: 'center', gap: 10, fontSize: 13.5, color: 'var(--text)', fontFamily: 'var(--font-body)' }}>
                      <span style={{ color: 'var(--accent)', fontSize: 16, lineHeight: 1 }}>✓</span> {item}
                    </div>
                  ))}
                </div>
                <a href={WA_LINK} target="_blank" style={{
                  display: 'block', textAlign: 'center', padding: '14px', fontSize: 12,
                  letterSpacing: 1.5, textTransform: 'uppercase', fontFamily: 'var(--font-body)', fontWeight: 600,
                  textDecoration: 'none',
                  background: dest ? 'var(--accent)' : 'transparent',
                  color: dest ? (dark ? '#0d1b2a' : '#fff') : 'var(--text)',
                  border: dest ? 'none' : `1px solid ${dark ? '#ffffff25' : '#1a2c1e25'}`,
                  borderRadius: dark ? 0 : 8, transition: 'opacity .2s'
                }}
                  onMouseEnter={e => e.currentTarget.style.opacity = '.8'}
                  onMouseLeave={e => e.currentTarget.style.opacity = '1'}
                >Quero este plano</a>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── FAQ ───────────────────────────────────────────
function FAQ({ theme }) {
  const dark = theme === 'dark';
  const [open, setOpen] = useState(null);
  const faqs = [
    { q: 'Como funciona a primeira consulta?', a: 'A consulta inicial tem duração de aproximadamente 1h30. Nela fazemos uma imersão clínica completa: histórico alimentar, objetivos, avaliação da composição corporal e definição do plano alimentar personalizado.' },
    { q: 'O atendimento online tem o mesmo resultado?', a: 'Sim! O atendimento online segue o mesmo padrão de excelência clínica. A diferença está apenas no método de avaliação corporal: online utilizamos medidas, fotos e peso.' },
    { q: 'Com que frequência terei consultas?', a: 'No plano trimestral, as consultas são agendadas de acordo com a sua evolução e necessidades. O suporte contínuo via WhatsApp garante acompanhamento entre as sessões.' },
    { q: 'Posso mudar o plano alimentar durante o acompanhamento?', a: 'Com certeza. O plano é ajustado continuamente conforme sua evolução, preferências, rotina e resultados. Flexibilidade é um dos pilares do nosso método.' },
    { q: 'Como funciona o suporte via WhatsApp?', a: 'Você tem acesso direto ao Dr. Denerval e sua equipe para dúvidas, ajustes de urgência e motivação no dia a dia, sem precisar esperar a próxima consulta.' },
  ];
  return (
    <section style={{ padding: '100px 5vw', background: 'var(--bg)' }}>
      <div style={{ maxWidth: 720, margin: '0 auto' }}>
        <Reveal>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: 'var(--accent)', fontFamily: 'var(--font-body)', marginBottom: 16 }}>FAQ</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2rem, 4vw, 3.2rem)', color: 'var(--text)', margin: '0 0 48px', letterSpacing: '-0.5px' }}>
            Perguntas<br/><em style={{ color: 'var(--accent)', fontStyle: 'italic' }}>frequentes</em>
          </h2>
        </Reveal>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
          {faqs.map(({ q, a }, i) => (
            <Reveal key={i} delay={i * 0.05}>
              <div style={{ borderTop: `1px solid ${dark ? '#ffffff10' : '#1a2c1e10'}`, overflow: 'hidden' }}>
                <button onClick={() => setOpen(open === i ? null : i)} style={{
                  width: '100%', background: 'none', border: 'none', cursor: 'pointer',
                  display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                  padding: '22px 0', textAlign: 'left', gap: 16
                }}>
                  <span style={{ fontSize: 15, fontFamily: 'var(--font-body)', fontWeight: 500, color: 'var(--text)' }}>{q}</span>
                  <span style={{ fontSize: 20, color: 'var(--accent)', transition: 'transform .3s', transform: open === i ? 'rotate(45deg)' : 'rotate(0)', flexShrink: 0 }}>+</span>
                </button>
                <div style={{
                  maxHeight: open === i ? 200 : 0, overflow: 'hidden',
                  transition: 'max-height .4s ease', paddingBottom: open === i ? 22 : 0
                }}>
                  <p style={{ fontSize: 14, lineHeight: 1.75, color: 'var(--text2)', fontFamily: 'var(--font-body)', margin: 0, fontWeight: 300 }}>{a}</p>
                </div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── CTA / Contato ─────────────────────────────────
function Contato({ theme }) {
  const dark = theme === 'dark';
  const gradients = {
    dark:      'linear-gradient(135deg, #c9a96e 0%, #a07c48 100%)',
    light:     'linear-gradient(135deg, #3a6b4a 0%, #2d5139 100%)',
    editorial: 'linear-gradient(135deg, #8b2635 0%, #6b1c29 100%)',
    terra:     'linear-gradient(135deg, #b85c38 0%, #93412a 100%)',
  };
  const textColor = dark ? '#0d1b2a' : '#fff';
  const subColor = dark ? '#0d1b2a99' : '#ffffff99';
  const btnBg = dark ? '#0d1b2a' : '#fff';
  const btnColor = { dark: '#c9a96e', light: '#3a6b4a', editorial: '#8b2635', terra: '#b85c38' }[theme];
  return (
    <section id="contato" style={{
      padding: '100px 5vw',
      background: gradients[theme],
      textAlign: 'center'
    }}>
      <Reveal>
        <div style={{ maxWidth: 640, margin: '0 auto' }}>
          <div style={{ fontSize: 11, letterSpacing: 3, textTransform: 'uppercase', color: subColor, fontFamily: 'var(--font-body)', marginBottom: 20 }}>Vamos começar?</div>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 300, fontSize: 'clamp(2.2rem, 5vw, 3.8rem)', color: textColor, margin: '0 0 20px', letterSpacing: '-1px', lineHeight: 1.1 }}>
            Sua jornada de<br/>saúde começa hoje.
          </h2>
          <p style={{ fontSize: 16, color: subColor, fontFamily: 'var(--font-body)', margin: '0 0 44px', lineHeight: 1.7, fontWeight: 300 }}>
            Agende sua consulta e dê o primeiro passo para uma nutrição que realmente funciona para você.
          </p>
          <a href={WA_LINK} target="_blank" style={{
            display: 'inline-flex', alignItems: 'center', gap: 12,
            padding: '18px 44px', fontSize: 14, letterSpacing: 1.5, textTransform: 'uppercase',
            background: btnBg, color: btnColor,
            textDecoration: 'none', fontFamily: 'var(--font-body)', fontWeight: 700,
            borderRadius: 50, transition: 'opacity .2s'
          }}
            onMouseEnter={e => e.currentTarget.style.opacity = '.85'}
            onMouseLeave={e => e.currentTarget.style.opacity = '1'}
          >
            <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><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>
            Agendar via WhatsApp
          </a>
          <div style={{ marginTop: 32, fontSize: 13, color: subColor, fontFamily: 'var(--font-body)' }}>
            Instituto Atos · Av. Francisco Matarazzo, 1752, Cj 505 · Água Branca, SP
          </div>
        </div>
      </Reveal>
    </section>
  );
}

// ── Footer ────────────────────────────────────────
function Footer({ theme }) {
  const dark = theme === 'dark';
  const mobile = useIsMobile();
  return (
    <footer style={{
      padding: '40px 5vw',
      background: dark ? '#060f1a' : '#1a2c1e',
      display: 'flex', alignItems: mobile ? 'flex-start' : 'center',
      justifyContent: 'space-between', flexDirection: mobile ? 'column' : 'row',
      flexWrap: 'wrap', gap: 16
    }}>
      <Logo theme="dark" size={90} />
      <div style={{ fontSize: 12, color: '#ffffff40', fontFamily: 'var(--font-body)', letterSpacing: .5 }}>
        © 2026 Dr. Dener Carolino · CRN3 93164 · Todos os direitos reservados
      </div>
    </footer>
  );
}

Object.assign(window, { Navbar, Hero, Sobre, Metodologia, Modalidades, Depoimentos, Precos, FAQ, Contato, Footer });
