import React from 'react';
import { StatusBar } from 'expo-status-bar';
import { Platform } from 'react-native';
import { ApolloProvider } from '@apollo/client';
import { Provider as PaperProvider, MD3DarkTheme, configureFonts } from 'react-native-paper';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { apolloClient } from './src/services/apollo-client';
import { AuthProvider } from './src/contexts/AuthContext';
import { AppNavigator } from './src/navigation/AppNavigator';

// Современная черно-серая тема
const theme = {
  ...MD3DarkTheme,
  colors: {
    ...MD3DarkTheme.colors,
    primary: '#ffffff',
    secondary: '#b3b3b3',
    tertiary: '#808080',
    background: '#0a0a0a',
    surface: '#1a1a1a',
    surfaceVariant: '#2d2d2d',
    onSurface: '#ffffff',
    onSurfaceVariant: '#e5e5e5',
    onPrimary: '#000000',
    elevation: {
      level0: 'transparent',
      level1: '#1a1a1a',
      level2: '#242424',
      level3: '#2e2e2e',
      level4: '#383838',
      level5: '#424242',
    },
    outline: '#666666',
    outlineVariant: '#4d4d4d',
    error: '#ff6b6b',
    inverseSurface: '#e6e6e6',
    inverseOnSurface: '#1a1a1a',
    inversePrimary: '#000000',
    backdrop: 'rgba(0, 0, 0, 0.8)',
    notification: '#ffffff',
    card: '#1a1a1a',
    text: '#ffffff',
    border: '#333333',
    placeholder: '#808080',
  },
  roundness: 16,
  fonts: configureFonts({
    customVariant: {
      fontFamily: Platform.select({
        ios: 'System',
        android: 'Roboto',
        default: 'sans-serif',
      }),
      fontWeight: '500',
      letterSpacing: 0.5,
    },
  }),
};

export default function App() {
  return (
    <SafeAreaProvider>
      <ApolloProvider client={apolloClient}>
        <PaperProvider theme={theme}>
          <AuthProvider>
            <AppNavigator />
            <StatusBar style="light" />
          </AuthProvider>
        </PaperProvider>
      </ApolloProvider>
    </SafeAreaProvider>
  );
}
