import type { Metadata } from 'next';
import { Plus_Jakarta_Sans } from 'next/font/google';
import { HTML_LANG } from '@/i18n/config';
import { LocaleProvider } from '@/i18n/client';
import { getLocale } from '@/i18n/server';
import './globals.css';

const plusJakartaSans = Plus_Jakarta_Sans({
  subsets: ['latin'],
  display: 'swap',
  variable: '--font-jakarta',
});

const META = {
  id: {
    title: 'Aura+ | Platform Cetak Biru Pribadi & Penemuan Diri',
    description:
      'Kenali dirimu lebih dalam. Jelajahi energi, pola kelahiran, dan angka-angkamu lewat tiga perspektif: Aura + Cakra, BaZi, dan Numerologi.',
    og: 'id_ID',
  },
  en: {
    title: 'Aura+ | Personal Blueprint & Self-Discovery Platform',
    description:
      'Understand yourself on a deeper level. Explore your energy, birth pattern, and numbers through three perspectives: Aura + Chakra, BaZi, and Numerology.',
    og: 'en_US',
  },
  zh: {
    title: 'Aura+ | 个人生命蓝图与自我探索平台',
    description: '更深入地认识自己。通过气场与脉轮、八字和数字命理三个视角，探索你的能量、出生格局与生命数字。',
    og: 'zh_CN',
  },
};

export async function generateMetadata(): Promise<Metadata> {
  const m = META[await getLocale()];
  return {
    title: m.title,
    description: m.description,
    keywords: ['Aura', 'Chakra', 'BaZi', 'Numerology', 'Personal Blueprint', 'Self Discovery', 'Energy Profile'],
    authors: [{ name: 'Aura+ Team' }],
    openGraph: {
      title: m.title,
      description: m.description,
      url: 'https://aura-plus.app',
      siteName: 'Aura+',
      locale: m.og,
      type: 'website',
    },
  };
}

export default async function RootLayout({ children }: { children: React.ReactNode }) {
  const locale = await getLocale();
  return (
    <html lang={HTML_LANG[locale]} className={`${plusJakartaSans.variable} h-full antialiased`}>
      <body className="min-h-full flex flex-col font-sans">
        <LocaleProvider locale={locale}>{children}</LocaleProvider>
      </body>
    </html>
  );
}
