import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'package:smart_hotel_app/views/report/rule/cubit/rule_management_state.dart';

class RuleCard extends StatelessWidget {
  final RuleInfo rule;
  final Function(String) onToggle;

  const RuleCard({
    super.key,
    required this.rule,
    required this.onToggle,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 24.h, horizontal: 28.w),
      decoration: BoxDecoration(
        color: Colors.white,
      ),
      child: Column(
        children: [
          Row(
            children: [
              Container(
                width: 72.w,
                height: 72.h,
                decoration: BoxDecoration(
                  color: const Color.fromRGBO(219, 234, 254, 1),
                  borderRadius: BorderRadius.circular(12.r),
                ),
                child: Icon(
                  rule.icon,
                  size: 36.sp,
                  color: const Color.fromRGBO(59, 130, 246, 1),
                ),
              ),
              SizedBox(width: 20.w),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      rule.name,
                      style: TextStyle(
                        fontSize: 32.sp,
                        fontWeight: FontWeight.bold,
                        color: const Color.fromRGBO(31, 41, 55, 1),
                      ),
                    ),
                    SizedBox(height: 8.h),
                    Text(
                      rule.description,
                      style: TextStyle(
                        fontSize: 26.sp,
                        color: const Color.fromRGBO(156, 163, 175, 1),
                      ),
                    ),
                  ],
                ),
              ),
              FlutterSwitch(
                width: 88.w,
                height: 48.h,
                valueFontSize: 20.sp,
                toggleSize: 40.h,
                value: rule.enabled,
                borderRadius: 24.r,
                padding: 4.w,
                activeColor: const Color.fromRGBO(59, 130, 246, 1),
                inactiveColor: const Color.fromRGBO(209, 213, 219, 1),
                onToggle: (_) => onToggle(rule.id),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
