import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class StatusLegendWidget extends StatelessWidget {
  const StatusLegendWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16.r),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '状态图例',
            style: TextStyle(
              fontSize: 28.sp,
              fontWeight: FontWeight.w600,
              color: const Color.fromRGBO(15, 23, 42, 1),
            ),
          ),
          SizedBox(height: 24.h),
          Wrap(
            spacing: 32.w,
            runSpacing: 20.h,
            children: [
              _buildLegendItem(const Color.fromRGBO(59, 130, 246, 1), '开启'),
              _buildLegendItem(const Color.fromRGBO(226, 232, 240, 1), '关闭'),
              _buildLegendItem(const Color.fromRGBO(16, 185, 129, 1), '在线'),
              _buildLegendItem(const Color.fromRGBO(71, 85, 105, 1), '离线'),
              _buildLegendItem(const Color.fromRGBO(251, 191, 36, 1), '告警'),
              _buildLegendItem(const Color.fromRGBO(239, 68, 68, 1), '故障'),
            ],
          ),
        ],
      ),
    );
  }

  Widget _buildLegendItem(Color color, String label) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Container(
          width: 32.w,
          height: 32.h,
          decoration: BoxDecoration(
            color: color,
            shape: BoxShape.circle,
          ),
        ),
        SizedBox(width: 12.w),
        Text(
          label,
          style: TextStyle(
            fontSize: 24.sp,
            color: const Color.fromRGBO(71, 85, 105, 1),
          ),
        ),
      ],
    );
  }
}
