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

/// Shimmer for horizontal appointment slider
class AppointmentSliderShimmer extends StatelessWidget {
  const AppointmentSliderShimmer({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 180,
      child: ListView.builder(
        scrollDirection: Axis.horizontal,
        itemCount: 3,
        padding: const EdgeInsets.symmetric(horizontal: 21),
        itemBuilder: (context, index) {
          return Shimmer.fromColors(
            baseColor: Colors.grey[300]!,
            highlightColor: Colors.grey[100]!,
            child: Container(
              width: MediaQuery.of(context).size.width * 0.85,
              margin: EdgeInsets.only(right: index < 2 ? 12 : 0),
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            ),
          );
        },
      ),
    );
  }
}

/// Shimmer for appointments list (vertical list of appointment cards)
class AppointmentsListShimmer extends StatelessWidget {
  final int itemCount;

  const AppointmentsListShimmer({super.key, this.itemCount = 5});

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300]!,
      highlightColor: Colors.grey[100]!,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 21),
        child: ListView.separated(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          itemCount: itemCount,
          separatorBuilder: (context, index) => const SizedBox(height: 12),
          itemBuilder: (context, index) {
            return Container(
              height: 140,
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            );
          },
        ),
      ),
    );
  }
}

/// Shimmer for branches list (vertical list of branch cards)
class BranchesListShimmer extends StatelessWidget {
  final int itemCount;

  const BranchesListShimmer({Key? key, this.itemCount = 5}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300]!,
      highlightColor: Colors.grey[100]!,
      child: Padding(
        padding: const EdgeInsets.all(12),
        child: ListView.separated(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          itemCount: itemCount,
          separatorBuilder: (context, index) => const SizedBox(height: 12),
          itemBuilder: (context, index) {
            return Container(
              height: 160,
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            );
          },
        ),
      ),
    );
  }
}

/// Shimmer for requests list (vertical list of request cards)
class RequestsListShimmer extends StatelessWidget {
  final int itemCount;

  const RequestsListShimmer({Key? key, this.itemCount = 5}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300]!,
      highlightColor: Colors.grey[100]!,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 21),
        child: ListView.separated(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          itemCount: itemCount,
          separatorBuilder: (context, index) => const SizedBox(height: 12),
          itemBuilder: (context, index) {
            return Container(
              height: 120,
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            );
          },
        ),
      ),
    );
  }
}

/// Shimmer for services grid (3 columns)
class ServicesGridShimmer extends StatelessWidget {
  const ServicesGridShimmer({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300]!,
      highlightColor: Colors.grey[100]!,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 21),
        child: GridView.builder(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 3,
            mainAxisSpacing: 12,
            crossAxisSpacing: 12,
            childAspectRatio: 0.9,
          ),
          itemCount: 6,
          itemBuilder: (context, index) {
            return Container(
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            );
          },
        ),
      ),
    );
  }
}

/// Shimmer for ads list
class AdsListShimmer extends StatelessWidget {
  final int itemCount;

  const AdsListShimmer({Key? key, this.itemCount = 3}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300]!,
      highlightColor: Colors.grey[100]!,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 21),
        child: ListView.separated(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          itemCount: itemCount,
          separatorBuilder: (context, index) => const SizedBox(height: 12),
          itemBuilder: (context, index) {
            return Container(
              height: 140,
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            );
          },
        ),
      ),
    );
  }
}

/// Shimmer for provider branches grid
class BranchesGridShimmer extends StatelessWidget {
  const BranchesGridShimmer({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300]!,
      highlightColor: Colors.grey[100]!,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 21),
        child: GridView.builder(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            mainAxisSpacing: 12,
            crossAxisSpacing: 12,
            childAspectRatio: 0.75,
          ),
          itemCount: 4,
          itemBuilder: (context, index) {
            return Container(
              decoration: const BoxDecoration(
                color: Colors.white,
              ),
            );
          },
        ),
      ),
    );
  }
}
