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

import '../../../../core/app_export.dart';

class StopAmenitiesWidget extends StatelessWidget {
  final Map<String, dynamic> amenitiesData;

  const StopAmenitiesWidget({
    super.key,
    required this.amenitiesData,
  });

  Widget _buildAmenityItem(
      BuildContext context, String iconName, String label, bool isAvailable) {
    final theme = Theme.of(context);

    return Column(
      children: [
        Container(
          width: 12.w,
          height: 6.h,
          decoration: BoxDecoration(
            color: isAvailable
                ? AppTheme.successGreen.withValues(alpha: 0.1)
                : theme.colorScheme.surface.withValues(alpha: 0.5),
            borderRadius: BorderRadius.circular(8),
            border: Border.all(
              color: isAvailable
                  ? AppTheme.successGreen.withValues(alpha: 0.3)
                  : theme.colorScheme.outline.withValues(alpha: 0.3),
              width: 1,
            ),
          ),
          child: Center(
            child: CustomIconWidget(
              iconName: iconName,
              color: isAvailable
                  ? AppTheme.successGreen
                  : theme.colorScheme.onSurface.withValues(alpha: 0.4),
              size: 24,
            ),
          ),
        ),
        SizedBox(height: 1.h),
        Text(
          label,
          style: theme.textTheme.labelSmall?.copyWith(
            color: isAvailable
                ? theme.colorScheme.onSurface
                : theme.colorScheme.onSurface.withValues(alpha: 0.5),
            fontWeight: FontWeight.w500,
          ),
          textAlign: TextAlign.center,
          overflow: TextOverflow.ellipsis,
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final hasShelter = amenitiesData['hasShelter'] as bool? ?? false;
    final hasBench = amenitiesData['hasBench'] as bool? ?? false;
    final isAccessible = amenitiesData['isAccessible'] as bool? ?? false;
    final hasLighting = amenitiesData['hasLighting'] as bool? ?? false;
    final hasTrashCan = amenitiesData['hasTrashCan'] as bool? ?? false;

    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(4.w),
      decoration: BoxDecoration(
        color: theme.colorScheme.surface,
        borderRadius: BorderRadius.circular(12),
        boxShadow: [
          BoxShadow(
            color: theme.shadowColor.withValues(alpha: 0.1),
            blurRadius: 8,
            offset: const Offset(0, 2),
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            'Comodidades de la parada',
            style: theme.textTheme.titleMedium?.copyWith(
              fontWeight: FontWeight.w600,
              color: theme.colorScheme.onSurface,
            ),
          ),
          SizedBox(height: 3.h),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Expanded(
                child: _buildAmenityItem(
                  context,
                  'home',
                  'Refugio',
                  hasShelter,
                ),
              ),
              Expanded(
                child: _buildAmenityItem(
                  context,
                  'chair',
                  'Asiento',
                  hasBench,
                ),
              ),
              Expanded(
                child: _buildAmenityItem(
                  context,
                  'accessible',
                  'Accesible',
                  isAccessible,
                ),
              ),
              Expanded(
                child: _buildAmenityItem(
                  context,
                  'lightbulb',
                  'Iluminación',
                  hasLighting,
                ),
              ),
              Expanded(
                child: _buildAmenityItem(
                  context,
                  'delete',
                  'Basura',
                  hasTrashCan,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
