import type { ReactNode } from "react";
import type { Metadata } from "next";
import { Cairo, Geist } from "next/font/google";
import { getI18n } from "@/lib/i18n/server";
import { getTheme } from "@/lib/theme";
import "./globals.css";

const geist = Geist({ variable: "--font-geist-sans", subsets: ["latin"] });
const cairo = Cairo({ variable: "--font-arabic", subsets: ["arabic", "latin"] });

export async function generateMetadata(): Promise<Metadata> {
  const { t } = await getI18n();
  return {
    title: t("Absher operations"),
    description: t("Local operations dashboard for Absher."),
  };
}

export default async function RootLayout({ children }: { children: ReactNode }) {
  const [{ locale, dir }, theme] = await Promise.all([getI18n(), getTheme()]);
  return (
    <html lang={locale} dir={dir} className={`${geist.variable} ${cairo.variable} ${theme === "dark" ? "dark" : ""} h-full antialiased`}>
      <body className="min-h-full">{children}</body>
    </html>
  );
}
