import 'package:flutter/material.dart';

/// Static definitions of color palettes and semantic colors for the Staff Design System.
/// Values are defined in design_tokens_react.md.
class UiColors {
  UiColors._();

  // ---------------------------------------------------------------------------
  // 1. Base Tokens
  // ---------------------------------------------------------------------------
  
  /// Background color (#FAFBFC)
  static const Color background = Color(0xFFFAFBFC);

  /// Foreground color (#121826)
  static const Color foreground = Color(0xFF121826);
  
  /// Primary brand color blue (#0A39DF)
  static const Color primary = Color(0xFF0A39DF);

  /// Foreground color on primary background (#F7FAFC)
  static const Color primaryForeground = Color(0xFFF7FAFC);

  /// Inverse primary color (#9FABF1)
  static const Color primaryInverse = Color(0xFF9FABF1);
  
  /// Secondary background color (#F1F3F5)
  static const Color secondary = Color(0xFFF1F3F5);

  /// Foreground color on secondary background (#121826)
  static const Color secondaryForeground = Color(0xFF121826);
  
  /// Muted background color (#F1F3F5)
  static const Color muted = Color(0xFFF1F3F5);

  /// Muted foreground color (#6A7382)
  static const Color mutedForeground = Color(0xFF6A7382);
  
  /// Accent yellow color (#F9E547)
  static const Color accent = Color(0xFFF9E547);

  /// Foreground color on accent background (#4C460D)
  static const Color accentForeground = Color(0xFF4C460D);
  
  /// Destructive red color (#F04444)
  static const Color destructive = Color(0xFFF04444);

  /// Foreground color on destructive background (#FAFAFA)
  static const Color destructiveForeground = Color(0xFFFAFAFA);
  
  /// Default border color (#D1D5DB)
  static const Color border = Color(0xFFD1D5DB);

  /// Default input border color (#E7EAEE)
  static const Color input = Color(0xFFF5F6F8);

  /// Focus ring color (#0A39DF)
  static const Color ring = Color(0xFF0A39DF);

  // ---------------------------------------------------------------------------
  // 2. Semantic Mappings
  // ---------------------------------------------------------------------------

  // --- Background Colors ---

  /// Primary background (#FAFBFC)
  static const Color bgPrimary = background;

  /// Secondary background (#F1F3F5)
  static const Color bgSecondary = secondary;

  /// Tertiary background (#EDF0F2)
  static const Color bgThird = Color(0xFFEDF0F2);

  /// Popup background (#FFFFFF)
  static const Color bgPopup = Color(0xFFFFFFFF);

  /// Highlighted background (#FEF9C3)
  static const Color bgHighlight = Color(0xFFFEF9C3);

  /// Menu background (#F8FAFC)
  static const Color bgMenu = Color(0xFFF8FAFC);

  /// Banner background (#FFFFFF)
  static const Color bgBanner = Color(0xFFFFFFFF);

  /// Overlay background (#000000 with 50% opacity)
  static const Color bgOverlay = Color(0x80000000);

  /// Toast background (#121826)
  static const Color toastBg = Color(0xFF121826);

  /// Input field background (#E3E6E9)
  static const Color bgInputField = input;

  /// Footer banner background (#F1F5F9)
  static const Color bgFooterBanner = Color(0xFFF1F5F9);
  
  // --- Text Colors ---

  /// Primary text (#121826)
  static const Color textPrimary = foreground;

  /// Secondary text (#6A7382)
  static const Color textSecondary = mutedForeground;

  /// Inactive text (#9CA3AF)
  static const Color textInactive = Color(0xFF9CA3AF);

  /// Placeholder text (#9CA3AF)
  static const Color textPlaceholder = Color(0xFF9CA3AF);

  /// Description text (#6A7382)
  static const Color textDescription = mutedForeground;

  /// Success text (#10B981)
  static const Color textSuccess = Color(0xFF10B981);

  /// Error text (#F04444)
  static const Color textError = destructive;

  /// Deep error text for containers (#450A0A)
  static const Color textErrorContainer = Color(0xFF450A0A);

  /// Warning text (#D97706)
  static const Color textWarning = Color(0xFFD97706);

  /// Link text (#0A39DF)
  static const Color textLink = primary;

  /// Filter text (#4B5563)
  static const Color textFilter = Color(0xFF4B5563);

  // --- Icon Colors ---

  /// Primary icon (#121826)
  static const Color iconPrimary = foreground;

  /// Secondary icon (#6A7382)
  static const Color iconSecondary = mutedForeground;

  /// Tertiary icon (#9CA3AF)
  static const Color iconThird = Color(0xFF9CA3AF);

  /// Inactive icon (#D1D5DB)
  static const Color iconInactive = Color(0xFFD1D5DB);

  /// Active icon (#0A39DF)
  static const Color iconActive = primary;

  /// Success icon (#10B981)
  static const Color iconSuccess = Color(0xFF10B981);

  /// Error icon (#F04444)
  static const Color iconError = destructive;

  // --- Loader Colors ---

  /// Active loader (#0A39DF)
  static const Color loaderActive = primary;

  /// Inactive loader (#E2E8F0)
  static const Color loaderInactive = Color(0xFFE2E8F0);

  // --- Pin Input Colors ---

  /// Unfilled pin (#E2E8F0)
  static const Color pinUnfilled = Color(0xFFE2E8F0);

  /// Active pin (#0A39DF)
  static const Color pinActive = primary;

  /// Inactive pin (#94A3B8)
  static const Color pinInactive = Color(0xFF94A3B8);

  // --- Separator Colors ---

  /// Primary separator (#E3E6E9)
  static const Color separatorPrimary = border;

  /// Secondary separator (#F1F5F9)
  static const Color separatorSecondary = Color(0xFFF1F5F9);

  /// Special separator (#F9E547)
  static const Color separatorSpecial = accent;

  // --- Tag Colors ---

  /// Default tag background (#F1F5F9)
  static const Color tagValue = Color(0xFFF1F5F9);

  /// Pending state tag background (#FEF3C7)
  static const Color tagPending = Color(0xFFFEF3C7);

  /// In-progress state tag background (#DBEAFE)
  static const Color tagInProgress = Color(0xFFDBEAFE);

  /// Error state tag background (#FEE2E2)
  static const Color tagError = Color(0xFFFEE2E2);

  /// Active state tag background (#DCFCE7)
  static const Color tagActive = Color(0xFFDCFCE7);

  /// Frozen state tag background (#F3F4F6)
  static const Color tagFreeze = Color(0xFFF3F4F6);

  /// Success state tag background (#DCFCE7)
  static const Color tagSuccess = Color(0xFFDCFCE7);

  /// Refunded state tag background (#E0E7FF)
  static const Color tagRefunded = Color(0xFFE0E7FF);

  // --- Border Colors ---

  /// Static border (#D1D5DB)
  static const Color borderStill = border;

  /// Primary border (#D1D5DB)
  static const Color borderPrimary = border;

  /// Error border (#F04444)
  static const Color borderError = destructive;

  /// Focus border (#0A39DF)
  static const Color borderFocus = ring;

  /// Inactive border (#F1F5F9)
  static const Color borderInactive = Color(0xFFF1F5F9);

  // --- Button Colors ---

  /// Primary button default (#0A39DF)
  static const Color buttonPrimaryStill = primary;

  /// Primary button hover (#082EB2)
  static const Color buttonPrimaryHover = Color(0xFF082EB2);

  /// Primary button inactive (#F1F3F5)
  static const Color buttonPrimaryInactive = secondary;
  
  /// Secondary button default (#F1F3F5)
  static const Color buttonSecondaryStill = secondary;

  /// Secondary button hover (#E2E8F0)
  static const Color buttonSecondaryHover = Color(0xFFE2E8F0);

  /// Secondary button inactive (#F3F4F6)
  static const Color buttonSecondaryInactive = Color(0xFFF3F4F6);

  /// Button inactive state (#94A3B8)
  static const Color buttonInactive = Color(0xFF94A3B8);

  /// Pin button background (#F8FAFC)
  static const Color pinButtonBackground = Color(0xFFF8FAFC);

  // --- Switch Colors ---

  /// Switch active state (#10B981)
  static const Color switchActive = Color(0xFF10B981);

  /// Switch inactive state (#CBD5E1)
  static const Color switchInactive = Color(0xFFCBD5E1);

  /// Switch dot inactive state (#FFFFFF)
  static const Color dotInactive = Color(0xFFFFFFFF);

  // --- Basic Colors ---

  /// Standard white (#FFFFFF)
  static const Color white = Color(0xFFFFFFFF);

  /// Standard black (#000000)
  static const Color black = Color(0xFF000000);

  /// Transparent color (0x00000000)
  static const Color transparent = Color(0x00000000);

  /// Card background (#FFFFFF)
  static const Color cardViewBackground = Color(0xFFFFFFFF);

  // --- Shadows ---

  /// Primary popup shadow (#000000 with 10% opacity)
  static const Color popupShadow = Color(0x1A000000);

  // ---------------------------------------------------------------------------
  // 3. ColorScheme
  // ---------------------------------------------------------------------------

  /// Generates a ColorScheme based on the tokens.
  static ColorScheme get colorScheme => const ColorScheme(
        brightness: Brightness.light,
        primary: primary,
        onPrimary: primaryForeground,
        primaryContainer: tagRefunded,
        onPrimaryContainer: primary,
        secondary: secondary,
        onSecondary: secondaryForeground,
        secondaryContainer: muted,
        onSecondaryContainer: secondaryForeground,
        tertiary: accent,
        onTertiary: accentForeground,
        tertiaryContainer: bgHighlight,
        onTertiaryContainer: accentForeground,
        error: destructive,
        onError: destructiveForeground,
        errorContainer: tagError,
        onErrorContainer: textErrorContainer,
        surface: background,
        onSurface: foreground,
        surfaceContainerHighest: muted,
        onSurfaceVariant: mutedForeground,
        outline: border,
        outlineVariant: separatorSecondary,
        shadow: black,
        scrim: black,
        inverseSurface: foreground,
        onInverseSurface: background,
        inversePrimary: primaryInverse,
        surfaceTint: primary,
      );
}
