/* Shared chrome: Header + Footer */ const { useAuth, AuthModal, logoutUser } = window; // Smooth scroll to an anchor on the landing page. // If we're NOT on the landing page, navigate to index.html#id first. function smoothNavTo(e, id) { const path = window.location.pathname; const onLanding = path.endsWith('/') || path.endsWith('/index.html') || path === ''; if (!onLanding) { // let the browser follow href="#id" by replacing with full path e.preventDefault(); window.location.href = `index.html#${id}`; return; } const target = document.getElementById(id); if (target) { e.preventDefault(); target.scrollIntoView({ behavior: 'smooth', block: 'start' }); // update hash without re-jumping history.replaceState(null, '', `#${id}`); } } const SiteHeader = ({ active = 'inicio' }) => { const user = useAuth(); const [authOpen, setAuthOpen] = React.useState(false); const [authMode, setAuthMode] = React.useState('login'); const [menuOpen, setMenuOpen] = React.useState(false); const openLogin = () => { setAuthMode('login'); setAuthOpen(true); }; const openRegister = () => { setAuthMode('register'); setAuthOpen(true); }; return ( <> Bristol Academy Aptis Exam Trainer smoothNavTo(e, 'inicio')}>Inicio smoothNavTo(e, 'examenes')}>Exámenes Cursos Aptis Privacidad smoothNavTo(e, 'contacto')}>Contacto {user && ( setMenuOpen(o => !o)} className="btn btn-sm" style={{ background: 'var(--accent-soft)', border: '1px solid var(--accent)', color: 'var(--accent-strong)', fontWeight: 600, display: 'flex', alignItems: 'center', gap: 8, }}> {(user.name || user.email).charAt(0).toUpperCase()} {user.name || user.email} ▾ {menuOpen && ( <> setMenuOpen(false)} style={{ position: 'fixed', inset: 0, zIndex: 50, }}> {user.name || 'Mi cuenta'} {user.email} Mi cuenta Mi examen 1 { logoutUser(); setMenuOpen(false); }} style={{ display: 'flex', alignItems: 'center', gap: 10, width: '100%', padding: '10px 16px', fontSize: 14, color: 'var(--danger)', background: 'transparent', border: 'none', borderTop: '1px solid var(--line-soft)', cursor: 'pointer', textAlign: 'left', }}> Cerrar sesión > )} )} setAuthOpen(false)} initialMode={authMode} /> > ); }; const WHATSAPP_NUMBER = '34604935221'; // E.164 for wa.me link const WHATSAPP_DISPLAY = '604 93 52 21'; const CONTACT_EMAIL = 'contacto@bristolprivatelessons.es'; const SiteFooter = () => { return ( ); }; // Floating WhatsApp button const WhatsAppFloat = () => ( e.currentTarget.style.transform = 'scale(1.08)'} onMouseLeave={(e) => e.currentTarget.style.transform = 'scale(1)'}> ); window.SiteHeader = SiteHeader; window.SiteFooter = SiteFooter; window.WhatsAppFloat = WhatsAppFloat; window.WHATSAPP_NUMBER = WHATSAPP_NUMBER; window.WHATSAPP_DISPLAY = WHATSAPP_DISPLAY; window.CONTACT_EMAIL = CONTACT_EMAIL;