/* global React */
// Shared icons — hand-drawn, thin stroke, geometric feel matching Amper Velocity

const Icon = {
  Plate: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <rect x="2.5" y="5.5" width="19" height="13" rx="2"/>
      <path d="M6 9h2M10 9h2M14 9h2M18 9h.01"/>
      <path d="M6 13h12"/>
    </svg>
  ),
  Car: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 13l2-5a3 3 0 0 1 2.8-2h8.4A3 3 0 0 1 19 8l2 5"/>
      <path d="M3 13h18v5a1 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-5z"/>
      <circle cx="7.5" cy="16" r="1"/>
      <circle cx="16.5" cy="16" r="1"/>
    </svg>
  ),
  Shield: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 2.5l8 3.5v6c0 5-3.5 8.5-8 9.5-4.5-1-8-4.5-8-9.5V6l8-3.5z"/>
      <path d="M9 12l2 2 4-4"/>
    </svg>
  ),
  Bolt: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M13 2L4 14h7l-1 8 9-12h-7l1-8z"/>
    </svg>
  ),
  Check: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M5 12.5l4.5 4.5L19 7.5"/>
    </svg>
  ),
  CheckCircle: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <circle cx="12" cy="12" r="9.5"/>
      <path d="M8 12l3 3 5-6"/>
    </svg>
  ),
  Arrow: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6"/>
    </svg>
  ),
  ArrowUp: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 19V5M6 11l6-6 6 6"/>
    </svg>
  ),
  ArrowDown: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 5v14M6 13l6 6 6-6"/>
    </svg>
  ),
  Sparkle: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8L12 3z"/>
      <path d="M19 16l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z"/>
    </svg>
  ),
  Clock: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <circle cx="12" cy="12" r="9"/>
      <path d="M12 7v5l3 2"/>
    </svg>
  ),
  Money: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <rect x="2.5" y="6" width="19" height="12" rx="2"/>
      <circle cx="12" cy="12" r="2.5"/>
      <path d="M6 10v4M18 10v4"/>
    </svg>
  ),
  Doc: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z"/>
      <path d="M14 3v5h5M9 13h6M9 17h4"/>
    </svg>
  ),
  Home: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1v-9z"/>
    </svg>
  ),
  Menu: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" {...p}>
      <path d="M4 7h16M4 12h16M4 17h16"/>
    </svg>
  ),
  Close: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" {...p}>
      <path d="M6 6l12 12M18 6L6 18"/>
    </svg>
  ),
  Plus: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" {...p}>
      <path d="M12 5v14M5 12h14"/>
    </svg>
  ),
  Minus: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" {...p}>
      <path d="M5 12h14"/>
    </svg>
  ),
  Star: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor" {...p}>
      <path d="M12 2l2.9 6.6 7.1.6-5.4 4.7 1.7 7-6.3-3.9-6.3 3.9 1.7-7L2 9.2l7.1-.6L12 2z"/>
    </svg>
  ),
  Search: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <circle cx="11" cy="11" r="7"/>
      <path d="M20 20l-3.5-3.5"/>
    </svg>
  ),
  TrendUp: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 17l6-6 4 4 8-8"/>
      <path d="M14 7h7v7"/>
    </svg>
  ),
  Phone: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1A19.5 19.5 0 0 1 5.1 12.8 19.8 19.8 0 0 1 2 4.2 2 2 0 0 1 4 2h3a2 2 0 0 1 2 1.7c.1 1 .3 1.8.6 2.7a2 2 0 0 1-.4 2.1L8 9.8a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.5c.9.3 1.8.5 2.7.6a2 2 0 0 1 1.7 2z"/>
    </svg>
  ),
  MapPin: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M20 10c0 6-8 13-8 13S4 16 4 10a8 8 0 0 1 16 0z"/>
      <circle cx="12" cy="10" r="3"/>
    </svg>
  ),
  User: (p) => (
    <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <circle cx="12" cy="8" r="4"/>
      <path d="M4 21a8 8 0 0 1 16 0"/>
    </svg>
  ),
};

// Amper wordmark (official vector). Wordmark only — no symbol.
const AMPER_WORDMARK_PATHS = ["M3532.187,2727.16l-321.525,0c-19.779,-202.783 -31.729,-404.946 -54.979,-606.071c-0.1,-0.879 -4.213,-1.292 -9.883,-2.892c-79.008,203.1 -157.983,406.117 -237.104,609.508l-254.021,0c-79.113,-203.267 -158.275,-406.667 -237.437,-610.062c-3.979,0.442 -7.954,0.887 -11.933,1.329c-18.087,202.333 -36.179,404.667 -54.379,608.233l-321.904,0c29.104,-318.338 58.121,-635.725 87.192,-953.721l420.642,0c79.046,200.504 158.542,402.137 237.338,601.996c17.129,0.392 19.308,-9.833 22.308,-17.438c73.346,-185.892 146.371,-371.904 219.479,-557.888c3.492,-8.879 7.213,-17.671 10.946,-26.783l418.05,0c29.033,317.508 58.017,634.487 87.213,953.787","M7075.235,2727.848l-352.792,0c-68.054,-101.971 -135.979,-203.75 -204.483,-306.396l-116.596,0l0,-171.654c11.896,0 21.971,0.204 32.246,-0.008c59.812,-1.258 119.729,2.683 179.442,-3.333c43.842,-4.417 60.058,-21.875 60.433,-65.492c0.408,-47.721 0.258,-95.446 0.062,-143.171c-0.204,-50.525 -16.312,-68.488 -66.921,-72.008c-29.004,-2.017 -58.192,-1.771 -87.304,-1.883c-63.092,-0.254 -126.183,-0.133 -189.279,-0.029c-8.746,0.017 -17.817,-1.604 -28.417,4.408l0,758.679l-320.125,0l0,-950.396c6.35,-6.617 14.067,-3.829 20.967,-3.833c197.371,-0.146 394.742,-1.037 592.1,0.304c88.158,0.6 175.188,12.567 258.042,45.012c77.529,30.358 126.508,86.308 147.621,167.196c19.579,74.992 22.425,150.554 4.433,225.596c-20.479,85.396 -74.363,143.183 -161.192,175.208c76.975,113.521 152.954,225.575 231.762,341.8","M1938.406,2727.762l-324.425,0c-23.533,-59.617 -47.1,-119.317 -71.992,-182.375l-340.546,0c22.683,-59.792 43.704,-115.196 64.975,-171.258l207.796,0c-50.304,-127.587 -99.429,-252.175 -148.646,-376.996c-5.333,-5.833 -11.879,-7.504 -22.833,-3.521c-96.225,242.921 -193.283,487.95 -290.496,733.371l-323.612,0c126.2,-319.488 251.512,-636.733 376.771,-953.829l495.9,0c125.142,316.788 250.454,633.992 377.108,954.608","M4911.589,1773.675l880.204,0c-13.758,62.837 -27.188,124.162 -41.488,189.475l-515.912,0l0,202.179l472.829,0l0,170.679l-473.212,0l0,201.088l554,0l0,190.096l-876.421,0l0,-953.517Z","M4767.045,2024.902c-16.029,-105.717 -70.962,-179.746 -174.675,-213.9c-70.592,-26.592 -143.896,-37.442 -219.012,-37.829l-622.575,0l0,953.325l317.254,0l0,-762.675c34.479,0 65.858,-0.162 97.238,0.033c65.512,0.412 131.071,-0.35 196.521,1.954c53.8,1.896 69.975,20.654 70.067,73.788c0.096,56.625 -1.433,113.296 0.458,169.858c1.646,49.108 -16.55,69.562 -68.921,72.562c-48.4,2.771 -97.008,1.675 -145.512,2.821c-17.554,0.412 -36.946,0.15 -54.421,0.15l0,169.929c6.908,0 14.612,-0.204 21.75,-0.208c65.521,-0.042 131.046,0.204 196.562,-0.417c63.3,-0.6 125.792,-8.183 186.479,-26.804c87.504,-26.85 152.6,-78.5 182.979,-167.896c26.117,-76.858 27.846,-155.312 15.808,-234.692"];
const AmperLogo = ({ size = 22, height, color = 'currentColor' }) => {
  const h = height || size;
  return (
    <svg height={h} width={h * (6386.61 / 955.7)} viewBox="688.63 1772.15 6386.61 955.7" fill={color} role="img" aria-label="Amper" style={{ display: 'block', flexShrink: 0 }}>
      {AMPER_WORDMARK_PATHS.map((d, i) => <path key={i} d={d} fillRule="nonzero"/>)}
    </svg>
  );
};

// Currency formatter
const fmtBRL = (n) =>
  'R$ ' + Math.round(n).toLocaleString('pt-BR');

const fmtBRLShort = (n) => {
  if (n >= 1000) return 'R$ ' + (n / 1000).toFixed(1).replace('.', ',') + 'k';
  return fmtBRL(n);
};

Object.assign(window, { Icon, AmperLogo, fmtBRL, fmtBRLShort });
