import 'package:flutter/material.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:lasertag_app/l10n/app_localizations.dart';
import 'ui/screens/device_selection_screen.dart';

void main() {
  runApp(const LasertagApp());
}

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

  @override
  Widget build(BuildContext context) {
    // Der Builder holt die Systemfarben (Accent Color)
    return DynamicColorBuilder(
      builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          
          // --- Lokalisierung ---
          localizationsDelegates: const [
            AppLocalizations.delegate,
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          supportedLocales: const [Locale('de')],
          locale: const Locale('de'),

          // --- Theme-Logik ---
          // Falls das OS Farben liefert, nutzen wir diese, sonst ein Standard-Blau
          theme: ThemeData(
            colorScheme: lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.blue),
            useMaterial3: true,
          ),
          darkTheme: ThemeData(
            colorScheme: darkDynamic ?? ColorScheme.fromSeed(
              seedColor: Colors.blue, 
              brightness: Brightness.dark
            ),
            useMaterial3: true,
          ),
          themeMode: ThemeMode.system, // Folgt macOS/Android Hell/Dunkel Modus

          home: DeviceSelectionScreen(),
        );
      },
    );
  }
}