// Icons & illustrations for Mitreden
// Inline SVGs — strokes match style: rounded, 2px

const Icon = {
  Mic: ({ size = 24, off = false }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/>
      <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>
      <line x1="12" y1="19" x2="12" y2="22"/>
      {off && <line x1="4" y1="4" x2="20" y2="20" stroke="currentColor" strokeWidth="2.5"/>}
    </svg>
  ),
  Cam: ({ size = 24, off = false }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M3 7a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"/>
      <path d="m16 10 5-3v10l-5-3"/>
      {off && <line x1="4" y1="4" x2="20" y2="20" stroke="currentColor" strokeWidth="2.5"/>}
    </svg>
  ),
  Phone: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ transform: 'rotate(135deg)' }}>
      <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 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-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/>
    </svg>
  ),
  Users: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/>
      <circle cx="9" cy="7" r="4"/>
      <path d="M22 21v-2a4 4 0 0 0-3-3.87"/>
      <path d="M16 3.13a4 4 0 0 1 0 7.75"/>
    </svg>
  ),
  Clock: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="10"/>
      <polyline points="12 6 12 12 16 14"/>
    </svg>
  ),
  Calendar: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
      <line x1="16" y1="2" x2="16" y2="6"/>
      <line x1="8" y1="2" x2="8" y2="6"/>
      <line x1="3" y1="10" x2="21" y2="10"/>
    </svg>
  ),
  Play: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
      <path d="M8 5v14l11-7z"/>
    </svg>
  ),
  Plus: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round">
      <line x1="12" y1="5" x2="12" y2="19"/>
      <line x1="5" y1="12" x2="19" y2="12"/>
    </svg>
  ),
  Chart: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <line x1="18" y1="20" x2="18" y2="10"/>
      <line x1="12" y1="20" x2="12" y2="4"/>
      <line x1="6" y1="20" x2="6" y2="14"/>
    </svg>
  ),
  Pin: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/>
      <circle cx="12" cy="10" r="3"/>
    </svg>
  ),
  Sparkle: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
      <path d="M12 2l2 7 7 2-7 2-2 7-2-7-7-2 7-2z"/>
    </svg>
  ),
  Hand: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M18 11V6a2 2 0 0 0-2-2 2 2 0 0 0-2 2"/>
      <path d="M14 10V4a2 2 0 0 0-2-2 2 2 0 0 0-2 2v2"/>
      <path d="M10 10.5V6a2 2 0 0 0-2-2 2 2 0 0 0-2 2v8"/>
      <path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/>
    </svg>
  ),
  Settings: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <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 0 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 0 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 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 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h.09a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h.09a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 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 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
    </svg>
  ),
  Lock: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
      <path d="M7 11V7a5 5 0 0 1 10 0v4"/>
    </svg>
  ),
  Ear: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0"/>
      <path d="M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4"/>
    </svg>
  ),
  Send: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <line x1="22" y1="2" x2="11" y2="13"/>
      <polygon points="22 2 15 22 11 13 2 9 22 2"/>
    </svg>
  ),
  Stop: ({ size = 24 }) => (
    <svg className="icon" width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
      <rect x="6" y="6" width="12" height="12" rx="2"/>
    </svg>
  ),
  Trend: ({ size = 16, down = false }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" style={{ transform: down ? 'scaleY(-1)' : 'none' }}>
      <polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/>
      <polyline points="17 6 23 6 23 12"/>
    </svg>
  ),
};

// Friendly hand-drawn illustration: a circle of diverse people around a screen
function IllusCommunity({ width = 420, height = 360 }) {
  return (
    <svg viewBox="0 0 420 360" width="100%" style={{ maxWidth: width }} xmlns="http://www.w3.org/2000/svg">
      {/* Soft background blob */}
      <ellipse cx="210" cy="210" rx="180" ry="120" fill="#DCE7F8" opacity="0.6"/>

      {/* Central video frame */}
      <rect x="130" y="120" width="160" height="110" rx="14" fill="#2456C7"/>
      <rect x="138" y="128" width="68" height="44" rx="8" fill="#FFE4B5"/>
      <circle cx="172" cy="148" r="11" fill="#FFB547"/>
      <path d="M161 168c0-7 5-11 11-11s11 4 11 11" fill="#FFB547"/>

      <rect x="214" y="128" width="68" height="44" rx="8" fill="#FFD0D0"/>
      <circle cx="248" cy="148" r="11" fill="#D14343"/>
      <path d="M237 168c0-7 5-11 11-11s11 4 11 11" fill="#D14343"/>

      <rect x="138" y="180" width="68" height="44" rx="8" fill="#D4F0DC"/>
      <circle cx="172" cy="200" r="11" fill="#16A34A"/>
      <path d="M161 220c0-7 5-11 11-11s11 4 11 11" fill="#16A34A"/>

      <rect x="214" y="180" width="68" height="44" rx="8" fill="#DCE7F8"/>
      <circle cx="248" cy="200" r="11" fill="#3B72E0"/>
      <path d="M237 220c0-7 5-11 11-11s11 4 11 11" fill="#3B72E0"/>

      {/* People around */}
      {/* Left person */}
      <g transform="translate(40,160)">
        <circle cx="30" cy="30" r="26" fill="#FFE4B5"/>
        <circle cx="30" cy="22" r="14" fill="#FFD693"/>
        <path d="M10 56c0-10 9-18 20-18s20 8 20 18" fill="#2456C7"/>
      </g>

      {/* Right person */}
      <g transform="translate(310,160)">
        <circle cx="30" cy="30" r="26" fill="#F8D9D9"/>
        <circle cx="30" cy="22" r="14" fill="#E8B0B0"/>
        <path d="M10 56c0-10 9-18 20-18s20 8 20 18" fill="#FFB547"/>
        {/* hand waving */}
        <path d="M55 25c4-2 8 0 7 5" stroke="#E8B0B0" strokeWidth="6" strokeLinecap="round" fill="none"/>
      </g>

      {/* Top center person */}
      <g transform="translate(180,30)">
        <circle cx="30" cy="30" r="22" fill="#D4F0DC"/>
        <circle cx="30" cy="24" r="12" fill="#B5DCBE"/>
        <path d="M14 50c0-9 7-15 16-15s16 6 16 15" fill="#16A34A"/>
      </g>

      {/* Flying emojis */}
      <g transform="translate(90,80)">
        <circle cx="0" cy="0" r="22" fill="#FFB547"/>
        <text x="0" y="8" textAnchor="middle" fontSize="22">👍</text>
      </g>
      <g transform="translate(340,90)">
        <circle cx="0" cy="0" r="20" fill="#F8D9D9"/>
        <text x="0" y="7" textAnchor="middle" fontSize="22">❤️</text>
      </g>
      <g transform="translate(350,250)">
        <circle cx="0" cy="0" r="20" fill="#D4F0DC"/>
        <text x="0" y="7" textAnchor="middle" fontSize="22">👏</text>
      </g>
      <g transform="translate(70,260)">
        <circle cx="0" cy="0" r="20" fill="#DCE7F8"/>
        <text x="0" y="7" textAnchor="middle" fontSize="22">😊</text>
      </g>
    </svg>
  );
}

// Calmer illustration for "no meeting" state — a cozy person waving
function IllusWaiting({ width = 380, height = 340 }) {
  return (
    <svg viewBox="0 0 380 340" width="100%" style={{ maxWidth: width }} xmlns="http://www.w3.org/2000/svg">
      <ellipse cx="190" cy="200" rx="160" ry="110" fill="#F4ECDA"/>

      {/* Sun */}
      <circle cx="310" cy="70" r="30" fill="#FFB547" opacity="0.7"/>
      <g stroke="#FFB547" strokeWidth="3" strokeLinecap="round" opacity="0.5">
        <line x1="310" y1="20" x2="310" y2="30"/>
        <line x1="356" y1="40" x2="350" y2="48"/>
        <line x1="364" y1="70" x2="354" y2="70"/>
        <line x1="356" y1="100" x2="350" y2="92"/>
        <line x1="260" y1="40" x2="266" y2="48"/>
      </g>

      {/* Couch */}
      <rect x="50" y="220" width="280" height="60" rx="20" fill="#2456C7"/>
      <rect x="40" y="240" width="60" height="60" rx="18" fill="#1A3A8C"/>
      <rect x="280" y="240" width="60" height="60" rx="18" fill="#1A3A8C"/>

      {/* Person */}
      <g transform="translate(140,90)">
        {/* Body */}
        <rect x="20" y="80" width="80" height="100" rx="30" fill="#FFB547"/>
        {/* Head */}
        <circle cx="60" cy="50" r="34" fill="#FFD693"/>
        {/* Hair */}
        <path d="M28 42c0-20 14-32 32-32s32 12 32 32c-6-4-14-6-22-6h-20c-8 0-16 2-22 6z" fill="#5A3B22"/>
        {/* Smile */}
        <path d="M50 58c3 3 7 3 10 0" stroke="#0F1B3D" strokeWidth="2.5" strokeLinecap="round" fill="none"/>
        {/* Eyes */}
        <circle cx="50" cy="48" r="2.5" fill="#0F1B3D"/>
        <circle cx="70" cy="48" r="2.5" fill="#0F1B3D"/>
        {/* Waving arm */}
        <path d="M95 100 Q130 70 120 30" stroke="#FFD693" strokeWidth="18" strokeLinecap="round" fill="none"/>
        <circle cx="118" cy="28" r="14" fill="#FFD693"/>
      </g>

      {/* Floor plant */}
      <g transform="translate(20,180)">
        <rect x="0" y="40" width="30" height="40" rx="4" fill="#5A3B22"/>
        <ellipse cx="15" cy="35" rx="20" ry="10" fill="#16A34A"/>
        <ellipse cx="15" cy="22" rx="16" ry="12" fill="#1B7A3C"/>
      </g>
    </svg>
  );
}

// Tiny avatar for use in tiles when video off
function AvatarMonogram({ name, color }) {
  const monogram = name.split(' ').map(n => n[0]).slice(0, 2).join('').toUpperCase();
  return (
    <div className="tile-avatar" style={{ background: color || '#DCE7F8', color: '#142E73' }}>
      {monogram}
    </div>
  );
}

Object.assign(window, { Icon, IllusCommunity, IllusWaiting, AvatarMonogram });
