"use client";

import Link from "next/link";
import { useState } from "react";
import { PhoneCall, Menu } from "lucide-react";
import { offices } from "@/lib/site-config";
import { Button } from "@/components/ui/button";

export function SiteHeader() {
  const vaOffice = offices.find((o) => o.id === "va");
  const [open, setOpen] = useState(false);

  return (
    <header className="pointer-events-none sticky top-0 z-40 bg-transparent pb-2">
      <div className="pointer-events-auto mx-auto mt-3 flex max-w-6xl items-center justify-between rounded-full border border-emerald-100 bg-white/95 px-4 py-2.5 shadow-md shadow-emerald-900/5 backdrop-blur md:px-6">
        <Link href="/" className="flex items-center gap-2">
          <span className="flex h-8 w-8 items-center justify-center rounded-full border border-emerald-400 bg-emerald-50 text-xs font-semibold text-emerald-800">
            GF
          </span>
        </Link>
        <nav className="hidden items-center gap-6 text-xs font-medium text-emerald-900/80 md:flex">
          <Link href="/" className="relative pb-1 hover:text-emerald-950">
            <span>Home</span>
          </Link>
          <Link
            href="#services"
            className="relative pb-1 hover:text-emerald-950"
          >
            Services
          </Link>
          <Link
            href="#reviews"
            className="relative pb-1 hover:text-emerald-950"
          >
            Reviews
          </Link>
          <Link
            href="#locations"
            className="relative pb-1 hover:text-emerald-950"
          >
            Locations
          </Link>
          <Link
            href="/contact"
            className="relative pb-1 hover:text-emerald-950"
          >
            Contact
          </Link>
        </nav>
        <div className="flex items-center gap-3">
          <div className="hidden md:block">
            <Button
              variant="outline"
              size="sm"
              className="h-9 rounded-full border-emerald-400 bg-emerald-50 px-4 text-[0.7rem] font-semibold text-emerald-950 hover:bg-emerald-100"
            >
              <Link href="/appointment">Book Appointment</Link>
            </Button>
          </div>
          <button
            type="button"
            className="flex h-9 w-9 items-center justify-center rounded-full border border-emerald-200 bg-white text-emerald-800 hover:bg-emerald-50 md:hidden"
            aria-label="Toggle navigation"
            onClick={() => setOpen((prev) => !prev)}
          >
            <Menu className="h-4 w-4" />
          </button>
        </div>
      </div>
      {open && (
        <div className="pointer-events-auto border-t border-emerald-100 bg-white md:hidden">
          <div className="mx-auto max-w-6xl px-4 py-3 text-sm text-slate-800">
            <nav className="flex flex-col gap-3">
              <Link href="/" onClick={() => setOpen(false)}>
                Home
              </Link>
              <a href="#services" onClick={() => setOpen(false)}>
                Services
              </a>
              <a href="#reviews" onClick={() => setOpen(false)}>
                Reviews
              </a>
              <a href="#locations" onClick={() => setOpen(false)}>
                Locations
              </a>
              <Link href="/contact" onClick={() => setOpen(false)}>
                Contact
              </Link>
              <Link
                href="/appointment"
                onClick={() => setOpen(false)}
                className="mt-2 inline-flex h-10 items-center justify-center rounded-full border border-emerald-400 bg-emerald-50 px-4 text-xs font-semibold text-emerald-950"
              >
                Book Appointment
              </Link>
            </nav>
          </div>
        </div>
      )}
    </header>
  );
}

