import type { Metadata, Viewport } from "next";
import "./globals.css";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { Header } from "../components/Header";
import { Footer } from "../components/Footer";

const siteUrl =
  process.env.NEXT_PUBLIC_SITE_URL || "https://xpectoglobaltrade.com";

export const metadata: Metadata = {
  metadataBase: new URL(siteUrl),
  title: {
    default: "Xpecto Global - Trusted Import Export Partner from India",
    template: "%s | Xpecto Global",
  },
  description:
    "Leading Indian export company connecting certified manufacturers with global buyers in USA, Europe & emerging markets. ISO certified, GMP aligned, FDA ready. Get compliance-first export solutions.",
  keywords: [
    "Indian export company",
    "import export India",
    "global trade partner",
    "B2B export",
    "Indian manufacturers",
    "export from India",
    "agricultural exports India",
    "pharmaceutical exports",
    "textile exports India",
    "industrial materials export",
    "auto parts export",
    "cosmetics export India",
    "ISO certified exporter",
    "GMP manufacturer India",
    "FDA ready products",
    "international trade",
    "supply chain India",
    "verified suppliers India",
  ],
  authors: [{ name: "Xpecto Global", url: siteUrl }],
  creator: "Xpecto Global",
  publisher: "Xpecto Global",
  formatDetection: {
    email: false,
    address: false,
    telephone: false,
  },
  alternates: {
    canonical: "/",
  },
  openGraph: {
    type: "website",
    locale: "en_US",
    url: siteUrl,
    siteName: "Xpecto Global",
    title: "Xpecto Global - Trusted Import Export Partner from India",
    description:
      "Leading Indian export company connecting certified manufacturers with global buyers. ISO certified, GMP aligned, FDA ready export solutions.",
    images: [
      {
        url: "/og-image.jpg",
        width: 1200,
        height: 630,
        alt: "Xpecto Global - Global Import Export Solutions",
      },
    ],
  },
  twitter: {
    card: "summary_large_image",
    title: "Xpecto Global - Trusted Import Export Partner from India",
    description:
      "Leading Indian export company connecting certified manufacturers with global buyers. ISO certified, GMP aligned, FDA ready.",
    images: ["/og-image.jpg"],
    creator: "@xpectoglobal",
  },
  robots: {
    index: true,
    follow: true,
    nocache: false,
    googleBot: {
      index: true,
      follow: true,
      noimageindex: false,
      "max-video-preview": -1,
      "max-image-preview": "large",
      "max-snippet": -1,
    },
  },
  verification: {
    google: "your-google-verification-code",
    yandex: "your-yandex-verification-code",
    // bing: "your-bing-verification-code",
  },
  category: "Business",
};

export const viewport: Viewport = {
  themeColor: [
    { media: "(prefers-color-scheme: light)", color: "#ffffff" },
    { media: "(prefers-color-scheme: dark)", color: "#0B1C2D" },
  ],
  width: "device-width",
  initialScale: 1,
  maximumScale: 5,
  userScalable: true,
};

// Organization Schema for rich snippets
const organizationSchema = {
  "@context": "https://schema.org",
  "@type": "Organization",
  name: "Xpecto Global",
  url: siteUrl,
  logo: `${siteUrl}/logo.png`,
  description:
    "Leading Indian export company connecting certified manufacturers with global buyers in USA, Europe & emerging markets.",
  address: {
    "@type": "PostalAddress",
    addressCountry: "IN",
    addressRegion: "India",
  },
  contactPoint: {
    "@type": "ContactPoint",
    contactType: "sales",
    availableLanguage: ["English", "Hindi"],
  },
  sameAs: [
    "https://www.linkedin.com/company/xpectoglobal",
    "https://twitter.com/xpectoglobal",
  ],
  areaServed: ["US", "EU", "AE", "GB", "AU", "CA", "SG"],
  serviceType: [
    "Export Services",
    "Import Services",
    "International Trade",
    "B2B Trade",
  ],
};

// Website Schema
const websiteSchema = {
  "@context": "https://schema.org",
  "@type": "WebSite",
  name: "Xpecto Global",
  url: siteUrl,
  potentialAction: {
    "@type": "SearchAction",
    target: {
      "@type": "EntryPoint",
      urlTemplate: `${siteUrl}/products?search={search_term_string}`,
    },
    "query-input": "required name=search_term_string",
  },
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <head>
        <link rel="icon" href="/favicon.ico" sizes="any" />
        <link rel="icon" href="/icon.svg" type="image/svg+xml" />
        <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
        <link rel="manifest" href="/manifest.json" />
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{
            __html: JSON.stringify(organizationSchema),
          }}
        />
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{
            __html: JSON.stringify(websiteSchema),
          }}
        />
      </head>
      <body>
        <ToastContainer
          position="top-right"
          autoClose={5000}
          hideProgressBar={false}
          newestOnTop
          closeOnClick
          rtl={false}
          pauseOnFocusLoss
          draggable
          pauseOnHover
        />
        <div className="min-h-screen flex flex-col">
          <Header />
          <main className="flex-1">{children}</main>
          <Footer />
        </div>
      </body>
    </html>
  );
}
