/**
 * BodyTypeSilhouette — SVG car silhouettes for each vehicle body type.
 * All viewBox="0 0 160 72". Wheels at y=60, r=13.
 * Body uses fill="currentColor" so Tailwind text-* classes control color.
 */

interface SilhouetteProps {
  className?: string;
}

// ─── SUV ─────────────────────────────────────────────────────────────────────
// Tall, upright greenhouse. High ride height. Square roofline.
export function SUVSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="34" cy="60" r="13" fill="currentColor" />
      <circle cx="34" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="126" cy="60" r="13" fill="currentColor" />
      <circle cx="126" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body */}
      <path
        d="M6 47 L6 24 Q7 19 13 17 L30 12 L36 6 Q42 2 54 2 L106 2 Q118 2 124 6 L130 12 L147 17 Q153 19 154 24 L154 47 L140 47 Q139 37 126 37 Q113 37 112 47 L48 47 Q47 37 34 37 Q21 37 20 47 Z"
        fill="currentColor"
      />
      {/* Windows */}
      <path d="M38 6 L37 45 L123 45 L122 6 Z" fill="white" opacity="0.18" />
      <line x1="80" y1="4" x2="80" y2="45" stroke="white" strokeWidth="1.5" opacity="0.12" />
    </svg>
  );
}

// ─── Sedan ───────────────────────────────────────────────────────────────────
// Classic 3-box: hood + cabin + separate boot. Medium height.
export function SedanSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="34" cy="60" r="13" fill="currentColor" />
      <circle cx="34" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="126" cy="60" r="13" fill="currentColor" />
      <circle cx="126" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body */}
      <path
        d="M4 47 L4 36 Q5 32 10 30 L20 26 L32 18 Q38 14 48 14 L96 14 Q108 14 114 18 L128 28 Q140 32 152 34 L156 36 L156 47 L140 47 Q139 37 126 37 Q113 37 112 47 L48 47 Q47 37 34 37 Q21 37 20 47 Z"
        fill="currentColor"
      />
      {/* Cabin / greenhouse */}
      <path
        d="M34 18 L32 45 L110 45 L114 18 Q108 14 96 14 L48 14 Q38 14 34 18 Z"
        fill="white"
        opacity="0.18"
      />
    </svg>
  );
}

// ─── Hatchback ───────────────────────────────────────────────────────────────
// 2-box: combined cabin+boot, sloping rear. Compact proportions.
export function HatchbackSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="36" cy="60" r="13" fill="currentColor" />
      <circle cx="36" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="122" cy="60" r="13" fill="currentColor" />
      <circle cx="122" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body */}
      <path
        d="M6 47 L6 36 Q7 32 12 30 L22 26 L34 16 Q40 12 52 12 L100 12 Q114 14 122 24 L132 34 Q140 38 150 40 L154 42 L154 47 L136 47 Q135 37 122 37 Q109 37 108 47 L50 47 Q49 37 36 37 Q23 37 22 47 Z"
        fill="currentColor"
      />
      {/* Windows — note sloping rear */}
      <path
        d="M36 16 L34 45 L132 45 L122 24 Q114 14 100 12 L52 12 Q40 12 36 16 Z"
        fill="white"
        opacity="0.18"
      />
    </svg>
  );
}

// ─── MUV / MPV ───────────────────────────────────────────────────────────────
// Van-like: very tall, flat roof, near-vertical pillars.
export function MUVSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="34" cy="60" r="13" fill="currentColor" />
      <circle cx="34" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="126" cy="60" r="13" fill="currentColor" />
      <circle cx="126" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body — very tall slab sides */}
      <path
        d="M8 47 L8 18 Q9 13 16 11 L30 8 Q36 4 50 3 L110 3 Q122 4 128 8 L142 12 Q150 14 152 20 L152 47 L140 47 Q139 37 126 37 Q113 37 112 47 L48 47 Q47 37 34 37 Q21 37 20 47 Z"
        fill="currentColor"
      />
      {/* Large windows */}
      <path d="M32 6 L31 45 L129 45 L128 8 Q122 4 110 3 L50 3 Q36 4 32 6 Z" fill="white" opacity="0.18" />
      {/* Sliding door line hint */}
      <line x1="84" y1="6" x2="84" y2="45" stroke="white" strokeWidth="1.5" opacity="0.12" />
    </svg>
  );
}

// ─── Coupe ───────────────────────────────────────────────────────────────────
// Sporty: very low, long hood, sweeping fastback roofline.
export function CoupeSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="34" cy="60" r="13" fill="currentColor" />
      <circle cx="34" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="126" cy="60" r="13" fill="currentColor" />
      <circle cx="126" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body — low, long, swept roofline */}
      <path
        d="M4 47 L4 38 Q5 34 10 32 L20 28 L38 22 Q46 18 58 18 L92 18 Q106 18 118 24 L138 34 Q150 38 156 40 L156 47 L140 47 Q139 37 126 37 Q113 37 112 47 L48 47 Q47 37 34 37 Q21 37 20 47 Z"
        fill="currentColor"
      />
      {/* Cabin — small, swept */}
      <path
        d="M40 22 L38 45 L118 45 L118 24 Q106 18 92 18 L58 18 Q46 18 40 22 Z"
        fill="white"
        opacity="0.18"
      />
    </svg>
  );
}

// ─── Electric ────────────────────────────────────────────────────────────────
// Modern EV: aerodynamic nose, flush surfaces, like a premium sedan.
export function ElectricSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="34" cy="60" r="13" fill="currentColor" />
      <circle cx="34" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="126" cy="60" r="13" fill="currentColor" />
      <circle cx="126" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body — rounded nose, flat undertray */}
      <path
        d="M6 47 L6 36 Q8 30 14 28 L26 24 L40 16 Q46 12 58 12 L96 12 Q110 12 118 16 L132 26 Q144 30 154 34 L156 38 L156 47 L140 47 Q139 37 126 37 Q113 37 112 47 L48 47 Q47 37 34 37 Q21 37 20 47 Z"
        fill="currentColor"
      />
      {/* Windows */}
      <path
        d="M42 16 L40 45 L114 45 L118 16 Q110 12 96 12 L58 12 Q46 12 42 16 Z"
        fill="white"
        opacity="0.18"
      />
      {/* Lightning bolt badge */}
      <path
        d="M78 20 L74 32 L80 32 L76 42 L84 28 L78 28 Z"
        fill="white"
        opacity="0.5"
      />
    </svg>
  );
}

// ─── Luxury ──────────────────────────────────────────────────────────────────
// Long-wheelbase sedan proportions. Extra-long hood, low roofline.
export function LuxurySilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels — wider spread */}
      <circle cx="30" cy="60" r="13" fill="currentColor" />
      <circle cx="30" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="130" cy="60" r="13" fill="currentColor" />
      <circle cx="130" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Body — very long, low */}
      <path
        d="M2 47 L2 36 Q4 30 10 28 L22 24 L36 16 Q44 12 56 12 L100 12 Q114 12 122 16 L140 28 Q150 32 158 36 L158 47 L144 47 Q143 37 130 37 Q117 37 116 47 L44 47 Q43 37 30 37 Q17 37 16 47 Z"
        fill="currentColor"
      />
      {/* Windows */}
      <path
        d="M38 16 L36 45 L116 45 L122 16 Q114 12 100 12 L56 12 Q44 12 38 16 Z"
        fill="white"
        opacity="0.18"
      />
    </svg>
  );
}

// ─── Convertible ─────────────────────────────────────────────────────────────
// Open-top: no roof, windshield only, sporty.
export function ConvertibleSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels */}
      <circle cx="34" cy="60" r="13" fill="currentColor" />
      <circle cx="34" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="126" cy="60" r="13" fill="currentColor" />
      <circle cx="126" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Low body */}
      <path
        d="M4 47 L4 38 Q6 34 12 32 L22 28 L34 22 Q42 18 54 18 L106 18 Q118 18 128 24 L144 32 Q152 36 156 40 L156 47 L140 47 Q139 37 126 37 Q113 37 112 47 L48 47 Q47 37 34 37 Q21 37 20 47 Z"
        fill="currentColor"
      />
      {/* Windshield only — open top */}
      <path
        d="M56 22 L52 40 L80 40 L82 22 Q76 18 66 18 L60 18 Q58 18 56 22 Z"
        fill="white"
        opacity="0.25"
      />
    </svg>
  );
}

// ─── Pickup Truck ─────────────────────────────────────────────────────────────
// Cab + open bed. Very tall, squared.
export function PickupSilhouette({ className = "" }: SilhouetteProps) {
  return (
    <svg viewBox="0 0 160 72" className={className} aria-hidden="true" fill="none">
      {/* Wheels — wide track */}
      <circle cx="36" cy="60" r="13" fill="currentColor" />
      <circle cx="36" cy="60" r="6"  fill="white" opacity="0.35" />
      <circle cx="124" cy="60" r="13" fill="currentColor" />
      <circle cx="124" cy="60" r="6"  fill="white" opacity="0.35" />
      {/* Cab */}
      <path
        d="M6 47 L6 20 Q7 15 14 13 L28 9 L36 4 Q42 2 54 2 L90 2 Q98 2 102 8 L108 20 L108 47 L48 47 Q47 37 36 37 Q25 37 22 47 Z"
        fill="currentColor"
      />
      {/* Cab windows */}
      <path d="M38 4 L37 45 L100 45 L102 8 Q98 2 90 2 L54 2 Q42 2 38 4 Z" fill="white" opacity="0.18" />
      {/* Bed */}
      <path d="M108 18 L108 47 L112 47 Q111 37 124 37 Q137 37 136 47 L152 47 L152 24 Q150 18 144 18 Z" fill="currentColor" />
      {/* Bed walls */}
      <line x1="108" y1="22" x2="152" y2="22" stroke="white" strokeWidth="2" opacity="0.2" />
    </svg>
  );
}

// ─── Generic (fallback) ───────────────────────────────────────────────────────
export function GenericCarSilhouette({ className = "" }: SilhouetteProps) {
  return <SedanSilhouette className={className} />;
}

// ─── Registry ─────────────────────────────────────────────────────────────────
const SILHOUETTE_MAP: Record<string, React.ComponentType<SilhouetteProps>> = {
  SUV:           SUVSilhouette,
  Sedan:         SedanSilhouette,
  Hatchback:     HatchbackSilhouette,
  MUV:           MUVSilhouette,
  MPV:           MUVSilhouette,
  Coupe:         CoupeSilhouette,
  Electric:      ElectricSilhouette,
  Luxury:        LuxurySilhouette,
  Convertible:   ConvertibleSilhouette,
  Cabriolet:     ConvertibleSilhouette,
  "Pickup Truck":PickupSilhouette,
};

/**
 * Convenience component: pick the right silhouette by body-type string.
 */
export default function BodyTypeSilhouette({
  type,
  className = "",
}: {
  type: string;
  className?: string;
}) {
  const Component = SILHOUETTE_MAP[type] ?? GenericCarSilhouette;
  return <Component className={className} />;
}
