import { AppProviders } from "@/providers/app-providers";
import { GoogleAnalytics } from "@/components/google-analytics";
import { PwaRegister } from "@/components/pwa-register";
import type { Metadata, Viewport } from "next";
import { Vazirmatn } from "next/font/google";
import "./globals.css";

const vazirmatn = Vazirmatn({
  variable: "--font-vazirmatn",
  subsets: ["arabic"],
});

const appDescription =
  "اپلیکیشن فارسی برنامه‌ریزی، پیگیری عادت، مدیریت اهداف و وظایف";

export const metadata: Metadata = {
  metadataBase: new URL(process.env.NEXT_PUBLIC_SITE_URL ?? "https://nextgoal.app"),
  title: {
    default: "Next Goal",
    template: "%s | Next Goal",
  },
  description: appDescription,
  applicationName: "Next Goal",
  appleWebApp: {
    capable: true,
    statusBarStyle: "default",
    title: "Next Goal",
  },
  icons: {
    icon: [
      { url: "/pwa/launchericon-48x48.png", sizes: "48x48", type: "image/png" },
      { url: "/pwa/launchericon-96x96.png", sizes: "96x96", type: "image/png" },
      { url: "/pwa/launchericon-192x192.png", sizes: "192x192", type: "image/png" },
    ],
    apple: [
      { url: "/pwa/launchericon-192x192.png", sizes: "192x192", type: "image/png" },
    ],
  },
};

export const viewport: Viewport = {
  themeColor: [
    { media: "(prefers-color-scheme: light)", color: "#f2994a" },
    { media: "(prefers-color-scheme: dark)", color: "#f2994a" },
  ],
};

export default function RootLayout({ children }: LayoutProps<"/">) {
  return (
    <html
      lang="fa"
      dir="rtl"
      suppressHydrationWarning
      className={`${vazirmatn.variable} h-full antialiased`}
    >
      <body className="min-h-full flex flex-col bg-background text-foreground">
        <GoogleAnalytics />
        <PwaRegister />
        <AppProviders>{children}</AppProviders>
      </body>
    </html>
  );
}
