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

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

class MapControlsWidget extends StatelessWidget {
  final VoidCallback onLocationPressed;
  final VoidCallback onZoomIn;
  final VoidCallback onZoomOut;
  final bool isLocationEnabled;

  const MapControlsWidget({
    super.key,
    required this.onLocationPressed,
    required this.onZoomIn,
    required this.onZoomOut,
    this.isLocationEnabled = true,
  });

  @override
  Widget build(BuildContext context) {
    return Positioned(
      right: 4.w,
      bottom: 25.h,
      child: Column(
        children: [
          // Zoom In Button
          _buildControlButton(
            icon: 'add',
            onPressed: () {
              HapticFeedback.lightImpact();
              onZoomIn();
            },
            tooltip: 'Acercar',
          ),

          SizedBox(height: 1.h),

          // Zoom Out Button
          _buildControlButton(
            icon: 'remove',
            onPressed: () {
              HapticFeedback.lightImpact();
              onZoomOut();
            },
            tooltip: 'Alejar',
          ),

          SizedBox(height: 2.h),

          // Location Button
          _buildControlButton(
            icon: 'my_location',
            onPressed: isLocationEnabled
                ? () {
                    HapticFeedback.mediumImpact();
                    onLocationPressed();
                  }
                : null,
            tooltip: 'Mi ubicación',
            isLocationButton: true,
            isEnabled: isLocationEnabled,
          ),
        ],
      ),
    );
  }

  Widget _buildControlButton({
    required String icon,
    required VoidCallback? onPressed,
    required String tooltip,
    bool isLocationButton = false,
    bool isEnabled = true,
  }) {
    return Container(
      width: 12.w,
      height: 12.w,
      decoration: BoxDecoration(
        color: isEnabled
            ? AppTheme.lightTheme.colorScheme.surface
            : AppTheme.lightTheme.colorScheme.surface.withValues(alpha: 0.7),
        borderRadius: BorderRadius.circular(8),
        boxShadow: [
          BoxShadow(
            color: AppTheme.primaryBlack.withValues(alpha: 0.1),
            blurRadius: 4,
            offset: const Offset(0, 2),
          ),
        ],
      ),
      child: Material(
        color: Colors.transparent,
        child: InkWell(
          onTap: onPressed,
          borderRadius: BorderRadius.circular(8),
          child: Center(
            child: CustomIconWidget(
              iconName: icon,
              color: isEnabled
                  ? (isLocationButton
                      ? AppTheme.accentYellow
                      : AppTheme.primaryBlack)
                  : AppTheme.textSecondary,
              size: 24,
            ),
          ),
        ),
      ),
    );
  }
}
