import 'package:flutter/material.dart';

class UIConstants {
  // Spacing
  static const double spacing4 = 4.0;
  static const double spacing6 = 6.0;

  static const double spacing8 = 8.0;
  static const double spacing12 = 12.0;
  static const double spacing14 = 14.0;

  static const double spacing16 = 16.0;
  static const double spacing18 = 18.0;

  static const double spacing20 = 20.0;
  static const double spacing24 = 24.0;
  static const double spacing32 = 32.0;
  static const double spacing40 = 40.0;
  static const double spacing48 = 48.0;
  static const double spacing56 = 56.0;
  static const double spacing64 = 64.0;
  static const double spacing72 = 72.0;
  static const double spacing80 = 80.0;
  static const double spacing96 = 96.0;

  // Border Radius
  static const double radius4 = 4.0;
  static const double radius8 = 8.0;
  static const double radius12 = 12.0;
  static const double radius16 = 16.0;
  static const double radius20 = 20.0;
  static const double radius24 = 24.0;
  static const double radius32 = 32.0;
  static const double radius40 = 40.0;
  static const double radiusFull = 999.0;

  // Elevation
  static const double elevation0 = 0.0;
  static const double elevation1 = 1.0;
  static const double elevation2 = 2.0;
  static const double elevation4 = 4.0;
  static const double elevation8 = 8.0;
  static const double elevation16 = 16.0;
  static const double elevation24 = 24.0;

  // Animation Durations
  static const Duration durationFast = Duration(milliseconds: 150);
  static const Duration durationNormal = Duration(milliseconds: 300);
  static const Duration durationSlow = Duration(milliseconds: 500);
  static const Duration durationVerySlow = Duration(milliseconds: 800);

  // Animation Curves
  static const Curve curveFast = Curves.easeInOut;
  static const Curve curveNormal = Curves.easeInOutCubic;
  static const Curve curveSlow = Curves.easeInOutQuart;
  static const Curve curveBounce = Curves.bounceOut;
  static const Curve curveElastic = Curves.elasticOut;

  // Screen Breakpoints
  static const double mobileBreakpoint = 600.0;
  static const double tabletBreakpoint = 900.0;
  static const double desktopBreakpoint = 1200.0;

  // Input Field Heights
  static const double inputHeightSmall = 40.0;
  static const double inputHeightMedium = 48.0;
  static const double inputHeightLarge = 56.0;

  // Button Heights
  static const double buttonHeightSmall = 36.0;
  static const double buttonHeightMedium = 48.0;
  static const double buttonHeightLarge = 56.0;

  // Icon Sizes
  static const double iconSizeSmall = 16.0;
  static const double iconSizeMedium = 24.0;
  static const double iconSizeLarge = 32.0;
  static const double iconSizeXLarge = 48.0;

  // Logo Sizes
  static const double logoSizeSmall = 32.0;
  static const double logoSizeMedium = 48.0;
  static const double logoSizeLarge = 64.0;
  static const double logoSizeXLarge = 96.0;

  // Card Padding
  static const EdgeInsets cardPaddingSmall = EdgeInsets.all(spacing12);
  static const EdgeInsets cardPaddingMedium = EdgeInsets.all(spacing16);
  static const EdgeInsets cardPaddingLarge = EdgeInsets.all(spacing24);

  // Screen Padding
  static const EdgeInsets screenPaddingSmall = EdgeInsets.all(spacing16);
  static const EdgeInsets screenPaddingMedium = EdgeInsets.all(spacing24);
  static const EdgeInsets screenPaddingLarge = EdgeInsets.all(spacing32);

  // Horizontal Padding
  static const EdgeInsets horizontalPaddingSmall =
      EdgeInsets.symmetric(horizontal: spacing16);
  static const EdgeInsets horizontalPaddingMedium =
      EdgeInsets.symmetric(horizontal: spacing24);
  static const EdgeInsets horizontalPaddingLarge =
      EdgeInsets.symmetric(horizontal: spacing32);

  // Vertical Padding
  static const EdgeInsets verticalPaddingSmall =
      EdgeInsets.symmetric(vertical: spacing16);
  static const EdgeInsets verticalPaddingMedium =
      EdgeInsets.symmetric(vertical: spacing24);
  static const EdgeInsets verticalPaddingLarge =
      EdgeInsets.symmetric(vertical: spacing32);

  // Responsive Helpers
  static bool isMobile(BuildContext context) {
    return MediaQuery.of(context).size.width < mobileBreakpoint;
  }

  static bool isTablet(BuildContext context) {
    final width = MediaQuery.of(context).size.width;
    return width >= mobileBreakpoint && width < tabletBreakpoint;
  }

  static bool isDesktop(BuildContext context) {
    return MediaQuery.of(context).size.width >= desktopBreakpoint;
  }

  static double getResponsiveValue(
    BuildContext context, {
    required double mobile,
    required double tablet,
    required double desktop,
  }) {
    if (isMobile(context)) return mobile;
    if (isTablet(context)) return tablet;
    return desktop;
  }

  static int getResponsiveInt(
    BuildContext context, {
    required int mobile,
    required int tablet,
    required int desktop,
  }) {
    if (isMobile(context)) return mobile;
    if (isTablet(context)) return tablet;
    return desktop;
  }

  static EdgeInsets getResponsivePadding(
    BuildContext context, {
    required EdgeInsets mobile,
    required EdgeInsets tablet,
    required EdgeInsets desktop,
  }) {
    if (isMobile(context)) return mobile;
    if (isTablet(context)) return tablet;
    return desktop;
  }

  static double getResponsiveSpacing(
    BuildContext context, {
    required double mobile,
    required double tablet,
    required double desktop,
  }) {
    if (isMobile(context)) return mobile;
    if (isTablet(context)) return tablet;
    return desktop;
  }

  // Animation Helpers
  static Widget fadeIn({
    required Widget child,
    Duration duration = durationNormal,
    Curve curve = curveNormal,
  }) {
    return TweenAnimationBuilder<double>(
      duration: duration,
      curve: curve,
      tween: Tween(begin: 0.0, end: 1.0),
      builder: (context, value, child) {
        return Opacity(
          opacity: value,
          child: child,
        );
      },
      child: child,
    );
  }

  static Widget slideInUp({
    required Widget child,
    Duration duration = durationNormal,
    Curve curve = curveNormal,
    double offset = 50.0,
  }) {
    return TweenAnimationBuilder<Offset>(
      duration: duration,
      curve: curve,
      tween: Tween(begin: Offset(0, offset), end: Offset.zero),
      builder: (context, value, child) {
        return Transform.translate(
          offset: value,
          child: child,
        );
      },
      child: child,
    );
  }

  static Widget scaleIn({
    required Widget child,
    Duration duration = durationNormal,
    Curve curve = curveNormal,
    double beginScale = 0.8,
  }) {
    return TweenAnimationBuilder<double>(
      duration: duration,
      curve: curve,
      tween: Tween(begin: beginScale, end: 1.0),
      builder: (context, value, child) {
        return Transform.scale(
          scale: value,
          child: child,
        );
      },
      child: child,
    );
  }
}
