import type { Metadata } from "next";
import { Inter, Sora } from "next/font/google";
import Header from "@/components/Header";
import Footer from "@/components/Footer";
import "./globals.css";

const bodyFont = Inter({
  variable: "--font-body",
  subsets: ["latin"],
  display: "swap",
  preload: true,
  adjustFontFallback: true,
});

const displayFont = Sora({
  variable: "--font-display",
  subsets: ["latin"],
  display: "swap",
  preload: true,
  adjustFontFallback: true,
});

export const metadata: Metadata = {
  title: "Master Electrician Corpus Christi, TX | Budd Electric Co. Since 1969",
  description:
    "Family-owned since 1969. Budd Electric Co. provides residential & commercial electrical services in Corpus Christi & South Texas. Call (361) 855-2255 for a free quote.",
  icons: {
    icon: '/images/logo.png',
  },
  metadataBase: new URL('https://buddelectric.com'),
  alternates: {
    canonical: '/',
  },
  openGraph: {
    type: 'website',
    locale: 'en_US',
    url: 'https://buddelectric.com',
    title: 'Master Electrician Corpus Christi, TX | Budd Electric Co. Since 1969',
    description: 'Family-owned since 1969. Budd Electric Co. provides residential & commercial electrical services in Corpus Christi & South Texas.',
    siteName: 'Budd Electric Co.',
    images: [
      {
        url: '/images/logo.png',
        width: 1200,
        height: 630,
        alt: 'Budd Electric Co. Logo',
      },
    ],
  },
  robots: {
    index: true,
    follow: true,
    googleBot: {
      index: true,
      follow: true,
      'max-video-preview': -1,
      'max-image-preview': 'large',
      'max-snippet': -1,
    },
  },
  verification: {
    google: 'your-google-verification-code',
  },
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  // LocalBusiness Schema for SEO
  const localBusinessSchema = {
    "@context": "https://schema.org",
    "@type": "Electrician",
    "@id": "https://buddelectric.com/#organization",
    "name": "Budd Electric Co.",
    "alternateName": "Budd Electric",
    "description": "Family-owned electrical contractor serving Corpus Christi & South Texas since 1969. Licensed Master Electricians providing residential & commercial electrical services.",
    "url": "https://buddelectric.com",
    "telephone": "+1-361-855-2255",
    "email": "info@buddelectric.com",
    "foundingDate": "1969",
    "priceRange": "$$",
    "image": "https://buddelectric.com/images/logo.png",
    "logo": "https://buddelectric.com/images/logo.png",
    "address": {
      "@type": "PostalAddress",
      "streetAddress": "5765 Ayers St",
      "addressLocality": "Corpus Christi",
      "addressRegion": "TX",
      "postalCode": "78415",
      "addressCountry": "US"
    },
    "geo": {
      "@type": "GeoCoordinates",
      "latitude": 27.7506,
      "longitude": -97.3964
    },
    "areaServed": [
      {
        "@type": "City",
        "name": "Corpus Christi",
        "containedInPlace": { "@type": "State", "name": "Texas" }
      },
      {
        "@type": "City",
        "name": "Portland",
        "containedInPlace": { "@type": "State", "name": "Texas" }
      },
      {
        "@type": "City",
        "name": "Robstown",
        "containedInPlace": { "@type": "State", "name": "Texas" }
      },
      {
        "@type": "City",
        "name": "Ingleside",
        "containedInPlace": { "@type": "State", "name": "Texas" }
      },
      {
        "@type": "City",
        "name": "Rockport",
        "containedInPlace": { "@type": "State", "name": "Texas" }
      }
    ],
    "hasCredential": {
      "@type": "EducationalOccupationalCredential",
      "credentialCategory": "license",
      "name": "Texas Electrical Contractor License",
      "recognizedBy": {
        "@type": "Organization",
        "name": "Texas Department of Licensing and Regulation"
      },
      "identifier": "TECL #17007"
    },
    "hasOfferCatalog": {
      "@type": "OfferCatalog",
      "name": "Electrical Services",
      "itemListElement": [
        {
          "@type": "Offer",
          "itemOffered": {
            "@type": "Service",
            "name": "Residential Electrical Services",
            "description": "Complete home electrical services including safety inspections, repairs, lighting, and fan installations."
          }
        },
        {
          "@type": "Offer",
          "itemOffered": {
            "@type": "Service",
            "name": "Commercial Electrical Services",
            "description": "New construction wiring, tenant build-outs, parking lot lighting, emergency lighting, and troubleshooting."
          }
        },
        {
          "@type": "Offer",
          "itemOffered": {
            "@type": "Service",
            "name": "Kohler Generator Installation",
            "description": "Authorized Kohler dealer providing generator sales, installation, maintenance plans, and warranty service."
          }
        }
      ]
    },
    "openingHoursSpecification": [
      {
        "@type": "OpeningHoursSpecification",
        "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
        "opens": "07:00",
        "closes": "17:00"
      }
    ],
    "sameAs": [
      "https://www.facebook.com/buddelectric",
      "https://www.google.com/maps/place/Budd+Electric+Co"
    ],
    "aggregateRating": {
      "@type": "AggregateRating",
      "ratingValue": "5.0",
      "reviewCount": "50",
      "bestRating": "5",
      "worstRating": "1"
    }
  };

  return (
    <html lang="en">
      <head>
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(localBusinessSchema) }}
        />
      </head>
      <body
        className={`${bodyFont.variable} ${displayFont.variable} antialiased flex flex-col min-h-screen bg-[color:var(--bg)] text-[color:var(--ink)] font-sans`}
      >
        <Header />
        <main className="flex-grow pt-[130px]">
          {children}
        </main>
        <Footer />
      </body>
    </html>
  );
}
