

// app/layout.tsx

import "./globals.css";
import Footer from "@/components/common/Footer";
import Providers from "./Providers";
import Script from "next/script";
import NavbarWrapper from "@/components/common/NavbarWrapper";
import OurPresence from "@/components/common/OurPresence";


import type { Metadata } from "next";
import { Geist } from "next/font/google";
import { cn } from "@/lib/utils";
import TawkTo from "@/components/common/TawkTo";
import UnderMaintenanceDialog from "@/components/common/UnderMaintenanceDialog";

const geist = Geist({subsets:['latin'],variable:'--font-sans'});

export const metadata: Metadata = {
  metadataBase: new URL("https://ridoo.co.in"), // ✅ VERY IMPORTANT

  title: {
    default: "Ridoo – Rent Drive Bikes & Cars Online Anytime, Anywhere",
    template: "%s | Ridoo",
  },

  description:
    "Book self-drive bikes and cars near you with Ridoo. Enjoy fast, secure, and 100% paperless rentals with verified partners across India.",

  alternates: {
    canonical: "/", // ✅ this becomes https://ridoo.co.in
  },

  openGraph: {
    title: "Ridoo – Rent Self Drive Bikes & Cars Online Anytime, Anywhere",
    description:
      "Book self-drive bikes and cars near you with Ridoo. Enjoy fast, secure, and 100% paperless rentals with verified partners across India.",
    url: "https://ridoo.co.in",
    siteName: "Ridoo",
    images: [
      {
        url: "/og-image.png",
        width: 1200,
        height: 630,
      },
    ],
    type: "website",
  },

  icons: {
    icon: [
      { url: "/ridoo_icon.png" },
      { url: "/ridoo_icon_new.png", type: "image/png", sizes: "32x32" },
    ],
    apple: [{ url: "/apple-touch-icon.png", sizes: "180x180" }],
  },
};


export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en" suppressHydrationWarning className={cn("font-sans", geist.variable)}>

       <head>
        {/* ✅ Google Tag Manager (HEAD script) */}
        <Script id="gtm-head" strategy="beforeInteractive">
          {`
            (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
            new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
            j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
            'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
            })(window,document,'script','dataLayer','GTM-M2QQJV42');
          `}
        </Script>
      </head>

      
      <body suppressHydrationWarning>
       
       <Script
  id="organization-schema"
  type="application/ld+json"
  dangerouslySetInnerHTML={{
    __html: JSON.stringify({
      "@context": "https://schema.org",
      "@type": "Organization",
      name: "Ridoo",
      url: "https://ridoo.co.in",
      logo: "https://ridoo.co.in/ridoo_icon.png",
      sameAs: [
        "https://www.instagram.com/",
        "https://www.facebook.com/"
      ],
    }),
  }}
/>

<Script
  id="local-business-schema"
  type="application/ld+json"
  dangerouslySetInnerHTML={{
    __html: JSON.stringify({
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      name: "Ridoo",
      image: "https://ridoo.co.in/og-image.png",
      url: "https://ridoo.co.in",
      telephone: "+91-8762680082",
      priceRange: "₹₹",
      address: {
        "@type": "PostalAddress",
        addressCountry: "IN",
      },
      aggregateRating: {
        "@type": "AggregateRating",
        ratingValue: "4.8",
        reviewCount: "1200",
      },
    }),
  }}
/>

       {/* ✅ Google Tag Manager (noscript) */}
        <noscript>
          <iframe
            src="https://www.googletagmanager.com/ns.html?id=GTM-M2QQJV42"
            height="0"
            width="0"
            style={{ display: "none", visibility: "hidden" }}
          />
        </noscript>

        <Providers>
          {/* ✅ FIX: Proper layout structure */}
          <div className="flex flex-col min-h-screen">

             <NavbarWrapper />

            {/* PAGE CONTENT */}
      
              <main className="flex-grow pt-[80px]">
              {children}
            </main>

            {/* FOOTER */}

            <OurPresence />

            <Footer />
          </div>
        </Providers>

        {/* ✅ Under Maintenance Dialog — shown on every page */}
        <UnderMaintenanceDialog />

        {/* ✅ KEEP YOUR EXISTING SCRIPTS (IMPORTANT) */}
        <TawkTo />

        <Script
          src="https://www.googletagmanager.com/gtag/js?id=G-1PXQS9E24Y"
          strategy="afterInteractive"
        />

        <Script id="google-analytics" strategy="afterInteractive">
          {`
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', 'G-1PXQS9E24Y');
          `}
        </Script>

      </body>
    </html>
  );
}