import { getTranslations } from "next-intl/server";
import { Link } from "@/i18n/navigation";
import { restaurant } from "@/content/restaurant";

const iconProps = {
  width: 18,
  height: 18,
  viewBox: "0 0 24 24",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round" as const,
  strokeLinejoin: "round" as const,
};

function ReserveIcon() {
  return (
    <svg {...iconProps} aria-hidden>
      <rect x="3.5" y="4.5" width="17" height="16" rx="2" />
      <path d="M3.5 9.5h17M8 3v3M16 3v3" />
    </svg>
  );
}

function OffersIcon() {
  return (
    <svg {...iconProps} aria-hidden>
      <path d="M20.59 13.41L11 3.83A2 2 0 009.57 3H4a1 1 0 00-1 1v5.57a2 2 0 00.59 1.41l9.58 9.58a2 2 0 002.83 0l4.59-4.59a2 2 0 000-2.83z" />
      <circle cx="7.5" cy="7.5" r="1.25" fill="currentColor" stroke="none" />
    </svg>
  );
}

function CallIcon() {
  return (
    <svg {...iconProps} aria-hidden>
      <path d="M5 4.5h3.5l1.5 4-2 1.5a12 12 0 005.5 5.5l1.5-2 4 1.5V18a1.5 1.5 0 01-1.6 1.5A15 15 0 013.5 6.1 1.5 1.5 0 015 4.5z" />
    </svg>
  );
}

function DirectionsIcon() {
  return (
    <svg {...iconProps} aria-hidden>
      <path d="M12 21s7-6.5 7-11.5a7 7 0 10-14 0C5 14.5 12 21 12 21z" />
      <circle cx="12" cy="9.5" r="2.25" />
    </svg>
  );
}

export async function MobileBottomBar() {
  const t = await getTranslations("mobileBar");

  return (
    <nav className="fixed inset-x-0 bottom-0 z-40 flex border-t border-brass/20 bg-ink text-ivory md:hidden">
      <Link href="/reserve" className="flex flex-1 flex-col items-center gap-1.5 py-3">
        <ReserveIcon />
        <span className="text-[10px] uppercase tracking-wide">{t("reserve")}</span>
      </Link>
      <Link href="/offers" className="flex flex-1 flex-col items-center gap-1.5 py-3">
        <OffersIcon />
        <span className="text-[10px] uppercase tracking-wide">{t("offers")}</span>
      </Link>
      <a href={`tel:${restaurant.phone.replace(/\s/g, "")}`} className="flex flex-1 flex-col items-center gap-1.5 py-3">
        <CallIcon />
        <span className="text-[10px] uppercase tracking-wide">{t("call")}</span>
      </a>
      <a href={restaurant.address.mapsUrl} target="_blank" rel="noopener" className="flex flex-1 flex-col items-center gap-1.5 py-3">
        <DirectionsIcon />
        <span className="text-[10px] uppercase tracking-wide">{t("directions")}</span>
      </a>
    </nav>
  );
}
