import type { ReactNode } from "react";
import { useWeb } from "../WebContext";
import { Container } from "../WebUI";

export default function WebPageHeader({
  title,
  desc,
  crumb,
  children,
}: {
  title: string;
  desc?: string;
  crumb?: string;
  children?: ReactNode;
}) {
  const { jump, t } = useWeb();
  return (
    <div className="bg-background-100 border-b border-background-200">
      <Container className="py-8">
        <nav className="flex items-center gap-2 text-[12.5px] text-foreground-500 mb-3">
          <button type="button" onClick={() => jump("home")} className="hover:text-foreground-950 cursor-pointer">
            {t("navHome")}
          </button>
          {crumb && (
            <>
              <i className="ri-arrow-left-s-line text-[14px] leading-none" />
              <span className="text-foreground-800 font-medium">{crumb}</span>
            </>
          )}
        </nav>
        <div className="flex flex-col sm:flex-row sm:items-end justify-between gap-4">
          <div>
            <h1 className="text-[28px] md:text-[34px] font-bold text-foreground-950 font-heading">{title}</h1>
            {desc && <p className="text-[14px] text-foreground-600 mt-1.5">{desc}</p>}
          </div>
          {children}
        </div>
      </Container>
    </div>
  );
}