import type { RoomTheme } from '@/entities/room';
import { cn } from '@/shared/lib/cn';

interface RoomPreviewCardProps {
  room: RoomTheme;
  selected: boolean;
  onSelect: (roomId: string) => void;
}

export const RoomPreviewCard = ({
  room,
  selected,
  onSelect,
}: RoomPreviewCardProps) => {
  return (
    <button
      type="button"
      onClick={() => onSelect(room.id)}
      className={cn(
        'group relative overflow-hidden rounded-2xl border p-4 text-left transition-all duration-250 motion-reduce:transition-none',
        selected
          ? 'border-brand-dark/28 shadow-[0_0_0_1px_rgba(48,77,109,0.18)]'
          : 'border-brand-dark/16 hover:border-brand-dark/28',
      )}
    >
      <div
        aria-hidden
        className="absolute inset-0"
        style={{
          backgroundColor: room.hubColor,
        }}
      />

      <div className="relative space-y-3 rounded-xl border border-brand-dark/10 bg-white/42 p-3 backdrop-blur-[1px]">
        <div>
          <h3 className="text-base font-semibold text-brand-dark">{room.name}</h3>
          <p className="mt-1 text-xs text-brand-dark/72">{room.description}</p>
        </div>

        <div className="flex flex-wrap gap-2">
          {room.tags.map((tag) => (
            <span
              key={tag}
              className="inline-flex items-center gap-1 rounded-full bg-white/62 px-3 py-1.5 text-xs font-medium text-brand-dark/86 ring-1 ring-brand-dark/12"
            >
              {tag}
            </span>
          ))}
        </div>

        <div className="space-y-2">
          <p className="text-xs text-brand-dark/78">
            추천 사운드: <span className="font-medium text-brand-dark">{room.recommendedSound}</span>
          </p>
          <div className="flex flex-wrap gap-2">
            <span className="inline-flex items-center gap-1 rounded-full bg-white/58 px-3 py-1.5 text-xs font-medium text-brand-dark/84 ring-1 ring-brand-dark/12">
              추천 시간 · {room.recommendedTime}
            </span>
            <span className="inline-flex items-center gap-1 rounded-full bg-white/58 px-3 py-1.5 text-xs font-medium text-brand-dark/84 ring-1 ring-brand-dark/12">
              지금 분위기 · {room.vibeLabel}
            </span>
          </div>
        </div>
      </div>
    </button>
  );
};
