import { AuthProvider } from '@/components/AuthProvider';
import QueryProvider from '@/components/QueryProvider';
import { ThemeProvider } from '@/components/ThemeContext';
import { useNotifications } from '@/hooks/useNotifications';
import i18n from '@/i18n/i18n';
import { ProfileDataProvider } from '@/screens/profile/lib/ProfileDataContext';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { I18nextProvider } from 'react-i18next';
import 'react-native-reanimated';
import { SafeAreaView } from 'react-native-safe-area-context';
import ToastManager from "toastify-react-native";

function AppContent() {
  useNotifications();

  return (
    <SafeAreaView style={{ flex: 1, backgroundColor: "#000" }}>
      <StatusBar style='light' backgroundColor='#000' />
      <Stack screenOptions={{ headerShown: false }} />
    </SafeAreaView>
  );
}

export default function RootLayout() {
  return (
    <I18nextProvider i18n={i18n}>
      <QueryProvider>
        <ThemeProvider>
          <ProfileDataProvider>
            <AuthProvider>
              <AppContent />
              <ToastManager />
            </AuthProvider>
          </ProfileDataProvider>
        </ThemeProvider>
      </QueryProvider>
    </I18nextProvider>
  );
}
