/* Phone mockup, transcript animation, waveform, calendar, voice player */

const { useState, useEffect, useRef, useMemo } = React;

/* ============== ICONS (originals, primitives only) ============== */
const Icon = {
  Phone: ({ size = 16 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <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.72c.13.96.36 1.9.7 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.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z"/>
    </svg>
  ),
  Arrow: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
      <path d="M5 12h14"/><path d="M13 5l7 7-7 7"/>
    </svg>
  ),
  ArrowUR: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
      <path d="M7 17L17 7"/><path d="M8 7h9v9"/>
    </svg>
  ),
  Check: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <path d="M20 6L9 17l-5-5"/>
    </svg>
  ),
  Plus: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round">
      <path d="M12 5v14M5 12h14"/>
    </svg>
  ),
  Minus: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round">
      <path d="M5 12h14"/>
    </svg>
  ),
  Play: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
      <path d="M8 5v14l11-7z"/>
    </svg>
  ),
  Pause: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
      <rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/>
    </svg>
  ),
  Mic: ({ size = 16 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/>
    </svg>
  ),
  Calendar: ({ size = 16 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18"/><path d="M8 3v4M16 3v4"/>
    </svg>
  ),
  ShieldCheck: ({ size = 16 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 3l8 3v6c0 5-3.5 8.5-8 9-4.5-.5-8-4-8-9V6z"/><path d="M9 12l2 2 4-4"/>
    </svg>
  ),
  Pin: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <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"/>
    </svg>
  ),
  Spark: ({ size = 16 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8"/>
    </svg>
  ),
  Bolt: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
      <path d="M13 2L3 14h7l-1 8 10-12h-7z"/>
    </svg>
  ),
  Doc: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/><path d="M8 13h8M8 17h6"/>
    </svg>
  ),
  Stethoscope: ({ size = 16 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M6 3v6a4 4 0 0 0 8 0V3"/><path d="M10 19a3 3 0 0 0 6 0v-3"/><circle cx="18" cy="13" r="2"/>
    </svg>
  ),
  Logo: ({ size = 22 }) => (
    /* Original Arcline mark — arc + line */
    <svg width={size} height={size} viewBox="0 0 32 32" fill="none">
      <circle cx="16" cy="16" r="14" stroke="currentColor" strokeWidth="1.4" fill="none" opacity="0.25"/>
      <path d="M5 19 C 9 9, 23 9, 27 19" stroke="currentColor" strokeWidth="2" fill="none" strokeLinecap="round"/>
      <circle cx="16" cy="16" r="2.4" fill="currentColor"/>
    </svg>
  ),
  External: ({ size = 12 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
      <path d="M14 4h6v6"/><path d="M20 4l-8 8"/><path d="M20 14v6H4V4h6"/>
    </svg>
  ),
  Sun: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.5 1.5M17.5 17.5L19 19M5 19l1.5-1.5M17.5 6.5L19 5"/>
    </svg>
  ),
  Moon: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>
    </svg>
  ),
  Globe: ({ size = 14 }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <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"/>
    </svg>
  ),
};

/* ============== WAVEFORM ============== */
function Waveform({ active = true, bars = 28, height = 36, color }) {
  return (
    <div className="waveform" style={{
      display: 'flex', gap: 3, alignItems: 'center', height,
      color: color || 'var(--accent)'
    }}>
      {Array.from({ length: bars }).map((_, i) => {
        const delay = (i * 80) % 1200;
        const baseHeight = 30 + Math.abs(Math.sin(i * 0.7)) * 50;
        return (
          <span key={i} style={{
            width: 2,
            height: `${baseHeight}%`,
            background: 'currentColor',
            borderRadius: 2,
            opacity: 0.85,
            animation: active ? `wf 1.2s ease-in-out ${delay}ms infinite` : 'none',
            transformOrigin: 'center'
          }}/>
        );
      })}
      <style>{`
        @keyframes wf {
          0%, 100% { transform: scaleY(0.35); }
          50% { transform: scaleY(1); }
        }
      `}</style>
    </div>
  );
}

/* ============== TRANSCRIPT SCENARIOS ============== */
const SCENARIOS = {
  workers_comp: {
    label: 'Workers Comp · New patient',
    caller: 'Marcus T.',
    callerNumber: '+61 4·· ··· 412',
    lines: [
      { who: 'caller', text: "Hi, I need to book a physio appointment — it's a workers comp claim through my employer." },
      { who: 'ai', text: "Of course. I'll book that under your workers compensation pathway. Can I have your claim number, or your insurer's name?", chips: ['icare NSW', 'WorkCover QLD', 'Allianz', 'EML'] },
      { who: 'caller', text: "It's an EML claim. Number is W-C-2-9-4-7-7-8-1." },
      { who: 'ai', text: "Got it — EML claim WC-2947781. Is this an initial consultation or a follow-up?", chips: [] },
      { who: 'caller', text: "It's the initial." },
      { who: 'ai', text: "I have Tuesday 28th at 9:40am with Dr Hannah Lim, who handles the EML pathway. Does that work?", action: 'BOOKING' },
      { who: 'caller', text: "Tuesday's perfect." },
      { who: 'ai', text: "Booked. I'll send the claim-form pre-fill link to your phone. Anything else?", action: 'CONFIRMED' },
    ],
  },
  cdm: {
    label: 'CDM care plan · Returning',
    caller: 'Priya R.',
    callerNumber: '+61 4·· ··· 209',
    lines: [
      { who: 'caller', text: "Hi, I have a CDM care plan from my GP — I need to book my next session." },
      { who: 'ai', text: "Welcome back, Priya. I can see your CDM plan — you have 3 of 5 visits remaining this cycle.", chips: ['3 of 5 left', 'expires 12 Jun'] },
      { who: 'caller', text: "Can I see the same physio as last time?" },
      { who: 'ai', text: "That's Dr James Okafor. He has Thursday 4:10pm or Saturday 10:00am open.", chips: [] },
      { who: 'caller', text: "Saturday morning, please." },
      { who: 'ai', text: "Booked — Saturday 10:00am with Dr Okafor. Bulk-billing applied under your CDM plan.", action: 'BOOKING' },
      { who: 'ai', text: "I'll text the confirmation now. Have a great week.", action: 'CONFIRMED' },
    ],
  },
  after_hours: {
    label: 'After hours · 9:42pm',
    caller: 'Daniel K.',
    callerNumber: '+61 4·· ··· 778',
    lines: [
      { who: 'caller', text: "Hi, sorry to call so late — I've hurt my back and need to see someone tomorrow if possible." },
      { who: 'ai', text: "No need to apologise — I can book you in tonight. Is this a new injury or ongoing?", chips: [] },
      { who: 'caller', text: "Brand new. Twisted lifting something this evening." },
      { who: 'ai', text: "I'll route you to acute lower-back protocol. Dr Reyes has 8:20am or Dr Lim 11:15am tomorrow.", chips: ['acute · same-day', 'lower back'] },
      { who: 'caller', text: "8:20 with Dr Reyes." },
      { who: 'ai', text: "Booked for tomorrow 8:20am. I'll send pre-visit instructions and parking info now.", action: 'BOOKING' },
      { who: 'ai', text: "Take care, Daniel — and try the heat-pack tip in the SMS tonight.", action: 'CONFIRMED' },
    ],
  },
  dva: {
    label: 'DVA Veterans · Reschedule',
    caller: 'Robert H.',
    callerNumber: '+61 4·· ··· 056',
    lines: [
      { who: 'caller', text: "I need to reschedule my appointment on Wednesday. It's under DVA." },
      { who: 'ai', text: "I can see your DVA Gold Card on file — appointment Wed 14th, 2:30pm with Dr Hannah Lim.", chips: ['DVA Gold', 'D904 referral'] },
      { who: 'caller', text: "Can I move it to next Monday?" },
      { who: 'ai', text: "Dr Lim is fully booked Monday. Dr Okafor — also DVA-credentialed — has Mon 19th at 10:45am.", chips: [] },
      { who: 'caller', text: "That works." },
      { who: 'ai', text: "Rescheduled to Mon 19th, 10:45am with Dr Okafor. DVA referral carries across — no new paperwork.", action: 'BOOKING' },
      { who: 'ai', text: "Confirmation sent. Thanks for your service, Robert.", action: 'CONFIRMED' },
    ],
  },
};

/* ============== TRANSCRIPT (animated, scenario-driven) ============== */
function Transcript({ scenario = 'workers_comp', autoPlay = true, compact = false }) {
  const data = SCENARIOS[scenario] || SCENARIOS.workers_comp;
  const [shown, setShown] = useState(autoPlay ? 0 : data.lines.length);
  const [typing, setTyping] = useState(false);
  const containerRef = useRef(null);

  useEffect(() => { setShown(autoPlay ? 0 : data.lines.length); }, [scenario, autoPlay]);

  useEffect(() => {
    if (!autoPlay) return;
    if (shown >= data.lines.length) {
      const t = setTimeout(() => setShown(0), 2800);
      return () => clearTimeout(t);
    }
    setTyping(true);
    const t1 = setTimeout(() => {
      setTyping(false);
      setShown(s => s + 1);
    }, 1400 + (data.lines[shown]?.text.length || 0) * 18);
    return () => clearTimeout(t1);
  }, [shown, autoPlay, data]);

  useEffect(() => {
    if (containerRef.current) {
      containerRef.current.scrollTop = containerRef.current.scrollHeight;
    }
  }, [shown, typing]);

  const lines = data.lines.slice(0, shown);

  return (
    <div className="transcript" ref={containerRef} style={{
      display: 'flex', flexDirection: 'column', gap: 10,
      padding: compact ? '12px 14px' : '14px 16px',
      overflow: 'hidden',
      flex: 1,
      minHeight: 0,
    }}>
      {lines.map((ln, i) => (
        <Bubble key={i} {...ln} />
      ))}
      {typing && shown < data.lines.length && (
        <TypingBubble who={data.lines[shown]?.who} />
      )}
    </div>
  );
}

function Bubble({ who, text, chips, action }) {
  const isAI = who === 'ai';
  return (
    <div className={`bubble bubble-${who}`} style={{
      alignSelf: isAI ? 'flex-start' : 'flex-end',
      maxWidth: '88%',
      animation: 'bubbleIn .45s cubic-bezier(.2,.7,.2,1)',
    }}>
      <div className="bubble-head" style={{
        fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.08em',
        textTransform: 'uppercase', color: 'var(--fg-4)',
        marginBottom: 4, display: 'flex', alignItems: 'center', gap: 6
      }}>
        {isAI ? <><span style={{width:5,height:5,borderRadius:'50%',background:'var(--accent)'}}/> Arcline</> : 'Caller'}
      </div>
      <div className="bubble-body" style={{
        background: isAI ? 'var(--bg-card)' : 'var(--fg)',
        color: isAI ? 'var(--fg)' : 'var(--bg)',
        border: isAI ? '1px solid var(--line)' : 'none',
        padding: '10px 12px',
        borderRadius: 12,
        fontSize: 13,
        lineHeight: 1.45,
        textWrap: 'pretty',
      }}>
        {text}
        {chips && chips.length > 0 && (
          <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, marginTop: 8 }}>
            {chips.map((c, j) => (
              <span key={j} style={{
                fontFamily: 'var(--font-mono)', fontSize: 10,
                padding: '3px 7px', borderRadius: 6,
                background: 'var(--accent-soft)', color: 'var(--accent)',
              }}>{c}</span>
            ))}
          </div>
        )}
        {action === 'BOOKING' && (
          <BookingPreview />
        )}
        {action === 'CONFIRMED' && (
          <div style={{
            marginTop: 8, padding: '6px 8px', borderRadius: 8,
            background: 'rgba(15,110,61,0.10)', color: 'var(--success)',
            fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.06em',
            textTransform: 'uppercase', display: 'inline-flex', gap: 6, alignItems: 'center'
          }}>
            <Icon.Check size={12}/> SMS confirmation sent · synced to PracSuite
          </div>
        )}
      </div>
      <style>{`
        @keyframes bubbleIn {
          from { opacity: 0; transform: translateY(6px); }
          to { opacity: 1; transform: none; }
        }
      `}</style>
    </div>
  );
}

function TypingBubble({ who }) {
  const isAI = who === 'ai';
  return (
    <div style={{ alignSelf: isAI ? 'flex-start' : 'flex-end', maxWidth: '60%' }}>
      <div style={{
        background: isAI ? 'var(--bg-card)' : 'var(--fg)',
        border: isAI ? '1px solid var(--line)' : 'none',
        padding: '10px 12px',
        borderRadius: 12,
        display: 'flex', gap: 4, alignItems: 'center',
      }}>
        {[0,1,2].map(i => (
          <span key={i} style={{
            width: 5, height: 5, borderRadius: '50%',
            background: isAI ? 'var(--fg-3)' : 'var(--bg)',
            animation: `typedot 1.2s ease-in-out ${i*0.2}s infinite`
          }}/>
        ))}
      </div>
      <style>{`
        @keyframes typedot {
          0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
          30% { opacity: 1; transform: translateY(-2px); }
        }
      `}</style>
    </div>
  );
}

function BookingPreview() {
  return (
    <div style={{
      marginTop: 10,
      border: '1px solid var(--line)',
      borderRadius: 10,
      padding: 10,
      background: 'var(--bg)',
      color: 'var(--fg)',
      animation: 'bookingIn .6s cubic-bezier(.2,.7,.2,1)',
    }}>
      <div style={{
        display: 'flex', justifyContent: 'space-between', alignItems: 'center',
        marginBottom: 8
      }}>
        <span style={{
          fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.08em',
          textTransform: 'uppercase', color: 'var(--fg-4)'
        }}>Booking · PracSuite</span>
        <span style={{
          fontFamily: 'var(--font-mono)', fontSize: 9, color: 'var(--success)',
          display: 'inline-flex', alignItems: 'center', gap: 4
        }}>
          <span style={{ width: 4, height: 4, borderRadius: '50%', background: 'var(--success)' }}/>
          drafting
        </span>
      </div>
      <div style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
        <div style={{
          width: 38, height: 44, borderRadius: 6, background: 'var(--accent-soft)',
          color: 'var(--accent)', display: 'flex', flexDirection: 'column',
          alignItems: 'center', justifyContent: 'center', flexShrink: 0
        }}>
          <span style={{ fontFamily: 'var(--font-mono)', fontSize: 8, letterSpacing: '0.08em' }}>TUE</span>
          <span style={{ fontWeight: 600, fontSize: 16, lineHeight: 1 }}>28</span>
        </div>
        <div style={{ flex: 1, fontSize: 11.5, lineHeight: 1.5 }}>
          <div style={{ fontWeight: 500 }}>9:40am · Initial physio</div>
          <div style={{ color: 'var(--fg-3)' }}>Dr Hannah Lim · EML pathway</div>
          <div style={{ color: 'var(--fg-3)', fontFamily: 'var(--font-mono)', fontSize: 10 }}>
            #WC-2947781
          </div>
        </div>
      </div>
      <style>{`
        @keyframes bookingIn {
          from { opacity: 0; transform: translateY(4px) scale(.98); }
          to { opacity: 1; transform: none; }
        }
      `}</style>
    </div>
  );
}

/* ============== PHONE MOCKUP ============== */
function PhoneMockup({ scenario = 'workers_comp', height = 600 }) {
  const data = SCENARIOS[scenario] || SCENARIOS.workers_comp;
  const [seconds, setSeconds] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setSeconds(s => s + 1), 1000);
    return () => clearInterval(id);
  }, [scenario]);
  useEffect(() => { setSeconds(0); }, [scenario]);
  const mm = String(Math.floor(seconds / 60)).padStart(2, '0');
  const ss = String(seconds % 60).padStart(2, '0');

  return (
    <div className="phone" style={{
      width: 320,
      height,
      borderRadius: 44,
      background: 'var(--bg-inverted)',
      padding: 10,
      boxShadow: 'var(--shadow-lg)',
      position: 'relative',
      flexShrink: 0,
    }}>
      <div style={{
        width: '100%', height: '100%',
        background: 'var(--bg)',
        borderRadius: 36,
        overflow: 'hidden',
        display: 'flex', flexDirection: 'column',
        position: 'relative',
      }}>
        {/* notch */}
        <div style={{
          position: 'absolute', left: '50%', top: 8,
          transform: 'translateX(-50%)',
          width: 92, height: 24, borderRadius: 14,
          background: 'var(--bg-inverted)',
          zIndex: 5,
        }}/>
        {/* status bar */}
        <div style={{
          padding: '14px 22px 4px',
          display: 'flex', justifyContent: 'space-between',
          fontFamily: 'var(--font-mono)', fontSize: 11, color: 'var(--fg-2)',
          fontWeight: 500,
        }}>
          <span>9:42</span>
          <span style={{ display: 'inline-flex', gap: 4, alignItems: 'center' }}>
            <span style={{ width: 14, height: 8, border: '1px solid currentColor', borderRadius: 2, position: 'relative' }}>
              <span style={{ position: 'absolute', inset: 1, right: 4, background: 'currentColor', borderRadius: 1 }}/>
            </span>
          </span>
        </div>
        {/* call header */}
        <div style={{
          padding: '14px 18px 12px',
          borderBottom: '1px solid var(--line)',
          display: 'flex', alignItems: 'center', gap: 10,
        }}>
          <div style={{
            width: 36, height: 36, borderRadius: '50%',
            background: 'var(--accent-soft)', color: 'var(--accent)',
            display: 'flex', alignItems: 'center', justifyContent: 'center',
            position: 'relative',
          }}>
            <Icon.Phone size={16}/>
            <span style={{
              position: 'absolute', inset: -3, borderRadius: '50%',
              border: '1px solid var(--accent)', opacity: 0.4,
              animation: 'phoneRing 2s ease-in-out infinite'
            }}/>
          </div>
          <div style={{ flex: 1, minWidth: 0 }}>
            <div style={{ fontSize: 13, fontWeight: 500, lineHeight: 1.2 }}>{data.caller}</div>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: 'var(--fg-3)' }}>
              {data.callerNumber}
            </div>
          </div>
          <div style={{ textAlign: 'right' }}>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, color: 'var(--success)', display: 'inline-flex', alignItems: 'center', gap: 4 }}>
              <span style={{ width: 5, height: 5, borderRadius: '50%', background: 'var(--success)' }}/>
              live
            </div>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: 'var(--fg-3)' }}>{mm}:{ss}</div>
          </div>
        </div>

        {/* AI badge bar */}
        <div style={{
          padding: '8px 18px', display: 'flex',
          alignItems: 'center', justifyContent: 'space-between',
          borderBottom: '1px solid var(--line-2)',
          background: 'var(--bg-2)'
        }}>
          <span style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.1em', textTransform: 'uppercase', color: 'var(--fg-3)' }}>
            Arcline · {data.label}
          </span>
          <Waveform bars={14} height={14}/>
        </div>

        {/* transcript */}
        <Transcript scenario={scenario} compact/>

        {/* footer hint */}
        <div style={{
          padding: '10px 18px',
          borderTop: '1px solid var(--line)',
          background: 'var(--bg-2)',
          display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.06em',
          textTransform: 'uppercase', color: 'var(--fg-4)',
        }}>
          <span>Latency 312ms</span>
          <span>End-to-end encrypted</span>
        </div>
      </div>
      <style>{`
        @keyframes phoneRing {
          0%, 100% { transform: scale(1); opacity: 0.4; }
          50% { transform: scale(1.4); opacity: 0; }
        }
      `}</style>
    </div>
  );
}

window.Icon = Icon;
window.Waveform = Waveform;
window.Transcript = Transcript;
window.PhoneMockup = PhoneMockup;
window.SCENARIOS = SCENARIOS;
