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

class DeviceOverviewCard extends StatelessWidget {
  final String deviceName;
  final String deviceType;
  final String deviceStatus;
  final String deviceModel;
  final String installLocation;
  final String area;
  final String responsiblePerson;
  final String lastInspectionTime;
  final IconData icon;

  const DeviceOverviewCard({
    super.key,
    required this.deviceName,
    required this.deviceType,
    required this.deviceStatus,
    required this.deviceModel,
    required this.installLocation,
    required this.area,
    required this.responsiblePerson,
    required this.lastInspectionTime,
    required this.icon,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(20.r),
      ),
      padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 24.h),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              Container(
                width: 100.w,
                height: 100.h,
                decoration: BoxDecoration(
                  color: const Color.fromRGBO(235, 244, 255, 1.0),
                  shape: BoxShape.circle,
                ),
                child: Icon(
                  icon,
                  color: const Color.fromRGBO(66, 165, 245, 1.0),
                  size: 50.sp,
                ),
              ),
              SizedBox(width: 20.w),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      deviceName,
                      style: TextStyle(
                        fontSize: 36.sp,
                        fontWeight: FontWeight.bold,
                        color: const Color.fromRGBO(10, 13, 20, 1.0),
                      ),
                    ),
                    SizedBox(height: 12.h),
                    Text(
                      deviceType,
                      style: TextStyle(
                        fontSize: 28.sp,
                        color: const Color.fromRGBO(100, 116, 139, 1.0),
                      ),
                    ),
                    SizedBox(height: 16.h),
                    Container(
                      padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 10.h),
                      decoration: BoxDecoration(
                        color: const Color.fromRGBO(225, 245, 238, 1.0),
                        borderRadius: BorderRadius.circular(20.r),
                      ),
                      child: Text(
                        deviceStatus,
                        style: TextStyle(
                          fontSize: 28.sp,
                          color: const Color.fromRGBO(26, 188, 156, 1.0),
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
          SizedBox(height: 32.h),
          Text(
            '基本信息',
            style: TextStyle(
              fontSize: 32.sp,
              fontWeight: FontWeight.bold,
              color: const Color.fromRGBO(10, 13, 20, 1.0),
            ),
          ),
          SizedBox(height: 24.h),
          _buildInfoItem('设备型号', deviceModel),
          SizedBox(height: 24.h),
          _buildInfoItem('安装位置', installLocation),
          SizedBox(height: 24.h),
          _buildInfoItem('所属区域', area),
          SizedBox(height: 24.h),
          _buildInfoItem('责任人', responsiblePerson),
          SizedBox(height: 24.h),
          _buildInfoItem('最后巡检', lastInspectionTime),
        ],
      ),
    );
  }

  Widget _buildInfoItem(String label, String value) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text(
          label,
          style: TextStyle(
            fontSize: 28.sp,
            color: const Color.fromRGBO(100, 116, 139, 1.0),
          ),
        ),
        Text(
          value,
          style: TextStyle(
            fontSize: 28.sp,
            color: const Color.fromRGBO(100, 116, 139, 1.0),
          ),
        ),
      ],
    );
  }
}
