import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
import 'package:sizer/sizer.dart';

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

  @override
  Widget build(BuildContext context) {
    final baseColor = Colors.grey[300]!;
    final highlightColor = Colors.grey[100]!;
    const backgroundColor = Color(0xFFF9FAFB);

    return Scaffold(
      backgroundColor: backgroundColor,
      body: Shimmer.fromColors(
        baseColor: baseColor,
        highlightColor: highlightColor,
        child: SingleChildScrollView(
          padding: EdgeInsets.fromLTRB(5.w, 3.h, 5.w, 5.h),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              _buildLabelPlaceholder(width: 25.w),
              SizedBox(height: 1.h),
              Container(
                width: 30.w,
                height: 30.w,
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(2.5.w),
                ),
              ),

              SizedBox(height: 4.h),
              _buildInputPlaceholder(labelWidth: 30.w),

              SizedBox(height: 3.h),
              _buildInputPlaceholder(labelWidth: 35.w),

              SizedBox(height: 3.h),
              _buildLabelPlaceholder(width: 25.w),
              SizedBox(height: 1.h),
              Row(
                children: [
                  Expanded(
                    child: _buildBlock(height: 7.h, borderRadius: 2.5.w),
                  ),
                  SizedBox(width: 4.w),
                  Expanded(
                    child: _buildBlock(height: 7.h, borderRadius: 2.5.w),
                  ),
                ],
              ),

              SizedBox(height: 3.h),
              _buildInputPlaceholder(labelWidth: 25.w),

              SizedBox(height: 3.h),
              _buildInputPlaceholder(labelWidth: 25.w),

              SizedBox(height: 3.h),
              _buildLabelPlaceholder(width: 25.w),
              SizedBox(height: 1.h),
              Row(
                children: [
                  Expanded(
                    child: _buildBlock(height: 7.h, borderRadius: 2.5.w),
                  ),
                  SizedBox(width: 4.w),
                  Expanded(
                    child: _buildBlock(height: 7.h, borderRadius: 2.5.w),
                  ),
                ],
              ),

              SizedBox(height: 3.h),
              _buildInputPlaceholder(labelWidth: 25.w),

              SizedBox(height: 5.h),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildLabelPlaceholder({required double width}) {
    return Container(
      width: width,
      height: 1.5.h,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(1.w),
      ),
    );
  }

  Widget _buildInputPlaceholder({required double labelWidth}) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        _buildLabelPlaceholder(width: labelWidth),
        SizedBox(height: 1.h),
        _buildBlock(height: 6.h, borderRadius: 2.5.w),
      ],
    );
  }

  Widget _buildBlock({required double height, required double borderRadius}) {
    return Container(
      width: double.infinity,
      height: height,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(borderRadius),
      ),
    );
  }
}
