/* recursosLegalesApp.jsx — App shell for the Legal Resources page. */
function RecursosLegalesApp() {
  const [themisxOpen, setThemisxOpen] = React.useState(false);

  React.useEffect(() => {
    if (window.lucide) window.lucide.createIcons();
  });
  React.useEffect(() => {
    document.body.style.overflow = themisxOpen ? "hidden" : "";
    return () => { document.body.style.overflow = ""; };
  }, [themisxOpen]);
  React.useEffect(() => {
    const onKey = (e) => { if (e.key === "Escape") setThemisxOpen(false); };
    window.addEventListener("keydown", onKey);
    return () => window.removeEventListener("keydown", onKey);
  }, []);
  React.useEffect(() => {
    const onOpen = () => setThemisxOpen(true);
    window.addEventListener("themisx:open", onOpen);
    return () => window.removeEventListener("themisx:open", onOpen);
  }, []);

  const [ready] = React.useState(() => { ResourceStore.seedIfEmpty(); return true; });

  return (
    <>
      <Header onThemisXClick={() => setThemisxOpen(true)} activePath="recursos-legales" />

      <ResourceCenter
        variant="legal"
        eyebrow="CENTRO DE RECURSOS"
        heading="Recursos Legales"
        lede="Documentos, guias y materiales de referencia para profesionales y ciudadanos."
      />

      <CTABanner
        variant="legal"
        primaryLabel="Solicita tu cita"
        onPrimary={() => window.location.href = "contacto.html"}
        secondaryLabel="Consultar a ThemisX"
        onSecondary={() => setThemisxOpen(true)}
      />

      <SiteFooter />
      <ThemisXModal open={themisxOpen} onClose={() => setThemisxOpen(false)} />
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<RecursosLegalesApp />);
