import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/models/bo/room_bo.dart';

class StatusStats extends StatelessWidget {
  final RoomOverviewSummaryBO summary;

  const StatusStats({super.key, required this.summary});

  @override
  Widget build(BuildContext context) {
    final items = [
      _StatItemData(label: '入住', count: summary.occupiedCount, color: const Color.fromRGBO(73, 149, 234, 1)),
      _StatItemData(label: '空闲', count: summary.vacantCount, color: const Color.fromRGBO(100, 116, 139, 1)),
      _StatItemData(label: '预定', count: summary.reservedCount, color: const Color.fromRGBO(139, 193, 255, 1)),
      _StatItemData(label: '告警', count: summary.alarmCount, color: const Color.fromRGBO(250, 204, 21, 1)),
    ];

    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(28.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(24.r),
      ),
      child: Row(
        spacing: 10.w,
        children: items.map((item) => _StatItem(item: item)).toList(),
      ),
    );
  }
}

class _StatItemData {
  final String label;
  final int count;
  final Color color;
  const _StatItemData({required this.label, required this.count, required this.color});
}

class _StatItem extends StatelessWidget {
  final _StatItemData item;

  const _StatItem({required this.item});

  @override
  Widget build(BuildContext context) {
    return Expanded(
        child: Container(
          padding: EdgeInsets.symmetric(vertical: 12.h, horizontal: 8.w),
          decoration: BoxDecoration(
            color: const Color.fromRGBO(238, 238, 238, 1),
            borderRadius: BorderRadius.circular(24.r),
          ),
          child: Column(
            children: [
              Text(
                item.count.toString(),
                style: TextStyle(
                  fontSize: 40.sp,
                  fontWeight: FontWeight.w600,
                  color: item.color,
                ),
              ),
              SizedBox(height: 4.h),
              Text(
                item.label,
                style: TextStyle(
                  fontSize: 24.sp,
                  color: const Color.fromRGBO(100, 116, 139, 1),
                ),
              ),
            ],
          ),
        )
    );
  }
}
