import 'package:flutter/material.dart';

import 'font.dart';

/// Gaslieferung – Material 3 Theme (Light + Dark)
class AppTheme {
  // ---- LIGHT COLORSCHEME (aus deiner Palette) ----
  static const ColorScheme lightScheme = ColorScheme(
    brightness: Brightness.light,

    primary: Color(0xFFF7931E),
    onPrimary: Color(0xFFFFFFFF),
    primaryContainer: Color(0xFFFFD8A8),
    onPrimaryContainer: Color(0xFF4A2A00),

    secondary: Color(0xFF2F5DA8),
    onSecondary: Color(0xFFFFFFFF),
    secondaryContainer: Color(0xFFD6E3FF),
    onSecondaryContainer: Color(0xFF0B1D36),

    tertiary: Color(0xFF3FAE6A),
    onTertiary: Color(0xFFFFFFFF),
    tertiaryContainer: Color(0xFFCFF5DF),
    onTertiaryContainer: Color(0xFF0F3D24),

    error: Color(0xFFB3261E),
    onError: Color(0xFFFFFFFF),
    errorContainer: Color(0xFFF9DEDC),
    onErrorContainer: Color(0xFF410E0B),

    surface: Color(0xFFFFF8F2),
    onSurface: Color(0xFF1F1F1F),

    surfaceContainerHighest: Color(0xFFF2E6DA),
    onSurfaceVariant: Color(0xFF4A4A4A),

    outline: Color(0xFFC8BEB4),
    outlineVariant: Color(0xFFE1D6CC),

    shadow: Color(0xFF000000),
    scrim: Color(0xFF000000),

    inverseSurface: Color(0xFF34302D),
    onInverseSurface: Color(0xFFF7F1EC),
    inversePrimary: Color(0xFFFFB95C),
  );

  // ---- DARK COLORSCHEME (abgeleitet) ----
  static const ColorScheme darkScheme = ColorScheme(
    brightness: Brightness.dark,

    primary: Color(0xFFFFB95C),
    onPrimary: Color(0xFF3A1F00),
    primaryContainer: Color(0xFF5C3A00),
    onPrimaryContainer: Color(0xFFFFDDB3),

    secondary: Color(0xFF9FC1FF),
    onSecondary: Color(0xFF0B1D36),
    secondaryContainer: Color(0xFF1E3F73),
    onSecondaryContainer: Color(0xFFD6E3FF),

    tertiary: Color(0xFF7ED6A3),
    onTertiary: Color(0xFF00391F),
    tertiaryContainer: Color(0xFF1F4D33),
    onTertiaryContainer: Color(0xFFCFF5DF),

    error: Color(0xFFF2B8B5),
    onError: Color(0xFF601410),
    errorContainer: Color(0xFF8C1D18),
    onErrorContainer: Color(0xFFF9DEDC),

    background: Color(0xFF121212),
    onBackground: Color(0xFFE6E1DC),

    surface: Color(0xFF1C1B1A),
    onSurface: Color(0xFFE6E1DC),

    surfaceVariant: Color(0xFF3A2F25),
    onSurfaceVariant: Color(0xFFD6CFC7),

    outline: Color(0xFF8F857A),
    outlineVariant: Color(0xFF51463C),

    shadow: Color(0xFF000000),
    scrim: Color(0xFF000000),

    inverseSurface: Color(0xFFE6E1DC),
    onInverseSurface: Color(0xFF1C1B1A),
    inversePrimary: Color(0xFFF7931E),
  );

  static ThemeData light() => _theme(lightScheme);

  static ThemeData dark() => _theme(darkScheme);

  static ThemeData _theme(ColorScheme scheme) {
    return ThemeData(
      useMaterial3: true,
      colorScheme: scheme,
      fontFamily: "Inter",

      textTheme: AppTypography.interTextTheme(),

      // Optional: Schrift/Shapes minimal „MD3-like“
      scaffoldBackgroundColor: scheme.surface,
      appBarTheme: AppBarTheme(
        backgroundColor: scheme.primary,
        foregroundColor: scheme.onPrimary,
        elevation: 0,
      ),

      listTileTheme: ListTileThemeData(shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), iconColor: scheme.primary),
      //iconTheme: IconThemeData(color: scheme.primary),

      dropdownMenuTheme: DropdownMenuThemeData(
        inputDecorationTheme: InputDecorationTheme(
          // Falls du das Eingabefeld selbst auch abrunden willst:
          border: OutlineInputBorder(borderRadius: BorderRadius.circular(14)),
        ),
        menuStyle: MenuStyle(
          shape: WidgetStateProperty.all<OutlinedBorder>(
            RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(
                20,
              ), // Hier den gewünschten Radius für das Overlay
            ),
          ),
        ),
      ),

      // Buttons (M3)
      filledButtonTheme: FilledButtonThemeData(
        style: FilledButton.styleFrom(
          backgroundColor: scheme.primary,
          foregroundColor: scheme.onPrimary,
          minimumSize: const Size.fromHeight(52),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(14),
          ),
        ),
      ),
      elevatedButtonTheme: ElevatedButtonThemeData(
        style: ElevatedButton.styleFrom(
          minimumSize: const Size.fromHeight(52),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(14),
          ),
        ),
      ),
      outlinedButtonTheme: OutlinedButtonThemeData(
        style: OutlinedButton.styleFrom(
          minimumSize: const Size.fromHeight(52),
          foregroundColor: scheme.primary,
          side: BorderSide(color: scheme.outline),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(14),
          ),
        ),
      ),

      // Inputs
      inputDecorationTheme: InputDecorationTheme(
        filled: true,
        fillColor: scheme.surfaceVariant,
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(14),
          borderSide: BorderSide.none,
        ),
      ),

      // Cards
      cardTheme: CardThemeData(
        color: scheme.surface,
        elevation: 1,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
      ),
    );
  }
}
