import type { Metadata, Viewport } from 'next'

import { I18nProvider } from '@/components/providers/i18n-provider'
import { getI18n } from '@/lib/i18n/server'

import './globals.css'

export const metadata: Metadata = {
  title: {
    default: 'NABDH | نَبْض — Predict. Simulate. Prevent.',
    template: '%s · NABDH | نَبْض',
  },
  description:
    'NABDH is an AI platform that predicts risks on the electricity grid, simulates their impact before they happen, and recommends the preventive action.',
  applicationName: 'NABDH',
  // A prototype console with simulated data has no business appearing in search results.
  robots: { index: false, follow: false },
  icons: {
    icon: [{ url: '/icon.svg', type: 'image/svg+xml' }],
  },
}

export const viewport: Viewport = {
  themeColor: '#05080f',
  colorScheme: 'dark',
  width: 'device-width',
  initialScale: 1,
}

export default async function RootLayout({ children }: { children: React.ReactNode }) {
  const { locale, dir, messages } = await getI18n()

  return (
    <html lang={locale} dir={dir} suppressHydrationWarning>
      <body className="min-h-dvh bg-base text-text antialiased">
        <I18nProvider locale={locale} messages={messages} renderedAt={Date.now()}>
          {children}
        </I18nProvider>
      </body>
    </html>
  )
}
