import type { Metadata } from "next";
import Script from "next/script";
import "../../styles/globals.css";
import { I18nProvider } from "@/lib/i18n/context";
import { siteUrl } from "@/lib/seo/site";

const title = "ScanReceipts | Instant AI Receipt Scanner to Excel & Sheets";
const description =
  "Scan receipts & invoices in seconds with AI precision. Automatic math validation, itemized extraction, and 1-click export to Excel (.xlsx) or a plain CSV.";

export const metadata: Metadata = {
  // Required for Open Graph/canonical URLs to resolve absolutely.
  metadataBase: new URL(siteUrl),
  title,
  description,
  keywords: [
    "scan receipts",
    "scan a receipt app",
    "receipt scanner",
    "ocr receipt scanner",
    "scan receipts into excel",
    "receipt spreadsheet",
    "kassenbon scanner",
    "receipt to excel",
    "spesen erfassen",
    "receipts to excel",
  ],
  icons: {
    icon: "/icon.png",
    apple: "/apple-icon.png",
  },
  openGraph: {
    type: "website",
    siteName: "ScanReceipts",
    title,
    description,
    images: [{ url: "/icon.png", width: 512, height: 512, alt: "ScanReceipts" }],
  },
  twitter: {
    card: "summary_large_image",
    title,
    description,
    images: ["/icon.png"],
  },
  robots: {
    index: true,
    follow: true,
    googleBot: { index: true, follow: true, "max-image-preview": "large" },
  },
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en" className="scroll-smooth">
      <body className="min-h-screen bg-[#F6F9FF] text-[#161C22] font-sans antialiased selection:bg-[#161C22] selection:text-white">
        <I18nProvider>{children}</I18nProvider>
        {process.env.NEXT_PUBLIC_UMAMI_SRC && process.env.NEXT_PUBLIC_UMAMI_ID && (
          <Script
            defer
            src={process.env.NEXT_PUBLIC_UMAMI_SRC}
            data-website-id={process.env.NEXT_PUBLIC_UMAMI_ID}
            strategy="afterInteractive"
          />
        )}
      </body>
    </html>
  );
}
