// JustZix icon library — wszystkie ikony zaprojektowane do użycia z `stroke="currentColor"`.
// Dziedziczą `color` z elementu rodzica i automatycznie respektują motyw light/dark.
// Pełna legenda: extension/justzix-docs/icons-legend.html
//
// Użycie:
//   element.innerHTML = JZ_ICONS.export;
// lub:
//   element.innerHTML = jzIcon('export', 'menu-icon');
//
// Każda ikona to kompletny <svg> 24x24 z atrybutem class="jz-icon".

const JZ_ICONS = {
  // 1. Nawigacja
  home:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 11L12 3L21 11"/><path d="M5 9.5V21H19V9.5"/><path d="M9 21V14H15V21"/></svg>',
  // 2. Hierarchia
  folder:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M22 19H2V5H9L7 8H2V19H22Z"/></svg>',
  group:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M22 19H2V5H9L7 8H2V19H22Z"/><line x1="7" y1="13" x2="17" y2="13"/></svg>',
  rule:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M14 2H6V22H18V6L14 2Z"/><path d="M14 2V6H18"/></svg>',
  add:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>',

  // 3. Toolbar actions
  export:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M21 15V19H3V15"/><path d="M12 14V3"/><path d="M17 8L12 3L7 8"/></svg>',
  import:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M21 15V19H3V15"/><path d="M12 3V14"/><path d="M7 9L12 14L17 9"/></svg>',
  insertUrl: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 21L12 13"/><path d="M16 5V13H8V5H16Z"/></svg>',
  shareNetwork: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="6" cy="12" r="3"/><circle cx="18" cy="6" r="3"/><circle cx="18" cy="18" r="3"/><line x1="8.6" y1="10.6" x2="15.4" y2="7.4"/><line x1="8.6" y1="13.4" x2="15.4" y2="16.6"/></svg>',
  refresh: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="20 7 20 2 15 2"/><path d="M20 7H4V13"/><polyline points="4 17 4 22 9 22"/><path d="M4 17H20V11"/></svg>',
  refreshCircle: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>',
  globe: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',
  search:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16" y2="16"/></svg>',
  storage: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 4H16L20 8V20H4V4Z"/><path d="M14 4V8H6V4"/><path d="M16 20V14H8V20"/></svg>',
  themeDark: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>',
  themeLight: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="5"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="4.93" y1="4.93" x2="7.05" y2="7.05"/><line x1="16.95" y1="16.95" x2="19.07" y2="19.07"/><line x1="2" y1="12" x2="5" y2="12"/><line x1="19" y1="12" x2="22" y2="12"/><line x1="4.93" y1="19.07" x2="7.05" y2="16.95"/><line x1="16.95" y1="7.05" x2="19.07" y2="4.93"/></svg>',
  themeAuto: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="9"/><path d="M12 3 a9 9 0 0 1 0 18 z" fill="currentColor" stroke="none"/></svg>',
  tag:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 4H10L20 14L14 20L4 10V4Z"/><line x1="8" y1="8" x2="8.01" y2="8" stroke-width="3"/></svg>',
  target:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 2L22 12L12 22L2 12Z"/><circle cx="12" cy="12" r="3" fill="currentColor" stroke="none"/></svg>',
  stats:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 20H20"/><rect x="6" y="12" width="3" height="8"/><rect x="11" y="4" width="3" height="16"/><rect x="16" y="8" width="3" height="12"/></svg>',
  eye:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M2 12L12 4L22 12L12 20Z"/><circle cx="12" cy="12" r="3"/></svg>',
  copy:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M16 4h2v16H6V4h2"/><rect x="8" y="2" width="8" height="4"/></svg>',
  move:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="2" y="6" width="8" height="12"/><line x1="10" y1="12" x2="20" y2="12"/><polyline points="17 9 20 12 17 15"/></svg>',
  dotsV:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/></svg>',
  undo:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="8 5 3 10 8 15"/><path d="M3 10H15C18.31 10 21 12.69 21 16V19"/></svg>',
  redo:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="16 5 21 10 16 15"/><path d="M21 10H9C5.69 10 3 12.69 3 16V19"/></svg>',
  back:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="9 14 4 9 9 4"/><path d="M4 9H15C17.76 9 20 11.24 20 14V20"/></svg>',
  help:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><path d="M9.09 9C9.325 8.33 9.975 7.8 10.8 7.8C11.9 7.8 12.8 8.7 12.8 9.8C12.8 11.8 9.8 11.4 9.8 14"/><line x1="12" y1="17" x2="12.01" y2="17" stroke-width="3"/></svg>',
  lineNumbers: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><line x1="4" y1="9" x2="20" y2="9"/><line x1="4" y1="15" x2="20" y2="15"/><line x1="10" y1="3" x2="8" y2="21"/><line x1="16" y1="3" x2="14" y2="21"/></svg>',
  block:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><line x1="5" y1="5" x2="19" y2="19"/></svg>',
  duplicate: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="8" y="8" width="12" height="12"/><path d="M4 16V4H16"/></svg>',
  close:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',

  // 4. Status
  active:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="12" cy="12" r="8"/></svg>',
  inactive:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="8"/></svg>',

  // 5. Etykiety zawartości
  flagCss:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18"/><path d="M15 9C15 9 14.5 8 12 8C9.5 8 8 9.5 8 12C8 14.5 9.5 16 12 16C14.5 16 15 15 15 15"/></svg>',
  flagJs:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18"/><path d="M15 8V14C15 15.5 14 16 12 16C10 16 9 15.5 9 14"/></svg>',
  flagActions: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18"/><path d="M15 16L12 8L9 16"/><line x1="10" y1="13" x2="14" y2="13"/></svg>',
  flagUrl:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18"/><path d="M9 8V13C9 15 10.5 16 12 16C13.5 16 15 15 15 13V8"/></svg>',

  // 6. Stany pływającego przycisku (solidne kółka — kolor przez klasę color-*)
  stateOn:        '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',
  stateMixed:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',
  stateOff:       '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',
  stateGlobalOff: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"><circle cx="12" cy="12" r="10"/><line x1="10" y1="8" x2="10" y2="16"/><line x1="14" y1="8" x2="14" y2="16"/></svg>',
  stateBadFile:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',
  statePartial:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',
  stateDragGroup: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><rect x="2" y="2" width="20" height="20" rx="4"/></svg>',
  stateError:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',

  // 7. Karta zestawu — zakładki
  tabCss:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M18 3L21 6L11 16H8V13L18 3Z"/><path d="M8 16L5 19L2 22"/></svg>',
  tabJs:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M13 2L3 14H12L11 22L21 10H12L13 2Z"/></svg>',
  tabActions: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="4" fill="currentColor"/></svg>',
  tabUrl:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>',
  fullEditor: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="4 8 4 4 8 4"/><polyline points="16 4 20 4 20 8"/><polyline points="4 16 4 20 8 20"/><polyline points="16 20 20 20 20 16"/></svg>',
  pin:       '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 4H15V10L18 13H6L9 10V4Z"/><line x1="12" y1="13" x2="12" y2="22"/></svg>',
  package:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M2 12L12 17L22 12"/><path d="M22 7L12 12L2 7L12 2L22 7Z"/><path d="M2 7V17L12 22V12"/><path d="M22 7V17L12 22"/></svg>',

  // 8. Sidebar — kontrolki
  expandRight: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><polygon points="9,6 15,12 9,18"/></svg>',
  expandDown:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><polygon points="6,9 12,15 18,9"/></svg>',
  caretDown:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><polygon points="8,10 12,14 16,10"/></svg>',
  toggleLeft:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="15 18 9 12 15 6"/></svg>',
  toggleRight: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="9 18 15 12 9 6"/></svg>',
  dragHandle:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="12" cy="6" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="12" cy="18" r="1.5"/></svg>',
  emptyDot:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="12" cy="12" r="2.5"/></svg>',
  expandAll:   '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="8" y1="12" x2="16" y2="12"/><line x1="12" y1="8" x2="12" y2="16"/></svg>',
  collapseAll: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="8" y1="12" x2="16" y2="12"/></svg>',

  // 9. Komunikaty
  check:    '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="20 6 9 17 4 12"/></svg>',
  warning:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 3L22 20H2Z"/><line x1="12" y1="9" x2="12" y2="14"/><line x1="12" y1="17" x2="12.01" y2="17" stroke-width="3"/></svg>',
  arrowRight: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>',
  toggleLoop: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M16 3H5V11"/><polyline points="8 8 5 11 2 8"/><path d="M8 21H19V13"/><polyline points="16 16 19 13 22 16"/></svg>',
  threeViews: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="3" y="3" width="18" height="18"/><line x1="9" y1="3" x2="9" y2="21"/></svg>',
  mute:     '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M11 5L6 9H2V15H6L11 19V5Z"/><line x1="22" y1="9" x2="16" y2="15"/><line x1="16" y1="9" x2="22" y2="15"/></svg>',
  fix:      '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M15 15L21 21M15 9V15H9M15 9H9M9 15L3 21"/><circle cx="12" cy="12" r="5"/></svg>',
  dev:      '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><rect x="2" y="6" width="20" height="12"/><line x1="6" y1="6" x2="2" y2="10"/><line x1="14" y1="6" x2="6" y2="18"/><line x1="22" y1="6" x2="14" y2="18"/><line x1="22" y1="14" x2="18" y2="18"/></svg>',
  ellipsis: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" stroke="none"><circle cx="5" cy="12" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="19" cy="12" r="2"/></svg>',

  // 10. Settings cog (drop-up trigger)
  settings: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',

  // 11. Action bar connections — disconnect (sugerowane użycie z klasą `color-red`).
  unlink:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/><line x1="2" y1="2" x2="22" y2="22"/></svg>',
  crossX:  '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><line x1="2" y1="2" x2="22" y2="22"/></svg>',

  // 12. Developer / programming — `< >` chevrons (kod, JS API).
  codeBrackets: '<svg class="jz-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square" stroke-linejoin="miter"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
};

// Helper: zwraca SVG jako string z opcjonalnymi dodatkowymi klasami.
function jzIcon(name, extraClass) {
  const svg = JZ_ICONS[name];
  if (!svg) {
    console.warn('[JustZix] icon not found:', name);
    return '';
  }
  if (!extraClass) return svg;
  return svg.replace('class="jz-icon"', `class="jz-icon ${extraClass}"`);
}

// Injection: podmienia placeholdery `<i data-jz-icon="name">` na pełne <svg> z JZ_ICONS.
// Zachowuje dodatkowe klasy CSS i inline style z placeholdera — przenosi je na docelowy <svg>.
//   <i data-jz-icon="folder"></i>                            → <svg class="jz-icon">...</svg>
//   <i data-jz-icon="warning" class="color-orange"></i>      → <svg class="jz-icon color-orange">...</svg>
//   <i data-jz-icon="tabUrl" style="color:#006870;"></i>     → <svg class="jz-icon" style="color:#006870;">...</svg>
function injectJzIcons(root) {
  const scope = root || document;
  scope.querySelectorAll('[data-jz-icon]').forEach(el => {
    const name = el.dataset.jzIcon;
    const svg = JZ_ICONS[name];
    if (!svg) {
      console.warn('[JustZix] injectJzIcons: unknown icon key', name, el);
      return;
    }
    const extraClass = (el.getAttribute('class') || '').trim();
    const inlineStyle = el.getAttribute('style') || '';
    let html = svg;
    if (extraClass) {
      html = html.replace('class="jz-icon"', `class="jz-icon ${extraClass}"`);
    }
    if (inlineStyle) {
      html = html.replace('<svg ', `<svg style="${inlineStyle}" `);
    }
    el.outerHTML = html;
  });
}

// Eksport dla skryptów wtyczki (inline w options.html / popup.html). Brak modułów ES — Manifest V3 service workers są moduli, ale options/popup są skryptami.
if (typeof window !== 'undefined') {
  window.JZ_ICONS = JZ_ICONS;
  window.jzIcon = jzIcon;
  window.injectJzIcons = injectJzIcons;

  // Auto-inject statycznych placeholderów w HTML — żeby konsumenci nie musieli dodawać
  // inline script tag (CSP w MV3 blokuje inline). Bezpieczne dla popup.html / innych
  // miejsc: jeśli nie ma `[data-jz-icon]` placeholderów, funkcja nic nie robi.
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', () => injectJzIcons());
  } else {
    injectJzIcons();
  }
}
