import 'package:flutter/material.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:sizer/sizer.dart';

class SubMenuCard extends StatelessWidget {
  final String title;
  final String subtitle;
  final IconData icon;
  final VoidCallback onTap;
  final int? badgeCount;
  const SubMenuCard({
    super.key,
    required this.title,
    required this.subtitle,
    required this.icon,
    required this.onTap,
    this.badgeCount,
  });

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w >= 600;
    return Container(
      margin: EdgeInsets.only(bottom: 2.h),
      child: Material(
        color: Colors.white,
        borderRadius: BorderRadius.circular(3.w),
        child: InkWell(
          onTap: onTap,
          borderRadius: BorderRadius.circular(3.w),
          child: Container(
            padding: EdgeInsets.all(4.w),
            decoration: BoxDecoration(
              border: Border.all(color: Colors.grey.shade200),
              borderRadius: BorderRadius.circular(3.w),
            ),
            child: Row(
              children: [
                Icon(icon, color: AppColor.primaryColor, size: 6.w),
                SizedBox(width: 4.w),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        title,
                        style: TextStyle(
                          fontWeight: FontWeight.bold,
                          fontSize:
                              (AppFontSize.medium - (isTablet ? 0 : 1.25)).sp,
                          color: Colors.black87,
                        ),
                      ),
                      Text(
                        subtitle,
                        style: TextStyle(
                          fontSize:
                              (AppFontSize.small - (isTablet ? 0 : 1.25)).sp,
                          color: Colors.grey.shade600,
                        ),
                      ),
                    ],
                  ),
                ),
                if (badgeCount != null)
                  CircleAvatar(
                    radius: 2.5.w,
                    backgroundColor: Colors.red,
                    child: Text(
                      badgeCount.toString(),
                      style: TextStyle(
                        color: Colors.white,
                        fontSize:
                            ((isTablet
                                        ? AppFontSize.medium
                                        : AppFontSize.small) -
                                    1.25)
                                .sp,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                Icon(
                  Icons.chevron_right,
                  color: Colors.grey.shade400,
                  size: 5.w,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
