/* ===== src/icons.jsx =====
   Bibliothèque d'icônes SVG — Maison Sereine
   Style : trait fin (1.6), arrondi, 24×24, currentColor.
   Usage : <Icon name="shield" size={18} style={{ color: 'var(--primary)' }} />
   ============================================================ */

const ICONS = {
  /* ---------- Navigation & UI ---------- */
  'home': (
    <path d="M3 11.5 12 4l9 7.5V20a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1v-8.5Z" />
  ),
  'arrow-right': (
    <>
      <path d="M5 12h14" />
      <path d="m13 6 6 6-6 6" />
    </>
  ),
  'arrow-left': (
    <>
      <path d="M19 12H5" />
      <path d="m11 6-6 6 6 6" />
    </>
  ),
  'chevron-down': <path d="m6 9 6 6 6-6" />,
  'chevron-up':   <path d="m6 15 6-6 6 6" />,
  'menu': (
    <>
      <path d="M4 7h16" /><path d="M4 12h16" /><path d="M4 17h16" />
    </>
  ),
  'close': (
    <>
      <path d="M6 6 18 18" /><path d="M18 6 6 18" />
    </>
  ),

  /* ---------- Sécurité ---------- */
  'shield': (
    <>
      <path d="M12 3 4 6v6c0 4.5 3.2 8.5 8 9 4.8-.5 8-4.5 8-9V6l-8-3Z" />
      <path d="m9 12 2 2 4-4" />
    </>
  ),
  'lock': (
    <>
      <rect x="4" y="11" width="16" height="9" rx="2" />
      <path d="M8 11V8a4 4 0 0 1 8 0v3" />
    </>
  ),
  'check': <path d="m5 12 4 4 10-10" />,
  'check-circle': (
    <>
      <circle cx="12" cy="12" r="9" />
      <path d="m8 12 3 3 5-6" />
    </>
  ),
  'info': (
    <>
      <circle cx="12" cy="12" r="9" />
      <path d="M12 11v5" />
      <circle cx="12" cy="8" r="0.6" fill="currentColor" stroke="none" />
    </>
  ),
  'warning': (
    <>
      <path d="M12 4 2.5 20h19L12 4Z" />
      <path d="M12 10v4" />
      <circle cx="12" cy="17" r="0.6" fill="currentColor" stroke="none" />
    </>
  ),

  /* ---------- Personnes & équipe ---------- */
  'user': (
    <>
      <circle cx="12" cy="8" r="4" />
      <path d="M4 21c1-4.4 4.5-7 8-7s7 2.6 8 7" />
    </>
  ),
  'users': (
    <>
      <circle cx="9" cy="9" r="3.5" />
      <path d="M2 20c.8-3.5 3.6-5.5 7-5.5s6.2 2 7 5.5" />
      <circle cx="17" cy="7" r="2.8" />
      <path d="M16 13.4c2.4.3 4.4 2 5 4.6" />
    </>
  ),
  'heart': (
    <path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z" />
  ),

  /* ---------- Temps & calendrier ---------- */
  'calendar': (
    <>
      <rect x="3.5" y="5" width="17" height="16" rx="2.5" />
      <path d="M3.5 10h17" />
      <path d="M8 3v4" /><path d="M16 3v4" />
    </>
  ),
  'clock': (
    <>
      <circle cx="12" cy="12" r="9" />
      <path d="M12 7v5l3 2" />
    </>
  ),

  /* ---------- Lieux & contact ---------- */
  'map-pin': (
    <>
      <path d="M12 21s7-6 7-12a7 7 0 0 0-14 0c0 6 7 12 7 12Z" />
      <circle cx="12" cy="9" r="2.5" />
    </>
  ),
  'phone': (
    <path d="M5 4h3l2 5-2.5 1.5a11 11 0 0 0 6 6L15 14l5 2v3a2 2 0 0 1-2 2A15 15 0 0 1 3 6a2 2 0 0 1 2-2Z" />
  ),
  'mail': (
    <>
      <rect x="3" y="5" width="18" height="14" rx="2" />
      <path d="m3.5 6.5 8.5 7 8.5-7" />
    </>
  ),

  /* ---------- Actions ---------- */
  'download': (
    <>
      <path d="M12 4v12" />
      <path d="m7 11 5 5 5-5" />
      <path d="M5 20h14" />
    </>
  ),
  'upload': (
    <>
      <path d="M12 20V8" />
      <path d="m7 13 5-5 5 5" />
      <path d="M5 4h14" />
    </>
  ),
  'sparkle': (
    <>
      <path d="M12 4v6m0 4v6M4 12h6m4 0h6" />
      <path d="m6 6 3 3m6 6 3 3M18 6l-3 3M9 15l-3 3" />
    </>
  ),
  'quote': (
    <>
      <path d="M7 6c-2 1.5-3 3.8-3 7v5h5v-6H6c0-2 .8-3.5 2.5-4.5L7 6Z" fill="currentColor" stroke="none" />
      <path d="M17 6c-2 1.5-3 3.8-3 7v5h5v-6h-3c0-2 .8-3.5 2.5-4.5L17 6Z" fill="currentColor" stroke="none" />
    </>
  ),
  'star': (
    <path d="m12 3 2.6 5.5 6 .8-4.4 4.2 1.1 6L12 16.7 6.7 19.5l1.1-6L3.4 9.3l6-.8L12 3Z" />
  ),
  'plus': <><path d="M12 5v14" /><path d="M5 12h14" /></>,
  'minus': <path d="M5 12h14" />,
  'edit': (
    <>
      <path d="M4 20h4l11-11-4-4L4 16v4Z" />
      <path d="m14 6 4 4" />
    </>
  ),
  'search': (
    <>
      <circle cx="11" cy="11" r="6.5" />
      <path d="m20 20-4.5-4.5" />
    </>
  ),

  /* ---------- Communication & notifications ---------- */
  'message': (
    <>
      <path d="M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H9l-5 4V6a1 1 0 0 1 1-1Z" />
    </>
  ),
  'bell': (
    <>
      <path d="M6 16V11a6 6 0 1 1 12 0v5l1.5 2.5h-15L6 16Z" />
      <path d="M10 20a2 2 0 0 0 4 0" />
    </>
  ),
  'credit-card': (
    <>
      <rect x="3" y="6" width="18" height="13" rx="2" />
      <path d="M3 10h18" />
      <path d="M7 15h4" />
    </>
  ),
  'chevron-right': <path d="m9 6 6 6-6 6" />,
  'chevron-left':  <path d="m15 6-6 6 6 6" />,

  /* ---------- Soins & quotidien ---------- */
  'pill': (
    <>
      <rect x="3" y="9" width="18" height="6" rx="3" transform="rotate(-30 12 12)" />
      <path d="m8.5 7.5 8 8" transform="rotate(-30 12 12)" />
    </>
  ),
  'sun': (
    <>
      <circle cx="12" cy="12" r="4" />
      <path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4" />
    </>
  ),
  'flower': (
    <>
      <circle cx="12" cy="12" r="2.5" />
      <path d="M12 9.5V5a2.5 2.5 0 1 1 0 5Z" />
      <path d="M12 14.5V19a2.5 2.5 0 1 0 0-5Z" />
      <path d="M14.5 12H19a2.5 2.5 0 1 0-5 0Z" />
      <path d="M9.5 12H5a2.5 2.5 0 1 1 5 0Z" />
    </>
  ),
  'car': (
    <>
      <path d="M5 16V11l2-5h10l2 5v5" />
      <path d="M3 16h18v3a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-1H7v1a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-3Z" />
      <circle cx="7.5" cy="16.5" r="1" fill="currentColor" stroke="none" />
      <circle cx="16.5" cy="16.5" r="1" fill="currentColor" stroke="none" />
    </>
  ),
  'bed': (
    <>
      <path d="M3 18V8" />
      <path d="M3 13h18v5" />
      <path d="M21 18v-5a3 3 0 0 0-3-3h-7v3" />
      <circle cx="7" cy="11" r="2" />
    </>
  ),
};

const Icon = ({ name, size = 20, style = {}, strokeWidth = 1.6, ...rest }) => {
  const path = ICONS[name];
  if (!path) {
    /* Placeholder visible si l'icône manque */
    return (
      <span style={{ display: 'inline-block', width: size, height: size, border: '1px dashed currentColor', borderRadius: 4, fontSize: size * 0.5, lineHeight: `${size}px`, textAlign: 'center', ...style }}>
        ?
      </span>
    );
  }
  return (
    <svg
      width={size}
      height={size}
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth={strokeWidth}
      strokeLinecap="round"
      strokeLinejoin="round"
      style={{ flexShrink: 0, ...style }}
      aria-hidden="true"
      {...rest}
    >
      {path}
    </svg>
  );
};

/* Export global pour les autres scripts Babel */
window.Icon = Icon;
window.ICONS = ICONS;
