// -----------------------------------------------------------------------------
// Author: Simon-Pierre Boucher
// Contact: contact@spboucher.ai
// Project: Toit-Ka
// components/Icons.tsx : iconographie MAISON — traits 1,7 px sur grille 24,
//   zéro emoji, zéro pack générique. Chaque icône est un tracé « stroke » net
//   qui hérite de la couleur du texte (currentColor).
// -----------------------------------------------------------------------------
import { ReactNode } from "react";

const P: Record<string, ReactNode> = {
  home: (<>
    <path d="M3.5 10.6 12 3.4l8.5 7.2" />
    <path d="M5.6 9.4V20h12.8V9.4" />
    <path d="M10 20v-5.6h4V20" />
  </>),
  key: (<>
    <circle cx="8" cy="8.6" r="4.6" />
    <path d="m11.4 12 8 8M16.2 16.8l2.4-2.4M13.6 19.4l2.2-2.2" />
  </>),
  map: (<>
    <path d="M3.2 6.4 9 4.2l6 2.2 5.8-2.2v13.4L15 19.8l-6-2.2-5.8 2.2z" />
    <path d="M9 4.2v13.4M15 6.4v13.4" />
  </>),
  chart: (<>
    <path d="M4 20h16" />
    <path d="M7.2 20v-5.6M12 20V8.8M16.8 20V12" />
  </>),
  building: (<>
    <path d="M5 20V5.6A1.6 1.6 0 0 1 6.6 4h6.2a1.6 1.6 0 0 1 1.6 1.6V20" />
    <path d="M14.4 9.4h3.4A1.6 1.6 0 0 1 19.4 11v9" />
    <path d="M3.2 20h17.6" />
    <path d="M8 8h2.4M8 11.6h2.4M8 15.2h2.4M16.4 13h.9M16.4 16.2h.9" />
  </>),
  bed: (<>
    <path d="M3.4 6.8V18.6" />
    <path d="M3.4 15.4h17.2v3.2" />
    <path d="M3.4 12.2h6.2v3.2" />
    <circle cx="6.5" cy="9.9" r="1.35" />
    <path d="M11.4 12.2h5.8a3.4 3.4 0 0 1 3.4 3.2" />
  </>),
  bath: (<>
    <path d="M3.6 12.4h16.8v1.4a5.2 5.2 0 0 1-5.2 5.2H8.8a5.2 5.2 0 0 1-5.2-5.2z" />
    <path d="M5.8 12.4V5.9a2.1 2.1 0 0 1 4-1" />
    <path d="m7 19.4-1 2.1M17 19.4l1 2.1" />
  </>),
  area: (<>
    <path d="M4.4 19.6 19.6 4.4" />
    <path d="M4.4 14v5.6H10" />
    <path d="M19.6 10V4.4H14" />
  </>),
  land: (<>
    <path d="M4.4 9.6v9.8M9.5 9.6v9.8M14.5 9.6v9.8M19.6 9.6v9.8" />
    <path d="M3 12.6h18M3 16.4h18" />
    <path d="M4.4 9.6 12 5.2l7.6 4.4" />
  </>),
  calendar: (<>
    <rect x="4" y="5.6" width="16" height="14.8" rx="2" />
    <path d="M4 10.2h16M8.2 3.4v4M15.8 3.4v4" />
  </>),
  tag: (<>
    <path d="m12.9 3.6 7.5 7.5a1.8 1.8 0 0 1 0 2.5l-6.8 6.8a1.8 1.8 0 0 1-2.5 0L3.6 12.9V3.6z" />
    <circle cx="8" cy="8" r="1.5" />
  </>),
  camera: (<>
    <rect x="3.4" y="7" width="17.2" height="13" rx="2" />
    <path d="M8.6 7 10 4.4h4L15.4 7" />
    <circle cx="12" cy="13.2" r="3.4" />
  </>),
  paw: (<>
    <circle cx="7.4" cy="9" r="1.7" />
    <circle cx="12" cy="7" r="1.7" />
    <circle cx="16.6" cy="9" r="1.7" />
    <path d="M8.2 16.6c0-2.3 1.7-4 3.8-4s3.8 1.7 3.8 4c0 1.9-1.5 3-3.8 3s-3.8-1.1-3.8-3z" />
  </>),
  sofa: (<>
    <path d="M4.4 11V7.6A1.6 1.6 0 0 1 6 6h12a1.6 1.6 0 0 1 1.6 1.6V11" />
    <path d="M3.2 13.4a1.8 1.8 0 0 1 3.6 0v.8h10.4v-.8a1.8 1.8 0 0 1 3.6 0V17a1.4 1.4 0 0 1-1.4 1.4H4.6A1.4 1.4 0 0 1 3.2 17z" />
    <path d="M5.4 18.4v1.8M18.6 18.4v1.8" />
  </>),
  search: (<>
    <circle cx="10.6" cy="10.6" r="6.2" />
    <path d="m15.3 15.3 5.3 5.3" />
  </>),
  arrow: (<>
    <path d="M4 12h15.2" />
    <path d="m13.8 6.4 5.4 5.6-5.4 5.6" />
  </>),
  check: (<path d="m5 12.8 4.3 4.4L19 7.4" />),
  alert: (<>
    <path d="M12 4.2 2.9 19.4h18.2z" />
    <path d="M12 10.2v4.4" />
    <path d="M12 17.4v.05" />
  </>),
  phone: (<path d="M5.2 4h3.6L10.4 8.4 8.3 10.1a12.5 12.5 0 0 0 5.6 5.6l1.7-2.1 4.4 1.6v3.6a1.8 1.8 0 0 1-1.9 1.8A16.4 16.4 0 0 1 3.4 5.9 1.8 1.8 0 0 1 5.2 4z" />),
  external: (<>
    <path d="M14.4 4h5.6v5.6" />
    <path d="M20 4 11.4 12.6" />
    <path d="M18.6 13.6V18a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7.4a2 2 0 0 1 2-2h4.4" />
  </>),
  pin: (<>
    <path d="M12 21.2S5.4 15.7 5.4 10.8a6.6 6.6 0 0 1 13.2 0c0 4.9-6.6 10.4-6.6 10.4z" />
    <circle cx="12" cy="10.6" r="2.3" />
  </>),
  people: (<>
    <circle cx="9" cy="8" r="3.2" />
    <path d="M3.6 20a5.4 5.4 0 0 1 10.8 0" />
    <path d="M15.4 5.4a3.2 3.2 0 0 1 0 5.9M17 14.8a5.4 5.4 0 0 1 3.4 5.2" />
  </>),
  instagram: (<>
    <rect x="4" y="4" width="16" height="16" rx="4.6" />
    <circle cx="12" cy="12" r="3.6" />
    <path d="M16.6 7.4v.05" />
  </>),
  facebook: (<>
    <path d="M14.8 4.2h-2.2a3.4 3.4 0 0 0-3.4 3.4V10H6.8v3.4h2.4V20h3.4v-6.6h2.6l.6-3.4h-3.2V8a1 1 0 0 1 1-1h2.2z" />
  </>),
  x: (<>
    <path d="M4.6 4.4h4.2L19.4 19.6h-4.2z" />
    <path d="M19 4.4 13.4 11M10.4 13.2 4.8 19.6" />
  </>),
  linkedin: (<>
    <rect x="4" y="4" width="16" height="16" rx="2.4" />
    <path d="M8 10.4V16.4M8 7.6v.05" />
    <path d="M11.6 16.4v-6M11.6 12.6a2.4 2.4 0 0 1 4.8 0v3.8" />
  </>),
  tiktok: (<>
    <path d="M13.6 3.8v10.9a3.5 3.5 0 1 1-3.5-3.5" />
    <path d="M13.6 5.4a5.4 5.4 0 0 0 5.2 4" />
  </>),
  youtube: (<>
    <rect x="3.2" y="6" width="17.6" height="12.4" rx="3.4" />
    <path d="m10.4 9.4 4.6 2.8-4.6 2.8z" />
  </>),
};

export type IconName = keyof typeof P;

export function Ico({ name, size = 18, className = "", stroke = 1.7 }:
  { name: IconName | string; size?: number; className?: string; stroke?: number }) {
  const paths = P[name as IconName];
  if (!paths) return null;
  return (
    <svg
      className={`ico ${className}`}
      width={size} height={size} viewBox="0 0 24 24"
      fill="none" stroke="currentColor" strokeWidth={stroke}
      strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"
    >
      {paths}
    </svg>
  );
}

/** Cœur des favoris ♥ — seule icône « remplissable » (état on/off). */
export function IcoHeart({ size = 16, filled = false, className = "" }:
  { size?: number; filled?: boolean; className?: string }) {
  return (
    <svg
      className={`ico ${className}`}
      width={size} height={size} viewBox="0 0 24 24"
      fill={filled ? "currentColor" : "none"} stroke="currentColor" strokeWidth={1.7}
      strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"
    >
      <path d="M12 20.5C7 16.5 3.5 13 3.5 9.3 3.5 6.8 5.5 5 7.8 5c1.7 0 3.2 1 4.2 2.6C13 6 14.5 5 16.2 5c2.3 0 4.3 1.8 4.3 4.3 0 3.7-3.5 7.2-8.5 11.2z" />
    </svg>
  );
}
