/* ═══════════════ Closink Landing · MOCKUPS (light app UI in dark frames) ═══════════════ */

/* ---- status bar bits ---- */
const SignalDots = ({ c = '#0F172A', bars = 2 }) => (
  <svg width="18" height="12" viewBox="0 0 18 12">{[3, 6, 9, 12].map((h, i) => (
    <rect key={i} x={i * 4.6} y={12 - h} width="3" height={h} rx="0.8" fill={c} opacity={i < bars ? 1 : 0.32} />
  ))}</svg>
);
const WifiIc = ({ c = '#0F172A' }) => (
  <svg width="17" height="12" viewBox="0 0 17 12" fill="none" stroke={c} strokeWidth="1.6" strokeLinecap="round">
    <path d="M2 4.5a9 9 0 0113 0M4.4 7a5.5 5.5 0 018.2 0" /><circle cx="8.5" cy="9.6" r="0.9" fill={c} stroke="none" />
  </svg>
);
const BatteryIc = ({ pct = 88, c = '#0F172A', charging }) => (
  <span className="inline-flex items-center gap-1" style={{ color: c, fontSize: 11, fontWeight: 700 }}>
    <span style={{ fontSize: 10 }}>{pct}</span>
    <svg width="22" height="12" viewBox="0 0 22 12"><rect x="0.7" y="0.7" width="18" height="10.6" rx="2.6" fill="none" stroke={c} strokeWidth="1" opacity="0.45" /><rect x="2.2" y="2.2" width={15.2 * pct / 100} height="7.6" rx="1.4" fill={pct < 20 ? '#EF4444' : (charging ? '#22C55E' : c)} /><rect x="20" y="3.6" width="1.6" height="4.8" rx="0.8" fill={c} opacity="0.45" /></svg>
  </span>
);
const StatusBar = ({ time = '01:09', dark = false, charging = true, pct = 88, bars = 2 }) => {
  const c = dark ? '#fff' : '#0F172A';
  return (
    <div className="flex items-center justify-between px-6 pt-3 pb-1 relative z-20" style={{ height: 40 }}>
      <span style={{ color: c, fontSize: 14, fontWeight: 700, letterSpacing: '0.3px' }}>{time}</span>
      <div className="flex items-center gap-1.5"><SignalDots c={c} bars={bars} /><WifiIc c={c} /><BatteryIc pct={pct} c={c} charging={charging} /></div>
    </div>
  );
};

/* ---- bottom nav ---- */
const NAV = [
  ['Harita', (a) => <IconLayers s={21} c={a ? '#3678F9' : '#94A3B8'} fill={a ? '#3678F9' : 'none'} sw={a ? 0 : 1.7} />],
  ['Çevre', (a) => <IconUsers s={21} c={a ? '#3678F9' : '#94A3B8'} />],
  ['SOS', (a) => <ShieldFill s={20} c={a ? '#EF4444' : '#94A3B8'} />, true],
  ['Bildirim', (a) => <IconBell s={21} c={a ? '#3678F9' : '#94A3B8'} />, false, 4],
  ['Plan', (a) => <IconStar s={20} c={a ? '#3678F9' : '#94A3B8'} />],
];
const BottomNav = ({ active = 0 }) => (
  <div className="absolute left-0 right-0 bottom-0 bg-white flex px-1.5 pt-1.5" style={{ height: 62, borderTop: '1px solid #EEF1F6', zIndex: 30 }}>
    {NAV.map(([label, icon, isSos, badge], i) => {
      const a = i === active;
      return (
        <div key={label} className="flex-1 flex flex-col items-center justify-center gap-0.5">
          <div className="relative flex items-center justify-center" style={{ width: 44, height: 26, borderRadius: 99, background: a && !isSos ? 'rgba(54,120,249,.12)' : 'transparent' }}>
            {icon(a)}
            {badge && <span className="absolute -top-0.5 right-1.5 flex items-center justify-center text-white font-bold" style={{ width: 14, height: 14, fontSize: 9, borderRadius: 99, background: '#EF4444' }}>{badge}</span>}
          </div>
          <span style={{ fontSize: 10, fontWeight: 600, color: a ? (isSos ? '#EF4444' : '#3678F9') : '#94A3B8' }}>{label}</span>
        </div>
      );
    })}
  </div>
);

/* ---- phone frame ---- */
const Phone = ({ children, w = 272, h = 568, dark = false, style, className = '' }) => (
  <div className={`relative ${className}`} style={{ width: w, height: h, ...style }}>
    <div className="absolute inset-0 rounded-[42px] bg-black" style={{ boxShadow: '0 50px 100px rgba(0,0,0,.6), 0 0 0 2px rgba(255,255,255,.06), inset 0 0 0 7px #060912' }}>
      <div className="absolute overflow-hidden rounded-[35px]" style={{ inset: 8, background: dark ? '#0A1020' : '#F0EEE9' }}>
        <div className="absolute left-1/2 -translate-x-1/2 bg-black rounded-full z-40" style={{ top: 11, width: 84, height: 23 }}></div>
        {children}
      </div>
    </div>
  </div>
);

/* ---- full-size phone (272×568) scaled to fit a slot — iç layout BOZULMAZ ---- */
const ScaledPhone = ({ targetW = 272, dark = false, className = '', style, children }) => {
  const s = targetW / 272;
  return (
    <div className={`relative ${className}`} style={{ width: targetW, height: Math.round(568 * s), ...style }}>
      <div style={{ width: 272, height: 568, transform: `scale(${s})`, transformOrigin: 'top left' }}>
        <Phone dark={dark}>{children}</Phone>
      </div>
    </div>
  );
};

/* ---- light map streets ---- */
const Road = ({ s }) => <div className="absolute" style={{ background: '#fff', opacity: 0.85, ...s }}></div>;
const StreetLabel = ({ t, s }) => <div className="absolute mono" style={{ fontSize: 8, fontWeight: 600, color: '#fff', opacity: 0.7, whiteSpace: 'nowrap', ...s }}>{t}</div>;

/* ════ SCREEN 1 · Live map (Harita) ════ */
const MapScreen = ({ scale = 1 }) => (
  <div className="absolute inset-0 flex flex-col" style={{ fontSize: 13 * scale }}>
    {/* dark-tone map (matches screenshot) */}
    <div className="absolute inset-0" style={{ background: 'linear-gradient(160deg,#5b6b80,#46566c 60%,#3c4a5e)' }}>
      <div className="absolute" style={{ left: '-10%', top: '8%', width: '50%', height: 14, background: '#5f6f85', transform: 'rotate(28deg)' }}></div>
      <div className="absolute" style={{ left: '30%', top: '-5%', width: 12, height: '70%', background: '#5f6f85', transform: 'rotate(12deg)' }}></div>
      <div className="absolute" style={{ left: '62%', top: '0%', width: 11, height: '100%', background: '#5f6f85', transform: 'rotate(-8deg)' }}></div>
      <div className="absolute" style={{ left: '0', top: '64%', width: '100%', height: 13, background: '#5f6f85', transform: 'rotate(-6deg)' }}></div>
      <div className="absolute rounded-full" style={{ left: '4%', top: '20%', width: 56, height: 40, background: 'rgba(34,90,60,.5)' }}></div>
      <div className="absolute rounded-full" style={{ right: '4%', top: '60%', width: 60, height: 50, background: 'rgba(34,90,60,.5)' }}></div>
      <StreetLabel t="GÜNEBAKAN SK." s={{ left: '40%', top: '26%' }} />
      <StreetLabel t="SALTUK SK." s={{ left: '14%', top: '60%', transform: 'rotate(-6deg)' }} />
      <StreetLabel t="ÇİFTLİK SK." s={{ right: '12%', top: '52%', transform: 'rotate(72deg)' }} />
      <div className="absolute mono" style={{ left: '30%', top: '40%', fontSize: 11, fontWeight: 800, color: '#cfd8e3', opacity: 0.85, letterSpacing: '1px' }}>GÜLENSU MH.</div>
    </div>
    {/* geofence */}
    <div className="absolute left-1/2 top-[46%] -translate-x-1/2 -translate-y-1/2 rounded-full" style={{ width: 188, height: 188, background: 'rgba(34,197,94,.16)', border: '2px solid rgba(34,197,94,.85)' }}></div>
    {/* avatar marker + home pin */}
    <div className="absolute left-1/2 top-[42%] -translate-x-1/2 -translate-y-1/2 flex flex-col items-center">
      <div className="relative rounded-full" style={{ width: 56, height: 56, border: '3px solid #3678F9', background: 'linear-gradient(150deg,#7c8aa0,#43617a)', boxShadow: '0 6px 16px rgba(0,0,0,.3)' }}>
        <span className="absolute -right-1 -bottom-1 flex items-center justify-center text-white font-bold rounded-full" style={{ width: 20, height: 20, fontSize: 10, background: '#EF4444', border: '2px solid #fff' }}>15</span>
      </div>
      <div style={{ width: 0, height: 0, borderLeft: '7px solid transparent', borderRight: '7px solid transparent', borderTop: '10px solid #3678F9', marginTop: -1 }}></div>
      <div className="flex items-center justify-center rounded-xl -mt-0.5" style={{ width: 40, height: 38, background: '#22C55E', border: '2.5px solid #fff', boxShadow: '0 4px 10px rgba(0,0,0,.25)' }}>
        <svg viewBox="0 0 24 24" width="20" height="20" fill="#fff"><path d="M4 11l8-6 8 6v8a1 1 0 01-1 1h-4v-5h-6v5H5a1 1 0 01-1-1z" /></svg>
      </div>
    </div>
    <StatusBar pct={18} charging={false} bars={2} time="01:08" />
    {/* top controls */}
    <div className="absolute left-0 right-0 flex items-center justify-between px-3.5" style={{ top: 44 }}>
      <div className="flex items-center justify-center bg-white rounded-2xl" style={{ width: 40, height: 40, boxShadow: '0 2px 8px rgba(0,0,0,.12)' }}>
        <svg width="18" height="14" viewBox="0 0 18 14" stroke="#0F172A" strokeWidth="1.8" strokeLinecap="round"><path d="M1 1h16M1 7h16M1 13h16" /></svg>
      </div>
      <div className="bg-white rounded-2xl flex items-center justify-center font-bold" style={{ width: 132, height: 40, fontSize: 14, color: '#0F172A', boxShadow: '0 2px 8px rgba(0,0,0,.12)', letterSpacing: '0.5px' }}>ARKADAŞLAR</div>
      <div className="flex items-center justify-center bg-white rounded-2xl" style={{ width: 40, height: 40, boxShadow: '0 2px 8px rgba(0,0,0,.12)' }}>
        <svg width="16" height="18" viewBox="0 0 16 18" stroke="#0F172A" strokeWidth="1.7" fill="none" strokeLinecap="round" strokeLinejoin="round"><path d="M8 2v10M4 6l4-4 4 4M2 11v4a1 1 0 001 1h10a1 1 0 001-1v-4" /></svg>
      </div>
    </div>
    {/* bottom action row */}
    <div className="absolute left-0 right-0 flex items-center justify-center gap-2.5 px-4" style={{ bottom: 132 }}>
      <div className="flex items-center gap-1.5 bg-white rounded-full px-3.5 font-semibold" style={{ height: 42, fontSize: 13, color: '#0F172A', boxShadow: '0 4px 12px rgba(0,0,0,.14)' }}>
        <IconMapPin s={16} c="#3678F9" />Yerini Bildir
      </div>
      <div className="flex items-center gap-1.5 bg-white rounded-full px-3.5 font-bold" style={{ height: 42, fontSize: 13, color: '#EF4444', border: '1.5px solid #EF4444', boxShadow: '0 4px 12px rgba(0,0,0,.14)' }}>
        <ShieldFill s={15} c="#EF4444" />SOS
      </div>
    </div>
    {/* sheet peek */}
    <div className="absolute left-0 right-0 bottom-0 bg-white rounded-t-3xl px-4 pt-2.5" style={{ height: 118, boxShadow: '0 -6px 22px rgba(0,0,0,.12)' }}>
      <div className="mx-auto rounded-full" style={{ width: 34, height: 4, background: '#E2E8F0' }}></div>
      <div className="flex gap-2 mt-3">
        <div className="flex-1 flex items-center justify-center gap-1.5 rounded-2xl font-semibold" style={{ height: 38, background: '#F1F5F9', fontSize: 12.5, color: '#0F172A' }}><IconMapPin s={15} c="#0F172A" />Yerler</div>
        <div className="flex-1 flex items-center justify-center gap-1.5 rounded-2xl font-semibold" style={{ height: 38, background: '#F1F5F9', fontSize: 12.5, color: '#0F172A' }}><IconRoute s={15} c="#0F172A" />Hareketler</div>
      </div>
      <div className="mt-2.5" style={{ fontSize: 10.5, fontWeight: 700, color: '#3678F9', letterSpacing: '0.4px' }}>ÇEVRE ÜYELERİ · 1/2 AKTİF</div>
    </div>
    <BottomNav active={0} />
  </div>
);

/* ════ SCREEN 2 · SOS Ready ════ */
const SosReadyScreen = ({ holding = false }) => (
  <div className="absolute inset-0 flex flex-col" style={{ background: '#F0EEE9' }}>
    <StatusBar time="01:10" pct={22} />
    <div className="px-4 pt-1 flex-1 flex flex-col">
      {/* emergency contacts */}
      <div className="bg-white rounded-2xl p-3.5" style={{ boxShadow: '0 2px 10px rgba(15,23,42,.05)' }}>
        <div className="flex items-center justify-between">
          <span className="flex items-center gap-1.5" style={{ fontSize: 11, fontWeight: 700, color: '#64748B', letterSpacing: '0.4px' }}><IconUsers s={14} c="#64748B" />ACİL DURUM KİŞİLERİ · 1</span>
          <span style={{ fontSize: 12.5, fontWeight: 700, color: '#3678F9' }}>+ Ekle</span>
        </div>
        <div className="inline-flex items-center gap-2 mt-2.5 rounded-full pr-3 pl-1 py-1" style={{ background: '#F1F5F9' }}>
          <span className="flex items-center justify-center rounded-full font-bold" style={{ width: 26, height: 26, fontSize: 12, background: 'rgba(54,120,249,.18)', color: '#3678F9' }}>A</span>
          <span style={{ fontSize: 13, fontWeight: 600, color: '#0F172A' }}>Abim</span>
          <span style={{ fontSize: 13, color: '#94A3B8' }}>✕</span>
        </div>
      </div>
      {/* evidence archive */}
      <div className="bg-white rounded-2xl p-3 flex items-center gap-3 mt-3" style={{ boxShadow: '0 2px 10px rgba(15,23,42,.05)' }}>
        <div className="flex items-center justify-center rounded-xl" style={{ width: 38, height: 38, background: '#0F172A' }}><IconShield s={19} c="#fff" /></div>
        <div className="flex-1">
          <div style={{ fontSize: 14, fontWeight: 700, color: '#0F172A' }}>Kanıt Arşivi</div>
          <div style={{ fontSize: 11.5, color: '#94A3B8' }}>Geçmiş SOS kayıtların — paylaş veya sil</div>
        </div>
        <IconChevR s={16} c="#CBD5E1" />
      </div>
      {/* ready pill + headline */}
      <div className="flex flex-col items-center mt-5">
        <span className="inline-flex items-center gap-1.5 rounded-full px-3.5 py-1.5" style={{ background: 'rgba(34,197,94,.12)', border: '1px solid rgba(34,197,94,.3)' }}>
          <span className="w-1.5 h-1.5 rounded-full" style={{ background: '#22C55E' }}></span>
          <span style={{ fontSize: 12, fontWeight: 800, color: '#16A34A', letterSpacing: '0.5px' }}>SOS HAZIR</span>
        </span>
        <div className="mt-3 text-center" style={{ fontSize: 21, fontWeight: 800, color: '#0F172A', letterSpacing: '-0.4px' }}>Maksimum güven,<br />sıfır panik</div>
        <div className="mt-1.5 text-center" style={{ fontSize: 12.5, color: '#94A3B8', maxWidth: 210, lineHeight: 1.4 }}>3 saniye basılı tut. Konum, ses ve video otomatik paylaşılır.</div>
      </div>
      {/* SOS button */}
      <div className="relative flex-1 flex items-center justify-center">
        <div className="absolute rounded-full" style={{ width: 168, height: 168, background: 'radial-gradient(circle,rgba(239,68,68,.28),transparent 68%)', filter: 'blur(8px)' }}></div>
        {/* progress ring */}
        <svg width="186" height="186" viewBox="0 0 186 186" className="absolute" style={{ transform: 'rotate(-90deg)' }}>
          <circle cx="93" cy="93" r="86" fill="none" stroke="#F59E0B" strokeWidth="5" strokeLinecap="round"
            strokeDasharray={2 * Math.PI * 86} strokeDashoffset={2 * Math.PI * 86 * (holding ? 0.12 : 0.72)} style={{ transition: 'stroke-dashoffset .3s' }} />
        </svg>
        <div className="rounded-full flex flex-col items-center justify-center" style={{ width: 150, height: 150, background: 'radial-gradient(circle at 34% 26%,#FB7185,#EF4444 52%,#DC2626)', boxShadow: '0 18px 46px rgba(239,68,68,.4)', animation: 'sosPulse 1.4s ease-in-out infinite' }}>
          <ShieldFill s={30} c="#fff" />
          <span className="text-white font-black mt-1" style={{ fontSize: 30, letterSpacing: '2px' }}>SOS</span>
        </div>
      </div>
      <div className="bg-white rounded-full flex items-center justify-center gap-2 mx-auto mb-4" style={{ height: 44, width: '88%', boxShadow: '0 4px 14px rgba(15,23,42,.08)' }}>
        <IconAlert s={16} c="#EF4444" /><span style={{ fontSize: 13.5, fontWeight: 700, color: '#0F172A' }}>Acil Durum Bildir · 3 sn basılı tut</span>
      </div>
    </div>
    <BottomNav active={2} />
  </div>
);

/* ════ SCREEN 3 · SOS Active (evidence recording) ════ */
const SosActiveScreen = () => (
  <div className="absolute inset-0 flex flex-col" style={{ background: '#F0EEE9' }}>
    <StatusBar time="01:10" dark pct={22} />
    {/* video card */}
    <div className="mx-3 mt-1 rounded-2xl overflow-hidden relative" style={{ height: 138, background: 'linear-gradient(165deg,#3a3530,#1c1916)' }}>
      <div className="absolute inset-0" style={{ background: 'radial-gradient(circle at 58% 14%,rgba(255,220,180,.28),transparent 52%)' }}></div>
      {/* recording subject — kurgusal kişi (selfie kamerası: acil anında video kaydı) */}
      <svg className="absolute left-1/2 bottom-0 -translate-x-1/2" width="138" height="124" viewBox="0 0 138 124" fill="none" style={{ filter: 'drop-shadow(0 -2px 16px rgba(255,200,150,.10))' }}>
        {/* shoulders / torso */}
        <path d="M14 124 C16 90 42 78 69 78 C96 78 122 90 124 124 Z" fill="#6a5645" />
        <path d="M14 124 C16 90 42 78 69 78 C96 78 122 90 124 124 Z" fill="none" stroke="rgba(255,214,170,.20)" strokeWidth="1.5" />
        {/* neck */}
        <rect x="58" y="60" width="22" height="22" rx="9" fill="#7c6553" />
        {/* head */}
        <circle cx="69" cy="44" r="28" fill="#8a6e58" />
        {/* hair */}
        <path d="M41 45 C41 22 57 14 69 14 C81 14 97 22 97 45 C97 34 87 29 69 29 C51 29 41 34 41 45 Z" fill="#2f2620" />
        {/* warm top rim light */}
        <path d="M47 30 A28 28 0 0 1 91 30" fill="none" stroke="rgba(255,226,188,.35)" strokeWidth="2.4" strokeLinecap="round" />
        {/* subtle face hint */}
        <circle cx="60" cy="45" r="2.3" fill="#2f2620" opacity=".5" />
        <circle cx="78" cy="45" r="2.3" fill="#2f2620" opacity=".5" />
        <path d="M62 56 q7 5 14 0" stroke="#2f2620" strokeWidth="1.6" fill="none" opacity=".38" strokeLinecap="round" />
      </svg>
      <div className="absolute top-2.5 left-2.5 flex items-center gap-1.5 rounded-full px-2.5 py-1" style={{ background: 'rgba(0,0,0,.5)' }}><span style={{ fontSize: 11, color: '#fff', fontWeight: 600 }}>↻ Çevir</span></div>
      <div className="absolute top-2.5 right-2.5 flex items-center gap-1.5 rounded-full px-2.5 py-1" style={{ background: '#EF4444' }}><span className="w-1.5 h-1.5 rounded-full bg-white" style={{ animation: 'blink 1s infinite' }}></span><span className="mono" style={{ fontSize: 11, color: '#fff', fontWeight: 700 }}>REC 00:06</span></div>
      <div className="absolute bottom-2.5 left-2.5 flex items-center gap-1 rounded-full px-2.5 py-1" style={{ background: 'rgba(0,0,0,.5)' }}><IconVideo s={13} c="#fff" /><span style={{ fontSize: 11, color: '#fff', fontWeight: 600 }}>1080p</span></div>
      <div className="absolute bottom-2.5 right-2.5 flex items-center gap-1 rounded-full px-2.5 py-1" style={{ background: 'rgba(0,0,0,.5)' }}><IconMapPin s={13} c="#fff" /><span style={{ fontSize: 11, color: '#fff', fontWeight: 600 }}>Konum sabit</span></div>
    </div>
    {/* status card */}
    <div className="mx-3 mt-2.5 bg-white rounded-2xl p-3.5 flex-1" style={{ boxShadow: '0 2px 12px rgba(15,23,42,.06)' }}>
      <div className="flex items-center gap-2.5">
        <div className="flex items-center justify-center rounded-xl" style={{ width: 34, height: 34, background: 'rgba(239,68,68,.1)' }}><IconAlert s={18} c="#EF4444" /></div>
        <div className="flex-1">
          <div style={{ fontSize: 13, fontWeight: 800, color: '#EF4444', letterSpacing: '0.4px' }}>SOS AKTİF</div>
          <div style={{ fontSize: 13, fontWeight: 600, color: '#0F172A' }}>Çevren bilgilendiriliyor</div>
        </div>
        <div className="mono" style={{ fontSize: 15, fontWeight: 800, color: '#EF4444' }}>00:06</div>
      </div>
      {/* countdown ring */}
      <div className="relative flex items-center justify-center my-2.5" style={{ height: 124 }}>
        <svg width="118" height="118" viewBox="0 0 118 118" style={{ transform: 'rotate(-90deg)' }}>
          <circle cx="59" cy="59" r="52" fill="none" stroke="#E2E8F0" strokeWidth="7" />
          <circle cx="59" cy="59" r="52" fill="none" stroke="#EF4444" strokeWidth="7" strokeLinecap="round" strokeDasharray={2 * Math.PI * 52} strokeDashoffset={2 * Math.PI * 52 * 0.2} />
        </svg>
        <div className="absolute flex flex-col items-center">
          <span style={{ fontSize: 38, fontWeight: 800, color: '#0F172A', lineHeight: 1 }}>24</span>
          <span className="mono" style={{ fontSize: 10, fontWeight: 700, color: '#94A3B8', letterSpacing: '0.5px' }}>/ 30 SANİYE</span>
        </div>
      </div>
      {/* audio wave */}
      <div className="rounded-xl flex items-center gap-2 px-3" style={{ height: 36, background: 'rgba(34,197,94,.08)', border: '1px solid rgba(34,197,94,.2)' }}>
        <IconMic s={14} c="#16A34A" /><span style={{ fontSize: 11, fontWeight: 700, color: '#16A34A' }}>SES</span>
        <div className="flex items-end gap-0.5 flex-1" style={{ height: 16 }}>
          {Array.from({ length: 26 }).map((_, i) => <span key={i} style={{ width: 2, borderRadius: 2, background: '#22C55E', height: `${30 + 60 * Math.abs(Math.sin(i * 1.3))}%`, animation: `wave ${0.7 + (i % 5) * 0.12}s ease-in-out infinite alternate` }}></span>)}
        </div>
        <span className="mono" style={{ fontSize: 10, fontWeight: 700, color: '#16A34A' }}>00:06</span>
      </div>
      {/* notified */}
      <div className="rounded-xl flex items-center gap-2 px-3 mt-2" style={{ height: 40, background: '#F1F5F9' }}>
        <span style={{ fontSize: 10.5, fontWeight: 700, color: '#94A3B8', letterSpacing: '0.3px' }}>BİLDİRİLDİ</span>
        <div className="flex" style={{ marginLeft: 2 }}>
          {[['MY', '#22C55E'], ['ZA', '#3678F9'], ['AT', '#E11D48']].map(([t, c], i) => (
            <span key={i} className="flex items-center justify-center text-white font-bold rounded-full" style={{ width: 22, height: 22, fontSize: 8.5, background: c, border: '1.5px solid #fff', marginLeft: i ? -7 : 0 }}>{t}</span>
          ))}
        </div>
        <span style={{ fontSize: 12.5, fontWeight: 700, color: '#0F172A' }}>Tüm aile</span>
        <span className="ml-auto flex items-center justify-center rounded-full" style={{ width: 20, height: 20, background: '#22C55E' }}><IconCheck s={13} c="#fff" sw={2.4} /></span>
      </div>
    </div>
    <BottomNav active={2} />
  </div>
);

/* ════ SCREEN 4 · Cinematic route (DARK) ════ */
const CinematicRouteScreen = ({ animate = true }) => {
  const path = "M40 470 C 70 380 150 410 150 330 S 90 250 150 200 S 230 170 220 110 S 170 60 232 40";
  return (
    <div className="absolute inset-0 dmap" style={{ background: 'radial-gradient(ellipse at 50% 35%,#13203c 0%,#0a1322 70%,#070d18)', backgroundSize: '26px 26px,26px 26px,auto' }}>
      {/* extruded blocks */}
      {[[30, 120, 26, 30], [200, 90, 30, 38], [60, 300, 34, 26], [180, 360, 28, 34], [120, 440, 30, 22], [210, 250, 24, 30]].map(([x, y, w, h], i) => (
        <div key={i} className="absolute" style={{ left: x, top: y, width: w, height: h, background: 'linear-gradient(180deg,#1c2c4a,#13203a)', borderRadius: 3, boxShadow: '0 6px 10px rgba(0,0,0,.4), inset 0 1px 0 rgba(125,211,252,.12)', transform: 'skewY(-2deg)' }}></div>
      ))}
      <StatusBar dark time="01:09" pct={64} />
      {/* glowing route */}
      <svg className="absolute inset-0" width="100%" height="100%" viewBox="0 0 272 520" fill="none" preserveAspectRatio="xMidYMid slice">
        <defs>
          <linearGradient id="routeg" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stopColor="#38BDF8" /><stop offset="1" stopColor="#7DD3FC" /></linearGradient>
          <filter id="rglow"><feGaussianBlur stdDeviation="4" /></filter>
        </defs>
        <path d={path} stroke="#38BDF8" strokeWidth="9" strokeLinecap="round" opacity="0.4" filter="url(#rglow)" />
        <path d={path} stroke="url(#routeg)" strokeWidth="4" strokeLinecap="round"
          strokeDasharray={animate ? 900 : 0} strokeDashoffset={animate ? 900 : 0}
          style={animate ? { animation: 'dash 3.4s ease-out forwards', animationIterationCount: 1 } : {}} />
        {/* start / end pins */}
        <circle cx="40" cy="470" r="6" fill="#22C55E" stroke="#0a1322" strokeWidth="2.5" />
        <circle cx="232" cy="40" r="6" fill="#EF4444" stroke="#0a1322" strokeWidth="2.5" />
        {/* moving car */}
        <circle r="5.5" fill="#fff" style={{ offsetPath: `path('${path}')`, offsetRotate: '0deg', animation: 'carMove 3.4s ease-in-out infinite' }} />
        <circle r="11" fill="#38BDF8" opacity="0.25" style={{ offsetPath: `path('${path}')`, animation: 'carMove 3.4s ease-in-out infinite' }} />
      </svg>
      {/* glass metric card */}
      <div className="glass glass-edge absolute left-1/2 -translate-x-1/2 rounded-2xl px-4 py-2.5 flex items-center gap-3" style={{ bottom: 86, border: '1px solid rgba(125,211,252,.3)' }}>
        <div className="flex items-center justify-center rounded-xl" style={{ width: 32, height: 32, background: 'rgba(56,189,248,.16)' }}><IconRoute s={17} c="#7DD3FC" /></div>
        <div>
          <div className="mono" style={{ fontSize: 9, color: '#7DD3FC', letterSpacing: '1px' }}>BU HAFTA</div>
          <div style={{ fontSize: 14, fontWeight: 800, color: '#fff' }}>18,4 km · 32 dk</div>
        </div>
      </div>
      {/* dark bottom nav */}
      <div className="absolute left-0 right-0 bottom-0 flex px-1.5 pt-2" style={{ height: 60, background: 'rgba(10,16,32,.85)', borderTop: '1px solid rgba(125,211,252,.12)', backdropFilter: 'blur(8px)' }}>
        {['Harita', 'Çevre', 'SOS', 'Bildirim', 'Plan'].map((l, i) => (
          <div key={l} className="flex-1 flex flex-col items-center justify-center gap-0.5">
            <div style={{ opacity: i === 4 ? 1 : 0.4 }}>{i === 4 ? <IconStar s={18} c="#7DD3FC" /> : <div className="w-4 h-4 rounded" style={{ border: '1.6px solid #94A3B8' }}></div>}</div>
            <span style={{ fontSize: 9.5, fontWeight: 600, color: i === 4 ? '#7DD3FC' : '#5b6b85' }}>{l}</span>
          </div>
        ))}
      </div>
    </div>
  );
};

/* ════ SCREEN 5 · Trip timeline (Hareketler) ════ */
const TripScreen = () => {
  const stops = [
    ['Kandil Sk.', '22:30 – 23:16 · 45 dk'],
    ['Turgut Özal Blv.', '22:08 – 22:14 · 5 dk'],
    ['Aydınevler, Maltepe', '19:32 – 21:49 · 2 sa 17 dk'],
  ];
  const legs = ['6.5 km · 16 dk · Araç', '5.7 km · 19 dk · Araç'];
  return (
    <div className="absolute inset-0 flex flex-col bg-white">
      <StatusBar time="01:08" pct={19} charging={false} />
      <div className="flex items-center px-4 pb-1">
        <IconChevR s={18} c="#0F172A" style={{ transform: 'rotate(180deg)' }} />
        <div className="flex-1 text-center" style={{ fontSize: 17, fontWeight: 800, color: '#0F172A' }}>Hareketler</div>
        <div style={{ width: 18 }}></div>
      </div>
      {/* people row */}
      <div className="flex gap-4 px-4 pt-2 pb-1">
        {[['Sen', '#3678F9', 'linear-gradient(150deg,#7c8aa0,#43617a)'], ['Mehmet Kara', '#22C55E', '#E2E8F0']].map(([n, ring, bg], i) => (
          <div key={i} className="flex flex-col items-center gap-1">
            <div className="rounded-full" style={{ width: 50, height: 50, background: bg, border: `2.5px solid ${ring}` }}></div>
            <span style={{ fontSize: 11, fontWeight: 600, color: '#64748B' }}>{n}</span>
          </div>
        ))}
      </div>
      {/* day */}
      <div className="flex items-center justify-between px-4 pt-1.5">
        <div><div style={{ fontSize: 19, fontWeight: 800, color: '#0F172A' }}>Dün</div><div style={{ fontSize: 11.5, color: '#94A3B8' }}>7 Haziran Pazar</div></div>
        <div className="flex gap-1.5">
          <div className="rounded-full flex items-center px-3" style={{ height: 32, background: 'rgba(54,120,249,.12)', fontSize: 12.5, fontWeight: 700, color: '#3678F9' }}>Bugün</div>
          <div className="rounded-xl flex items-center justify-center" style={{ width: 34, height: 32, background: 'rgba(54,120,249,.12)' }}><IconCalendar s={16} c="#3678F9" /></div>
        </div>
      </div>
      <div style={{ height: 1, background: '#EEF1F6', margin: '8px 16px 0' }}></div>
      {/* stat cards */}
      <div className="flex gap-2 px-4 pt-3">
        {[['111 km', 'Mesafe'], ['10', 'Durak'], ['9', 'Yolculuk']].map(([v, l], i) => (
          <div key={i} className="flex-1 rounded-2xl flex flex-col items-center justify-center" style={{ height: 64, background: '#F4F6FA' }}>
            <span style={{ fontSize: 19, fontWeight: 800, color: '#0F172A' }}>{v}</span>
            <span style={{ fontSize: 11, color: '#94A3B8' }}>{l}</span>
          </div>
        ))}
      </div>
      {/* timeline */}
      <div className="px-4 pt-3 flex-1 overflow-hidden">
        {stops.map((s, i) => (
          <React.Fragment key={i}>
            <div className="flex gap-2.5">
              <div className="flex flex-col items-center pt-1.5" style={{ width: 32 }}>
                <div className="flex items-center justify-center rounded-lg" style={{ width: 30, height: 30, background: '#EEF1F6' }}><IconPinFill s={15} c="#64748B" /></div>
              </div>
              <div className="flex-1 rounded-2xl px-3.5 py-2.5 mb-1" style={{ border: '1px solid #EEF1F6' }}>
                <div style={{ fontSize: 14, fontWeight: 700, color: '#0F172A' }}>{s[0]}</div>
                <div style={{ fontSize: 11.5, color: '#94A3B8', marginTop: 1 }}>{s[1]}</div>
              </div>
            </div>
            {legs[i] && (
              <div className="flex gap-2.5 items-center" style={{ marginLeft: 0 }}>
                <div className="flex justify-center" style={{ width: 32 }}><div style={{ width: 1.5, height: 22, background: '#E2E8F0' }}></div></div>
                <div className="inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 mb-1" style={{ background: '#F4F6FA' }}><IconCar s={14} c="#94A3B8" /><span style={{ fontSize: 11.5, fontWeight: 600, color: '#64748B' }}>{legs[i]}</span></div>
              </div>
            )}
          </React.Fragment>
        ))}
      </div>
      <BottomNav active={0} />
    </div>
  );
};

Object.assign(window, { Phone, ScaledPhone, StatusBar, BottomNav, MapScreen, SosReadyScreen, SosActiveScreen, CinematicRouteScreen, TripScreen });
