/* Inline SVG icons (lucide-style strokes). Globally scoped. */
const { useEffect, useState, useRef, useMemo } = React;

const Icon = ({ d, size = 20, stroke = 'currentColor', sw = 2, fill = 'none', className = '', children, viewBox = '0 0 24 24' }) => (
  <svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox={viewBox}
       fill={fill} stroke={stroke} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round"
       className={className}>
    {d ? <path d={d} /> : children}
  </svg>
);

const Mic       = (p) => <Icon {...p}><rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 19v3"/></Icon>;
const Bell      = (p) => <Icon {...p}><path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9"/><path d="M10.5 21a1.7 1.7 0 0 0 3 0"/></Icon>;
const Menu      = (p) => <Icon {...p}><path d="M3 6h18"/><path d="M3 12h18"/><path d="M3 18h18"/></Icon>;
const Home      = (p) => <Icon {...p}><path d="M3 11.5 12 4l9 7.5"/><path d="M5 10v10h14V10"/></Icon>;
const Pkg       = (p) => <Icon {...p}><path d="M3 7.5 12 3l9 4.5v9L12 21 3 16.5z"/><path d="M3 7.5 12 12l9-4.5"/><path d="M12 12v9"/></Icon>;
const Wallet    = (p) => <Icon {...p}><path d="M3 7h15a3 3 0 0 1 3 3v7a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3z"/><path d="M3 7V6a2 2 0 0 1 2-2h11"/><circle cx="17" cy="14" r="1.4" fill="currentColor" stroke="none"/></Icon>;
const Chart     = (p) => <Icon {...p}><path d="M4 20V10"/><path d="M10 20V4"/><path d="M16 20v-7"/><path d="M22 20H2"/></Icon>;
const User      = (p) => <Icon {...p}><circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/></Icon>;
const Check     = (p) => <Icon {...p}><path d="M5 12.5 10 17 19 7"/></Icon>;
const CheckCirc = (p) => <Icon {...p}><circle cx="12" cy="12" r="9"/><path d="M8 12.5 11 15.5 16 9.5"/></Icon>;
const Phone     = (p) => <Icon {...p}><path d="M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2"/></Icon>;
const MapPin    = (p) => <Icon {...p}><path d="M12 22s7-7 7-12a7 7 0 1 0-14 0c0 5 7 12 7 12z"/><circle cx="12" cy="10" r="2.5"/></Icon>;
const Camera    = (p) => <Icon {...p}><path d="M4 8h3l2-3h6l2 3h3a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2z"/><circle cx="12" cy="13" r="4"/></Icon>;
const ChevR     = (p) => <Icon {...p}><path d="M9 5l7 7-7 7"/></Icon>;
const ChevL     = (p) => <Icon {...p}><path d="M15 5l-7 7 7 7"/></Icon>;
const Play      = (p) => <Icon {...p} fill="currentColor"><path d="M7 4.5v15l13-7.5z"/></Icon>;
const Pause     = (p) => <Icon {...p} fill="currentColor"><rect x="6" y="5" width="4" height="14" rx="1.2"/><rect x="14" y="5" width="4" height="14" rx="1.2"/></Icon>;
const X         = (p) => <Icon {...p}><path d="M6 6l12 12"/><path d="M18 6 6 18"/></Icon>;
const Flame     = (p) => <Icon {...p}><path d="M12 3c1 4 5 4 5 9a5 5 0 1 1-10 0c0-2 1-3 2-4 0 2 1 3 2 3 0-3 0-6 1-8z"/></Icon>;
const Sparkles  = (p) => <Icon {...p}><path d="M12 3v4"/><path d="M12 17v4"/><path d="M3 12h4"/><path d="M17 12h4"/><path d="M5.6 5.6l2.8 2.8"/><path d="M15.6 15.6l2.8 2.8"/><path d="M5.6 18.4l2.8-2.8"/><path d="M15.6 8.4l2.8-2.8"/></Icon>;
const ShieldOk  = (p) => <Icon {...p}><path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6z"/><path d="M9 12l2 2 4-4"/></Icon>;
const Clock     = (p) => <Icon {...p}><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></Icon>;
const Bolt      = (p) => <Icon {...p}><path d="M13 2 4 14h6l-1 8 9-12h-6z"/></Icon>;
const Star      = (p) => <Icon {...p}><path d="m12 3 2.7 5.6 6.3.9-4.6 4.4 1.1 6.1L12 17l-5.6 3 1.1-6.1L3 9.5l6.3-.9z"/></Icon>;
const ArrowR    = (p) => <Icon {...p}><path d="M4 12h16"/><path d="m14 6 6 6-6 6"/></Icon>;
const Wifi      = (p) => <Icon {...p}><path d="M5 12.5a10 10 0 0 1 14 0"/><path d="M8.5 16a5 5 0 0 1 7 0"/><circle cx="12" cy="19" r="1" fill="currentColor" stroke="none"/></Icon>;
const Battery   = (p) => <Icon {...p}><rect x="2" y="7" width="18" height="10" rx="2"/><rect x="4" y="9" width="14" height="6" rx="1" fill="currentColor" stroke="none"/><path d="M22 11v2"/></Icon>;
const Signal    = (p) => <Icon {...p}><rect x="3" y="14" width="3" height="6" rx="0.5" fill="currentColor" stroke="none"/><rect x="8" y="11" width="3" height="9" rx="0.5" fill="currentColor" stroke="none"/><rect x="13" y="7" width="3" height="13" rx="0.5" fill="currentColor" stroke="none"/><rect x="18" y="3" width="3" height="17" rx="0.5" fill="currentColor" stroke="none"/></Icon>;

/* The Sarthi mark — a stylized soft orb. */
const SarthiOrb = ({ size = 64, listening = false, glow = true, className = '' }) => (
  <div className={`relative inline-flex items-center justify-center ${className}`} style={{ width: size, height: size }}>
    <div className={`absolute inset-0 rounded-full orb-grad shadow-orb ${glow ? (listening ? 'orb-pulse-lg' : 'orb-pulse') : ''}`}></div>
    {/* inner highlight */}
    <div className="absolute inset-0 rounded-full"
         style={{ background: 'radial-gradient(ellipse at 30% 25%, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 45%)' }}></div>
    {/* tiny inner core */}
    <div className="absolute rounded-full"
         style={{
           width: size * 0.28, height: size * 0.28,
           background: 'radial-gradient(circle, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.0) 70%)',
           filter: 'blur(2px)',
         }}></div>
  </div>
);

/* Small "speaking" indicator (3 bars) */
const SpeakingDots = ({ color = '#fff', size = 14 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
    <rect x="4"  y="6"  width="3" height="12" rx="1.5" fill={color} className="speak-dot" style={{ animationDelay: '0ms' }}/>
    <rect x="10" y="6"  width="3" height="12" rx="1.5" fill={color} className="speak-dot" style={{ animationDelay: '150ms' }}/>
    <rect x="16" y="6"  width="3" height="12" rx="1.5" fill={color} className="speak-dot" style={{ animationDelay: '300ms' }}/>
  </svg>
);

Object.assign(window, {
  Icon, Mic, Bell, Menu, Home, Pkg, Wallet, Chart, User, Check, CheckCirc, Phone,
  MapPin, Camera, ChevR, ChevL, Play, Pause, X, Flame, Sparkles, ShieldOk, Clock,
  Bolt, Star, ArrowR, Wifi, Battery, Signal, SarthiOrb, SpeakingDots,
});
