import React from 'react';
import {
  Wifi,
  Tv,
  Wind,
  Coffee,
  Utensils,
  Car,
  Dumbbell,
  Waves,
  UtensilsCrossed,
  Shield,
  Cigarette,
  Bath,
  Home,
  Bed,
  Sofa,
  Key,
  Phone,
  Zap,
  Gamepad2,
  Music,
  Sparkles,
  Flame,
  Lock,
  Heart,
  MapPin,
  Building,
  Users,
  Laptop,
  Smartphone,
  Monitor,
  Headphones,
  UtensilsCrossed as Restaurant,
  Briefcase,
  Printer,
  Clock,
  Sunrise,
  Moon,
  Eye,
  Ear,
  Accessibility,
  Baby as BabyIcon,
  PawPrint,
  Radio as RadioIcon,
  Flame as Fireplace,
} from 'lucide-react';

interface RoomAmenitiesProps {
  amenities: string[];
}

const RoomAmenities: React.FC<RoomAmenitiesProps> = ({ 
  amenities 
}) => {
  const normalizeAmenities = (input: unknown): string[] => {
    if (Array.isArray(input)) return input;
    if (!input) return [];
    if (typeof input === 'string') {
      
      try {
        const parsed = JSON.parse(input);
        if (Array.isArray(parsed)) return parsed;
      } catch {
        // Silently fail if JSON parsing fails - will fall back to comma-separated parsing
      }

      
      return input
        .split(',')
        .map((s) => s.trim())
        .filter(Boolean);
    }

    
    if (typeof input === 'object') {
      try {
        
        const vals = Object.values(input);
        if (Array.isArray(vals) && vals.length > 0) {
          
          return vals.flat().map((v: unknown) => String(v).trim()).filter(Boolean);
        }
      } catch {
        // Silently fail if JSON parsing fails - will fall back to comma-separated parsing
      }
    }

    return [];
  };

  const safeAmenities = normalizeAmenities(amenities);

  
  const amenityIcons: Record<string, React.ReactNode> = {
    
    wifi: <Wifi className="w-5 h-5" />,
    'wi-fi': <Wifi className="w-5 h-5" />,
    'free wifi': <Wifi className="w-5 h-5" />,
    'wifi in room': <Wifi className="w-5 h-5" />,
    'high-speed internet': <Wifi className="w-5 h-5" />,
    
    
    tv: <Tv className="w-5 h-5" />,
    television: <Tv className="w-5 h-5" />,
    'flat-screen tv': <Tv className="w-5 h-5" />,
    'cable tv': <Tv className="w-5 h-5" />,
    'satellite tv': <Tv className="w-5 h-5" />,
    'smart tv': <Tv className="w-5 h-5" />,
    netflix: <Tv className="w-5 h-5" />,
    'streaming services': <Tv className="w-5 h-5" />,
    'dvd player': <Monitor className="w-5 h-5" />,
    'stereo system': <Music className="w-5 h-5" />,
    radio: <RadioIcon className="w-5 h-5" />,
    'ipod dock': <Smartphone className="w-5 h-5" />,
    'blu-ray player': <Monitor className="w-5 h-5" />,
    'gaming console': <Gamepad2 className="w-5 h-5" />,
    playstation: <Gamepad2 className="w-5 h-5" />,
    xbox: <Gamepad2 className="w-5 h-5" />,
    'sound system': <Headphones className="w-5 h-5" />,
    'surround sound': <Headphones className="w-5 h-5" />,
    'music system': <Music className="w-5 h-5" />,
    
    
    'air-conditioning': <Wind className="w-5 h-5" />,
    'air conditioning': <Wind className="w-5 h-5" />,
    ac: <Wind className="w-5 h-5" />,
    heating: <Flame className="w-5 h-5" />,
    'climate control': <Wind className="w-5 h-5" />,
    'ceiling fan': <Wind className="w-5 h-5" />,
    'air purifier': <Wind className="w-5 h-5" />,
    
    
    'private bathroom': <Bath className="w-5 h-5" />,
    'ensuite bathroom': <Bath className="w-5 h-5" />,
    bathtub: <Bath className="w-5 h-5" />,
    'jacuzzi bathtub': <Bath className="w-5 h-5" />,
    'hot tub': <Waves className="w-5 h-5" />,
    shower: <Bath className="w-5 h-5" />,
    'rain shower': <Bath className="w-5 h-5" />,
    'walk-in shower': <Bath className="w-5 h-5" />,
    'steam shower': <Bath className="w-5 h-5" />,
    bidet: <Bath className="w-5 h-5" />,
    'hair dryer': <Sparkles className="w-5 h-5" />,
    hairdryer: <Sparkles className="w-5 h-5" />,
    bathrobes: <Bath className="w-5 h-5" />,
    slippers: <Bath className="w-5 h-5" />,
    toiletries: <Bath className="w-5 h-5" />,
    'premium toiletries': <Bath className="w-5 h-5" />,
    towels: <Bath className="w-5 h-5" />,
    
    
    'mini bar': <Coffee className="w-5 h-5" />,
    minibar: <Coffee className="w-5 h-5" />,
    refrigerator: <Coffee className="w-5 h-5" />,
    fridge: <Coffee className="w-5 h-5" />,
    microwave: <Coffee className="w-5 h-5" />,
    'coffee maker': <Coffee className="w-5 h-5" />,
    'electric kettle': <Coffee className="w-5 h-5" />,
    kettle: <Coffee className="w-5 h-5" />,
    'tea making facilities': <Coffee className="w-5 h-5" />,
    'coffee machine': <Coffee className="w-5 h-5" />,
    'nespresso machine': <Coffee className="w-5 h-5" />,
    kitchenette: <Utensils className="w-5 h-5" />,
    'dining table': <Utensils className="w-5 h-5" />,
    'room service': <UtensilsCrossed className="w-5 h-5" />,
    'breakfast included': <Coffee className="w-5 h-5" />,
    breakfast: <Coffee className="w-5 h-5" />,
    'complimentary water': <Coffee className="w-5 h-5" />,
    'bottled water': <Coffee className="w-5 h-5" />,
    
    
    desk: <Briefcase className="w-5 h-5" />,
    'writing desk': <Briefcase className="w-5 h-5" />,
    'office desk': <Briefcase className="w-5 h-5" />,
    'work desk': <Briefcase className="w-5 h-5" />,
    sofa: <Sofa className="w-5 h-5" />,
    'sitting area': <Sofa className="w-5 h-5" />,
    'lounge area': <Sofa className="w-5 h-5" />,
    'dining area': <Utensils className="w-5 h-5" />,
    'separate living area': <Home className="w-5 h-5" />,
    wardrobe: <Home className="w-5 h-5" />,
    closet: <Home className="w-5 h-5" />,
    dresser: <Home className="w-5 h-5" />,
    mirror: <Sparkles className="w-5 h-5" />,
    'full-length mirror': <Sparkles className="w-5 h-5" />,
    'seating area': <Sofa className="w-5 h-5" />,
    
    
    'king size bed': <Bed className="w-5 h-5" />,
    'queen size bed': <Bed className="w-5 h-5" />,
    'double bed': <Bed className="w-5 h-5" />,
    'twin beds': <Bed className="w-5 h-5" />,
    'single bed': <Bed className="w-5 h-5" />,
    'extra bedding': <Bed className="w-5 h-5" />,
    'pillow menu': <Bed className="w-5 h-5" />,
    'premium bedding': <Bed className="w-5 h-5" />,
    'blackout curtains': <Moon className="w-5 h-5" />,
    soundproofing: <Shield className="w-5 h-5" />,
    
    
    safe: <Shield className="w-5 h-5" />,
    'in-room safe': <Shield className="w-5 h-5" />,
    'safety deposit box': <Shield className="w-5 h-5" />,
    'smoke detector': <Shield className="w-5 h-5" />,
    'fire extinguisher': <Flame className="w-5 h-5" />,
    'security system': <Shield className="w-5 h-5" />,
    'key card access': <Key className="w-5 h-5" />,
    'door lock': <Lock className="w-5 h-5" />,
    
    
    'usb charging ports': <Zap className="w-5 h-5" />,
    'usb ports': <Zap className="w-5 h-5" />,
    'usb outlets': <Zap className="w-5 h-5" />,
    'power outlets': <Zap className="w-5 h-5" />,
    'charging station': <Zap className="w-5 h-5" />,
    'laptop safe': <Laptop className="w-5 h-5" />,
    'hdmi port': <Monitor className="w-5 h-5" />,
    phone: <Phone className="w-5 h-5" />,
    'desk phone': <Phone className="w-5 h-5" />,
    'wake-up service': <Sunrise className="w-5 h-5" />,
    'alarm clock': <Clock className="w-5 h-5" />,
    'digital clock': <Clock className="w-5 h-5" />,
    
    
    balcony: <MapPin className="w-5 h-5" />,
    'private balcony': <MapPin className="w-5 h-5" />,
    terrace: <MapPin className="w-5 h-5" />,
    patio: <MapPin className="w-5 h-5" />,
    'city view': <MapPin className="w-5 h-5" />,
    'ocean view': <Waves className="w-5 h-5" />,
    'sea view': <Waves className="w-5 h-5" />,
    'mountain view': <MapPin className="w-5 h-5" />,
    'garden view': <MapPin className="w-5 h-5" />,
    'pool view': <Waves className="w-5 h-5" />,
    'park view': <MapPin className="w-5 h-5" />,
    window: <Eye className="w-5 h-5" />,
    'large windows': <Eye className="w-5 h-5" />,
    'floor-to-ceiling windows': <Eye className="w-5 h-5" />,
    
    
    '24-hour front desk': <Building className="w-5 h-5" />,
    '24 hour front desk': <Building className="w-5 h-5" />,
    '24/7 front desk': <Building className="w-5 h-5" />,
    'front desk': <Building className="w-5 h-5" />,
    'concierge service': <Users className="w-5 h-5" />,
    'butler service': <Users className="w-5 h-5" />,
    butler: <Users className="w-5 h-5" />,
    housekeeping: <Home className="w-5 h-5" />,
    'daily housekeeping': <Home className="w-5 h-5" />,
    'turndown service': <Moon className="w-5 h-5" />,
    'laundry service': <Home className="w-5 h-5" />,
    laundry: <Home className="w-5 h-5" />,
    'dry cleaning': <Home className="w-5 h-5" />,
    'ironing service': <Sparkles className="w-5 h-5" />,
    'luggage storage': <Home className="w-5 h-5" />,
    'bell service': <Shield className="w-5 h-5" />,
    'valet parking': <Car className="w-5 h-5" />,
    parking: <Car className="w-5 h-5" />,
    'free parking': <Car className="w-5 h-5" />,
    'airport shuttle': <Car className="w-5 h-5" />,
    'shuttle service': <Car className="w-5 h-5" />,
    shuttle: <Car className="w-5 h-5" />,
    'car rental': <Car className="w-5 h-5" />,
    'taxi service': <Car className="w-5 h-5" />,
    
    
    'gym access': <Dumbbell className="w-5 h-5" />,
    'fitness center': <Dumbbell className="w-5 h-5" />,
    'fitness room': <Dumbbell className="w-5 h-5" />,
    gym: <Dumbbell className="w-5 h-5" />,
    fitness: <Dumbbell className="w-5 h-5" />,
    'spa access': <Waves className="w-5 h-5" />,
    spa: <Waves className="w-5 h-5" />,
    sauna: <Waves className="w-5 h-5" />,
    'steam room': <Waves className="w-5 h-5" />,
    'massage service': <Heart className="w-5 h-5" />,
    'beauty services': <Sparkles className="w-5 h-5" />,
    
    
    'swimming pool': <Waves className="w-5 h-5" />,
    pool: <Waves className="w-5 h-5" />,
    'indoor pool': <Waves className="w-5 h-5" />,
    'outdoor pool': <Waves className="w-5 h-5" />,
    'infinity pool': <Waves className="w-5 h-5" />,
    'pool access': <Waves className="w-5 h-5" />,
    'golf course': <Car className="w-5 h-5" />,
    'tennis court': <Dumbbell className="w-5 h-5" />,
    'beach access': <Waves className="w-5 h-5" />,
    'water sports': <Waves className="w-5 h-5" />,
    
    
    'business center': <Briefcase className="w-5 h-5" />,
    'meeting room': <Briefcase className="w-5 h-5" />,
    'conference room': <Briefcase className="w-5 h-5" />,
    'fax service': <Printer className="w-5 h-5" />,
    photocopying: <Printer className="w-5 h-5" />,
    'printing service': <Printer className="w-5 h-5" />,
    'secretarial services': <Briefcase className="w-5 h-5" />,
    
    
    'wheelchair accessible': <Accessibility className="w-5 h-5" />,
    'accessible room': <Accessibility className="w-5 h-5" />,
    'elevator access': <Accessibility className="w-5 h-5" />,
    'ramp access': <Accessibility className="w-5 h-5" />,
    'accessible bathroom': <Accessibility className="w-5 h-5" />,
    'lowered sink': <Accessibility className="w-5 h-5" />,
    'grab bars': <Accessibility className="w-5 h-5" />,
    'hearing accessible': <Ear className="w-5 h-5" />,
    'visual alarm': <Eye className="w-5 h-5" />,
    
    
    'family room': <Users className="w-5 h-5" />,
    'kids welcome': <BabyIcon className="w-5 h-5" />,
    'baby crib': <BabyIcon className="w-5 h-5" />,
    crib: <BabyIcon className="w-5 h-5" />,
    'extra bed': <Bed className="w-5 h-5" />,
    'childcare services': <BabyIcon className="w-5 h-5" />,
    'pets allowed': <PawPrint className="w-5 h-5" />,
    pets: <PawPrint className="w-5 h-5" />,
    'pet friendly': <PawPrint className="w-5 h-5" />,
    
    
    'smoking room': <Cigarette className="w-5 h-5" />,
    'non-smoking room': <Shield className="w-5 h-5" />,
    'no smoking': <Cigarette className="w-5 h-5" />,
    'interconnecting rooms': <Home className="w-5 h-5" />,
    'adjoining rooms': <Home className="w-5 h-5" />,
    suite: <Home className="w-5 h-5" />,
    'separate bedroom': <Bed className="w-5 h-5" />,
    kitchen: <Utensils className="w-5 h-5" />,
    'full kitchen': <Utensils className="w-5 h-5" />,
    dishwasher: <Utensils className="w-5 h-5" />,
    oven: <Flame className="w-5 h-5" />,
    stove: <Flame className="w-5 h-5" />,
    'washing machine': <Home className="w-5 h-5" />,
    dryer: <Home className="w-5 h-5" />,
    iron: <Sparkles className="w-5 h-5" />,
    'ironing board': <Sparkles className="w-5 h-5" />,
    'clothes rack': <Home className="w-5 h-5" />,
    umbrella: <Home className="w-5 h-5" />,
    'shoe shine service': <Sparkles className="w-5 h-5" />,
    
    
    fireplace: <Fireplace className="w-5 h-5" />,
    jacuzzi: <Waves className="w-5 h-5" />,
    'spa bath': <Bath className="w-5 h-5" />,
    'bidet toilet': <Bath className="w-5 h-5" />,
    'smart home system': <Home className="w-5 h-5" />,
    'lighting control': <Zap className="w-5 h-5" />,
    'curtain control': <Eye className="w-5 h-5" />,
    'automated systems': <Zap className="w-5 h-5" />,
    'personalized service': <Users className="w-5 h-5" />,
    'vip treatment': <Sparkles className="w-5 h-5" />,
    'private entrance': <Key className="w-5 h-5" />,
    'private elevator': <Building className="w-5 h-5" />,
    'panic button': <Shield className="w-5 h-5" />,
    
    
    restaurant: <Restaurant className="w-5 h-5" />,
    
    
    library: <Briefcase className="w-5 h-5" />,
    'reading room': <Briefcase className="w-5 h-5" />,
    'study room': <Briefcase className="w-5 h-5" />,
    'private pool': <Waves className="w-5 h-5" />,
    'private garden': <MapPin className="w-5 h-5" />,
    yard: <MapPin className="w-5 h-5" />,
    courtyard: <MapPin className="w-5 h-5" />,
    'outdoor furniture': <Sofa className="w-5 h-5" />,
    'bbq facilities': <Flame className="w-5 h-5" />,
    'picnic area': <Utensils className="w-5 h-5" />,
  };

  const amenityLabels: Record<string, string> = {
    
    wifi: 'Wi‑Fi',
    'wi-fi': 'Wi‑Fi',
    'free wifi': 'Free WiFi',
    'wifi in room': 'WiFi in Room',
    'high-speed internet': 'High-Speed Internet',
    
    
    tv: 'TV',
    television: 'TV',
    'flat-screen tv': 'Flat-Screen TV',
    'cable tv': 'Cable TV',
    'satellite tv': 'Satellite TV',
    'smart tv': 'Smart TV',
    netflix: 'Netflix',
    'streaming services': 'Streaming Services',
    'dvd player': 'DVD Player',
    'stereo system': 'Stereo System',
    radio: 'Radio',
    'ipod dock': 'iPod Dock',
    'blu-ray player': 'Blu-ray Player',
    'gaming console': 'Gaming Console',
    playstation: 'PlayStation',
    xbox: 'Xbox',
    'sound system': 'Sound System',
    'surround sound': 'Surround Sound',
    'music system': 'Music System',
    
    
    'air-conditioning': 'Air Conditioning',
    'air conditioning': 'Air Conditioning',
    ac: 'Air Conditioning',
    heating: 'Heating',
    'climate control': 'Climate Control',
    'ceiling fan': 'Ceiling Fan',
    'air purifier': 'Air Purifier',
    
    
    'private bathroom': 'Private Bathroom',
    'ensuite bathroom': 'Ensuite Bathroom',
    bathtub: 'Bathtub',
    'jacuzzi bathtub': 'Jacuzzi Bathtub',
    'hot tub': 'Hot Tub',
    shower: 'Shower',
    'rain shower': 'Rain Shower',
    'walk-in shower': 'Walk-in Shower',
    'steam shower': 'Steam Shower',
    bidet: 'Bidet',
    'hair dryer': 'Hair Dryer',
    hairdryer: 'Hair Dryer',
    bathrobes: 'Bathrobes',
    slippers: 'Slippers',
    toiletries: 'Toiletries',
    'premium toiletries': 'Premium Toiletries',
    towels: 'Towels',
    
    
    'mini bar': 'Mini Bar',
    minibar: 'Mini Bar',
    refrigerator: 'Refrigerator',
    fridge: 'Refrigerator',
    microwave: 'Microwave',
    'coffee maker': 'Coffee Maker',
    'electric kettle': 'Electric Kettle',
    kettle: 'Electric Kettle',
    'tea making facilities': 'Tea Making Facilities',
    'coffee machine': 'Coffee Machine',
    'nespresso machine': 'Nespresso Machine',
    kitchenette: 'Kitchenette',
    'dining table': 'Dining Table',
    'room service': 'Room Service',
    'breakfast included': 'Breakfast Included',
    breakfast: 'Breakfast Included',
    'complimentary water': 'Complimentary Water',
    'bottled water': 'Bottled Water',
    
    
    desk: 'Desk',
    'writing desk': 'Writing Desk',
    'office desk': 'Office Desk',
    'work desk': 'Work Desk',
    sofa: 'Sofa',
    'sitting area': 'Sitting Area',
    'lounge area': 'Lounge Area',
    'dining area': 'Dining Area',
    'separate living area': 'Separate Living Area',
    wardrobe: 'Wardrobe',
    closet: 'Closet',
    dresser: 'Dresser',
    mirror: 'Mirror',
    'full-length mirror': 'Full-Length Mirror',
    'seating area': 'Seating Area',
    
    
    'king size bed': 'King Size Bed',
    'queen size bed': 'Queen Size Bed',
    'double bed': 'Double Bed',
    'twin beds': 'Twin Beds',
    'single bed': 'Single Bed',
    'extra bedding': 'Extra Bedding',
    'pillow menu': 'Pillow Menu',
    'premium bedding': 'Premium Bedding',
    'blackout curtains': 'Blackout Curtains',
    soundproofing: 'Soundproofing',
    
    
    safe: 'Safe',
    'in-room safe': 'In-Room Safe',
    'safety deposit box': 'Safety Deposit Box',
    'smoke detector': 'Smoke Detector',
    'fire extinguisher': 'Fire Extinguisher',
    'security system': 'Security System',
    'key card access': 'Key Card Access',
    'door lock': 'Door Lock',
    
    
    'usb charging ports': 'USB Charging Ports',
    'usb ports': 'USB Ports',
    'usb outlets': 'USB Outlets',
    'power outlets': 'Power Outlets',
    'charging station': 'Charging Station',
    'laptop safe': 'Laptop Safe',
    'hdmi port': 'HDMI Port',
    phone: 'Phone',
    'desk phone': 'Desk Phone',
    'wake-up service': 'Wake-Up Service',
    'alarm clock': 'Alarm Clock',
    'digital clock': 'Digital Clock',
    
    
    balcony: 'Balcony',
    'private balcony': 'Private Balcony',
    terrace: 'Terrace',
    patio: 'Patio',
    'city view': 'City View',
    'ocean view': 'Ocean View',
    'sea view': 'Sea View',
    'mountain view': 'Mountain View',
    'garden view': 'Garden View',
    'pool view': 'Pool View',
    'park view': 'Park View',
    window: 'Window',
    'large windows': 'Large Windows',
    'floor-to-ceiling windows': 'Floor-to-Ceiling Windows',
    
    
    '24-hour front desk': '24/7 Front Desk',
    '24 hour front desk': '24/7 Front Desk',
    '24/7 front desk': '24/7 Front Desk',
    'front desk': 'Front Desk',
    'concierge service': 'Concierge Service',
    'butler service': 'Butler Service',
    butler: 'Butler',
    housekeeping: 'Housekeeping',
    'daily housekeeping': 'Daily Housekeeping',
    'turndown service': 'Turndown Service',
    'laundry service': 'Laundry Service',
    laundry: 'Laundry Service',
    'dry cleaning': 'Dry Cleaning',
    'ironing service': 'Ironing Service',
    'luggage storage': 'Luggage Storage',
    'bell service': 'Bell Service',
    'valet parking': 'Valet Parking',
    parking: 'Parking',
    'free parking': 'Free Parking',
    'airport shuttle': 'Airport Shuttle',
    'shuttle service': 'Shuttle Service',
    shuttle: 'Shuttle Service',
    'car rental': 'Car Rental',
    'taxi service': 'Taxi Service',
    
    
    'gym access': 'Gym Access',
    'fitness center': 'Fitness Center',
    'fitness room': 'Fitness Room',
    gym: 'Gym',
    fitness: 'Fitness Center',
    'spa access': 'Spa Access',
    spa: 'Spa',
    sauna: 'Sauna',
    'steam room': 'Steam Room',
    'massage service': 'Massage Service',
    'beauty services': 'Beauty Services',
    
    
    'swimming pool': 'Swimming Pool',
    pool: 'Swimming Pool',
    'indoor pool': 'Indoor Pool',
    'outdoor pool': 'Outdoor Pool',
    'infinity pool': 'Infinity Pool',
    'pool access': 'Pool Access',
    'golf course': 'Golf Course',
    'tennis court': 'Tennis Court',
    'beach access': 'Beach Access',
    'water sports': 'Water Sports',
    
    
    'business center': 'Business Center',
    'meeting room': 'Meeting Room',
    'conference room': 'Conference Room',
    'fax service': 'Fax Service',
    photocopying: 'Photocopying',
    'printing service': 'Printing Service',
    'secretarial services': 'Secretarial Services',
    
    
    'wheelchair accessible': 'Wheelchair Accessible',
    'accessible room': 'Accessible Room',
    'elevator access': 'Elevator Access',
    'ramp access': 'Ramp Access',
    'accessible bathroom': 'Accessible Bathroom',
    'lowered sink': 'Lowered Sink',
    'grab bars': 'Grab Bars',
    'hearing accessible': 'Hearing Accessible',
    'visual alarm': 'Visual Alarm',
    
    
    'family room': 'Family Room',
    'kids welcome': 'Kids Welcome',
    'baby crib': 'Baby Crib',
    crib: 'Baby Crib',
    'extra bed': 'Extra Bed',
    'childcare services': 'Childcare Services',
    'pets allowed': 'Pets Allowed',
    pets: 'Pets Allowed',
    'pet friendly': 'Pet Friendly',
    
    
    'smoking room': 'Smoking Room',
    'non-smoking room': 'Non-Smoking Room',
    'no smoking': 'No Smoking',
    'interconnecting rooms': 'Interconnecting Rooms',
    'adjoining rooms': 'Adjoining Rooms',
    suite: 'Suite',
    'separate bedroom': 'Separate Bedroom',
    kitchen: 'Kitchen',
    'full kitchen': 'Full Kitchen',
    dishwasher: 'Dishwasher',
    oven: 'Oven',
    stove: 'Stove',
    'washing machine': 'Washing Machine',
    dryer: 'Dryer',
    iron: 'Iron',
    'ironing board': 'Ironing Board',
    'clothes rack': 'Clothes Rack',
    umbrella: 'Umbrella',
    'shoe shine service': 'Shoe Shine Service',
    
    
    fireplace: 'Fireplace',
    jacuzzi: 'Jacuzzi',
    'spa bath': 'Spa Bath',
    'bidet toilet': 'Bidet Toilet',
    'smart home system': 'Smart Home System',
    'lighting control': 'Lighting Control',
    'curtain control': 'Curtain Control',
    'automated systems': 'Automated Systems',
    'personalized service': 'Personalized Service',
    'vip treatment': 'VIP Treatment',
    'private entrance': 'Private Entrance',
    'private elevator': 'Private Elevator',
    'panic button': 'Panic Button',
    
    
    restaurant: 'Restaurant',
    
    
    library: 'Library',
    'reading room': 'Reading Room',
    'study room': 'Study Room',
    'private pool': 'Private Pool',
    'private garden': 'Private Garden',
    yard: 'Yard',
    courtyard: 'Courtyard',
    'outdoor furniture': 'Outdoor Furniture',
    'bbq facilities': 'BBQ Facilities',
    'picnic area': 'Picnic Area',
  };

  const amenityDescriptions: Record<string, string> = {
    wifi: 'Free wireless internet connection',
    tv: 'TV with cable or satellite',
    ac: 'Air conditioning system in room',
    minibar: 'Drinks and snacks in mini bar',
    pool: 'Outdoor or indoor swimming pool',
    gym: 'Fitness center/gym',
    'room service': 'Order food to room',
    breakfast: 'Breakfast served at restaurant',
    balcony: 'Private balcony with view',
    '24-hour front desk': '24-hour front desk service',
    spa: 'Spa and relaxation services',
  };

  const getIcon = (amenity: string) => {
    const key = amenity.toLowerCase().trim();
    return amenityIcons[key] || (
      <span className="w-5 h-5 flex items-center 
        justify-center text-blue-600 font-bold"
      >
        ✓
      </span>
    );
  };

  const getLabel = (amenity: string) => {
    const key = amenity.toLowerCase().trim();
    if (amenityLabels[key]) return amenityLabels[key];
    
    return amenity
      .toLowerCase()
      .replace(/[_-]/g, ' ')
      .split(' ')
      .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
      .join(' ');
  };

  const getDescription = (amenity: string) => {
    const key = amenity.toLowerCase().trim();
    return amenityDescriptions[key] || '';
  };

  if (safeAmenities.length === 0) {
    return (
      <div className="text-gray-500 text-center py-4">
        Amenity information is being updated
      </div>
    );
  }

  return (
    <div className="grid grid-cols-1 md:grid-cols-2 
      lg:grid-cols-3 gap-4"
    >
      {safeAmenities.map((amenity, index) => (
        <div
          key={index}
          className="flex items-center gap-3 p-3 
            bg-gray-50 rounded-lg hover:bg-gray-100 
            transition-colors"
          title={getDescription(amenity)}
        >
          <div className="text-blue-600">{getIcon(amenity)}</div>
          <div>
            <div className="text-gray-800 font-medium">
              {getLabel(amenity)}
            </div>
            {getDescription(amenity) && (
              <div className="text-xs text-gray-500">
                {getDescription(amenity)}
              </div>
            )}
          </div>
        </div>
      ))}
    </div>
  );
};

export default RoomAmenities;
