import 'package:flutter/material.dart';

abstract class AppColors {
  // Base colors
  static const colorPrimary = Color(0xFF677169);
  static const colorSecondary = Color(0xffF0EAE2);
  static const colorBackground = Color(0xFFFFFFFF);

  // Text colors
  static const colorPrimaryText = Color(0xFF000000);
  static const colorSecondaryText = Color(0xFF000000);
  static const colorOnPrimaryTextColor = Color(0xFFFFFFFF);

  // System / semantic colors
  static const colorPrimarySystem = Color(0xFF000000);
  static const colorSecondarySystem = Color.fromARGB(237, 227, 216, 1);
  static const colorTertiary = Color(0xFF000000);
  static const colorTertiaryText = Color(0xFF000000);
  static const colorTertiarySystem = Color(0xFF000000);

  static const colorShadow = Color(0xFF000000);
  static const colorDivider = Color(0xFFE0E0E0);
  static const disabledButtonColor = Color(0xFFF0F0F0);

  static const error = Color(0xFFEB0026);

  // Greys used by components
  static const secondaryText = Color(0xFF888888);
  static const disabledText = Color(0xFFCCCCCC);

  // Material palettes
  static const colorBlack = MaterialColor(0xFF000000, {
    75: Color(0xB3000000),
    65: Color(0xA6000000),
  });

  static const int _earthColor = 0xFF677169;
  static const earthColor = MaterialColor(_earthColor, <int, Color>{
    100: Color(_earthColor),
    80: Color.fromRGBO(128, 139, 130, 1.0),
    60: Color.fromRGBO(160, 171, 163, 1.0),
    40: Color.fromRGBO(192, 200, 194, 1.0),
    20: Color.fromRGBO(227, 230, 227, 1.0),
    10: Color.fromRGBO(238, 239, 238, 1.0),
  });

  static const int _sandColor = 0xFFAA8D65;
  static const sandColor = MaterialColor(_sandColor, <int, Color>{
    100: Color(_sandColor),
    80: Color.fromRGBO(190, 161, 121, 1.0),
    60: Color.fromRGBO(215, 201, 185, 1.0),
    40: Color.fromRGBO(237, 227, 216, 1.0),
    20: Color.fromRGBO(240, 234, 226, 1.0),
    10: Color.fromRGBO(249, 246, 242, 1.0),
  });

  /// Maps backend "theme" strings to a palette.
  /// Accepts both older lowercase values and newer uppercase values.
  static MaterialColor fromTheme(String theme) {
    final t = theme.trim().toUpperCase();
    return switch (t) {
      'EARTH' || 'EARTH_COLOR' => earthColor,
      'SAND' || 'SAND_COLOR' => sandColor,
      _ => earthColor,
    };
  }
}

extension CustomColors on ColorScheme {
  Color get secondaryText => AppColors.secondaryText;
  Color get disabledText => AppColors.disabledText;
}