'use client';

/**
 * SVG Game Icons for the 11 gauges + SIT score.
 *
 * Refactored to match the v2 mockup's nav-icon visual language: fuller /
 * more modern shapes (filled polygons where it reads best, thin 1.75 strokes
 * elsewhere). Size + color inherit via the existing IconProps API so the
 * GaugeBar code doesn't need to change.
 *
 * The "bourse" and "hash" nav-icons from the mockup are NOT reused per
 * user instruction — we use purpose-fit icons for our gauges instead.
 */

interface IconProps {
  size?: number;
  color?: string;
  className?: string;
}

const base = (size: number, color?: string, className?: string) => ({
  width: size,
  height: size,
  viewBox: '0 0 24 24',
  fill: 'none',
  stroke: color || 'currentColor',
  strokeWidth: 1.75,
  strokeLinecap: 'round' as const,
  strokeLinejoin: 'round' as const,
  className,
  'aria-hidden': true as const,
});

/** Fortune — stacked coins (patrimoine total, ∞ + Shadow). */
export function IconFortune({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <ellipse cx="12" cy="6" rx="7" ry="2.5" fill={color || 'currentColor'} fillOpacity={0.15} />
      <ellipse cx="12" cy="6" rx="7" ry="2.5" />
      <path d="M5 6v6c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5V6" />
      <path d="M5 12v6c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5v-6" />
    </svg>
  );
}

/** Pouvoir — Empire-style building with peaks (mockup empire nav-icon). */
export function IconPouvoir({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <path
        d="M3 10 8 5l4 3 4-3 5 5v9H3z"
        fill={color || 'currentColor'}
        fillOpacity={0.18}
      />
      <path d="M3 10 8 5l4 3 4-3 5 5v9H3z" />
      <path d="M7 14h10" />
    </svg>
  );
}

/** Chaleur — filled flame with inner ember. */
export function IconChaleur({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <path
        d="M12 2c1.5 3 6 5 6 10a6 6 0 0 1-12 0c0-5 4.5-7 6-10Z"
        fill={color || 'currentColor'}
        fillOpacity={0.22}
      />
      <path d="M12 2c1.5 3 6 5 6 10a6 6 0 0 1-12 0c0-5 4.5-7 6-10Z" />
      <path
        d="M12 12c1 1.2 2 2.2 2 4 0 1.7-1 3-2 3s-2-1.3-2-3c0-1.8 1-2.8 2-4z"
        fill={color || 'currentColor'}
      />
    </svg>
  );
}

/** Conscience — brain/soul (rounded hat shape). */
export function IconConscience({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <path
        d="M12 2a6 6 0 0 0-6 6c0 2 1 3 1 4.5 0 1.5-1 2-1 4a4 4 0 0 0 4 4h4a4 4 0 0 0 4-4c0-2-1-2.5-1-4 0-1.5 1-2.5 1-4.5a6 6 0 0 0-6-6z"
        fill={color || 'currentColor'}
        fillOpacity={0.15}
      />
      <path d="M12 2a6 6 0 0 0-6 6c0 2 1 3 1 4.5 0 1.5-1 2-1 4a4 4 0 0 0 4 4h4a4 4 0 0 0 4-4c0-2-1-2.5-1-4 0-1.5 1-2.5 1-4.5a6 6 0 0 0-6-6z" />
    </svg>
  );
}

/** Respect — filled star (mockup réputation nav-icon polygon). */
export function IconRespect({ size = 16, color, className }: IconProps) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill={color || 'currentColor'} className={className} aria-hidden>
      <polygon points="12,2 15.1,8.6 22,9.3 17,14.1 18.2,21 12,17.8 5.8,21 7,14.1 2,9.3 8.9,8.6" />
    </svg>
  );
}

/** Social — filled heart (mockup social nav-icon). */
export function IconSocial({ size = 16, color, className }: IconProps) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill={color || 'currentColor'} className={className} aria-hidden>
      <path d="M12 21s-7-5-9-10a5 5 0 0 1 9-3 5 5 0 0 1 9 3c-2 5-9 10-9 10z" />
    </svg>
  );
}

/** Popularité — megaphone / broadcast (mockup popularité nav-icon). */
export function IconPopularite({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <path
        d="M3 11v2a2 2 0 0 0 2 2h1l5 4V5L6 9H5a2 2 0 0 0-2 2z"
        fill={color || 'currentColor'}
        fillOpacity={0.2}
      />
      <path d="M3 11v2a2 2 0 0 0 2 2h1l5 4V5L6 9H5a2 2 0 0 0-2 2z" />
      <path d="M15 8a5 5 0 0 1 0 8M18 5a9 9 0 0 1 0 14" />
    </svg>
  );
}

/** Instabilité — filled lightning bolt (mockup actions nav-icon). */
export function IconInstabilite({ size = 16, color, className }: IconProps) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill={color || 'currentColor'} className={className} aria-hidden>
      <polygon points="13,2 3,14 12,14 11,22 21,10 12,10" />
    </svg>
  );
}

/** Influence — concentric radio waves around central dot. */
export function IconInfluence({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <circle cx="12" cy="12" r="2" fill={color || 'currentColor'} />
      <path d="M8 12a4 4 0 0 1 8 0M5 12a7 7 0 0 1 14 0M2 12a10 10 0 0 1 20 0" />
    </svg>
  );
}

/** Écologie — filled leaf with vein (mockup rédemption nav-icon). */
export function IconEcologie({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <path
        d="M5 21c0-8 5-13 14-13-1 9-6 13-14 13z"
        fill={color || 'currentColor'}
        fillOpacity={0.22}
      />
      <path d="M5 21c0-8 5-13 14-13-1 9-6 13-14 13z" />
      <path d="M5 21c4-4 8-6 14-8" />
    </svg>
  );
}

/** Santé physique — rounded heart (filled). */
export function IconSantePhysique({ size = 16, color, className }: IconProps) {
  return (
    <svg {...base(size, color, className)}>
      <path
        d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21.3l8.8-8.9a5.5 5.5 0 0 0 0-7.8z"
        fill={color || 'currentColor'}
        fillOpacity={0.22}
      />
      <path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21.3l8.8-8.9a5.5 5.5 0 0 0 0-7.8z" />
    </svg>
  );
}

/* ─── Map lookup (same API shape as the pre-refactor version) ─── */
export const GAUGE_ICONS: Record<string, React.ComponentType<IconProps>> = {
  fortune: IconFortune,
  pouvoir: IconPouvoir,
  chaleur: IconChaleur,
  conscience: IconConscience,
  respect: IconRespect,
  social: IconSocial,
  popularite: IconPopularite,
  instabilite: IconInstabilite,
  influence: IconInfluence,
  ecologie: IconEcologie,
  // Phase 8 v2 (2026-05-01) — clé canonique 'physical_health' (matche
  // PlayerHealth.physical_health côté backend). L'icône reste la même.
  physical_health: IconSantePhysique,
};
