import 'package:flutter/material.dart';
import '../core/app_colors.dart';
import '../core/app_theme.dart';

class AppCard extends StatelessWidget {
  final Widget child;
  final EdgeInsetsGeometry? padding;
  final EdgeInsetsGeometry? margin;
  final VoidCallback? onTap;
  final Color? backgroundColor;
  final BorderRadius? borderRadius;
  final Border? border;

  const AppCard({
    super.key,
    required this.child,
    this.padding = const EdgeInsets.all(AppTheme.sLg),
    this.margin,
    this.onTap,
    this.backgroundColor,
    this.borderRadius,
    this.border,
  });

  @override
  Widget build(BuildContext context) {
    final radius = borderRadius ?? BorderRadius.circular(AppTheme.rLg);
    final card = Container(
      margin:
          margin ??
          const EdgeInsets.symmetric(
            horizontal: AppTheme.sLg,
            vertical: AppTheme.sSm,
          ),
      padding: padding,
      decoration: BoxDecoration(
        gradient: backgroundColor == null ? AppColors.surfaceGradient : null,
        color: backgroundColor,
        borderRadius: radius,
        border: border ?? Border.all(color: AppColors.borderLight),
        boxShadow: AppColors.cardShadowLight,
      ),
      child: child,
    );

    if (onTap == null) return card;
    return InkWell(onTap: onTap, borderRadius: radius, child: card);
  }
}
