import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'core/app_colors.dart';
import 'services/auth_service.dart';
import 'services/route_simulator_service.dart';
import 'screens/splash_screen.dart';
import 'screens/login_screen.dart';
import 'screens/register_screen.dart';
import 'screens/citizen/citizen_home_screen.dart';
import 'screens/driver/driver_home_screen.dart';
import 'screens/admin/admin_dashboard_screen.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const CelayaLimpiaApp());
}

class CelayaLimpiaApp extends StatelessWidget {
  const CelayaLimpiaApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => AuthService()),
        ChangeNotifierProvider(create: (_) => RouteSimulatorService()),
      ],
      child: MaterialApp(
        title: 'Celaya Limpia',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          useMaterial3: true,
          colorScheme: ColorScheme.fromSeed(
            seedColor: AppColors.guindaPrimary,
            primary: AppColors.guindaPrimary,
            secondary: AppColors.dorado,
          ),
          inputDecorationTheme: const InputDecorationTheme(
            focusedBorder: OutlineInputBorder(
              borderSide: BorderSide(color: AppColors.guindaPrimary, width: 2),
            ),
            labelStyle: TextStyle(color: AppColors.guindaPrimary),
          ),
        ),
        initialRoute: '/splash',
        routes: {
          '/splash':   (_) => const SplashScreen(),
          '/login':    (_) => const LoginScreen(),
          '/register': (_) => const RegisterScreen(),
          '/home':     (_) => const CitizenHomeScreen(),
          '/driver':   (_) => const DriverHomeScreen(),
          '/admin':    (_) => const AdminDashboardScreen(),
        },
      ),
    );
  }
}
