// Chrome.jsx — Nav + Footer
function Nav({ onNav, active }) {
  const [open, setOpen] = React.useState(false);
  const items = [
    { id: 'club',     label: 'El Club',  num: '01' },
    { id: 'plantel',  label: 'Plantel',  num: '02' },
    { id: 'partidos', label: 'Partidos', num: '03' },
    { id: 'galeria',  label: 'Galería',  num: '04' },
  ];
  function handleNav(id) { setOpen(false); onNav(id); }

  React.useEffect(() => {
    document.body.style.overflow = open ? 'hidden' : '';
    return () => { document.body.style.overflow = ''; };
  }, [open]);

  return (
    <>
      <nav className="nav">
        <a className="nav-brand" href="#top" onClick={() => handleNav('top')}>
          <img src="img/logo.png" alt="Jebaño FC"/>
          <div className="nav-brand-mark">JEBAÑO FC</div>
        </a>
        <div className="nav-links">
          {items.map(it => (
            <a key={it.id} href={`#${it.id}`}
               className={'nav-link' + (active === it.id ? ' active' : '')}
               onClick={() => onNav(it.id)}>
              {it.label}
            </a>
          ))}
          <a href="#unete" className="nav-cta" onClick={() => onNav('unete')}>Únete →</a>
        </div>
        <button className={'nav-hamburger' + (open ? ' is-open' : '')}
                onClick={() => setOpen(o => !o)} aria-label="Menú">
          <span/><span/><span/>
        </button>
      </nav>

      {open && (
        <div className="mobile-menu">
          <div className="mobile-menu-top">
            <a className="nav-brand" onClick={() => handleNav('top')} style={{cursor:'pointer'}}>
              <img src="img/logo.png" alt="Jebaño FC"/>
              <div className="nav-brand-mark" style={{color:'#ebe6d5'}}>JEBAÑO FC</div>
            </a>
            <button className="mobile-menu-close" onClick={() => setOpen(false)} aria-label="Cerrar">
              <svg width="22" height="22" viewBox="0 0 22 22" fill="none">
                <line x1="2" y1="2" x2="20" y2="20" stroke="#ebe6d5" strokeWidth="2" strokeLinecap="round"/>
                <line x1="20" y1="2" x2="2" y2="20" stroke="#ebe6d5" strokeWidth="2" strokeLinecap="round"/>
              </svg>
            </button>
          </div>
          <nav className="mobile-menu-links">
            {items.map(it => (
              <a key={it.id} className="mobile-menu-link" onClick={() => handleNav(it.id)}>
                <span className="mobile-menu-num">{it.num}</span>
                <span className="mobile-menu-label">{it.label}</span>
              </a>
            ))}
          </nav>
          <a className="mobile-menu-cta" onClick={() => handleNav('unete')}>
            ÚNETE →
          </a>
        </div>
      )}
    </>
  );
}

function Footer({ onLiga, onNav }) {
  return (
    <footer className="footer">
      <div className="wrap">
        <div className="footer-grid">
          <div className="footer-brand">
            <div className="nav-brand-mark">JEBAÑO FC</div>
            <p>Desde el sur, a la capital. Un grupo de amigos de Temuco que llegó a Santiago y nunca dejó de encontrarse en la cancha.</p>
          </div>
          <div className="footer-col">
            <div className="label">Navegación</div>
            <ul>
              <li><button className="footer-link-btn" onClick={() => onNav && onNav('club')}>El club</button></li>
              <li><button className="footer-link-btn" onClick={() => onNav && onNav('plantel')}>Plantel</button></li>
              <li><button className="footer-link-btn" onClick={() => onNav && onNav('palmares')}>Palmarés</button></li>
              <li><button className="footer-link-btn" onClick={() => onNav && onNav('galeria')}>Galería</button></li>
            </ul>
          </div>
          <div className="footer-col">
            <div className="label">Club</div>
            <ul>
              <li><button className="footer-link-btn" onClick={() => onLiga && onLiga('tabla')}>Próximo partido</button></li>
              <li><button className="footer-link-btn" onClick={() => onLiga && onLiga('resultados')}>Últimos resultados</button></li>
              <li><button className="footer-link-btn" onClick={() => onLiga && onLiga('tabla')}>Clasificación</button></li>
            </ul>
          </div>
          <div className="footer-col">
            <div className="label">Contacto</div>
            <ul>
              <li>hola@jebanofc.cl</li>
              <li>Únete</li>
              <li>Sponsors</li>
            </ul>
          </div>
        </div>
        <div className="footer-bottom">
          <span>© 2026 · Jebaño FC</span>
          <div className="socials">
            {/* Instagram */}
            <a href="https://instagram.com/jebanofc" target="_blank" rel="noopener noreferrer" aria-label="Instagram" title="Instagram">
              <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
                <path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/>
              </svg>
            </a>
            {/* X (Twitter) */}
            <a href="https://x.com/jebanofc" target="_blank" rel="noopener noreferrer" aria-label="X" title="X / Twitter">
              <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
                <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.748l7.73-8.835L1.254 2.25H8.08l4.253 5.622zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>
              </svg>
            </a>
            {/* Facebook */}
            <a href="https://facebook.com/jebanofc" target="_blank" rel="noopener noreferrer" aria-label="Facebook" title="Facebook">
              <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
                <path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/>
              </svg>
            </a>
          </div>
        </div>
      </div>
    </footer>
  );
}

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