// T2 Falcon Admin — Icon library

const I = ({ children, size = 18, stroke = 2, fill = 'none', ...rest }) => (
  <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24"
       fill={fill} stroke="currentColor" strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round" {...rest}>
    {children}
  </svg>
);

// --- Sidebar ---
const IcDashboard = (p) => <I {...p}><rect x="3" y="3" width="8" height="8" rx="1.5"/><rect x="13" y="3" width="8" height="5" rx="1.5"/><rect x="13" y="10" width="8" height="11" rx="1.5"/><rect x="3" y="13" width="8" height="8" rx="1.5"/></I>;
const IcContactGroup = (p) => <I {...p}><path d="M16 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z"/><path d="M8.5 13a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z"/><path d="M1 20c0-3.5 3-6 7.5-6s7.5 2.5 7.5 6"/><path d="M16 14c3.5 0 7 2 7 6"/></I>;
const IcTemplate = (p) => <I {...p}><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/><path d="M9 9v11"/></I>;
const IcBuilding = (p) => <I {...p}><rect x="3" y="2" width="18" height="20" rx="2"/><path d="M8 6h2M14 6h2M8 10h2M14 10h2M8 14h2M14 14h2"/><path d="M10 22v-4h4v4"/></I>;
const IcFalcon = ({ size = 18, color = '#104C54' }) => (
  <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 201 201" fill="none" aria-hidden="true">
    <path d="M81.5074 24.2065H81.5593V24.2656L118.227 60.8461V24.3166L158.694 24.2656L197 62.32V100.537L158.753 138.739C171.549 138.791 184.323 138.79 197 138.79V177H120.735L82.6294 138.599C107.822 138.599 133.332 138.687 158.738 138.746C158.738 113.286 158.694 87.9426 158.694 62.4819L119.688 62.3423L119.754 62.4085H82.5336C82.5336 100.232 82.334 138.793 82.334 176.624H44.1098V100.463L82.5264 62.4085H43.5196C40.6122 59.6008 8.77816 27.7657 5 24C42.7594 24 43.6377 24.2065 81.3085 24.2065V24L81.5074 24.2065Z" fill={color}/>
  </svg>
);
const IcLock = (p) => <I {...p}><rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></I>;
const IcWallet = (p) => <I {...p}><path d="M3 7c0-1.5 1-2.5 2.5-2.5H18a2.5 2.5 0 0 1 2.5 2.5v10a2.5 2.5 0 0 1-2.5 2.5H5.5A2.5 2.5 0 0 1 3 17V7Z"/><path d="M16 12.5h2"/><path d="M3 7h14"/></I>;
const IcComm = (p) => <I {...p}><path d="M21 12a9 9 0 1 1-3.5-7.1l2.5-2.5v5.5h-5.5l2-2A6 6 0 1 0 18 12"/></I>;
const IcMarket = (p) => <I {...p}><path d="M3 7l1-3h16l1 3"/><path d="M3 7h18v3a3 3 0 1 1-6 0 3 3 0 1 1-6 0 3 3 0 1 1-6 0V7Z"/><path d="M5 14v7h14v-7"/></I>;
const IcContracts = (p) => <I {...p}><path d="M7 3h8l5 5v11a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h5"/></I>;
const IcSettings = (p) => <I {...p}><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 0 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 4.27 16.96l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06A2 2 0 1 1 7.04 4.27l.06.06a1.65 1.65 0 0 0 1.82.33h.01a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 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.82v.01a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z"/></I>;
const IcAudit = (p) => <I {...p}><rect x="4" y="3" width="16" height="18" rx="2"/><path d="M8 8h8M8 12h8M8 16h5"/></I>;

// --- Topbar ---
const IcSearch = (p) => <I {...p}><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></I>;
const IcBell = (p) => <I {...p}><path d="M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-12 0v3.2a2 2 0 0 1-.6 1.4L4 17h5"/><path d="M9 17a3 3 0 0 0 6 0"/></I>;
const IcChevronDown = (p) => <I {...p}><polyline points="6 9 12 15 18 9"/></I>;
const IcChevronUp = (p) => <I {...p}><polyline points="18 15 12 9 6 15"/></I>;
const IcChevronRight = (p) => <I {...p}><polyline points="9 18 15 12 9 6"/></I>;
const IcChevronLeft = (p) => <I {...p}><polyline points="15 18 9 12 15 6"/></I>;
const IcHome = (p) => <I {...p}><path d="m3 11 9-8 9 8"/><path d="M5 10v10a1 1 0 0 0 1 1h4v-6h4v6h4a1 1 0 0 0 1-1V10"/></I>;

// --- Content ---
const IcInfo = (p) => <I {...p}><circle cx="12" cy="12" r="9"/><path d="M12 8h.01M11 12h1v5h1"/></I>;
const IcPlus = (p) => <I {...p}><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></I>;
const IcUserPlus = (p) => <I {...p}><circle cx="10" cy="8" r="4"/><path d="M2 21c0-4 4-6 8-6s8 2 8 6"/><path d="M19 8v6M22 11h-6"/></I>;
const IcMore = (p) => <I {...p}><circle cx="12" cy="5" r="1.5" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="12" cy="19" r="1.5" fill="currentColor" stroke="none"/></I>;
const IcCheck = (p) => <I {...p}><polyline points="20 6 9 17 4 12"/></I>;
const IcClose = (p) => <I {...p}><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></I>;
const IcFilter = (p) => <I {...p}><polygon points="4 4 20 4 14 12 14 19 10 21 10 12 4 4"/></I>;
const IcArrowLeft = (p) => <I {...p}><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></I>;
const IcEdit = (p) => <I {...p}><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z"/></I>;
const IcDownload = (p) => <I {...p}><path d="M12 3v12"/><polyline points="7 10 12 15 17 10"/><path d="M5 21h14"/></I>;

// --- User menu ---
const IcGlobe = (p) => <I {...p}><circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"/></I>;
const IcUserCircle = (p) => <I {...p}><circle cx="12" cy="12" r="9"/><circle cx="12" cy="10" r="3"/><path d="M6.5 19a6 6 0 0 1 11 0"/></I>;
const IcKey = (p) => <I {...p}><circle cx="8" cy="15" r="4"/><path d="m11 12 9-9"/><path d="m16 7 3 3"/><path d="m18 5 3 3"/></I>;
const IcLogout = (p) => <I {...p}><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></I>;
const IcSun = (p) => <I {...p} stroke={2}><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></I>;
const IcMoon = (p) => <I {...p}><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z"/></I>;

// --- Status ---
const IcTrash = (p) => <I {...p}><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></I>;

// --- Buttons / actions ---
const IcZap = (p) => <I {...p}><polygon points="13 2 4 14 12 14 11 22 20 10 12 10 13 2" fill="currentColor" stroke="currentColor"/></I>;
const IcSquare = (p) => <I {...p}><rect x="4" y="4" width="16" height="16" rx="2"/></I>;
const IcReply = (p) => <I {...p}><polyline points="9 14 4 9 9 4"/><path d="M4 9h11a5 5 0 0 1 5 5v6"/></I>;
const IcGrid = (p) => <I {...p}><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></I>;
const IcContact = (p) => <I {...p}><rect x="4" y="3" width="16" height="18" rx="2"/><circle cx="12" cy="10" r="3"/><path d="M7 18a5 5 0 0 1 10 0"/></I>;
const IcText = (p) => <I {...p}><path d="M5 4h14M9 4v16M15 4v16"/></I>;
const IcImage = (p) => <I {...p}><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="m21 16-5-5-7 8"/></I>;
const IcDot = (p) => <I {...p} fill="currentColor"><circle cx="12" cy="12" r="4" stroke="none"/></I>;
const IcCheckSq = (p) => <I {...p}><rect x="3" y="3" width="18" height="18" rx="3"/><path d="m8 12 3 3 5-6"/></I>;
const IcInputBox = (p) => <I {...p}><rect x="3" y="8" width="18" height="8" rx="2"/><path d="M7 12h2"/></I>;
const IcDropdown = (p) => <I {...p}><rect x="3" y="6" width="18" height="12" rx="2"/><polyline points="9 11 12 14 15 11"/></I>;
const IcBuildingS = (p) => <I {...p}><rect x="4" y="3" width="16" height="18" rx="1.5"/><path d="M9 7h2M13 7h2M9 11h2M13 11h2M9 15h2M13 15h2M11 21v-3h2v3"/></I>;
const IcUsers = (p) => <I {...p}><circle cx="9" cy="8" r="3.5"/><path d="M2 20c0-3.5 3-5 7-5s7 1.5 7 5"/><circle cx="17" cy="9" r="2.5"/><path d="M22 20c0-3-1.5-4.5-4-4.5"/></I>;
const IcExternal = (p) => <I {...p}><path d="M14 4h6v6"/><path d="M20 4 11 13"/><path d="M19 13v6a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h6"/></I>;
const IcWa = (p) => <I {...p}><path d="M3 21l1.7-5A9 9 0 1 1 8 19.5L3 21Z"/><path d="M9.5 9.2c.4 1.2 1.2 2.3 2.3 3.2 1.1.9 2.3 1.5 3.5 1.7"/></I>;
const IcPhone = (p) => <I {...p}><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.86 19.86 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6A19.86 19.86 0 0 1 2.12 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.37 1.9.72 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.35 1.85.59 2.81.72a2 2 0 0 1 1.72 2Z"/></I>;
const IcSms = (p) => <I {...p}><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8A8.5 8.5 0 0 1 11.5 3a8.5 8.5 0 0 1 8.5 8.5z"/><circle cx="9" cy="12" r="0.9" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="0.9" fill="currentColor" stroke="none"/><circle cx="15" cy="12" r="0.9" fill="currentColor" stroke="none"/></I>;
const IcMail = (p) => <I {...p}><rect x="2" y="5" width="20" height="14" rx="2"/><path d="m2 7 10 7 10-7"/></I>;

// Saudi Riyal — updated 2026 glyph (currentColor)
const IcRiyal = ({ size = 14, style }) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    width={size}
    height={size}
    viewBox="0 0 21 21"
    fill="currentColor"
    aria-hidden="true"
    style={{ verticalAlign: '-0.12em', flex: 'none', ...style }}
  >
    <path d="M18.5771 16.084C18.5021 16.8304 18.3065 17.5425 18.0107 18.1982L11.751 19.5283C11.8259 18.7822 12.0217 18.0707 12.3174 17.415L18.5771 16.084ZM9.7998 9.97461L11.75 9.55957V3.6123C12.2893 2.95367 12.9531 2.3951 13.7002 1.97559V9.14551L18.5771 8.10938C18.5022 8.8555 18.3064 9.56714 18.0107 10.2227L13.7002 11.1387V13.1328L18.5771 12.0957C18.5023 12.8419 18.3064 13.5534 18.0107 14.209L11.75 15.541V11.5537L9.7998 11.9678V14.1797C9.79977 14.3815 9.73894 14.5691 9.63379 14.7246L8.61914 16.2285C8.36757 16.5948 7.98048 16.8614 7.53027 16.9551L2 18.1299C2.07492 17.3835 2.27062 16.6713 2.56641 16.0156L7.84961 14.8936V12.3828L2.91992 13.4297C2.995 12.6835 3.19066 11.972 3.48633 11.3164L7.84961 10.3887V2.63672C8.389 1.97804 9.05266 1.41938 9.7998 1V9.97461Z"/>
  </svg>
);

// Loyalty Points — circled "Pt" glyph (currentColor)
// Mirrors the asset at admin/assets/points-pt-circle.svg. Renders inline like
// IcRiyal so it can be dropped anywhere a currency mark is shown.
const IcPoints = ({ size = 14, style }) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    width={size}
    height={size}
    viewBox="0 0 24 24"
    fill="currentColor"
    aria-hidden="true"
    style={{ verticalAlign: '-0.12em', flex: 'none', ...style }}
  >
    <path fillRule="evenodd" d="M12,0C5.383,0,0,5.383,0,12s5.383,12,12,12,12-5.383,12-12S18.617,0,12,0Zm0,22c-5.514,0-10-4.486-10-10S6.486,2,12,2s10,4.486,10,10-4.486,10-10,10Z"/>
    <path d="M0.09187 0.72906 L0.40375 0.72906 Q0.54297 0.72906 0.61734 0.66719 Q0.69188 0.60547 0.69188 0.49125 Q0.69188 0.37641 0.61734 0.31469 Q0.54297 0.25297 0.40375 0.25297 L0.27984 0.25297 L0.27984 0 L0.09187 0 L0.09187 0.72906 Z M0.27984 0.59281 L0.27984 0.38922 L0.38375 0.38922 Q0.43844 0.38922 0.46828 0.41578 Q0.49812 0.44234 0.49812 0.49125 Q0.49812 0.54 0.46828 0.56641 Q0.43844 0.59281 0.38375 0.59281 L0.27984 0.59281 Z M1.00775 0.70219 L1.00775 0.54688 L1.18807 0.54688 L1.18807 0.42188 L1.00775 0.42188 L1.00775 0.19 Q1.00775 0.15188 1.02291 0.13844 Q1.03807 0.125 1.08307 0.125 L1.17291 0.125 L1.17291 0 L1.02291 0 Q0.91947 0 0.87619 0.04313 Q0.83307 0.08641 0.83307 0.19 L0.83307 0.42188 L0.74604 0.42188 L0.74604 0.54688 L0.83307 0.54688 L0.83307 0.70219 L1.00775 0.70219 Z" transform="translate(6.88023 15.06625) scale(8 -8)"/>
  </svg>
);

// T2 brand
const T2Mark = ({ size = 22, color = 'currentColor' }) => (
  <svg width={size} height={size * (105/130)} viewBox="0 0 130 105" fill={color} xmlns="http://www.w3.org/2000/svg">
    <path d="M52.614 0.131h0.033v0.037L75.946 23.36V0.201l25.714-0.033L126 24.294v24.23l-24.302 24.219c8.13 0.033 16.247 0.033 24.302 0.033V97H77.540L53.327 72.654c16.008 0 32.217 0.056 48.361 0.094 0-16.142-0.028-32.209-0.028-48.351l-24.786-0.089 0.042 0.042H53.266c0 23.98-0.127 48.427-0.127 72.412H28.851V48.476L53.262 24.350H28.476C26.629 22.570 6.401 2.387 4 0c23.993 0 24.551 0.131 48.488 0.131V0L52.614 0.131Z"/>
  </svg>
);

// Export
Object.assign(window, {
  I, IcDashboard, IcContactGroup, IcTemplate, IcBuilding, IcFalcon, IcLock, IcWallet, IcComm,
  IcMarket, IcContracts, IcSettings, IcAudit,
  IcSearch, IcBell, IcChevronDown, IcChevronUp, IcChevronRight, IcChevronLeft, IcHome,
  IcInfo, IcPlus, IcUserPlus, IcMore, IcCheck, IcClose, IcFilter, IcArrowLeft, IcEdit, IcDownload,
  IcGlobe, IcUserCircle, IcKey, IcLogout, IcSun, IcMoon, IcTrash, T2Mark, IcRiyal, IcPoints,
  IcZap, IcSquare, IcReply, IcGrid, IcContact, IcText, IcImage, IcDot, IcCheckSq, IcInputBox, IcDropdown, IcBuildingS, IcUsers, IcExternal, IcWa, IcPhone, IcSms, IcMail,
});
