import { getSettings } from "@/lib/queries";
import { SiteHeader } from "@/components/site/header";
import { SiteFooter } from "@/components/site/footer";
import { WhatsAppButton } from "@/components/site/whatsapp-button";

export default async function SiteLayout({ children }: { children: React.ReactNode }) {
  let settings = await getSettings();
  // Fallback if settings somehow missing
  if (!settings) {
    settings = {
      id: "singleton",
      companyName: "AL-HASAN ENGINEERING SERVICE",
      shortName: "AHE Services",
      tagline: "Complete HVAC Solutions for Industrial & Commercial Needs",
      logo: null,
      favicon: null,
      phone: "0301-2435144",
      whatsapp: "923012435144",
      email: "alhasanengineeringservice@gmail.com",
      address: "Shop # A-12, Jama Masjid Yaqoob, Al-Marooq Ayubi, SITE Area, Karachi",
      mapEmbed: null,
      workingHours: "Mon - Sat: 9:00 AM - 8:00 PM",
      ntn: "4597057-6",
      footerText: "Your trusted partner for industrial and commercial HVAC solutions across Pakistan.",
      copyright: "AL-HASAN ENGINEERING SERVICE. All rights reserved.",
      facebook: null, instagram: null, linkedin: null, youtube: null, twitter: null,
      defaultMetaTitle: "AHE Services",
      defaultMetaDescription: "",
      updatedAt: new Date(),
    } as any;
  }
  return (
    <div className="min-h-screen flex flex-col">
      <SiteHeader settings={settings} />
      <main className="flex-1">{children}</main>
      <SiteFooter settings={settings} />
      <WhatsAppButton phone={settings.whatsapp} />
    </div>
  );
}
