// Shared icons + small UI primitives for QTicket redesign.
// Stroke-based icons in a single style — 24px viewBox.

const Ico = {
  bell: (p={}) => (
    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10 21a2 2 0 0 0 4 0"/>
    </svg>
  ),
  search: (p={}) => (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>
    </svg>
  ),
  swap: (p={}) => (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M7 4v16M7 4l-3 3M7 4l3 3M17 20V4M17 20l-3-3M17 20l3-3"/>
    </svg>
  ),
  filter: (p={}) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 6h18M6 12h12M10 18h4"/>
    </svg>
  ),
  home: (p={}) => (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 11 12 3l9 8"/><path d="M5 10v10h14V10"/>
    </svg>
  ),
  ticket: (p={}) => (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v2a2 2 0 0 0 0 4v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2a2 2 0 0 0 0-4Z"/><path d="M13 7v10" strokeDasharray="2 2"/>
    </svg>
  ),
  wallet: (p={}) => (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 7a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2"/><path d="M21 9H5a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2"/><circle cx="17" cy="14" r="1.5" fill="currentColor"/>
    </svg>
  ),
  user: (p={}) => (
    <svg width="22" height="22" viewBox="0 0 24 24" 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>
  ),
  pin: (p={}) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}>
      <circle cx="12" cy="12" r="6"/>
    </svg>
  ),
  arrowRight: (p={}) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6"/>
    </svg>
  ),
  back: (p={}) => (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M19 12H5M11 18l-6-6 6-6"/>
    </svg>
  ),
  bus: (p={}) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <rect x="4" y="3" width="16" height="15" rx="2"/><path d="M4 12h16M8 18v2M16 18v2"/><circle cx="8.5" cy="15" r="1" fill="currentColor" stroke="none"/><circle cx="15.5" cy="15" r="1" fill="currentColor" stroke="none"/>
    </svg>
  ),
  bolt: (p={}) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="m13 2-8 12h6l-1 8 8-12h-6l1-8z"/>
    </svg>
  ),
  qr: (p={}) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/>
      <path d="M14 14h3M20 14v3M14 17v4M17 20h4" strokeLinecap="round"/>
    </svg>
  ),
  download: (p={}) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 3v13M7 12l5 5 5-5M5 21h14"/>
    </svg>
  ),
  plus: (p={}) => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" {...p}>
      <path d="M12 5v14M5 12h14"/>
    </svg>
  ),
  check: (p={}) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="m5 12 5 5 9-11"/>
    </svg>
  ),
  chevR: (p={}) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="m9 6 6 6-6 6"/>
    </svg>
  ),
  star: (p={}) => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M12 2 14.6 8.5 21.5 9l-5.3 4.6L17.8 21 12 17.3 6.2 21l1.6-7.4L2.5 9l6.9-.5L12 2Z"/>
    </svg>
  ),
  luggage: (p={}) => (
    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <rect x="5" y="6" width="14" height="14" rx="2"/><path d="M9 6V4h6v2M9 10v6M15 10v6"/>
    </svg>
  ),
  wifi: (p={}) => (
    <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M2 9a15 15 0 0 1 20 0M5 13a10 10 0 0 1 14 0M8.5 16.5a5 5 0 0 1 7 0"/><circle cx="12" cy="20" r="1" fill="currentColor"/>
    </svg>
  ),
  snow: (p={}) => (
    <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" {...p}>
      <path d="M12 2v20M2 12h20M5 5l14 14M19 5 5 19"/>
    </svg>
  ),
  outlet: (p={}) => (
    <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" {...p}>
      <rect x="4" y="4" width="16" height="16" rx="4"/><circle cx="9" cy="11" r="1" fill="currentColor"/><circle cx="15" cy="11" r="1" fill="currentColor"/><path d="M9 16h6"/>
    </svg>
  ),
};

// Striped placeholder helper
function StripeFill({ color = '#0E1116', opacity = 0.06, size = 6, angle = 45 }) {
  const id = React.useId();
  return (
    <svg width="100%" height="100%" style={{position:'absolute', inset:0}}>
      <defs>
        <pattern id={id} patternUnits="userSpaceOnUse" width={size*2} height={size*2} patternTransform={`rotate(${angle})`}>
          <rect width={size} height={size*2} fill={color} opacity={opacity}/>
        </pattern>
      </defs>
      <rect width="100%" height="100%" fill={`url(#${id})`}/>
    </svg>
  );
}

// Pill that holds the selected date in a horizontal carousel
function DateStripPill({ items, selectedIdx = 2, dark = false }) {
  return (
    <div style={{position:'relative', padding:'6px 4px'}}>
      {/* highlight pill behind the selected item — inset-inline-start
          flips automatically under dir="rtl" parents */}
      <div style={{
        position:'absolute',
        insetInlineStart: `calc(${selectedIdx} * (100% / ${items.length}) + 4px)`,
        top: 6, bottom: 6,
        width: `calc(100% / ${items.length} - 8px)`,
        borderRadius: 999,
        background: dark ? '#FFFFFF' : '#0E1116',
        transition: 'inset-inline-start .25s ease',
      }}/>
      <div style={{position:'relative', display:'flex'}}>
        {items.map((it, i) => {
          const sel = i === selectedIdx;
          const c = sel ? (dark ? '#0E1116' : '#FFFFFF') : (dark ? 'rgba(255,255,255,.6)' : '#5B6270');
          return (
            <div key={i} style={{
              flex:1, padding:'10px 0', textAlign:'center',
              color: c, fontWeight: sel ? 600 : 500,
            }}>
              <div style={{fontSize:11, opacity:.7, letterSpacing:.4, textTransform:'uppercase'}}>{it.dow}</div>
              <div style={{fontSize:18, marginTop:2, fontWeight: sel ? 700 : 600}}>{it.d}</div>
              <div style={{fontSize:10, opacity:.7, marginTop:1, letterSpacing:.3, textTransform:'uppercase'}}>{it.mon}</div>
            </div>
          );
        })}
      </div>
    </div>
  );
}

// Small chip
function Chip({ children, dark = false, style = {} }) {
  return (
    <span style={{
      display:'inline-flex', alignItems:'center', gap:6,
      height:26, padding:'0 10px', borderRadius:999,
      fontSize:11, fontWeight:600, letterSpacing:.2,
      background: dark ? '#0E1116' : '#F0EDE5',
      color: dark ? '#FFFFFF' : '#0E1116',
      ...style,
    }}>{children}</span>
  );
}

// Logo-mark — circular monogram for the company list
function LogoMark({ initials, bg = '#0E1116', fg = '#FFFFFF', size = 36 }) {
  return (
    <div style={{
      width:size, height:size, borderRadius:'50%',
      background:bg, color:fg, display:'flex',
      alignItems:'center', justifyContent:'center',
      fontWeight:700, fontSize: size*0.36, letterSpacing:.5,
      fontFamily: 'var(--font-sans)',
    }}>{initials}</div>
  );
}

Object.assign(window, { Ico, StripeFill, DateStripPill, Chip, LogoMark });
