import "@/app/globals.css";
import { Metadata } from "next";
import { Inter, Noto_Sans } from "next/font/google";
import { LocalBusiness, Organization, WithContext } from "schema-dts";

import { Providers } from "@/app/providers";
import TelemetryBootstrap from "@/app/telemetry-bootstrap";
import UnderMaintenanceMode from "@/components/pages/under-maintenance/under-maintenance";
import { INFO_EMAIL } from "@/constants/signup-form-constants";
import SkipLinks from "@/components/common/skip-links";

export const metadata: Metadata = {
  metadataBase: new URL("https://peopleforresearch.co.uk"),
  title: {
    template: "%s | People for Research",
    default:
      "Your trusted recruitment partner for user research | People for Research",
  },
  description:
    "People for Research is a leading UK-based participant recruitment agency specializing in user research and usability testing. We partner with global brands, innovative startups, and government departments to deliver high-quality research participants tailored to your project needs.",
  authors: [
    {
      name: "People for Research",
      url: "https://peopleforresearch.co.uk",
    },
  ],
  icons: {
    icon: "/favicon.ico",
    other: [
      {
        rel: "icon",
        type: "image/png",
        sizes: "32x32",
        url: "/favicon-32x32.png",
      },
      {
        rel: "icon",
        type: "image/png",
        sizes: "16x16",
        url: "/favicon-16x16.png",
      },
      {
        rel: "apple-touch-icon",
        type: "image/png",
        sizes: "180x180",
        url: "/apple-touch-icon.png",
      },
      {
        rel: "manifest",
        url: "/manifest.json",
      },
      {
        rel: "mask-icon",
        url: "/safari-pinned-tab.svg",
        color: "#5bbad5",
      },
    ],
  },
  openGraph: {
    title:
      "Your trusted recruitment partner for user research | People for Research",
    description:
      "People for Research is a leading participant recruitment agency for user research and usability testing. We work in partnership with clients, including global brands, innovative start-ups, and government departments.",
    url: "https://peopleforresearch.co.uk",
    type: "website",
    locale: "en_GB",
    siteName:
      "Your trusted recruitment partner for user research | People for Research",
    images: [
      {
        url: "/global-assets/pfr-logo-og-client.svg",
        alt: "People for Research logo, featuring a person inside a circle, representing a focus on human-centered research and activities.",
        width: 200,
        height: 150,
      },
    ],
  },
  twitter: {
    title:
      "Your trusted recruitment partner for user research | People for Research",
    card: "summary_large_image",
    images: "/global-assets/pfr-logo-og-client.svg",
  },
};

const jsonLdOrganization: WithContext<Organization> = {
  "@context": "https://schema.org",
  "@type": "Organization",
  name: "People for Research",
  url: "https://peopleforresearch.co.uk",
  email: INFO_EMAIL,
  legalName: "People for Research",
  description:
    "People for Research is a leading participant recruitment agency for user research and usability testing. We work in partnership with clients, including global brands, innovative start-ups, and government departments.",
  logo: {
    "@type": "ImageObject",
    url: "https://peopleforresearch.co.uk/global-assets/pfr-logo.svg",
  },
  contactPoint: {
    "@type": "ContactPoint",
    telephone: "+44 117 921 0008",
    contactType: "Customer Service",
    areaServed: "GB",
    availableLanguage: ["English"],
  },
  address: {
    "@type": "PostalAddress",
    streetAddress: "Suite 302, QC30 Queen Charlotte Street",
    addressLocality: "Bristol",
    addressRegion: "BS1",
    postalCode: "4HJ",
    addressCountry: "GB",
  },
  sameAs: [
    "https://facebook.com/PeopleForResearch",
    "https://x.com/Research4People",
    "https://youtube.com/playlist?list=PLGsrBfLYZ5bffbLvNq8uyOj7vajqJ7Y93",
    "https://instagram.com/people4research",
    "https://tiktok.com/@people4research",
    "https://linkedin.com/company/people-for-research",
    "https://x.com/people4research",
    "https://medium.com/@people4research",
    "https://youtube.com/channel/UC1gAe1wCChwTqh19XON_0yA",
    "https://trustpilot.com/review/www.peopleforresearch.co.uk",
  ],
  foundingDate: "1989-01-01",
  founder: {
    "@type": "Person",
    name: "Paul Gooding",
  },
};

const jsonLdLocalBusiness: WithContext<LocalBusiness> = {
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  name: "People for Research",
  address: {
    "@type": "PostalAddress",
    streetAddress: "Suite 302, QC30 Queen Charlotte Street",
    addressLocality: "Bristol",
    addressRegion: "BS1",
    postalCode: "4HJ",
    addressCountry: "GB",
  },
  geo: {
    "@type": "GeoCoordinates",
    latitude: "51.4523437",
    longitude: "-2.5937107",
  },
  openingHoursSpecification: [
    {
      "@type": "OpeningHoursSpecification",
      dayOfWeek: ["Monday", "Tuesday", "Wednesday", "Thursday"],
      opens: "09:00",
      closes: "17:30",
    },
    {
      "@type": "OpeningHoursSpecification",
      dayOfWeek: "Friday",
      opens: "09:00",
      closes: "17:00",
    },
  ],
  telephone: "+44 117 921 0008",
  url: "https://peopleforresearch.co.uk",
  aggregateRating: {
    "@type": "AggregateRating",
    ratingValue: "4.5",
    reviewCount: "104",
    bestRating: "5",
    worstRating: "1",
  },
  review: [
    {
      "@type": "Review",
      author: {
        "@type": "Organization",
        name: "British Heart Foundation",
      },
      reviewBody:
        "Recruiting users with a suitable background was paramount for the project and we wouldn't have been able to do it so swiftly without People for Research. The participants were all perfectly suited to the tasks we wanted them to undertake.",
      reviewRating: {
        "@type": "Rating",
        ratingValue: "5",
        bestRating: "5",
      },
    },
    {
      "@type": "Review",
      author: {
        "@type": "Organization",
        name: "BT",
      },
      reviewBody:
        "PFR has been fantastic on all of the projects we've worked on so far. Their communication is prompt and concise, evidenced by the speed at which they are able to sign off quotes, screeners and ultimately go from brief to a full list of recruited participants.",
      reviewRating: {
        "@type": "Rating",
        ratingValue: "5",
        bestRating: "5",
      },
    },
    {
      "@type": "Review",
      author: {
        "@type": "Organization",
        name: "Penguin",
      },
      reviewBody:
        "We've had great experiences with the People for Research team. They deliver smart, efficient service, responding to briefs with engaging and creative screeners and advertisements. The project managers are really thorough, and always on top of timings and logistics. We've found the participants recruited to be great quality, enthusiastic and to spec.",
      reviewRating: {
        "@type": "Rating",
        ratingValue: "5",
        bestRating: "5",
      },
    },
    {
      "@type": "Review",
      author: {
        "@type": "Organization",
        name: "Philips",
      },
      reviewBody:
        "It has been a great pleasure working with the team at PFR. We would like to thank them for all the advice and suggestions given from time to time. It feels like they are very dedicated to our projects with strong sense of responsibility and accountability.",
      reviewRating: {
        "@type": "Rating",
        ratingValue: "5",
        bestRating: "5",
      },
    },
    {
      "@type": "Review",
      author: {
        "@type": "Organization",
        name: "Make Human",
      },
      reviewBody:
        "We just returned from a fascinating two days of research into how people interacted with a prototype of an innovative new kitchen appliance. We designed and moderated research at People for Research's studios - they were amazing. Researching with a physical product was a refreshing change from a recent trend of remote digital studies. Having the client team on-site for real-time feedback amplified the value of our research.",
      reviewRating: {
        "@type": "Rating",
        ratingValue: "5",
        bestRating: "5",
      },
    },
    {
      "@type": "Review",
      author: {
        "@type": "Organization",
        name: "Trustpilot",
      },
      reviewBody: "Trustpilot score 4.4 based on 107 reviews",
      reviewRating: {
        "@type": "Rating",
        ratingValue: "4.4",
        bestRating: "5",
      },
      url: "https://trustpilot.com/review/www.peopleforresearch.co.uk",
    },
  ],
};

const inter = Inter({
  subsets: ["latin"],
  variable: "--font-inter",
});

const notoSans = Noto_Sans({
  subsets: ["latin"],
  variable: "--font-noto",
});

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const currentEnv = process.env.NODE_ENV || "";
  const GTM_ID = process.env.PFR_GTM_ID || "";
  const cookieFirstKey = process.env.PFR_COOKIE_FIRST_KEY || "";
  const hotjarSiteId = process.env.PFR_HOTJAR_SITE_ID || "";
  const isInMaintenanceMode = process.env.UNDER_MAINTENANCE === "true";

  return (
    <html className={`${inter.variable} ${notoSans.variable}`} lang="en">
      <head>
        {/* used on search console. can be public. */}
        <meta
          content="cUX7wb3FZ4IOLq6IgWBI71KoGgxqP1_2vNQUTEp_s2Y"
          name="google-site-verification"
        />
      </head>
      <body>
        <SkipLinks />
        <script
          dangerouslySetInnerHTML={{
            __html: JSON.stringify(jsonLdOrganization),
          }}
          type="application/ld+json"
        />
        <script
          dangerouslySetInnerHTML={{
            __html: JSON.stringify(jsonLdLocalBusiness),
          }}
          type="application/ld+json"
        />
        <Providers>
          {isInMaintenanceMode ? <UnderMaintenanceMode /> : children}
        </Providers>
        <TelemetryBootstrap
          cookieFirstKey={cookieFirstKey}
          currentEnv={currentEnv}
          gtmId={GTM_ID}
          hotjarSiteId={hotjarSiteId}
        />
      </body>
    </html>
  );
}
