// Photo capture — 3 modern concepts. Same palette (teal accent, amber shutter,
// dark surfaces) as the shipping app; the chrome around the camera is what changes.
// Shared: fake camera feed, 393×852, dark.

function CameraFeed({ children, src }) {
  if (src) {
    return (
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <img src={src} alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' }}/>
        {children}
      </div>
    );
  }
  return (
    <div style={{ position: 'absolute', inset: 0, background: 'radial-gradient(ellipse at 35% 25%, #4a4238 0%, #2a2420 45%, #12100d 100%)' }}>
      {/* abstract keyboard-ish scene */}
      <div style={{ position: 'absolute', top: '18%', left: '10%', right: '10%', height: '38%', borderRadius: 14, background: 'linear-gradient(160deg, rgba(120,110,95,0.35), rgba(40,36,30,0.5))', transform: 'perspective(700px) rotateX(30deg)' }}/>
      <div style={{ position: 'absolute', top: '30%', left: '20%', width: 70, height: 56, borderRadius: 8, background: 'rgba(20,18,15,0.55)' }}/>
      <div style={{ position: 'absolute', top: '32%', left: '48%', width: 84, height: 60, borderRadius: 8, background: 'rgba(25,22,18,0.5)' }}/>
      {children}
    </div>
  );
}

const PC_DARK = '#181B22';
const PC_GLASS = 'rgba(24,27,34,0.72)';
const PC_TEAL = '#14B8A6';
const PC_AMBER = '#F5A623';

function GlassCircle({ children, size = 44, style }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: size / 2,
      background: PC_GLASS, backdropFilter: 'blur(16px)',
      border: '1px solid rgba(255,255,255,0.08)',
      display: 'flex', alignItems: 'center', justifyContent: 'center',
      boxShadow: '0 4px 16px rgba(0,0,0,0.35)', ...style,
    }}>{children}</div>
  );
}

// ── Concept A · Glass HUD ────────────────────────────────────
// Floating glass chrome, teal viewfinder brackets, one-piece bottom bar.
function PhotoConceptA() {
  return (
    <Screen dark bg="#000">
      <CameraFeed/>
      <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(0,0,0,0.45) 0%, transparent 18%, transparent 70%, rgba(0,0,0,0.55) 100%)' }}/>

      {/* Top glass row */}
      <div style={{ position: 'absolute', top: 58, left: 16, right: 16, display: 'flex', alignItems: 'center', justifyContent: 'space-between', zIndex: 10 }}>
        <GlassCircle><Icons.ChevronL size={22} color={PC_TEAL}/></GlassCircle>
        <div style={{ ...TYPE.h3, color: '#fff', fontSize: 15, textShadow: '0 1px 8px rgba(0,0,0,0.5)' }}>Scan items</div>
        {/* scans pill with mini progress ring */}
        <div style={{ height: 36, borderRadius: 18, background: PC_GLASS, backdropFilter: 'blur(16px)', border: '1px solid rgba(255,255,255,0.08)', display: 'flex', alignItems: 'center', gap: 8, padding: '0 12px 0 8px' }}>
          <svg width="20" height="20" viewBox="0 0 20 20">
            <circle cx="10" cy="10" r="8" fill="none" stroke="rgba(255,255,255,0.15)" strokeWidth="2.5"/>
            <circle cx="10" cy="10" r="8" fill="none" stroke={PC_TEAL} strokeWidth="2.5" strokeDasharray="50.3" strokeDashoffset="50.3" strokeLinecap="round" transform="rotate(-90 10 10)"/>
          </svg>
          <span style={{ fontSize: 12, fontWeight: 600, color: '#fff' }}>0/2 free</span>
        </div>
      </div>

      {/* Viewfinder corner brackets */}
      {[['top','left'],['top','right'],['bottom','left'],['bottom','right']].map(([v,h]) => (
        <div key={v+h} style={{
          position: 'absolute', [v]: 170, [h]: 44, width: 34, height: 34, zIndex: 5,
          [`border${v[0].toUpperCase()+v.slice(1)}`]: `3px solid ${PC_TEAL}`,
          [`border${h[0].toUpperCase()+h.slice(1)}`]: `3px solid ${PC_TEAL}`,
          [`border${v[0].toUpperCase()+v.slice(1)}${h[0].toUpperCase()+h.slice(1)}Radius`]: 12,
          filter: `drop-shadow(0 0 6px ${PC_TEAL}66)`,
          ...(v === 'bottom' ? { bottom: 260 } : {}),
        }}/>
      ))}

      {/* AI hint chip */}
      <div style={{ position: 'absolute', left: '50%', transform: 'translateX(-50%)', bottom: 196, display: 'flex', alignItems: 'center', gap: 8, background: PC_GLASS, backdropFilter: 'blur(16px)', border: '1px solid rgba(255,255,255,0.08)', borderRadius: 18, padding: '8px 14px', zIndex: 10 }}>
        <Icons.Sparkles size={14} color="#A78BFA"/>
        <span style={{ fontSize: 13, color: 'rgba(255,255,255,0.9)', fontWeight: 500 }}>Point at your items — AI finds them</span>
      </div>

      {/* Bottom one-piece glass bar */}
      <div style={{ position: 'absolute', left: 20, right: 20, bottom: 44, height: 96, borderRadius: 48, background: PC_GLASS, backdropFilter: 'blur(20px)', border: '1px solid rgba(255,255,255,0.1)', display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '0 22px', zIndex: 10, boxShadow: '0 10px 32px rgba(0,0,0,0.45)' }}>
        <GlassCircle size={48} style={{ background: 'rgba(255,255,255,0.06)' }}><Icons.Settings size={20} color="rgba(255,255,255,0.75)"/></GlassCircle>
        {/* Shutter: amber ring + core */}
        <div style={{ width: 76, height: 76, borderRadius: 38, border: `4px solid ${PC_AMBER}`, padding: 5, boxShadow: `0 0 24px ${PC_AMBER}55` }}>
          <div style={{ width: '100%', height: '100%', borderRadius: '50%', background: PC_AMBER }}/>
        </div>
        <GlassCircle size={48} style={{ background: 'rgba(255,255,255,0.06)', border: `1.5px solid ${PC_TEAL}` }}><Icons.Image size={20} color={PC_TEAL}/></GlassCircle>
      </div>
    </Screen>
  );
}

// ── Concept B · Bottom dock ──────────────────────────────────
// Camera stays clean; all controls live in a dark rounded dock that reads
// like a sheet — grabber, copy, scan-quota progress, big shutter.
function PhotoConceptB() {
  return (
    <Screen dark bg="#000">
      <CameraFeed/>
      <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(0,0,0,0.4) 0%, transparent 15%)' }}/>

      {/* Top minimal: back + scans dots */}
      <div style={{ position: 'absolute', top: 58, left: 16, right: 16, display: 'flex', alignItems: 'center', justifyContent: 'space-between', zIndex: 10 }}>
        <GlassCircle><Icons.ChevronL size={22} color="#fff"/></GlassCircle>
        <div style={{ display: 'flex', alignItems: 'center', gap: 6, background: PC_GLASS, backdropFilter: 'blur(16px)', borderRadius: 16, padding: '8px 14px', border: '1px solid rgba(255,255,255,0.08)' }}>
          <span style={{ fontSize: 12, color: 'rgba(255,255,255,0.85)', fontWeight: 500 }}>Free scans</span>
          <div style={{ display: 'flex', gap: 4 }}>
            <div style={{ width: 14, height: 5, borderRadius: 3, background: PC_TEAL }}/>
            <div style={{ width: 14, height: 5, borderRadius: 3, background: PC_TEAL }}/>
          </div>
        </div>
      </div>

      {/* Bottom dock */}
      <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0, background: PC_DARK, borderTopLeftRadius: 28, borderTopRightRadius: 28, padding: '10px 24px 40px', zIndex: 10, boxShadow: '0 -10px 40px rgba(0,0,0,0.5)' }}>
        <div style={{ width: 36, height: 4, borderRadius: 2, background: 'rgba(255,255,255,0.18)', margin: '4px auto 14px' }}/>
        <div style={{ textAlign: 'center', marginBottom: 4 }}>
          <div style={{ fontSize: 16, fontWeight: 600, color: '#fff' }}>Take a photo of your items</div>
          <div style={{ fontSize: 13, color: 'rgba(255,255,255,0.55)', marginTop: 3 }}>AI detects each item automatically</div>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '14px 10px 0' }}>
          <GlassCircle size={50} style={{ background: 'rgba(255,255,255,0.06)' }}><Icons.Settings size={20} color="rgba(255,255,255,0.7)"/></GlassCircle>
          <div style={{ width: 82, height: 82, borderRadius: 41, background: `radial-gradient(circle at 35% 30%, #FFC14D, ${PC_AMBER})`, boxShadow: `0 6px 24px ${PC_AMBER}66, inset 0 -3px 8px rgba(0,0,0,0.15)`, border: '3px solid rgba(255,255,255,0.25)' }}/>
          <GlassCircle size={50} style={{ background: `${PC_TEAL}22`, border: `1.5px solid ${PC_TEAL}` }}><Icons.Image size={20} color={PC_TEAL}/></GlassCircle>
        </div>
      </div>
    </Screen>
  );
}

// ── Concept C · Minimal pro ──────────────────────────────────
// Pro-camera feel: dashed detection frame, zoom chips, slim quota bar,
// offset gallery thumbnail. Least chrome, most camera.
function PhotoConceptC({ photoSrc, detections }) {
  return (
    <Screen dark bg="#000">
      <CameraFeed src={photoSrc}/>
      <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 16%, transparent 72%, rgba(0,0,0,0.6) 100%)' }}/>

      {/* Top: AI Scan pill center, X right */}
      <div style={{ position: 'absolute', top: 58, left: 16, right: 16, display: 'flex', alignItems: 'center', zIndex: 10 }}>
        <div style={{ width: 44 }}/>
        <div style={{ flex: 1, display: 'flex', justifyContent: 'center' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 7, background: PC_GLASS, backdropFilter: 'blur(16px)', borderRadius: 17, padding: '8px 16px', border: `1px solid ${PC_TEAL}44` }}>
            <Icons.Sparkles size={14} color={PC_TEAL}/>
            <span style={{ fontSize: 13, fontWeight: 600, color: '#fff', letterSpacing: 0.2 }}>AI Scan</span>
          </div>
        </div>
        <GlassCircle><Icons.X size={20} color="#fff"/></GlassCircle>
      </div>

      {/* Dashed detection frame */}
      <div style={{ position: 'absolute', top: 160, left: 36, right: 36, bottom: 300, border: `2px dashed ${PC_TEAL}AA`, borderRadius: 22, zIndex: 5, boxShadow: `inset 0 0 60px rgba(20,184,166,0.06)` }}>
        <div style={{ position: 'absolute', top: -13, left: '50%', transform: 'translateX(-50%)', background: PC_TEAL, color: '#06231F', fontSize: 11, fontWeight: 700, padding: '4px 12px', borderRadius: 12, letterSpacing: 0.4 }}>{detections ? `${detections.length} ITEMS FOUND` : 'FIT ITEMS IN FRAME'}</div>
      </div>

      {/* AI detection overlays — bounding boxes with labels (x/y/w/h in % of screen) */}
      {detections && detections.map((d, i) => (
        <div key={i} style={{ position: 'absolute', left: `${d.x}%`, top: `${d.y}%`, width: `${d.w}%`, height: `${d.h}%`, border: `2px solid ${PC_TEAL}`, borderRadius: 10, zIndex: 6, boxShadow: `0 0 12px ${PC_TEAL}44` }}>
          <div style={{ position: 'absolute', top: -22, left: -2, background: PC_TEAL, color: '#06231F', fontSize: 10.5, fontWeight: 700, padding: '2px 8px', borderRadius: 7, whiteSpace: 'nowrap' }}>{d.label}</div>
        </div>
      ))}

      {/* Zoom chips */}
      <div style={{ position: 'absolute', left: '50%', transform: 'translateX(-50%)', bottom: 236, display: 'flex', gap: 6, zIndex: 10 }}>
        {['0.5', '1×', '2'].map((z, i) => (
          <div key={z} style={{ width: i === 1 ? 40 : 32, height: i === 1 ? 40 : 32, borderRadius: '50%', background: i === 1 ? PC_GLASS : 'rgba(0,0,0,0.35)', border: i === 1 ? `1px solid ${PC_AMBER}` : '1px solid rgba(255,255,255,0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: i === 1 ? 13 : 11, fontWeight: 600, color: i === 1 ? PC_AMBER : 'rgba(255,255,255,0.6)', alignSelf: 'center' }}>{z}</div>
        ))}
      </div>

      {/* Slim quota bar */}
      <div style={{ position: 'absolute', left: '50%', transform: 'translateX(-50%)', bottom: 190, display: 'flex', alignItems: 'center', gap: 8, zIndex: 10 }}>
        <div style={{ width: 60, height: 4, borderRadius: 2, background: 'rgba(255,255,255,0.18)', overflow: 'hidden' }}>
          <div style={{ width: '0%', height: '100%', background: PC_TEAL }}/>
        </div>
        <span style={{ fontSize: 11, color: 'rgba(255,255,255,0.65)', fontWeight: 500 }}>0 of 2 free scans</span>
      </div>

      {/* Bottom controls: gear · shutter · gallery thumb */}
      <div style={{ position: 'absolute', left: 36, right: 36, bottom: 52, display: 'flex', alignItems: 'center', justifyContent: 'space-between', zIndex: 10 }}>
        <GlassCircle size={52}><Icons.Settings size={21} color="rgba(255,255,255,0.75)"/></GlassCircle>
        {/* shutter: ring + gap + core */}
        <div style={{ width: 84, height: 84, borderRadius: 42, border: '3px solid rgba(255,255,255,0.85)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <div style={{ width: 66, height: 66, borderRadius: 33, background: PC_AMBER, boxShadow: `0 0 28px ${PC_AMBER}66` }}/>
        </div>
        {/* offset polaroid-ish gallery thumb */}
        <div style={{ width: 52, height: 52, borderRadius: 12, background: 'linear-gradient(140deg, #5a4a38, #2c261f)', border: `2px solid ${PC_TEAL}`, transform: 'rotate(6deg)', boxShadow: '0 4px 14px rgba(0,0,0,0.5)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <Icons.Plus size={18} color={PC_TEAL} strokeWidth={2.5}/>
        </div>
      </div>
    </Screen>
  );
}

// ── Real app: PhotoCaptureSheet ──────────────────────────────
// Faithful to src/components/PhotoCaptureSheet.tsx: full-screen sheet on the
// app's white surface (NOT full-bleed camera chrome) — back chevron + scan
// counter header, black viewfinder in the middle, controls on white below
// ("Take a photo of your items", amber 64px shutter centered, 48px gallery
// button right with accentTint bg + accent border).
function PhotoCaptureRealScreen({ photoSrc, detections = [], processing = false }) {
  const ACC = '#0D7377', ACC_TINT = 'rgba(13,115,119,0.10)', AMB = '#F5A623';
  return (
    <Screen bg="#FFFFFF">
      {/* Header: back + ScanCounter */}
      <div style={{ padding: '54px 12px 8px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
        <div style={{ width: 44, height: 44, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <Icons.ChevronL size={28} color={ACC}/>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 6, background: ACC_TINT, borderRadius: 999, padding: '6px 12px' }}>
          <Icons.Camera size={13} color={ACC}/>
          <span style={{ fontSize: 12, fontWeight: 600, color: ACC }}>2 free scans left</span>
        </div>
      </div>

      {/* Viewfinder: black, photo contained, AI detection boxes */}
      <div style={{ flex: 1, background: '#000', position: 'relative', overflow: 'hidden' }}>
        {photoSrc && <img src={photoSrc} alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' }}/>}
        {detections.map((d, i) => (
          <div key={i} style={{ position: 'absolute', left: `${d.x}%`, top: `${d.y}%`, width: `${d.w}%`, height: `${d.h}%`, border: `2px solid ${AMB}`, borderRadius: 6, boxShadow: '0 0 0 1px rgba(0,0,0,0.35)' }}>
            {detections.length > 6 ? (
              <div style={{ position: 'absolute', top: -9, left: -9, width: 20, height: 20, borderRadius: 10, background: AMB, color: '#3A2A05', fontSize: 11, fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: '0 1px 4px rgba(0,0,0,0.35)' }}>{i + 1}</div>
            ) : (
              <div style={{ position: 'absolute', top: -22, left: -2, background: AMB, color: '#3A2A05', fontSize: 10.5, fontWeight: 700, padding: '3px 7px', borderRadius: 5, whiteSpace: 'nowrap' }}>{d.label}</div>
            )}
          </div>
        ))}
      </div>

      {/* Controls on white */}
      <div style={{ padding: '18px 32px 40px', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16 }}>
        {processing ? (
          <>
            <div style={{ width: 28, height: 28, borderRadius: '50%', border: `3px solid ${ACC_TINT}`, borderTopColor: ACC }}/>
            <div style={{ fontSize: 13, color: '#6B7280' }}>Identifying items...</div>
            <div style={{ fontSize: 13, fontWeight: 600, color: ACC }}>Cancel</div>
          </>
        ) : (
          <>
            <div style={{ fontSize: 13, color: '#6B7280' }}>Take a photo of your items</div>
            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
              <div style={{ width: 64 }}/>
              <div style={{ width: 64, height: 64, borderRadius: 32, background: AMB, boxShadow: '0 2px 10px rgba(245,166,35,0.4)' }}/>
              <div style={{ width: 64, display: 'flex', justifyContent: 'center' }}>
                <div style={{ width: 48, height: 48, borderRadius: 24, background: ACC_TINT, border: `1px solid ${ACC}`, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                  <Icons.Image size={22} color={ACC}/>
                </div>
              </div>
            </div>
          </>
        )}
      </div>
    </Screen>
  );
}

Object.assign(window, { PhotoConceptA, PhotoConceptB, PhotoConceptC, PhotoCaptureRealScreen });
