// ── SHARED TOKENS ──────────────────────────────────────────
const C = {
  warmWhite:  'oklch(0.98 0.008 80)',
  sandLight:  'oklch(0.95 0.018 78)',
  sand:       'oklch(0.87 0.04 78)',
  sandMid:    'oklch(0.72 0.055 78)',
  sandDark:   'oklch(0.50 0.06 78)',
  tealLight:  'oklch(0.91 0.055 193)',
  teal:       'oklch(0.70 0.09 193)',
  tealDeep:   'oklch(0.44 0.09 193)',
  ink:        'oklch(0.22 0.02 198)',
  inkSoft:    'oklch(0.42 0.02 198)',
};

const WA_PHONE = '34651023514';
const WA_LINK = `https://wa.me/${WA_PHONE}?text=Hola%20Cristina%2C%20no%20s%C3%A9%20muy%20bien%20por%20d%C3%B3nde%20empezar%2C%20pero%20me%20gustar%C3%ADa%20hablar%20contigo.`;
function openWA(e, link = WA_LINK) {
  if (e) e.preventDefault();
  window.open(link, '_blank', 'noopener');
}
const EMAIL   = 'cristina@centrobarcala.com';
const PHONE   = '651 023 514';
const WEB     = 'www.centrobarcala.com';
const LEGAL_URL = 'aviso-legal.html';
const COLEGIADA = 'AO14448';
// Pega aquí la Access Key de Web3Forms (web3forms.com → escribe tu email → te la envían al momento).
// Mientras esté vacía, el formulario sigue funcionando abriendo el correo del visitante.
const WEB3FORMS_KEY = '23548fd2-db4b-4890-958a-115afdba2a50';
const DOCTORALIA = 'https://www.doctoralia.es/cristina-lopez-quiroga/psicologo/malaga';

// ── WHATSAPP ICON ──────────────────────────────────────────
function WaIcon({ size = 16 }) {
  return (
    <svg width={size} height={size} 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>
  );
}

// ── WHATSAPP FLOATING BUTTON ────────────────────────────────
function WaFloat() {
  return (
    <a href={WA_LINK} onClick={(e) => openWA(e)} target="_blank" rel="noopener" aria-label="Abrir WhatsApp"
      style={{ position: 'fixed', bottom: 26, right: 26, zIndex: 200, width: 58, height: 58, borderRadius: '50%', background: '#25D366', display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: '0 6px 20px rgba(0,0,0,0.22)', color: '#fff', textDecoration: 'none' }}>
      <WaIcon size={28} />
    </a>
  );
}

// ── CTA BUTTON ─────────────────────────────────────────────
function CtaBtn({ label = 'Reservar primera sesión', large = false, msg, inverted = false }) {
  const [hov, setHov] = React.useState(false);
  const href = msg ? `https://wa.me/${WA_PHONE}?text=${encodeURIComponent(msg)}` : WA_LINK;
  const bg = inverted ? (hov ? C.tealLight : C.warmWhite) : (hov ? C.teal : C.tealDeep);
  const fg = inverted ? C.tealDeep : C.warmWhite;
  return (
    <a href={href} target="_blank" rel="noopener"
      onMouseEnter={() => setHov(true)}
      onMouseLeave={() => setHov(false)}
      style={{
        display: 'inline-flex', alignItems: 'center', gap: 10,
        fontFamily: 'Lato, sans-serif',
        fontSize: large ? 14 : 13,
        letterSpacing: '0.1em',
        color: fg,
        background: bg,
        padding: large ? '18px 44px' : '14px 28px',
        textDecoration: 'none',
        transition: 'background 0.25s',
      }}>
      <WaIcon size={large ? 18 : 15} />
      {label}
    </a>
  );
}

// ── CREDENCIALES ────────────────────────────────────────
function Credenciales({ center = false, dark = false, marginTop = 28 }) {
  return (
    <div className="credenciales" style={{ display: 'flex', alignItems: 'center', gap: 18, marginTop, flexWrap: 'wrap', justifyContent: center ? 'center' : 'flex-start' }}>
      <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 11, letterSpacing: '0.16em', textTransform: 'uppercase', color: dark ? 'rgba(255,255,255,0.45)' : C.inkSoft, lineHeight: 1.6 }}>
        Psicóloga · Col. nº AO14448<br />Nutricionista · Col. nº AND956
      </span>
      <span style={{ width: 1, height: 14, background: dark ? 'rgba(255,255,255,0.2)' : C.sand }} />
      <a href={DOCTORALIA} target="_blank" rel="noopener" style={{ display: 'inline-flex', alignItems: 'center', gap: 8, textDecoration: 'none', borderBottom: `1px solid ${dark ? 'rgba(255,255,255,0.35)' : C.tealDeep}`, paddingBottom: 2 }}>
        <img src="assets/doctoralia-logo.png" style={{ height: 20, mixBlendMode: dark ? 'normal' : 'multiply' }} />
        <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: dark ? 'rgba(255,255,255,0.7)' : C.tealDeep, fontWeight: 700 }}>Perfil en Doctoralia →</span>
      </a>
    </div>
  );
}

// ── PHOTO ──────────────────────────────────────────────────
function Photo({ style = {}, position = 'center 15%', src = 'assets/cristina-calida.png', className }) {
  return (
    <div className={className} style={{
      backgroundImage: `url(${src})`,
      backgroundSize: 'cover',
      backgroundPosition: position,
      flexShrink: 0,
      ...style,
    }} />
  );
}

// ── NAV ────────────────────────────────────────────────────
function Nav({ scrollY }) {
  const solid = scrollY > 60;
  const links = ['Sobre mí', 'Psiconutrición', 'Talleres', 'Contacto', 'Tarifas'];
  return (
    <nav className="nav" style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 100,
      background: solid ? 'rgba(250,250,248,0.96)' : 'transparent',
      backdropFilter: solid ? 'blur(12px)' : 'none',
      borderBottom: solid ? `1px solid ${C.tealLight}` : '1px solid transparent',
      transition: 'all 0.4s ease',
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      padding: '0 56px', height: 72,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
        <img src="assets/logo_symbol.png" style={{ height: 40 }} />
        <div style={{
          fontFamily: "'Cormorant Garamond', serif",
          fontSize: 22, fontWeight: 400, letterSpacing: '0.14em',
          color: C.tealDeep, textTransform: 'uppercase',
        }}>Barcala</div>
      </div>
      <div className="nav-links" style={{ display: 'flex', alignItems: 'center', gap: 40 }}>
        {links.map(l => {
          const [hov, setHov] = React.useState(false);
          return (
            <a key={l} className="nav-link" href={`#${l.toLowerCase().replace(' ', '')}`}
              onMouseEnter={() => setHov(true)}
              onMouseLeave={() => setHov(false)}
              style={{
                fontFamily: 'Lato, sans-serif', fontSize: 13,
                color: hov ? C.teal : C.inkSoft,
                textDecoration: 'none', letterSpacing: '0.06em',
                transition: 'color 0.2s',
              }}>
              {l}
            </a>
          );
        })}
        <CtaBtn label="Escríbeme" />
      </div>
    </nav>
  );
}

// ── HERO A — EQUILIBRIO (split) ───────────────────────────
function HeroEquilibrio() {
  return (
    <section className="hero-eq" style={{ minHeight: '100vh', display: 'grid', gridTemplateColumns: '1fr 1fr', background: C.warmWhite, paddingTop: 72 }}>
      <div className="hero-inner" style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', padding: '80px 64px 80px 80px' }}>
        <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, letterSpacing: '0.24em', color: C.teal, textTransform: 'uppercase', marginBottom: 28 }}>Centro Barcala · Málaga</div>
        <h1 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 60, fontWeight: 300, color: C.ink, lineHeight: 1.1, letterSpacing: '-0.01em', marginBottom: 0 }}>
          Un espacio<br /><em>para volver a ti.</em>
        </h1>
        <div style={{ width: 48, height: 1, background: C.teal, margin: '28px 0' }} />
        <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: C.inkSoft, lineHeight: 1.8, marginBottom: 40, maxWidth: 420 }}>
          Soy Cristina López, psicóloga sanitaria y nutricionista. Te acompaño en tu proceso con presencia, respeto y cercanía — en Málaga y online.
        </p>
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
          <CtaBtn label="Reservar primera sesión" large />
          <a href="#tarifas" style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, color: C.inkSoft, marginTop: 14, letterSpacing: '0.04em', textDecoration: 'underline' }}>Primera consulta sin compromiso</a>
        </div>
        <Credenciales />
      </div>
      <Photo className="hero-eq-photo" style={{ minHeight: 'calc(100vh - 72px)' }} position="center 10%" />
    </section>
  );
}

// ── HERO B — PRESENCIA (full bleed) ──────────────────────
function HeroPresencia() {
  return (
    <section className="hero-presencia" style={{ minHeight: '100vh', position: 'relative', paddingTop: 72, overflow: 'hidden' }}>
      <Photo style={{ position: 'absolute', inset: 0 }} position="center 6%" />
      <div className="hero-scrim" style={{
        position: 'absolute', inset: 0,
        background: `linear-gradient(to right, rgba(250,250,248,0.985) 36%, rgba(250,250,248,0.74) 52%, rgba(250,250,248,0.18) 74%, rgba(250,250,248,0) 92%)`,
      }} />
      <div className="hero-inner" style={{ position: 'relative', display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: 'calc(100vh - 72px)', padding: '80px 80px', maxWidth: 600 }}>
        <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, letterSpacing: '0.24em', color: C.tealDeep, textTransform: 'uppercase', marginBottom: 28 }}>Centro Barcala · Málaga</div>
        <h1 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 66, fontWeight: 300, color: C.tealDeep, lineHeight: 1.08 }}>
          Si te sientes perdido<br /><em>regresa a ti.</em>
        </h1>
        <div style={{ width: 48, height: 1, background: C.teal, margin: '28px 0' }} />
        <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 17, fontWeight: 400, color: C.ink, lineHeight: 1.8, marginBottom: 40, maxWidth: 420 }}>
          Psicología sanitaria en Málaga. Sesiones presenciales y online adaptadas a ti.
        </p>
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
          <CtaBtn label="Reservar primera sesión" large />
        </div>
        <Credenciales />
      </div>
    </section>
  );
}

// ── HERO D — LUGAR (texto + foto del espacio) ────────────────────
function HeroLugar() {
  return (
    <section className="hero-eq" style={{ minHeight: '100vh', display: 'grid', gridTemplateColumns: '1fr 1.05fr', background: C.warmWhite, paddingTop: 72 }}>
      <div className="hero-inner" style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', padding: '80px 64px 80px 80px' }}>
        <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, letterSpacing: '0.24em', color: C.tealDeep, textTransform: 'uppercase', marginBottom: 28 }}>Centro Barcala · Málaga</div>
        <h1 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 62, fontWeight: 300, color: C.ink, lineHeight: 1.08, letterSpacing: '-0.01em' }}>
          Aquí SÍ puedes<br /><em style={{ color: C.tealDeep }}>ser tú.</em>
        </h1>
        <div style={{ width: 48, height: 1, background: C.teal, margin: '28px 0' }} />
        <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 17, fontWeight: 300, color: C.ink, lineHeight: 1.8, marginBottom: 40, maxWidth: 430 }}>
          Psicología sanitaria en Málaga. Sesiones presenciales y online adaptadas a ti.
        </p>
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
          <CtaBtn label="Reservar primera sesión" large />
        </div>
        <Credenciales />
      </div>
      <div className="hero-lugar-foto" style={{ position: 'relative', minHeight: 'calc(100vh - 72px)' }}>
        <image-slot id="hero-lugar" shape="rect" fit="cover" placeholder="Arrastra aquí una foto de la consulta o del camino"></image-slot>
      </div>
    </section>
  );
}

// ── HERO CITA FORM ─────────────────────────────────────────
function HeroCitaForm() {
  const [form, setForm] = React.useState({ nombre: '', apellidos: '', telefono: '', contacto: 'whatsapp' });
  const [sent, setSent] = React.useState(false);

  const inputStyle = {
    fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300,
    border: 'none', borderBottom: `1px solid ${C.tealLight}`,
    background: 'transparent', padding: '10px 0',
    color: C.ink, outline: 'none', width: '100%',
    transition: 'border-color 0.2s',
  };

  const handleSubmit = (e) => {
    e.preventDefault();
    if (!form.nombre || !form.telefono) return;
    if (form.contacto === 'whatsapp') {
      const msg = encodeURIComponent(`Hola Cristina, soy ${form.nombre} ${form.apellidos}. Me gustaría pedir cita. Mi teléfono es ${form.telefono}.`);
      openWA(null, `https://wa.me/${WA_PHONE}?text=${msg}`);
    } else {
      window.open(`tel:+${WA_PHONE}`, '_self');
    }
    setSent(true);
  };

  if (sent) return (
    <div style={{ textAlign: 'center', padding: '16px 0' }}>
      <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 22, color: C.tealDeep, marginBottom: 8 }}>¡Gracias, {form.nombre}!</div>
      <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, color: C.inkSoft }}>Te contactamos en menos de 24 horas.</div>
    </div>
  );

  return (
    <form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
        <input placeholder="Nombre *" value={form.nombre} required
          onChange={e => setForm(f => ({ ...f, nombre: e.target.value }))}
          onFocus={e => e.target.style.borderBottomColor = C.teal}
          onBlur={e => e.target.style.borderBottomColor = C.tealLight}
          style={inputStyle} />
        <input placeholder="Apellidos" value={form.apellidos}
          onChange={e => setForm(f => ({ ...f, apellidos: e.target.value }))}
          onFocus={e => e.target.style.borderBottomColor = C.teal}
          onBlur={e => e.target.style.borderBottomColor = C.tealLight}
          style={inputStyle} />
      </div>
      <input placeholder="Teléfono *" value={form.telefono} required type="tel"
        onChange={e => setForm(f => ({ ...f, telefono: e.target.value }))}
        onFocus={e => e.target.style.borderBottomColor = C.teal}
        onBlur={e => e.target.style.borderBottomColor = C.tealLight}
        style={inputStyle} />
      <div style={{ display: 'flex', gap: 2, marginTop: 4 }}>
        {[['whatsapp', 'Escribir WhatsApp'], ['llamar', 'Prefiero que me llamen']].map(([val, label]) => (
          <label key={val} style={{
            flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center',
            gap: 8, cursor: 'pointer', padding: '11px 8px',
            background: form.contacto === val ? C.tealDeep : C.sandLight,
            color: form.contacto === val ? C.warmWhite : C.inkSoft,
            fontFamily: 'Lato, sans-serif', fontSize: 12, letterSpacing: '0.04em',
            transition: 'all 0.2s',
          }}>
            <input type="radio" name="contacto" value={val} checked={form.contacto === val}
              onChange={() => setForm(f => ({ ...f, contacto: val }))}
              style={{ display: 'none' }} />
            {label}
          </label>
        ))}
      </div>
      <button type="submit"
        onMouseEnter={e => e.currentTarget.style.background = C.tealDeep}
        onMouseLeave={e => e.currentTarget.style.background = C.teal}
        style={{
          fontFamily: 'Lato, sans-serif', fontSize: 12, letterSpacing: '0.1em',
          color: C.warmWhite, background: C.teal, border: 'none',
          padding: '14px', cursor: 'pointer', marginTop: 4,
          transition: 'background 0.2s',
        }}>
        ENVIAR SOLICITUD
      </button>
    </form>
  );
}

// ── HERO C — CALIGRAFÍA (tipografía) ─────────────────────
function HeroCaligrafia() {
  return (
    <section className="hero-calig" style={{ minHeight: '100vh', background: C.warmWhite, display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', paddingTop: 72, textAlign: 'center', position: 'relative', overflow: 'hidden' }}>
      <div style={{ position: 'absolute', top: 0, left: 0, right: 0, height: 3, background: C.teal }} />
      <img src="assets/logo_symbol.png" alt="" aria-hidden="true" style={{ position: 'absolute', width: 900, maxWidth: '150%', left: '50%', top: '52%', transform: 'translate(-50%, -50%)', opacity: 0.05, pointerEvents: 'none' }} />
      <img className="hero-logo" src="assets/logo_symbol.png" alt="Centro Barcala" style={{ height: 200, marginBottom: 36, opacity: 0.93, position: 'relative' }} />
      <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, letterSpacing: '0.3em', color: C.sandMid, textTransform: 'uppercase', marginBottom: 32 }}>Centro Barcala · Málaga</div>
      <h1 className="hero-calig-h1" style={{
        fontFamily: "'Cormorant Garamond', serif",
        fontSize: 78, fontWeight: 300, color: C.ink,
        lineHeight: 1.05, letterSpacing: '-0.02em',
        maxWidth: 820, padding: '0 48px', position: 'relative',
      }}>
        Aquí SÍ puedes<br /><em style={{ color: C.tealDeep }}>ser tú.</em>
      </h1>
      <div style={{ width: 60, height: 1, background: C.teal, margin: '40px auto' }} />
      <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 17, fontWeight: 300, color: C.inkSoft, lineHeight: 1.8, marginBottom: 48, maxWidth: 520, padding: '0 48px' }}>
        Cristina López · Psicóloga sanitaria y nutricionista<br />Sesiones presenciales en Málaga y online
      </p>

      <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 0 }}>
        <CtaBtn label="Reservar primera sesión" large />
        <a href="#tarifas" style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, color: C.inkSoft, marginTop: 14, letterSpacing: '0.04em', textDecoration: 'underline' }}>Primera consulta sin compromiso</a>
        <Credenciales center />
      </div>
    </section>
  );
}

// ── SECTION SHELL ──────────────────────────────────────────
function Sec({ id, bg = C.warmWhite, children, pad = '100px 80px' }) {
  return <section className="sec" id={id} style={{ background: bg, padding: pad }}>{children}</section>;
}
function SLabel({ text }) {
  return <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 10, letterSpacing: '0.26em', color: C.teal, textTransform: 'uppercase', marginBottom: 20 }}>{text}</div>;
}
function STitle({ children, centered = false, color = C.ink }) {
  return (
    <h2 className="stitle" style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 44, fontWeight: 300, color, lineHeight: 1.15, marginBottom: 8, textAlign: centered ? 'center' : 'left' }}>
      {children}
    </h2>
  );
}

// ── SOBRE MÍ ───────────────────────────────────────────────
function SobreMi() {
  return (
    <Sec id="sobremí" bg={C.sandLight}>
      <div className="sobremi-grid" style={{ maxWidth: 1100, margin: '0 auto', display: 'grid', gridTemplateColumns: '440px 1fr', gap: 72, alignItems: 'center' }}>
        <div className="sobremi-photo" style={{
          width: 440, aspectRatio: '4 / 5', flexShrink: 0, position: 'relative',
        }}>
          <div aria-hidden="true" style={{ position: 'absolute', left: -22, top: 22, right: 22, bottom: -22, background: C.sand }} />
          <img src="assets/cristina-nueva-calida.png" alt="Cristina López, psicóloga sanitaria en Málaga" style={{ position: 'relative', width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 12%' }} />
        </div>
        <div>
          <SLabel text="Sobre mí" />
          <STitle>Hola, soy<br /><em>Cristina López.</em></STitle>
          <div style={{ width: 40, height: 1, background: C.teal, margin: '24px 0 28px' }} />
          <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: C.ink, lineHeight: 1.85, marginBottom: 20 }}>
            Soy psicóloga sanitaria humanista integrativa y nutricionista experta en TCA, con consulta en Málaga. Creo en una terapia cercana, real y adaptada a las necesidades de cada persona — sin protocolos rígidos ni prisas.
          </p>
          <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: C.inkSoft, lineHeight: 1.85, marginBottom: 36 }}>
            Mi forma de trabajar parte de la convicción de que cada persona lleva dentro los recursos que necesita. Mi papel es acompañarte a encontrarlos, con presencia, respeto y sin juicios.<br /><br />Hemos aprendido muchas formas de sobrevivir y nunca nos enseñaron a atravesar las adversidades.<br />Juntos encontraremos otra forma de vivir, más libre, más tú.
          </p>
          <blockquote style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 21, fontStyle: 'italic', color: C.tealDeep, borderLeft: `2px solid ${C.teal}`, paddingLeft: 22, lineHeight: 1.6, margin: 0 }}>
            "Cada proceso es único, como lo es cada persona."
          </blockquote>
        </div>
      </div>
    </Sec>
  );
}

// ── PSICONUTRICIÓN / TCA ───────────────────────────────────
const TCA_SENALES = [
  'La comida ocupa gran parte de tus pensamientos del día',
  'Comes a escondidas, con culpa o hasta sentirte mal',
  'Compensas lo que comes con ejercicio, ayunos o restricción',
  'Sientes ascos, rechazo o mucha rigidez con ciertos alimentos',
  'Tienes manías o rituales alrededor de la comida que te limitan',
  'Tu estado de ánimo depende de lo que has comido o de tu cuerpo',
  'Restringes, evitas o controlas sin que sea una dieta consciente',
  'Has probado muchas dietas y siempre acabas en el mismo sitio',
];

function Psiconutricion() {
  return (
    <Sec id="psiconutrición" bg={C.tealDeep}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <div className="grid-2" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 72, alignItems: 'start', marginBottom: 56 }}>
          <div>
            <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 15, letterSpacing: '0.24em', color: C.tealLight, textTransform: 'uppercase', marginBottom: 22 }}>Psiconutrición</div>
            <h2 className="stitle" style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 40, fontWeight: 300, color: C.warmWhite, lineHeight: 1.2, marginBottom: 0 }}>
              La comida se convirtió<br />en el problema.<br /><em>Nunca fue el origen.</em>
            </h2>
          </div>
          <div>
            <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: 'rgba(255,255,255,0.88)', lineHeight: 1.85, marginBottom: 18 }}>
              Soy psicóloga sanitaria y nutricionista, y trabajo cualquier comportamiento alterado con la comida desde los dos lados a la vez: el psicológico y el nutricional. No hace falta que te repartas entre dos consultas que no se hablan entre sí.
            </p>
            <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: 'rgba(255,255,255,0.84)', lineHeight: 1.85 }}>
              Trastornos de la conducta alimentaria, ascos y rechazos, restricciones, manías o rituales con la comida — no importa si tiene o no un diagnóstico. Aquí no hay dietas ni planes cerrados: hay entender qué hay detrás de lo que te pasa y devolverte la calma al comer.
            </p>
          </div>
        </div>
        <div style={{ borderTop: '1px solid rgba(255,255,255,0.18)', paddingTop: 40 }}>
          <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 10, letterSpacing: '0.22em', color: C.tealLight, textTransform: 'uppercase', marginBottom: 26 }}>Quizá te suene</div>
          <div className="grid-3" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '18px 44px' }}>
            {TCA_SENALES.map(s => (
              <div key={s} style={{ display: 'flex', gap: 14, alignItems: 'baseline' }}>
                <div style={{ width: 16, height: 1, background: C.teal, flexShrink: 0, transform: 'translateY(-4px)' }} />
                <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 15, fontWeight: 300, color: 'rgba(255,255,255,0.82)', lineHeight: 1.7 }}>{s}</span>
              </div>
            ))}
          </div>
          <div className="row-split" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 36, flexWrap: 'wrap', marginTop: 48 }}>
            <p style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 22, fontStyle: 'italic', color: C.tealLight, lineHeight: 1.5, maxWidth: 560 }}>
              Si has reconocido varias, merece la pena que lo hablemos.
            </p>
            <CtaBtn label="Hablar de psiconutrición" msg="Hola Cristina, me gustaría informarme sobre las sesiones de psiconutrición." large inverted />
          </div>
        </div>
      </div>
    </Sec>
  );
}

// ── PARA QUIÉN ─────────────────────────────────────────────
const AUDIENCIAS = [
  { label: 'Trastornos alimentarios', desc: 'Anorexia, bulimia, atracón, ortorexia u otras formas de relación dañada con la comida y el cuerpo.' },
  { label: 'Ascos y rechazos',   desc: 'Aversión a ciertas texturas, sabores o grupos de alimentos que limitan tu día a día.' },
  { label: 'Restricción y control', desc: 'Reglas rígidas, miedo a ciertos alimentos o necesidad de controlar cada comida.' },
  { label: 'Atracones y culpa',  desc: 'Episodios de comer sin control seguidos de culpa, vergüenza o compensación.' },
  { label: 'Manías y rituales',  desc: 'Costumbres o rituales alrededor de la comida que se han vuelto rígidos o limitantes.' },
  { label: 'Imagen corporal',    desc: 'Malestar con el propio cuerpo que condiciona cómo, cuándo o cuánto comes.' },
];

function ParaQuien() {
  return (
    <Sec id="paraquién" bg={C.sand}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <div style={{ marginBottom: 64 }}>
          <SLabel text="Para quién" />
          <STitle>¿Esto es<br /><em>para ti?</em></STitle>
        </div>
        <div className="grid-3" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 40 }}>
          {AUDIENCIAS.map(a => (
            <div key={a.label} style={{ borderTop: `1px solid ${C.sandMid}`, paddingTop: 24 }}>
              <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 26, fontWeight: 400, color: C.tealDeep, marginBottom: 12 }}>{a.label}</h3>
              <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: C.ink, lineHeight: 1.8 }}>{a.desc}</p>
            </div>
          ))}
        </div>
      </div>
    </Sec>
  );
}

// ── CÓMO FUNCIONA ──────────────────────────────────────────
const PASOS = [
  { n: '01', title: 'Escríbeme',       desc: 'Mándame un mensaje por WhatsApp contándome brevemente lo que necesitas.' },
  { n: '02', title: 'Primera sesión',  desc: 'Nos conocemos en una sesión sin compromiso. Escucho tu situación y resolvemos tus dudas.' },
  { n: '03', title: 'Tu proceso',      desc: 'Definimos juntos el ritmo y la modalidad que mejor se adaptan a ti — presencial u online.' },
];

function ComoFunciona() {
  return (
    <Sec id="cómofunciona" bg={C.warmWhite}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 72 }}>
          <SLabel text="Cómo funciona" />
          <STitle centered>Así es como<br /><em>empezamos.</em></STitle>
        </div>
        <div className="grid-3" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 56, position: 'relative' }}>
          {PASOS.map((p, i) => (
            <div key={p.n} style={{ position: 'relative' }}>
              <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 80, fontWeight: 300, color: C.tealLight, lineHeight: 1, marginBottom: 16 }}>{p.n}</div>
              <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 30, fontWeight: 400, color: C.ink, marginBottom: 16 }}>{p.title}</h3>
              <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 15, fontWeight: 300, color: C.inkSoft, lineHeight: 1.8 }}>{p.desc}</p>
              {i < 2 && <div style={{ position: 'absolute', top: 40, right: -28, width: 56, height: 1, background: C.tealLight }} />}
            </div>
          ))}
        </div>
      </div>
    </Sec>
  );
}

// ── TALLERES GRUPALES ──────────────────────────────────────
const TALLERES = [
  { title: 'Gestión de la ansiedad', desc: 'Herramientas prácticas para reconocer, sostener y calmar la ansiedad en el día a día.', formato: '4 sesiones · grupos de 6 a 10' },
  { title: 'Relación con la comida', desc: 'Un espacio para revisar la relación con el cuerpo y la alimentación desde el respeto y sin culpa.', formato: '6 sesiones · grupos de 6 a 8' },
  { title: 'Autoestima y límites', desc: 'Aprender a poner límites, sostener el no y construir una mirada más amable hacia uno mismo.', formato: '4 sesiones · grupos de 6 a 10' },
];

function TalleresGrupales() {
  const [hov, setHov] = React.useState(null);
  return (
    <Sec id="talleres" bg={C.sandLight}>
      <div style={{ maxWidth: 1100, margin: '0 auto' }}>
        <div className="grid-2" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 72, alignItems: 'end', marginBottom: 64 }}>
          <div>
            <SLabel text="Talleres grupales en Málaga" />
            <STitle>Sanar también<br /><em>se hace en grupo.</em></STitle>
          </div>
          <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: C.inkSoft, lineHeight: 1.85 }}>
            Encuentros reducidos donde compartir, aprender y practicar con otras personas que atraviesan algo parecido. El grupo sostiene lo que a veces en solitario cuesta sostener.
          </p>
        </div>
        <div className="talleres-foto" role="img" aria-label="Taller grupal presencial en Málaga con Cristina López" style={{ position: 'relative', width: '100%', height: 400, marginBottom: 56, overflow: 'hidden' }}>
          <image-slot id="talleres-foto" shape="rect" fit="cover" placeholder="Arrastra aquí una foto real de un taller grupal"></image-slot>
        </div>
        <div className="grid-3" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 2 }}>
          {TALLERES.map((t, i) => (
            <div key={t.title}
              onMouseEnter={() => setHov(i)}
              onMouseLeave={() => setHov(null)}
              style={{ padding: '40px 32px', background: hov === i ? C.tealLight : C.warmWhite, borderTop: `2px solid ${hov === i ? C.teal : C.tealLight}`, transition: 'all 0.2s', display: 'flex', flexDirection: 'column', gap: 14 }}>
              <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 25, fontWeight: 400, color: C.ink, lineHeight: 1.25 }}>{t.title}</h3>
              <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: C.inkSoft, lineHeight: 1.8 }}>{t.desc}</p>
              <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 11, letterSpacing: '0.14em', textTransform: 'uppercase', color: C.tealDeep, marginTop: 'auto', paddingTop: 10 }}>{t.formato}</div>
            </div>
          ))}
        </div>
        <div className="row-split" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 40, flexWrap: 'wrap', marginTop: 48, borderTop: `1px solid ${C.sandMid}`, paddingTop: 36 }}>
          <p style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 21, fontStyle: 'italic', color: C.tealDeep, lineHeight: 1.5, maxWidth: 560 }}>
            Los grupos se abren a lo largo del año, presenciales en Málaga provincia. Plazas limitadas.
          </p>
          <CtaBtn label="Consultar próximos talleres" msg="Hola Cristina, me gustaría saber cuándo empieza el próximo taller grupal." />
        </div>
      </div>
    </Sec>
  );
}

// ── PRESENCIAL / ONLINE ────────────────────────────────────
function PresencialOnline() {
  return (
    <Sec id="sesiones" bg={C.tealDeep} pad="100px 80px">
      <div className="grid-2" style={{ maxWidth: 1100, margin: '0 auto', display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 2 }}>
        {[
          { mode: 'Presencial', sub: 'Málaga capital y alrededores', items: ['Consulta en Málaga capital', 'Ambiente cuidado y confidencial', 'Horarios flexibles', 'Sesiones individuales, de pareja y familia'] },
          { mode: 'Online',     sub: 'Desde cualquier lugar',        items: ['Videollamada segura y privada', 'Misma calidad que en consulta', 'Adaptado a tu agenda', 'Para cualquier lugar del mundo'] },
        ].map(m => (
          <div key={m.mode} style={{ padding: '60px 52px', background: 'rgba(255,255,255,0.05)', border: '1px solid rgba(255,255,255,0.1)' }}>
            <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 10, letterSpacing: '0.22em', color: C.tealLight, textTransform: 'uppercase', marginBottom: 16 }}>{m.sub}</div>
            <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 44, fontWeight: 300, color: C.warmWhite, marginBottom: 40 }}>{m.mode}</h3>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
              {m.items.map(item => (
                <div key={item} style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
                  <div style={{ width: 22, height: 1, background: C.teal, flexShrink: 0 }} />
                  <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 15, fontWeight: 300, color: 'rgba(255,255,255,0.8)' }}>{item}</span>
                </div>
              ))}
            </div>
          </div>
        ))}
      </div>
    </Sec>
  );
}

// ── TARIFAS ────────────────────────────────────────────────
const TARIFAS = [
  { name: 'Sesión individual', price: '70', note: '60 minutos · presencial u online' },
  { name: 'Nutrición',         price: '50', note: 'Abordaje nutricional' },
  { name: 'Psiconutrición',    price: '90', note: 'Abordaje psicológico y nutricional' },
];

const BONOS = [
  { name: 'Bono 3 sesiones individuales', price: '190', note: '3 sesiones de 60 min · ahorras 20€' },
  { name: 'Bono 3 sesiones de psiconutrición', price: '250', note: '3 sesiones de 60 min · ahorras 20€' },
  { name: 'Bono 5 sesiones de psiconutrición', price: '400', note: '5 sesiones de 60 min · ahorras 50€' },
];

function Tarifas() {
  return (
    <Sec id="tarifas" bg={C.sandLight}>
      <div style={{ maxWidth: 900, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 56 }}>
          <SLabel text="Tarifas" />
          <STitle centered>Claro desde<br /><em>el principio.</em></STitle>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 24, flexWrap: 'wrap', justifyContent: 'space-between', background: C.tealDeep, padding: '30px 32px', marginBottom: 8 }}>
            <div style={{ flex: 1, minWidth: 220 }}>
              <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 26, fontWeight: 400, color: C.warmWhite, marginBottom: 6 }}>Consulta informativa</h3>
              <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: 'rgba(255,255,255,0.82)', lineHeight: 1.7 }}>
                Hablaremos para que decidas si mi forma de trabajar es la que necesitas. Sin compromiso · 15 min · por teléfono
              </p>
            </div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 20, flexShrink: 0 }}>
              <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 38, fontWeight: 300, color: C.tealLight }}>Gratis</div>
              <CtaBtn label="Quiero mi consulta" msg="Hola Cristina, me gustaría reservar la llamada de bienvenida gratuita." inverted />
            </div>
          </div>
          {TARIFAS.map(t => (
            <div key={t.name} style={{ display: 'flex', alignItems: 'baseline', gap: 24, borderTop: `1px solid ${C.tealLight}`, padding: '26px 0' }}>
              <div style={{ flex: 1 }}>
                <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 26, fontWeight: 400, color: C.ink, marginBottom: 6 }}>{t.name}</h3>
                <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: C.inkSoft }}>{t.note}</p>
              </div>
              <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 38, fontWeight: 300, color: C.tealDeep, flexShrink: 0 }}>{t.price}€</div>
            </div>
          ))}
          <div style={{ marginTop: 40, marginBottom: 8 }}>
            <h4 style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, fontWeight: 700, color: C.sandDark, letterSpacing: '0.12em', textTransform: 'uppercase' }}>Bonos</h4>
          </div>
          {BONOS.map(b => (
            <div key={b.name} style={{ display: 'flex', alignItems: 'baseline', gap: 24, borderTop: `1px solid ${C.tealLight}`, padding: '26px 0' }}>
              <div style={{ flex: 1 }}>
                <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 26, fontWeight: 400, color: C.ink, marginBottom: 6 }}>{b.name}</h3>
                <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: C.inkSoft }}>{b.note}</p>
              </div>
              <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 38, fontWeight: 300, color: C.tealDeep, flexShrink: 0 }}>{b.price}€</div>
            </div>
          ))}
          <div className="row-split" style={{ borderTop: `1px solid ${C.tealLight}`, paddingTop: 28, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 32, flexWrap: 'wrap' }}>
            <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: C.inkSoft, lineHeight: 1.8, maxWidth: 520 }}>
              Para tarifas de talleres grupales y terapia familiar, escríbeme y lo vemos.
            </p>
            <CtaBtn label="Reservar primera sesión" />
          </div>
        </div>
      </div>
    </Sec>
  );
}

// ── FRASE ──────────────────────────────────────────────────
function Frase() {
  return (
    <section className="sec" style={{ background: C.sandLight, padding: '120px 80px', textAlign: 'center' }}>
      <div style={{ maxWidth: 860, margin: '0 auto' }}>
        <blockquote className="frase" style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 40, fontWeight: 300, fontStyle: 'italic', color: C.tealDeep, margin: 0, lineHeight: 1.42, textWrap: 'pretty' }}>
          A veces nos perdemos y, sin darnos cuenta, olvidamos el camino de vuelta a casa.
        </blockquote>
        <p className="frase-sub" style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 27, fontWeight: 300, color: C.ink, lineHeight: 1.6, marginTop: 28, textWrap: 'pretty' }}>
          Te acompaño a atravesar los obstáculos, a encontrar la calma y a volver a sentirte tú.
        </p>
        <div style={{ width: 40, height: 1, background: C.sandMid, margin: '44px auto 22px' }} />
        <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 26, fontStyle: 'italic', color: C.tealDeep, lineHeight: 1.2 }}>Cristina López</div>
        <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 11, letterSpacing: '0.18em', textTransform: 'uppercase', color: C.inkSoft, marginTop: 10 }}>Psicóloga sanitaria · Col. nº {COLEGIADA} · Nutricionista clínica · Col. nº AND956</div>
      </div>
    </section>
  );
}

// ── FAQ ────────────────────────────────────────────────────
const FAQS = [
  { q: '¿Cuánto dura cada sesión?',                       a: 'Las sesiones individuales duran 60 minutos. Las sesiones de pareja o familia pueden extenderse hasta 80 minutos.' },
  { q: '¿Cuánto tiempo dura el proceso terapéutico?',     a: 'Depende de cada persona y de lo que quieras trabajar. Hay procesos breves de pocas semanas y otros que se extienden durante meses. Lo decidimos juntos a tu ritmo.' },
  { q: '¿Cómo son las sesiones online?',                  a: 'Se realizan por videollamada en una plataforma segura y privada. La calidad del trabajo es la misma que en consulta presencial.' },
  { q: '¿Necesito haber ido antes a terapia?',            a: 'No. Es frecuente que sea la primera vez. La primera sesión sirve precisamente para conocernos y resolver todas tus dudas sin compromiso.' },
  { q: '¿Trabajas con menores?',                          a: 'Sí, trabajo con niños y adolescentes. En los primeros contactos con familias incluimos una reunión inicial con los padres o tutores.' },
];

function FAQ() {
  const [open, setOpen] = React.useState(null);
  return (
    <Sec id="faq" bg={C.warmWhite}>
      <div style={{ maxWidth: 760, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 56 }}>
          <SLabel text="Preguntas frecuentes" />
          <STitle centered>Lo que más<br /><em>me preguntan.</em></STitle>
        </div>
        {FAQS.map((f, i) => (
          <div key={i} style={{ borderTop: `1px solid ${C.tealLight}`, cursor: 'pointer' }} onClick={() => setOpen(open === i ? null : i)}>
            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '24px 0' }}>
              <h3 style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 22, fontWeight: 400, color: C.ink }}>{f.q}</h3>
              <span style={{ color: C.teal, fontSize: 24, lineHeight: 1, transition: 'transform 0.3s', display: 'inline-block', transform: open === i ? 'rotate(45deg)' : 'none', flexShrink: 0, marginLeft: 16 }}>+</span>
            </div>
            {open === i && (
              <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 15, fontWeight: 300, color: C.inkSoft, lineHeight: 1.85, paddingBottom: 28 }}>{f.a}</p>
            )}
          </div>
        ))}
        <div style={{ borderTop: `1px solid ${C.tealLight}` }} />
      </div>
    </Sec>
  );
}

// ── OPINIONES (Doctoralia) ─────────────────────────────────
function Opiniones() {
  const [hov, setHov] = React.useState(false);
  return (
    <Sec id="opiniones" bg={C.sand} pad="72px 80px">
      <div className="row-split" style={{ maxWidth: 1100, margin: '0 auto', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 48, flexWrap: 'wrap' }}>
        <div style={{ maxWidth: 620 }}>
          <SLabel text="Opiniones" />
          <p style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 27, fontWeight: 300, color: C.ink, lineHeight: 1.45, marginBottom: 14 }}>
            Las valoraciones de quienes ya han pasado por consulta están publicadas y verificadas en Doctoralia.
          </p>
          <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, fontWeight: 300, color: C.inkSoft, lineHeight: 1.75 }}>
            No publico testimonios de pacientes en esta web: el código deontológico del psicólogo no lo permite. Prefiero que las leas en una plataforma independiente.
          </p>
        </div>
        <a href={`${DOCTORALIA}#opinions`} target="_blank" rel="noopener"
          onMouseEnter={() => setHov(true)} onMouseLeave={() => setHov(false)}
          style={{
            display: 'inline-flex', alignItems: 'center', gap: 14,
            fontFamily: 'Lato, sans-serif', fontSize: 14, letterSpacing: '0.08em',
            color: hov ? C.warmWhite : C.tealDeep, background: hov ? C.tealDeep : C.warmWhite,
            border: `1px solid ${C.tealDeep}`, padding: '18px 32px',
            textDecoration: 'none', whiteSpace: 'nowrap', transition: 'all 0.25s',
          }}>
          <img src="assets/doctoralia-logo.png" alt="" style={{ height: 22, mixBlendMode: 'multiply' }} />
          Ver opiniones en Doctoralia
        </a>
      </div>
    </Sec>
  );
}

// ── CONTACTO ───────────────────────────────────────────────
function ContactoForm() {
  const [form, setForm] = React.useState({ nombre: '', email: '', mensaje: '' });
  const [sent, setSent] = React.useState(false);

  const inputStyle = {
    fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300,
    border: 'none', borderBottom: `1px solid ${C.teal}`,
    background: 'transparent', padding: '10px 0',
    color: C.ink, outline: 'none', width: '100%',
    transition: 'border-color 0.2s',
  };

  const [sending, setSending] = React.useState(false);
  const [consent, setConsent] = React.useState(false);
  const [error, setError] = React.useState(false);

  const mailtoFallback = () => {
    const subject = encodeURIComponent(`Nueva consulta desde la web — ${form.nombre}`);
    const body = encodeURIComponent(`Nombre: ${form.nombre}\nEmail: ${form.email}\n\n${form.mensaje}`);
    window.location.href = `mailto:${EMAIL}?subject=${subject}&body=${body}`;
  };

  const handleSubmit = async (e) => {
    e.preventDefault();
    if (!form.nombre || !form.email) return;
    if (!consent) return;
    if (!WEB3FORMS_KEY) { mailtoFallback(); setSent(true); return; }
    setSending(true); setError(false);
    try {
      const res = await fetch('https://api.web3forms.com/submit', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
        body: JSON.stringify({
          access_key: WEB3FORMS_KEY,
          subject: `Nueva consulta desde la web — ${form.nombre}`,
          from_name: 'Centro Barcala · Web',
          name: form.nombre,
          email: form.email,
          message: form.mensaje,
        }),
      });
      const data = await res.json();
      if (!data.success) throw new Error('fail');
      setSent(true);
    } catch {
      setError(true);
    } finally {
      setSending(false);
    }
  };

  if (sent) return (
    <div style={{ textAlign: 'center', padding: '32px 0' }}>
      <div style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 26, color: C.tealDeep, marginBottom: 10 }}>¡Gracias, {form.nombre}!</div>
      <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 14, fontWeight: 300, color: C.inkSoft }}>{WEB3FORMS_KEY ? 'He recibido tu mensaje. Te respondo en menos de 24 horas.' : 'Se ha abierto tu correo con el mensaje listo. Envíalo y te respondo en menos de 24 horas.'}</div>
    </div>
  );

  return (
    <form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: 22 }}>
      <input placeholder="Tu nombre" value={form.nombre} required
        onChange={e => setForm(f => ({ ...f, nombre: e.target.value }))}
        onFocus={e => e.target.style.borderBottomColor = C.tealDeep}
        onBlur={e => e.target.style.borderBottomColor = C.teal}
        style={inputStyle} />
      <input placeholder="Tu email" value={form.email} required type="email"
        onChange={e => setForm(f => ({ ...f, email: e.target.value }))}
        onFocus={e => e.target.style.borderBottomColor = C.tealDeep}
        onBlur={e => e.target.style.borderBottomColor = C.teal}
        style={inputStyle} />
      <textarea placeholder="Cuéntame lo que necesites..." value={form.mensaje} rows={3}
        onChange={e => setForm(f => ({ ...f, mensaje: e.target.value }))}
        onFocus={e => e.target.style.borderBottomColor = C.tealDeep}
        onBlur={e => e.target.style.borderBottomColor = C.teal}
        style={{ ...inputStyle, resize: 'none' }} />
      <label style={{ display: 'flex', alignItems: 'flex-start', gap: 12, cursor: 'pointer' }}>
        <input type="checkbox" checked={consent} required onChange={e => setConsent(e.target.checked)}
          style={{ accentColor: C.tealDeep, width: 15, height: 15, marginTop: 3, flexShrink: 0 }} />
        <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, fontWeight: 300, color: C.inkSoft, lineHeight: 1.7 }}>
          He leído y acepto la <a href={LEGAL_URL} style={{ color: C.tealDeep }}>política de privacidad</a>. Tus datos se usan solo para responderte, nunca se ceden a terceros.
        </span>
      </label>
      <ContactoSubmitBtn sending={sending} />
      {error && (
        <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, fontWeight: 300, color: C.tealDeep, lineHeight: 1.7 }}>
          No he podido enviarlo ahora mismo. <a href="#" onClick={(ev) => { ev.preventDefault(); mailtoFallback(); }} style={{ color: C.tealDeep }}>Envíamelo por correo</a> o escríbeme por WhatsApp.
        </p>
      )}
    </form>
  );
}

function ContactoSubmitBtn({ sending = false }) {
  const [hov, setHov] = React.useState(false);
  return (
    <button type="submit" disabled={sending}
      onMouseEnter={() => setHov(true)}
      onMouseLeave={() => setHov(false)}
      style={{
        fontFamily: 'Lato, sans-serif', fontSize: 13, letterSpacing: '0.1em',
        color: C.warmWhite, background: hov && !sending ? C.teal : C.tealDeep,
        border: 'none', padding: '16px', cursor: sending ? 'default' : 'pointer',
        opacity: sending ? 0.6 : 1,
        transition: 'background 0.25s', textAlign: 'center',
      }}>
      {sending ? 'Enviando…' : 'Enviar mensaje'}
    </button>
  );
}

function Contacto() {
  const [waHov, setWaHov] = React.useState(false);
  return (
    <Sec id="contacto" bg={C.sandLight} pad="120px 80px">
      <div style={{ maxWidth: 720, margin: '0 auto', textAlign: 'center' }}>
        <SLabel text="Contacto" />
        <STitle centered><em>Da el primer paso.</em></STitle>

        <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 16, fontWeight: 300, color: C.inkSoft, lineHeight: 1.85, margin: '24px 0 0' }}>
          No tienes que saber explicarlo perfecto.<br />Escríbeme como te salga.
        </p>

        {/* WhatsApp principal */}
        <div style={{ margin: '52px 0 0' }}>
          <a href={WA_LINK} target="_blank" rel="noopener"
            onMouseEnter={() => setWaHov(true)}
            onMouseLeave={() => setWaHov(false)}
            style={{
              display: 'inline-flex', alignItems: 'center', gap: 14,
              fontFamily: 'Lato, sans-serif', fontSize: 16, letterSpacing: '0.08em',
              color: C.warmWhite,
              background: waHov ? C.teal : C.tealDeep,
              padding: '22px 44px',
              textDecoration: 'none',
              whiteSpace: 'nowrap',
              transition: 'background 0.25s',
            }}>
            <WaIcon size={20} />
            Escribirme por WhatsApp
          </a>
          <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, color: C.inkSoft, marginTop: 14, letterSpacing: '0.04em' }}>
            La forma más rápida y directa
          </p>
        </div>

        {/* Separador */}
        <div style={{ display: 'flex', alignItems: 'center', gap: 20, margin: '52px 0' }}>
          <div style={{ flex: 1, height: 1, background: C.sand }} />
          <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 11, color: C.sandMid, letterSpacing: '0.12em', whiteSpace: 'nowrap' }}>
            — o si lo prefieres —
          </span>
          <div style={{ flex: 1, height: 1, background: C.sand }} />
        </div>

        {/* Formulario */}
        <div style={{ textAlign: 'left' }}>
          <p style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 24, fontWeight: 300, color: C.inkSoft, marginBottom: 32, textAlign: 'center', fontStyle: 'italic' }}>
            Si lo prefieres, puedo escribirte yo
          </p>
          <ContactoForm />
        </div>

        {/* Info pequeña */}
        <div className="row-wrap" style={{ marginTop: 56, display: 'flex', justifyContent: 'center', gap: 40 }}>
          <a href={`tel:+${WA_PHONE}`} style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, color: C.inkSoft, textDecoration: 'none' }}>{PHONE}</a>
          <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, color: C.sand }}>·</span>
          <a href={`mailto:${EMAIL}`} style={{ fontFamily: 'Lato, sans-serif', fontSize: 13, color: C.inkSoft, textDecoration: 'none' }}>{EMAIL}</a>
        </div>

        <p style={{ fontFamily: 'Lato, sans-serif', fontSize: 11, color: C.inkSoft, marginTop: 36, lineHeight: 1.7, maxWidth: 520, margin: '36px auto 0', textAlign: 'center' }}>
          Tus datos son tratados con absoluta confidencialidad conforme al RGPD y la LOPDGDD.
        </p>
      </div>
    </Sec>
  );
}

// ── FOOTER ─────────────────────────────────────────────────
function Footer() {
  return (
    <footer className="footer" style={{ background: C.ink, padding: '52px 80px', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
        <img src="assets/logo_symbol.png" style={{ height: 34, filter: 'brightness(0) invert(1)', opacity: 0.6 }} />
        <span style={{ fontFamily: "'Cormorant Garamond', serif", fontSize: 18, letterSpacing: '0.14em', color: 'rgba(255,255,255,0.55)', textTransform: 'uppercase' }}>Barcala</span>
      </div>
      <div style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, color: 'rgba(255,255,255,0.32)', letterSpacing: '0.06em', textAlign: 'center' }}>
        Cristina López · Psicóloga sanitaria y nutricionista · Col. nº {COLEGIADA} · Málaga
      </div>
      <a href={LEGAL_URL} style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, color: 'rgba(255,255,255,0.32)', letterSpacing: '0.06em', textDecoration: 'none' }}>Aviso legal y privacidad</a>
      <span style={{ fontFamily: 'Lato, sans-serif', fontSize: 12, color: 'rgba(255,255,255,0.32)' }}>{WEB}</span>
    </footer>
  );
}

Object.assign(window, {
  C, WA_LINK, WA_PHONE, openWA, Nav, WaIcon, WaFloat, CtaBtn, Photo, Credenciales,
  HeroEquilibrio, HeroPresencia, HeroCaligrafia, HeroLugar, TalleresGrupales, Tarifas,
  Sec, SLabel, STitle,
  SobreMi, Psiconutricion, ParaQuien, ComoFunciona,
  PresencialOnline, Frase, FAQ, Opiniones, Contacto, Footer,
});
