import type { Metadata } from "next";
import type { ReactNode } from "react";
import { SiteFooter } from "@/components/site-footer";
import { SiteHeader } from "@/components/site-header";
import "./globals.css";

const isPreviewDeployment =
  process.env.NYSA_PREVIEW_DEPLOYMENT?.toLowerCase() === "true";

export const metadata: Metadata = {
  metadataBase: new URL(
    process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3000",
  ),
  title: {
    default: "NYSA Realty | Dubai Property Intelligence",
    template: "%s | NYSA Realty",
  },
  description:
    "A development baseline for NYSA's future public property experience.",
  openGraph: {
    type: "website",
    title: "NYSA Realty | Dubai Property Intelligence",
    description:
      "Move from property search to confident decision with clearer Dubai property intelligence.",
    images: [
      {
        url: "/og.png",
        width: 1731,
        height: 909,
        alt: "NYSA — Dubai property, made clearer",
      },
    ],
  },
  twitter: {
    card: "summary_large_image",
    title: "NYSA Realty | Dubai Property Intelligence",
    description: "Move from property search to confident decision.",
    images: ["/og.png"],
  },
  ...(isPreviewDeployment
    ? {
        robots: {
          index: false,
          follow: false,
          noarchive: true,
          nosnippet: true,
          googleBot: {
            index: false,
            follow: false,
            noimageindex: true,
          },
        },
      }
    : {}),
};

export default function RootLayout({
  children,
}: Readonly<{ children: ReactNode }>) {
  return (
    <html lang="en">
      <body>
        <a className="skip-link" href="#main-content">
          Skip to content
        </a>
        <SiteHeader />
        <main id="main-content">{children}</main>
        <SiteFooter />
      </body>
    </html>
  );
}
