import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';

class CustomSelectableChip extends StatelessWidget {
  final String label;
  final bool selected;
  final VoidCallback? onTap;
  final Color activeColor;
  final Color activeTextColor;
  final Color inactiveBorderColor;
  final Color? inactiveTextColor;

  const CustomSelectableChip({
    super.key,
    required this.label,
    required this.selected,
    this.onTap,
    this.activeColor = const Color(0xFFD03C32), // red accent
    this.activeTextColor = Colors.white,
    this.inactiveBorderColor = const Color(0xFFE8E8E8),
    this.inactiveTextColor,
  });

  @override
  Widget build(BuildContext context) {
    final resolvedInactiveTextColor = inactiveTextColor ?? AppColors.textColor;
    final double radius = 8.0;
    return AnimatedContainer(
      duration: const Duration(milliseconds: 180),
      padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h),
      decoration: BoxDecoration(
        color: selected ? activeColor.withValues(alpha: 0.12) : AppColors.whiteColor,
        borderRadius: BorderRadius.circular(radius),
        border: Border.all(
          color: selected ? activeColor : inactiveBorderColor,
          width: 1,
        ),
      ),
      child: InkWell(
        borderRadius: BorderRadius.circular(radius),
        onTap: onTap,
        child: Text(
          label,
          style: TextStyle(
            fontSize: 12.f,
            fontWeight: FontWeight.w600,
            color: selected ? activeTextColor : resolvedInactiveTextColor,
            letterSpacing: -0.02 * 18,
            height: 1.0,
          ),
        ),
      ),
    );
  }
}
