import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class AppColors {
  // Dark mode (default)
  static const Color darkBgPrimary = Color(0xFF12181F);
  static const Color darkBgSecondary = Color(0xFF1A222D);
  static const Color darkBgTertiary = Color(0xFF242F3E);
  static const Color darkTextPrimary = Color(0xFFF0F4F8);
  static const Color darkTextSecondary = Color(0xFF8B9BB4);
  static const Color darkBorder = Color(0xFF2D3B4E);

  // Light mode
  static const Color lightBgPrimary = Color(0xFFF3F4F6);
  static const Color lightBgSecondary = Color(0xFFFFFFFF);
  static const Color lightBgTertiary = Color(0xFFEDF2F7);
  static const Color lightTextPrimary = Color(0xFF1F2937);
  static const Color lightTextSecondary = Color(0xFF6B7280);
  static const Color lightBorder = Color(0xFFD1D5DB);

  // Common colors
  static const Color accent = Color(0xFF2563EB);
  static const Color accentHover = Color(0xFF3B82F6);
  static const Color danger = Color(0xFFDC2626);
  static const Color success = Color(0xFF16A34A);

  // Gradient colors for branding
  static const List<Color> darkGradient = [Color(0xFF60A5FA), Color(0xFF2563EB)];
  static const List<Color> lightGradient = [Color(0xFF1E40AF), Color(0xFF2563EB)];
}

ThemeData buildDarkTheme() {
  final base = ThemeData.dark();
  return base.copyWith(
    scaffoldBackgroundColor: AppColors.darkBgPrimary,
    colorScheme: const ColorScheme.dark(
      primary: AppColors.accent,
      secondary: AppColors.accentHover,
      surface: AppColors.darkBgSecondary,
      error: AppColors.danger,
    ),
    dividerColor: AppColors.darkBorder,
    cardColor: AppColors.darkBgTertiary,
    textTheme: GoogleFonts.outfitTextTheme(base.textTheme).copyWith(
      bodyLarge: const TextStyle(color: AppColors.darkTextPrimary),
      bodyMedium: const TextStyle(color: AppColors.darkTextSecondary),
      titleLarge: const TextStyle(
        color: AppColors.darkTextPrimary,
        fontWeight: FontWeight.bold,
      ),
    ),
    appBarTheme: const AppBarTheme(
      backgroundColor: AppColors.darkBgSecondary,
      foregroundColor: AppColors.darkTextPrimary,
      elevation: 0,
      shape: Border(
        bottom: BorderSide(color: AppColors.darkBorder, width: 1),
      ),
    ),
    buttonTheme: const ButtonThemeData(
      buttonColor: AppColors.accent,
      textTheme: ButtonTextTheme.primary,
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        backgroundColor: AppColors.accent,
        foregroundColor: Colors.white,
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(8),
        ),
        textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16),
      ),
    ),
    outlinedButtonTheme: OutlinedButtonThemeData(
      style: OutlinedButton.styleFrom(
        foregroundColor: AppColors.darkTextPrimary,
        side: const BorderSide(color: AppColors.darkBorder),
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(8),
        ),
      ),
    ),
  );
}

ThemeData buildLightTheme() {
  final base = ThemeData.light();
  return base.copyWith(
    scaffoldBackgroundColor: AppColors.lightBgPrimary,
    colorScheme: const ColorScheme.light(
      primary: AppColors.accent,
      secondary: AppColors.accentHover,
      surface: AppColors.lightBgSecondary,
      error: AppColors.danger,
    ),
    dividerColor: AppColors.lightBorder,
    cardColor: AppColors.lightBgTertiary,
    textTheme: GoogleFonts.outfitTextTheme(base.textTheme).copyWith(
      bodyLarge: const TextStyle(color: AppColors.lightTextPrimary),
      bodyMedium: const TextStyle(color: AppColors.lightTextSecondary),
      titleLarge: const TextStyle(
        color: AppColors.lightTextPrimary,
        fontWeight: FontWeight.bold,
      ),
    ),
    appBarTheme: const AppBarTheme(
      backgroundColor: AppColors.lightBgSecondary,
      foregroundColor: AppColors.lightTextPrimary,
      elevation: 0,
      shape: Border(
        bottom: BorderSide(color: AppColors.lightBorder, width: 1),
      ),
    ),
    elevatedButtonTheme: ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        backgroundColor: AppColors.accent,
        foregroundColor: Colors.white,
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(8),
        ),
        textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16),
      ),
    ),
    outlinedButtonTheme: OutlinedButtonThemeData(
      style: OutlinedButton.styleFrom(
        foregroundColor: AppColors.lightTextPrimary,
        side: const BorderSide(color: AppColors.lightBorder),
        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(8),
        ),
      ),
    ),
  );
}
