import type React from "react"
import type { Metadata, Viewport } from "next"
import { Analytics } from "@vercel/analytics/next"
import "./globals.css"
import { PlayerProvider } from "@/components/player-provider"
import { UserProvider } from "@/components/user-provider"
import { AuthProvider } from "@/components/auth-provider"
import { GlobalMiniPlayer } from "@/components/global-mini-player"
import { HistorySync } from "@/components/history-sync"
import { PWAProvider } from "@/components/pwa-provider"
import { ThemeProvider } from "@/components/theme-provider"
import { OfflineIndicator } from "@/components/offline-indicator"

export const metadata: Metadata = {
  title: "African Music Pact - Plateforme de Musique Africaine",
  description: "Decouvrez et ecoutez la meilleure musique africaine partout, meme hors ligne. Streaming, videos, artistes africains.",
  generator: "v0.app",
  manifest: "/manifest.json",
  keywords: ["musique africaine", "afrobeats", "streaming", "african music", "artistes africains"],
  authors: [{ name: "African Music Pact" }],
  openGraph: {
    title: "African Music Pact",
    description: "La plateforme de streaming dediee a la musique africaine",
    type: "website",
    locale: "fr_FR",
  },
  twitter: {
    card: "summary_large_image",
    title: "African Music Pact",
    description: "La plateforme de streaming dediee a la musique africaine",
  },
  appleWebApp: {
    capable: true,
    statusBarStyle: "black-translucent",
    title: "African Music Pact",
  },
  formatDetection: {
    telephone: false,
  },
  icons: {
    icon: [
      { url: "/icons/icon-192x192.jpg", sizes: "192x192", type: "image/png" },
      { url: "/icons/icon-512x512.jpg", sizes: "512x512", type: "image/png" },
    ],
    apple: [
      { url: "/icons/icon-152x152.jpg", sizes: "152x152", type: "image/png" },
      { url: "/icons/icon-192x192.jpg", sizes: "192x192", type: "image/png" },
    ],
  },
}

export const viewport: Viewport = {
  themeColor: "#a855f7",
  width: "device-width",
  initialScale: 1,
  maximumScale: 1,
  userScalable: false,
  viewportFit: "cover",
}

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode
}>) {
  return (
    <html lang="fr" suppressHydrationWarning>
      <head>
        <link rel="apple-touch-icon" href="/icons/icon-192x192.jpg" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
        <meta name="mobile-web-app-capable" content="yes" />
      </head>
      <body className="font-sans antialiased">
        <ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
          <AuthProvider>
            <UserProvider>
              <PlayerProvider>
                <PWAProvider>
                  <OfflineIndicator />
                  <HistorySync />
                  {children}
                  <GlobalMiniPlayer />
                </PWAProvider>
              </PlayerProvider>
            </UserProvider>
          </AuthProvider>
        </ThemeProvider>
        <Analytics />
      </body>
    </html>
  )
}
