import type { Metadata } from 'next'
import './globals.css'
import { LangProvider } from '@/context/LangContext'
import { siteConfig } from '@/lib/site'

export const metadata: Metadata = {
  metadataBase: new URL(siteConfig.domain),
  title: {
    default: 'GreenLens - Plant Identifier and Care Planner',
    template: '%s | GreenLens',
  },
  description:
    'GreenLens helps you identify plants, organize your collection, and keep up with care routines in one app.',
  keywords: [
    'plant identifier by picture',
    'plant care app',
    'watering reminders',
    'houseplant tracker',
    'plant identification',
    'plant health check',
    'Pflanzen App',
    'GreenLens',
  ],
  authors: [{ name: siteConfig.name }],
  openGraph: {
    title: 'GreenLens - Plant Identifier and Care Planner',
    description: 'Identify plants, get care guidance, and manage your collection with GreenLens.',
    type: 'website',
    url: siteConfig.domain,
  },
  alternates: {
    canonical: '/',
    languages: {
      de: '/',
      en: '/',
      es: '/',
      'x-default': '/',
    },
  },
}

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="de">
      <head>
        <link rel="preconnect" href="https://fonts.googleapis.com" />
        <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
        <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{
            __html: JSON.stringify({
              '@context': 'https://schema.org',
              '@type': 'SoftwareApplication',
              name: siteConfig.name,
              operatingSystem: 'iOS, Android',
              applicationCategory: 'LifestyleApplication',
              offers: {
                '@type': 'Offer',
                price: '0',
                priceCurrency: 'EUR',
              },
            }),
          }}
        />
      </head>
      <body>
        <LangProvider>{children}</LangProvider>
      </body>
    </html>
  )
}
