/* global React */
const { useState, useEffect, useRef } = React;
const { MarqueeIcon } = window.GroppFlowComponents;

// ── Rugged Tablet Illustration ────────────────────────────────────────────────
function TabletIllustration({ lang }) {
  const [camFeed, setCamFeed] = useState(0);
  const feeds = lang === "es"
    ? ["CAM-01 · FRONTAL", "CAM-02 · CABINA", "CAM-03 · LATERAL IZQ", "CAM-04 · LATERAL DER"]
    : ["CAM-01 · ROAD", "CAM-02 · CABIN", "CAM-03 · LEFT SIDE", "CAM-04 · RIGHT SIDE"];

  useEffect(() => {
    const id = setInterval(() => setCamFeed(f => (f + 1) % 4), 2200);
    return () => clearInterval(id);
  }, []);

  const isEs = lang === "es";

  return (
    <div style={{ position: "relative", display: "flex", justifyContent: "center", alignItems: "center" }}>
      {/* Ambient glow */}
      <div style={{
        position: "absolute", width: 600, height: 400,
        background: "radial-gradient(ellipse at 50% 60%, oklch(0.55 0.18 245 / 0.12) 0%, transparent 70%)",
        pointerEvents: "none",
      }} />

      {/* Tablet body */}
      <div style={{
        width: 580, height: 370,
        background: "oklch(0.13 0.03 250)",
        borderRadius: 14,
        border: "3px solid oklch(0.22 0.04 250)",
        boxShadow: `
          0 0 0 1px oklch(0.30 0.05 250),
          0 2px 4px oklch(0.10 0.04 250 / 0.8),
          0 30px 80px -20px oklch(0.08 0.03 250 / 0.9),
          inset 0 1px 0 oklch(0.25 0.04 250)
        `,
        position: "relative", overflow: "hidden", flexShrink: 0,
      }}>
        {/* Rubber corner guards */}
        {[{top:0,left:0},{top:0,right:0},{bottom:0,left:0},{bottom:0,right:0}].map((s,i) => (
          <div key={i} style={{
            position:"absolute", width:28, height:28,
            background:"oklch(0.09 0.02 250)",
            borderRadius: i===0?"12px 0 10px 0":i===1?"0 12px 0 10px":i===2?"0 10px 12px 0":"10px 0 0 12px",
            zIndex:10, ...s
          }} />
        ))}

        {/* Status bar */}
        <div style={{
          position: "absolute", top: 0, left: 0, right: 0, height: 32,
          background: "oklch(0.09 0.03 250)",
          borderBottom: "1px solid oklch(0.20 0.03 250)",
          display: "flex", alignItems: "center", justifyContent: "space-between",
          padding: "0 16px", zIndex: 5,
          fontFamily: "var(--font-mono)", fontSize: 9, color: "oklch(0.55 0.04 240)",
          letterSpacing: "0.08em",
        }}>
          <span style={{ color: "var(--accent-2)" }}>● GROPP FLOW · {isEs ? "EN VIVO" : "LIVE"}</span>
          <span>{feeds[camFeed]}</span>
          <span style={{ display:"flex", gap:6, alignItems:"center" }}>
            <span>LTE</span>
            <span style={{ color:"var(--accent-2)" }}>●</span>
            <span>14:42</span>
          </span>
        </div>

        {/* Screen content — split: map left, camera feed right */}
        <div style={{ position:"absolute", inset:0, top:32, display:"flex" }}>

          {/* Left: Navigation */}
          <div style={{
            flex:1, background:"oklch(0.11 0.03 250)",
            borderRight:"1px solid oklch(0.18 0.03 250)",
            position:"relative", overflow:"hidden",
          }}>
            {/* Map grid */}
            <svg width="100%" height="100%" viewBox="0 0 290 320" style={{ position:"absolute", inset:0 }}>
              {/* Grid lines */}
              {Array.from({length:12}).map((_,i) => (
                <line key={`h${i}`} x1="0" y1={i*28} x2="290" y2={i*28} stroke="oklch(0.18 0.03 250)" strokeWidth="0.5" />
              ))}
              {Array.from({length:11}).map((_,i) => (
                <line key={`v${i}`} x1={i*30} y1="0" x2={i*30} y2="320" stroke="oklch(0.18 0.03 250)" strokeWidth="0.5" />
              ))}
              {/* Route line */}
              <path d="M 40 280 Q 80 240, 100 200 T 140 160 Q 170 130, 200 110 T 240 70" fill="none" stroke="var(--accent)" strokeWidth="2.5" strokeLinecap="round" opacity="0.9">
                <animate attributeName="stroke-dashoffset" from="0" to="-40" dur="3s" repeatCount="indefinite" />
              </path>
              {/* Streets */}
              <line x1="60" y1="0" x2="60" y2="320" stroke="oklch(0.22 0.03 250)" strokeWidth="1.2" />
              <line x1="160" y1="0" x2="160" y2="320" stroke="oklch(0.22 0.03 250)" strokeWidth="1.2" />
              <line x1="0" y1="120" x2="290" y2="120" stroke="oklch(0.22 0.03 250)" strokeWidth="1.2" />
              <line x1="0" y1="220" x2="290" y2="220" stroke="oklch(0.22 0.03 250)" strokeWidth="1.2" />
              {/* Vehicle dot */}
              <circle cx="140" cy="160" r="5" fill="var(--accent)">
                <animate attributeName="r" values="5;7;5" dur="2s" repeatCount="indefinite" />
                <animate attributeName="opacity" values="1;0.6;1" dur="2s" repeatCount="indefinite" />
              </circle>
              <circle cx="140" cy="160" r="3" fill="white" />
              {/* Next stops */}
              {[[200,110],[240,70]].map(([x,y],i)=>(
                <g key={i}>
                  <circle cx={x} cy={y} r="4" fill="none" stroke="var(--accent-2)" strokeWidth="1.4" />
                  <text x={x+7} y={y+3} fontSize="7" fill="oklch(0.65 0.10 130)" fontFamily="var(--font-mono)">#{i+2}</text>
                </g>
              ))}
            </svg>

            {/* ETA chip */}
            <div style={{
              position:"absolute", bottom:10, left:10,
              background:"oklch(0.09 0.03 250 / 0.92)",
              border:"1px solid oklch(0.25 0.04 250)",
              borderRadius:6, padding:"6px 10px",
              fontFamily:"var(--font-mono)", fontSize:8.5, color:"oklch(0.75 0.04 240)",
              backdropFilter:"blur(8px)",
            }}>
              <div style={{ color:"var(--accent)", fontSize:14, fontWeight:600, letterSpacing:"-0.02em" }}>4.2 km</div>
              <div style={{ color:"var(--accent-2)", marginTop:2 }}>ETA · 12 {isEs?"min":"min"}</div>
            </div>
          </div>

          {/* Right: Camera + stats */}
          <div style={{
            width: 190, display:"flex", flexDirection:"column",
            background:"oklch(0.10 0.02 250)",
          }}>
            {/* Camera feed */}
            <div style={{
              flex:1, background: feedColors[camFeed],
              borderBottom:"1px solid oklch(0.18 0.03 250)",
              position:"relative", overflow:"hidden",
              transition:"background 0.4s",
            }}>
              {/* Scanlines effect */}
              <div style={{
                position:"absolute", inset:0,
                backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 3px, oklch(0 0 0 / 0.08) 3px, oklch(0 0 0 / 0.08) 4px)",
                pointerEvents:"none",
              }} />
              {/* Camera label */}
              <div style={{
                position:"absolute", top:8, left:8,
                fontFamily:"var(--font-mono)", fontSize:7.5,
                color:"oklch(0.90 0.02 240)", letterSpacing:"0.08em",
                background:"oklch(0 0 0 / 0.5)", padding:"2px 6px", borderRadius:3,
              }}>
                {feeds[camFeed]}
              </div>
              {/* REC indicator */}
              <div style={{
                position:"absolute", top:8, right:8,
                display:"flex", alignItems:"center", gap:4,
                fontFamily:"var(--font-mono)", fontSize:7, color:"oklch(0.90 0.06 25)",
                background:"oklch(0 0 0 / 0.5)", padding:"2px 6px", borderRadius:3,
              }}>
                <span style={{ animation:"pulse 1.2s ease infinite" }}>●</span> REC
              </div>
              {/* AI overlay bounding box for cabin cam */}
              {camFeed === 1 && (
                <div style={{
                  position:"absolute", top:"25%", left:"22%", width:"56%", height:"50%",
                  border:"1.5px solid var(--accent-2)", borderRadius:3,
                }}>
                  <div style={{
                    position:"absolute", top:-10, left:4, fontSize:6.5,
                    fontFamily:"var(--font-mono)", color:"var(--accent-2)",
                    background:"oklch(0.14 0.04 250)", padding:"1px 4px",
                  }}>FACE · 0.97</div>
                </div>
              )}
              {/* Road cam: ADAS overlay */}
              {camFeed === 0 && (
                <>
                  <div style={{
                    position:"absolute", bottom:"30%", left:"15%", right:"15%",
                    height:"35%", borderBottom:"2px solid oklch(0.80 0.18 100 / 0.8)",
                  }} />
                  <div style={{
                    position:"absolute", bottom:10, left:"50%", transform:"translateX(-50%)",
                    fontFamily:"var(--font-mono)", fontSize:6.5, color:"oklch(0.80 0.18 100)",
                    background:"oklch(0 0 0 / 0.5)", padding:"2px 6px", borderRadius:3,
                    whiteSpace:"nowrap",
                  }}>LANE · OK</div>
                </>
              )}
            </div>

            {/* Mini stats */}
            <div style={{ padding:"8px 10px", display:"flex", flexDirection:"column", gap:5 }}>
              {[
                { label: isEs?"VEL":"SPD", val:"54 km/h", ok:true },
                { label: isEs?"ATEN":"ATTN", val:"0.91", ok:true },
                { label: isEs?"TURNO":"SHIFT", val:"5h 24m", ok:true },
              ].map((s,i) => (
                <div key={i} style={{ display:"flex", justifyContent:"space-between", alignItems:"center" }}>
                  <span style={{ fontFamily:"var(--font-mono)", fontSize:7.5, color:"oklch(0.50 0.03 240)", letterSpacing:"0.08em" }}>{s.label}</span>
                  <span style={{ fontFamily:"var(--font-mono)", fontSize:8, color: s.ok?"var(--accent-2)":"var(--warn)" }}>{s.val}</span>
                </div>
              ))}
              <div style={{ height:1, background:"oklch(0.20 0.03 250)", margin:"2px 0" }} />
              <div style={{ fontFamily:"var(--font-mono)", fontSize:7, color:"oklch(0.35 0.03 240)", letterSpacing:"0.06em", textAlign:"center" }}>
                {isEs ? "PARADA · #7 / 24" : "STOP · #7 / 24"}
              </div>
            </div>

            {/* Cam selector */}
            <div style={{
              display:"grid", gridTemplateColumns:"1fr 1fr",
              borderTop:"1px solid oklch(0.18 0.03 250)",
            }}>
              {[0,1,2,3].map(i => (
                <button key={i} onClick={() => setCamFeed(i)} style={{
                  padding:"5px 0", fontSize:7, fontFamily:"var(--font-mono)",
                  background: camFeed===i ? "oklch(0.18 0.04 250)" : "transparent",
                  color: camFeed===i ? "var(--accent)" : "oklch(0.35 0.03 240)",
                  border:"none", borderRight: i%2===0 ? "1px solid oklch(0.18 0.03 250)" : "none",
                  borderBottom: i<2 ? "1px solid oklch(0.18 0.03 250)" : "none",
                  cursor:"pointer", letterSpacing:"0.06em",
                  transition:"all .15s",
                }}>CH{i+1}</button>
              ))}
            </div>
          </div>
        </div>

        {/* Bottom bar */}
        <div style={{
          position:"absolute", bottom:0, left:0, right:0, height:28,
          background:"oklch(0.09 0.03 250)",
          borderTop:"1px solid oklch(0.20 0.03 250)",
          display:"flex", alignItems:"center", justifyContent:"space-between",
          padding:"0 16px",
          fontFamily:"var(--font-mono)", fontSize:8, color:"oklch(0.40 0.03 240)",
          letterSpacing:"0.07em",
        }}>
          <span>VT-10 PRO · GROPP EDGE OS 2.1</span>
          <span style={{ display:"flex", gap:10, alignItems:"center" }}>
            <span>● GPS · FIX</span>
            <span style={{ color:"var(--accent-2)" }}>● LTE · −82dBm</span>
            <span>TEMP · 42°C</span>
          </span>
        </div>
      </div>

      <style>{`
        @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.2} }
      `}</style>
    </div>
  );
}

// ── Spec Table ────────────────────────────────────────────────────────────────
function SpecTable({ specs }) {
  return (
    <div style={{
      border:"1px solid var(--line)",
      borderRadius:"var(--radius)",
      overflow:"hidden",
    }}>
      {specs.map((s,i) => (
        <div key={i} style={{
          display:"grid", gridTemplateColumns:"1fr 1.4fr",
          borderBottom: i < specs.length-1 ? "1px solid var(--line-soft)" : "none",
          background: i%2===0 ? "var(--bone)" : "var(--ink-3)",
        }}>
          <div style={{
            padding:"12px 16px",
            fontFamily:"var(--font-mono)", fontSize:11, letterSpacing:"0.07em",
            color:"var(--fog)", borderRight:"1px solid var(--line-soft)",
          }}>{s.k}</div>
          <div style={{ padding:"12px 16px", fontSize:13, color:"var(--ink)", fontWeight:500 }}>{s.v}</div>
        </div>
      ))}
    </div>
  );
}

// ── Camera Card ───────────────────────────────────────────────────────────────
function CameraCard({ icon, title, body, badge }) {
  return (
    <div style={{
      border:"1px solid var(--line)",
      borderRadius:"var(--radius)",
      background:"var(--bone)",
      padding:"24px",
      display:"flex", flexDirection:"column", gap:12,
    }}>
      <div style={{
        width:44, height:44, borderRadius:"var(--radius)",
        background:"var(--ink-3)", border:"1px solid var(--line)",
        display:"flex", alignItems:"center", justifyContent:"center",
      }}>
        {icon}
      </div>
      <div>
        <div style={{ display:"flex", alignItems:"center", gap:8, marginBottom:4 }}>
          <div style={{ fontSize:15, fontWeight:600, color:"var(--ink)" }}>{title}</div>
          {badge && (
            <span style={{
              fontFamily:"var(--font-mono)", fontSize:9, letterSpacing:"0.08em",
              background:"var(--accent)", color:"var(--accent-ink)",
              padding:"2px 7px", borderRadius:2,
            }}>{badge}</span>
          )}
        </div>
        <p style={{ fontSize:13.5, color:"var(--fog)", lineHeight:1.6, margin:0 }}>{body}</p>
      </div>
    </div>
  );
}

// ── Camera Ecosystem Animation ────────────────────────────────────────────────
function CameraEcosystemViz({ isEs }) {
  const [tick, setTick] = useState(0);
  const [active, setActive] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setTick(t => t + 1), 80);
    return () => clearInterval(id);
  }, []);
  useEffect(() => {
    const id = setInterval(() => setActive(a => (a + 1) % 4), 2000);
    return () => clearInterval(id);
  }, []);

  // Camera positions around a central vehicle (top-down)
  const cameras = [
    { id:"road",  x:300, y:60,  badge:"ADAS",    label: isEs?"FRONTAL":"ROAD",   color:"var(--accent)",         angle:0   },
    { id:"cabin", x:490, y:200, badge:"DMS",     label: isEs?"CABINA":"CABIN",   color:"oklch(0.60 0.16 280)",  angle:90  },
    { id:"left",  x:110, y:200, badge:"LADO IZQ",label: isEs?"LATERAL":"SIDE L", color:"oklch(0.60 0.14 200)",  angle:270 },
    { id:"cargo", x:300, y:340, badge:"POD",     label: isEs?"BODEGA":"CARGO",   color:"oklch(0.62 0.18 145)",  angle:180 },
  ];

  // Center tablet
  const cx = 300, cy = 200;

  // Animate a pulse dot along path from camera to center
  const pulseProgress = (tick % 30) / 30; // 0→1 per 2.4s

  return (
    <div style={{ position:"relative", width:"100%", aspectRatio:"2/1", maxHeight:340 }}>
      <svg viewBox="0 0 600 400" style={{ width:"100%", height:"100%", display:"block" }}>
        {/* Background grid */}
        {Array.from({length:10}).map((_,i) => (
          <line key={`h${i}`} x1="0" y1={i*44} x2="600" y2={i*44} stroke="var(--line-soft)" strokeWidth="0.4" />
        ))}
        {Array.from({length:14}).map((_,i) => (
          <line key={`v${i}`} x1={i*46} y1="0" x2={i*46} y2="400" stroke="var(--line-soft)" strokeWidth="0.4" />
        ))}

        {/* Vehicle silhouette (top-down) */}
        <g opacity="0.85">
          {/* Body */}
          <rect x="248" y="110" width="104" height="180" rx="14" fill="var(--ink-3)" stroke="var(--line)" strokeWidth="1.5" />
          {/* Cab */}
          <rect x="258" y="118" width="84" height="70" rx="8" fill="oklch(0.88 0.01 240)" stroke="var(--line)" strokeWidth="1" />
          {/* Cargo area */}
          <rect x="256" y="196" width="88" height="86" rx="4" fill="oklch(0.93 0.01 240)" stroke="var(--line)" strokeWidth="1" />
          {/* Wheels */}
          {[[248,138],[336,138],[248,262],[336,262]].map(([wx,wy],i) => (
            <rect key={i} x={wx-10} y={wy-14} width="10" height="28" rx="4" fill="oklch(0.25 0.02 250)" />
          ))}
          {/* Windshield */}
          <rect x="268" y="126" width="64" height="38" rx="5" fill="oklch(0.82 0.03 230)" opacity="0.7" />
        </g>

        {/* Connection lines: cameras → center */}
        {cameras.map((cam, i) => {
          const isActiveCam = i === active;
          return (
            <g key={cam.id}>
              <line
                x1={cam.x} y1={cam.y} x2={cx} y2={cy}
                stroke={cam.color}
                strokeWidth={isActiveCam ? 1.8 : 1}
                strokeDasharray="5 4"
                opacity={isActiveCam ? 0.7 : 0.25}
                style={{ transition:"all 0.4s" }}
              />
              {/* Animated pulse dot */}
              {isActiveCam && (
                <circle r="4" fill={cam.color} opacity="0.9">
                  <animateMotion
                    dur="0.8s" repeatCount="indefinite"
                    path={`M${cam.x},${cam.y} L${cx},${cy}`}
                  />
                </circle>
              )}
            </g>
          );
        })}

        {/* Central tablet */}
        <g>
          <rect x={cx-40} y={cy-28} width="80" height="56" rx="6"
            fill="oklch(0.13 0.03 250)" stroke="var(--accent)" strokeWidth="1.8" />
          {/* Screen */}
          <rect x={cx-34} y={cy-22} width="68" height="44" rx="3" fill="oklch(0.09 0.03 250)" />
          {/* 4-quad camera view */}
          {[[cx-34,cy-22],[cx-1,cy-22],[cx-34,cy],[cx-1,cy]].map(([qx,qy],i) => (
            <rect key={i} x={qx+1} y={qy+1} width="32" height="20"
              fill={i === active ? cameras[i].color : "oklch(0.14 0.03 250)"}
              opacity={i === active ? 0.5 : 0.3}
              rx="1"
            />
          ))}
          {/* REC dot */}
          <circle cx={cx+30} cy={cy-18} r="3" fill="oklch(0.65 0.18 25)">
            <animate attributeName="opacity" values="1;0.2;1" dur="1.2s" repeatCount="indefinite" />
          </circle>
          <text x={cx} y={cy+36} textAnchor="middle" fontSize="7"
            fontFamily="var(--font-mono)" fill="var(--accent)" letterSpacing="0.07em">GROPP EDGE</text>
        </g>

        {/* Camera nodes */}
        {cameras.map((cam, i) => {
          const isActiveCam = i === active;
          return (
            <g key={cam.id} style={{ cursor:"pointer" }} onClick={() => setActive(i)}>
              {/* Ping ring on active */}
              {isActiveCam && (
                <circle cx={cam.x} cy={cam.y} r="22" fill="none" stroke={cam.color} strokeWidth="1.2" opacity="0.3">
                  <animate attributeName="r" values="16;28;16" dur="1.8s" repeatCount="indefinite" />
                  <animate attributeName="opacity" values="0.4;0;0.4" dur="1.8s" repeatCount="indefinite" />
                </circle>
              )}
              {/* Camera body */}
              <circle cx={cam.x} cy={cam.y} r="16"
                fill={isActiveCam ? cam.color : "var(--bone)"}
                stroke={cam.color} strokeWidth="1.8"
                style={{ transition:"fill 0.3s" }}
              />
              {/* Camera icon */}
              <svg x={cam.x-8} y={cam.y-8} width="16" height="16" viewBox="0 0 24 24"
                fill="none" stroke={isActiveCam ? "white" : cam.color} strokeWidth="2"
                strokeLinecap="round" strokeLinejoin="round">
                <path d="M23 7l-7 5 7 5V7z"/><rect x="1" y="5" width="15" height="14" rx="2"/>
              </svg>
              {/* Badge */}
              <rect x={cam.x-22} y={cam.y+18} width="44" height="14" rx="3"
                fill={isActiveCam ? cam.color : "var(--ink-3)"}
                style={{ transition:"fill 0.3s" }} />
              <text x={cam.x} y={cam.y+28} textAnchor="middle" fontSize="7"
                fontFamily="var(--font-mono)" letterSpacing="0.07em"
                fill={isActiveCam ? "white" : "var(--fog)"}>{cam.badge}</text>
              {/* AI detection label on active */}
              {isActiveCam && (
                <text x={cam.x} y={cam.y-22} textAnchor="middle" fontSize="7.5"
                  fontFamily="var(--font-mono)" fill={cam.color} letterSpacing="0.06em">
                  {cam.label} · {isEs ? "EN VIVO" : "LIVE"}
                </text>
              )}
            </g>
          );
        })}

        {/* AI result chips floating near center */}
        {active === 0 && (
          <g>
            <rect x={cx+46} y={cy-40} width="100" height="18" rx="3" fill="var(--bone)" stroke="var(--accent)" strokeWidth="1" />
            <text x={cx+96} y={cy-28} textAnchor="middle" fontSize="7.5" fontFamily="var(--font-mono)" fill="var(--accent)">LANE · OK · 0.97</text>
          </g>
        )}
        {active === 1 && (
          <g>
            <rect x={cx+46} y={cy-40} width="100" height="18" rx="3" fill="var(--bone)" stroke="oklch(0.60 0.16 280)" strokeWidth="1" />
            <text x={cx+96} y={cy-28} textAnchor="middle" fontSize="7.5" fontFamily="var(--font-mono)" fill="oklch(0.55 0.16 280)">{isEs ? "ATEN · 0.91 · OK" : "ATTN · 0.91 · OK"}</text>
          </g>
        )}
        {active === 2 && (
          <g>
            <rect x={cx-146} y={cy-40} width="100" height="18" rx="3" fill="var(--bone)" stroke="oklch(0.60 0.14 200)" strokeWidth="1" />
            <text x={cx-96} y={cy-28} textAnchor="middle" fontSize="7.5" fontFamily="var(--font-mono)" fill="oklch(0.55 0.14 200)">{isEs ? "PUNTO CIEGO · OK" : "BLIND SPOT · OK"}</text>
          </g>
        )}
        {active === 3 && (
          <g>
            <rect x={cx-50} y={cy+52} width="100" height="18" rx="3" fill="var(--bone)" stroke="oklch(0.62 0.18 145)" strokeWidth="1" />
            <text x={cx} y={cy+64} textAnchor="middle" fontSize="7.5" fontFamily="var(--font-mono)" fill="oklch(0.58 0.18 145)">{isEs ? "ENTREGA · GRABANDO" : "DELIVERY · REC"}</text>
          </g>
        )}
      </svg>

      {/* Click hint */}
      <div style={{
        position:"absolute", bottom:8, right:12,
        fontFamily:"var(--font-mono)", fontSize:9.5, color:"var(--mist)",
        letterSpacing:"0.06em",
      }}>{isEs ? "clic en cámara para activar" : "click camera to activate"}</div>
    </div>
  );
}
function DockIllustration() {
  return (
    <div style={{ display:"flex", justifyContent:"center", padding:"20px 0" }}>
      <svg viewBox="0 0 400 220" width="400" height="220" style={{ overflow:"visible" }}>
        {/* Dock base */}
        <rect x="60" y="120" width="280" height="70" rx="8" fill="oklch(0.13 0.03 250)" stroke="oklch(0.22 0.04 250)" strokeWidth="1.5" />
        {/* Dock slots */}
        <rect x="90" y="135" width="220" height="40" rx="4" fill="oklch(0.10 0.02 250)" stroke="oklch(0.20 0.03 250)" strokeWidth="1" />
        {/* Connector pins */}
        {Array.from({length:8}).map((_,i) => (
          <rect key={i} x={110+i*24} y="145" width="10" height="20" rx="2"
            fill={i<3?"var(--accent)":i<6?"oklch(0.24 0.04 250)":"oklch(0.30 0.05 250)"} />
        ))}
        {/* Labels */}
        <text x="200" y="183" textAnchor="middle" fontSize="9" fill="oklch(0.40 0.03 240)" fontFamily="monospace" letterSpacing="0.1em">GROPP DOCK V2 · CAN / LTE / PWR</text>
        {/* Tablet sitting in dock */}
        <rect x="80" y="36" width="240" height="90" rx="8" fill="oklch(0.13 0.03 250)" stroke="oklch(0.25 0.04 250)" strokeWidth="1.5" />
        <rect x="88" y="44" width="224" height="74" rx="4" fill="oklch(0.09 0.03 250)" />
        {/* Screen content — route preview */}
        <rect x="92" y="48" width="100" height="66" rx="2" fill="oklch(0.11 0.03 250)" />
        {/* Mini map */}
        <path d="M 100 100 Q 120 80, 135 75 T 160 60 Q 170 55, 185 50" fill="none" stroke="var(--accent)" strokeWidth="1.5" />
        <circle cx="135" cy="75" r="3" fill="var(--accent)" opacity="0.8" />
        {/* Right panel */}
        <rect x="196" y="48" width="110" height="66" rx="2" fill="oklch(0.11 0.03 250)" />
        <rect x="200" y="52" width="102" height="28" rx="2" fill="oklch(0.16 0.08 150 / 0.4)" />
        {/* DMS face box */}
        <rect x="220" y="56" width="30" height="20" rx="2" fill="none" stroke="var(--accent-2)" strokeWidth="1" />
        <text x="235" y="80" textAnchor="middle" fontSize="6" fill="oklch(0.70 0.10 130)" fontFamily="monospace">FACE · OK</text>
        {/* Stats rows */}
        {[0,1,2].map(i => (
          <g key={i}>
            <rect x="200" y={88+i*8} width="60" height="5" rx="1" fill="oklch(0.20 0.03 250)" />
            <rect x="200" y={88+i*8} width={[45,30,52][i]} height="5" rx="1" fill="var(--accent)" opacity="0.7" />
          </g>
        ))}
        {/* Connection cable */}
        <path d="M 200 126 Q 200 133, 200 135" fill="none" stroke="oklch(0.30 0.04 250)" strokeWidth="3" strokeLinecap="round" />
        {/* Power indicator */}
        <circle cx="344" cy="145" r="5" fill="var(--accent-2)">
          <animate attributeName="opacity" values="1;0.4;1" dur="2s" repeatCount="indefinite" />
        </circle>
        <text x="344" y="170" textAnchor="middle" fontSize="7" fill="oklch(0.55 0.03 240)" fontFamily="monospace">PWR</text>
        {/* Side ports */}
        {[{x:60,label:"CAN"},{x:340,label:"LTE"}].map((p,i) => (
          <g key={i}>
            <rect x={p.x-12} y="138" width="8" height="16" rx="2" fill="oklch(0.20 0.04 250)" stroke="oklch(0.28 0.04 250)" strokeWidth="1" />
            <text x={p.x-8} y="166" textAnchor="middle" fontSize="7" fill="oklch(0.45 0.03 240)" fontFamily="monospace">{p.label}</text>
          </g>
        ))}
      </svg>
    </div>
  );
}

// ── Architecture Diagram ──────────────────────────────────────────────────────
function ArchDiagram({ isEs }) {
  const nodes = [
    { x:200, y:40, w:140, label: isEs?"Tablet · Cabina":"Tablet · In-Cab", color:"var(--accent)", sub:"Edge AI" },
    { x:40, y:150, w:110, label:"CAN-Bus", color:"oklch(0.60 0.10 200)", sub:isEs?"Velocidad / RPM":"Speed / RPM" },
    { x:170, y:150, w:110, label:isEs?"Cámaras AHD":"AHD Cameras", color:"oklch(0.60 0.12 280)", sub:"4-ch · 1080p" },
    { x:300, y:150, w:110, label:"GPS + IMU", color:"oklch(0.60 0.10 150)", sub:"10 Hz" },
    { x:200, y:260, w:140, label:"Gropp Flow Cloud", color:"var(--accent-2)", sub:isEs?"Agentes IA":"AI Agents" },
  ];
  const edges = [
    [200+70, 40+28, 40+55, 150+14],
    [200+70, 40+28, 170+55, 150+14],
    [200+70, 40+28, 300+55, 150+14],
    [200+70, 40+28+28, 200+70, 260],
  ];

  return (
    <div style={{ display:"flex", justifyContent:"center", padding:"10px 0" }}>
      <svg viewBox="0 0 480 320" width="480" height="320" style={{ overflow:"visible" }}>
        {edges.map(([x1,y1,x2,y2],i) => (
          <line key={i} x1={x1} y1={y1} x2={x2} y2={y2}
            stroke="oklch(0.30 0.04 250)" strokeWidth="1.5" strokeDasharray="4 3">
            <animate attributeName="stroke-dashoffset" from="0" to="-14" dur={`${1.5+i*0.3}s`} repeatCount="indefinite" />
          </line>
        ))}
        {nodes.map((n,i) => (
          <g key={i}>
            <rect x={n.x} y={n.y} width={n.w} height={28} rx="4"
              fill="oklch(0.12 0.03 250)" stroke={n.color} strokeWidth="1.4" />
            <text x={n.x+n.w/2} y={n.y+11} textAnchor="middle"
              fontSize="9.5" fontFamily="monospace" fill={n.color} letterSpacing="0.06em">{n.label}</text>
            <text x={n.x+n.w/2} y={n.y+22} textAnchor="middle"
              fontSize="7.5" fontFamily="monospace" fill="oklch(0.45 0.03 240)">{n.sub}</text>
          </g>
        ))}
        {/* LTE uplink arrow */}
        <path d="M 270 68 Q 420 68, 420 200 Q 420 300, 340 282" fill="none" stroke="oklch(0.35 0.08 245)" strokeWidth="1.2" strokeDasharray="3 4" />
        <text x="425" y="185" fontSize="8" fontFamily="monospace" fill="oklch(0.45 0.04 245)" letterSpacing="0.06em" transform="rotate(90,425,185)">LTE · {isEs?"cifrado":"encrypted"}</text>
      </svg>
    </div>
  );
}

// ── Image Carousel ────────────────────────────────────────────────────────────
function HwCarousel({ isEs }) {
  const slides = isEs ? [
    { src:"assets/hw-tablet-front.png", caption:"VT-10 Pro AHD · vista frontal", bg:"var(--ink-3)" },
    { src:"assets/hw-tablet-dock.png",  caption:"Tablet + docking station", bg:"white" },
    { src:"assets/hw-dock-cables.png",  caption:"Conexiones del dock · CAN · AHD · LTE", bg:"white" },
  ] : [
    { src:"assets/hw-tablet-front.png", caption:"VT-10 Pro AHD · front view", bg:"var(--ink-3)" },
    { src:"assets/hw-tablet-dock.png",  caption:"Tablet + docking station", bg:"white" },
    { src:"assets/hw-dock-cables.png",  caption:"Dock connections · CAN · AHD · LTE", bg:"white" },
  ];

  const [idx, setIdx] = useState(0);
  const [animating, setAnimating] = useState(false);

  const go = (next) => {
    if (animating) return;
    setAnimating(true);
    setTimeout(() => {
      setIdx((next + slides.length) % slides.length);
      setAnimating(false);
    }, 200);
  };

  useEffect(() => {
    const id = setInterval(() => go(idx + 1), 3500);
    return () => clearInterval(id);
  }, [idx]);

  return (
    <div style={{ display:"flex", flexDirection:"column", gap:12 }}>
      {/* Main image frame */}
      <div style={{
        position:"relative", borderRadius:10,
        border:"1px solid var(--line)", overflow:"hidden",
        background: slides[idx].bg,
        aspectRatio:"4/3",
      }}>
        <img
          src={slides[idx].src}
          alt={slides[idx].caption}
          style={{
            width:"100%", height:"100%", objectFit:"contain",
            display:"block", padding: slides[idx].bg === "white" ? 16 : 0,
            opacity: animating ? 0 : 1,
            transition:"opacity 0.2s ease",
          }}
        />

        {/* Prev / Next arrows */}
        {[{dir:-1,pos:{left:10}},{dir:1,pos:{right:10}}].map(({dir,pos},i) => (
          <button key={i} onClick={() => go(idx + dir)} style={{
            position:"absolute", top:"50%", transform:"translateY(-50%)",
            ...pos,
            width:36, height:36, borderRadius:"50%",
            background:"color-mix(in oklch, var(--bone), transparent 10%)",
            border:"1px solid var(--line)", cursor:"pointer",
            display:"flex", alignItems:"center", justifyContent:"center",
            backdropFilter:"blur(8px)",
            transition:"all .15s",
            fontSize:14, color:"var(--ink)",
          }}>{dir === -1 ? "←" : "→"}</button>
        ))}

        {/* Caption */}
        <div style={{
          position:"absolute", bottom:0, left:0, right:0,
          background:"color-mix(in oklch, var(--bone), transparent 15%)",
          backdropFilter:"blur(8px)",
          borderTop:"1px solid var(--line-soft)",
          padding:"8px 14px",
          fontFamily:"var(--font-mono)", fontSize:10, letterSpacing:"0.07em",
          color:"var(--fog)",
        }}>{slides[idx].caption}</div>
      </div>

      {/* Dot indicators */}
      <div style={{ display:"flex", gap:6, justifyContent:"center" }}>
        {slides.map((_, i) => (
          <button key={i} onClick={() => go(i)} style={{
            width: i === idx ? 20 : 6, height:6,
            borderRadius:3, border:"none", cursor:"pointer",
            background: i === idx ? "var(--accent)" : "var(--line)",
            transition:"all .25s ease", padding:0,
          }} />
        ))}
      </div>
    </div>
  );
}

// ── Main Hardware Page ────────────────────────────────────────────────────────
function HardwarePage({ lang, onBack }) {
  const isEs = lang === "es";

  const tabletSpecs = isEs ? [
    { k:"PANTALLA", v:'10.1" IPS · 1920×1200 · 800 nits' },
    { k:"PROCESO.", v:"Octa-core ARM · 4 GB RAM · 64 GB eMMC" },
    { k:"CÁMARAS", v:"4 canales AHD simultáneos · 1080p / 30fps" },
    { k:"IA", v:"NPU integrada · ADAS + DMS en tiempo real" },
    { k:"CONECT.", v:"LTE Cat.6 · WiFi 6 · BT 5.0 · GPS L1+L5" },
    { k:"RUGGED", v:"IP65 · MIL-STD-810H · −20°C a +70°C" },
    { k:"ALIMENT.", v:"9–36V DC · Ignition sense · UPS 30 min" },
    { k:"CAN-BUS", v:"SAE J1939 / OBD-II · ISO 15765" },
  ] : [
    { k:"DISPLAY", v:'10.1" IPS · 1920×1200 · 800 nits' },
    { k:"CPU", v:"Octa-core ARM · 4 GB RAM · 64 GB eMMC" },
    { k:"CAMERAS", v:"4-ch AHD simultaneous · 1080p / 30fps" },
    { k:"AI", v:"On-board NPU · Real-time ADAS + DMS" },
    { k:"CONNECT.", v:"LTE Cat.6 · WiFi 6 · BT 5.0 · GPS L1+L5" },
    { k:"RUGGED", v:"IP65 · MIL-STD-810H · −20°C to +70°C" },
    { k:"POWER", v:"9–36V DC · Ignition sense · 30 min UPS" },
    { k:"CAN-BUS", v:"SAE J1939 / OBD-II · ISO 15765" },
  ];

  const cameras = isEs ? [
    {
      title:"Cámara frontal de ruta",
      badge:"ADAS",
      body:"1080p apuntando al frente. Detecta semáforos, señales de pare, peatones y vehículos. Alimenta el motor ADAS para alertas de carril y distancia de seguimiento.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>,
    },
    {
      title:"Cámara de cabina (DMS)",
      badge:"DMS",
      body:"Infrarrojo de onda corta. Detecta fatiga, bostezos, cierre de ojos, desvío de atención y uso de celular. Funciona de noche sin iluminación adicional.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><circle cx="12" cy="8" r="4"/><path d="M6 20v-2a6 6 0 0112 0v2"/></svg>,
    },
    {
      title:"Cámaras laterales (×2)",
      badge:"LATERAL",
      body:"Punto ciego izquierdo y derecho. Grabación continua, activación por señalero o acercamiento. Prueba de maniobra para reclamos de seguro.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"/></svg>,
    },
    {
      title:"Cámara de bodega / entrega",
      badge:"POD",
      body:"Apunta a la puerta trasera. Captura automática al abrir y cerrar. Prueba de entrega irrefutable, sincronizada con timestamp GPS en el clip.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><polyline points="21 8 21 21 3 21 3 8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>,
    },
  ] : [
    {
      title:"Road-facing camera",
      badge:"ADAS",
      body:"1080p forward-facing. Detects traffic lights, stop signs, pedestrians, and vehicles. Feeds the ADAS engine for lane-departure and following-distance alerts.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><path d="M3 9l9-7 9 7v11a2 2 0 01-2 2H5a2 2 0 01-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>,
    },
    {
      title:"Cabin camera (DMS)",
      badge:"DMS",
      body:"Short-wave infrared. Detects fatigue, yawning, eye-closure, head position, and phone use. Operates at night with no extra lighting.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><circle cx="12" cy="8" r="4"/><path d="M6 20v-2a6 6 0 0112 0v2"/></svg>,
    },
    {
      title:"Side cameras (×2)",
      badge:"SIDE",
      body:"Left and right blind-spot coverage. Continuous recording, triggered on turn-signal or proximity event. Maneuver evidence for insurance claims.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"/></svg>,
    },
    {
      title:"Cargo door / delivery camera",
      badge:"POD",
      body:"Rear-facing. Auto-captures on door open/close events. Irrefutable proof of delivery, synced with GPS timestamp on the clip.",
      icon: <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="var(--accent)" strokeWidth="1.8"><polyline points="21 8 21 21 3 21 3 8"/><rect x="1" y="3" width="22" height="5"/><line x1="10" y1="12" x2="14" y2="12"/></svg>,
    },
  ];

  const installSteps = isEs ? [
    { n:"01", t:"Montaje en tablero", b:"Base magnética anti-vibración con brazo ajustable. Sin taladrar. Instalación en 20 minutos." },
    { n:"02", t:"Conexión al dock", b:"Un cable: alimentación + CAN-Bus + cámaras. El dock se fija detrás del tablero." },
    { n:"03", t:"Activación en Gropp", b:"Escaneás el QR del dispositivo en la app de despacho. La tablet se registra sola en la flota." },
    { n:"04", t:"Listo para el turno", b:"Al girar la llave, la tablet arranca, obtiene fix GPS y conecta a los agentes de Gropp Flow." },
  ] : [
    { n:"01", t:"Dashboard mount", b:"Anti-vibration magnetic base with adjustable arm. No drilling. 20-minute install." },
    { n:"02", t:"Dock connection", b:"One cable: power + CAN-Bus + cameras. The dock mounts behind the dashboard." },
    { n:"03", t:"Gropp activation", b:"Scan the device QR from the dispatch app. The tablet self-registers into the fleet." },
    { n:"04", t:"Ready for shift", b:"On ignition, the tablet boots, acquires GPS fix, and connects to Gropp Flow agents." },
  ];

  return (
    <main>
      {/* ── HERO ── */}
      <section style={{
        background:"var(--bone)", borderBottom:"1px solid var(--line-soft)",
        padding:"80px 0 0",
      }}>
        <div className="container" style={{ display:"grid", gridTemplateColumns:"1fr 1fr", gap:60, alignItems:"center" }}>
          <div>
            <h1 style={{ fontSize:"clamp(32px, 3.5vw, 52px)", lineHeight:1.08, fontWeight:600, marginBottom:20, letterSpacing:"-0.025em" }}>
              {isEs ? <>La computadora<br/><span style={{ color:"var(--accent)" }}>del camión</span>.</> : <>The computer<br/><span style={{ color:"var(--accent)" }}>inside the cab</span>.</>}
            </h1>
            <p style={{ fontSize:16, color:"var(--fog)", lineHeight:1.7, maxWidth:480, marginBottom:32 }}>
              {isEs
                ? "Una tablet robusta de 10\" montada sobre el tablero que funde navegación, IA visual en tiempo real, cuatro cámaras AHD y CAN-Bus del vehículo en un único dispositivo — conectado permanentemente a Gropp Flow."
                : "A 10\" rugged tablet mounted above the driver that fuses navigation, real-time vision AI, four AHD cameras, and vehicle CAN-Bus into a single device — permanently connected to Gropp Flow."}
            </p>
            <div style={{ display:"flex", gap:24, flexWrap:"wrap", marginBottom:40 }}>
              {(isEs
                ? [
                    { num:"4", unit:"canales", label:"cámara AHD simultáneos" },
                    { num:"IP65", unit:"", label:"sellado polvo y agua" },
                    { num:"<200", unit:"ms", label:"latencia de inferencia IA" },
                  ]
                : [
                    { num:"4", unit:"ch", label:"simultaneous AHD camera" },
                    { num:"IP65", unit:"", label:"dust & water sealed" },
                    { num:"<200", unit:"ms", label:"AI inference latency" },
                  ]
              ).map((m,i) => (
                <div key={i} style={{ paddingRight:24, borderRight: i<2 ? "1px solid var(--line)" : "none" }}>
                  <div style={{ fontSize:28, fontWeight:700, letterSpacing:"-0.03em", color:"var(--ink)", lineHeight:1 }}>
                    {m.num}<span style={{ fontSize:14, fontWeight:400, marginLeft:3, color:"var(--accent)" }}>{m.unit}</span>
                  </div>
                  <div style={{ fontSize:11.5, color:"var(--fog)", marginTop:4 }}>{m.label}</div>
                </div>
              ))}
            </div>
            <div style={{ display:"flex", gap:12, flexWrap:"wrap" }}>
              <a className="btn btn-primary" href="#cta">{isEs ? "Pedir demo →" : "Request demo →"}</a>
              <a className="btn btn-ghost" href="#specs">{isEs ? "Ver especificaciones" : "View specs"}</a>
            </div>
          </div>
          {/* Hero visual: in-cab photo */}
          <div style={{ position:"relative", borderRadius:10, overflow:"hidden", boxShadow:"0 40px 80px -20px oklch(0.15 0.04 250 / 0.35)" }}>
            <img
              src="assets/hw-incab.png"
              alt={isEs ? "Tablet montada en cabina de camión" : "Tablet mounted in truck cab"}
              style={{ width:"100%", display:"block", borderRadius:10 }}
            />
            {/* Live overlay — same style as home map-overlay */}
            <div className="map-overlay tr mono" style={{ top:16, right:16, left:"auto", bottom:"auto" }}>
              <div className="ovl-row">
                <span className="ovl-dot ok" style={{ animation:"pulse 1.2s ease infinite" }}></span>
                <span className="ovl-label">{isEs ? "EN VIVO · GROPP FLOW" : "LIVE · GROPP FLOW"}</span>
              </div>
              <div className="ovl-row">
                <span className="ovl-label">{isEs ? "VEL" : "SPD"}</span>
                <span className="ovl-val">54 km/h</span>
              </div>
              <div className="ovl-row">
                <span className="ovl-label">{isEs ? "ATEN" : "ATTN"}</span>
                <span className="ovl-bar"><span style={{ width:"91%" }}></span></span>
                <span className="ovl-val" style={{ color:"var(--accent)" }}>0.91</span>
              </div>
              <div className="ovl-row">
                <span className="ovl-label">{isEs ? "FATIGA" : "FATIGUE"}</span>
                <span className="ovl-bar"><span style={{ width:"12%" }}></span></span>
                <span className="ovl-val" style={{ color:"oklch(0.65 0.18 145)" }}>{isEs ? "BAJA" : "LOW"}</span>
              </div>
            </div>

            {/* AI events feed — bottom-left */}
            <div className="map-overlay mono" style={{ bottom:16, left:16, top:"auto", right:"auto", minWidth:220 }}>
              <div className="ovl-title">{isEs ? "IA · EVENTOS" : "AI · EVENTS"}</div>
              {(isEs
                ? [
                    { t:"14:42:01", k:"DETECTA", label:"Señal de pare · cumple", tone:"ok" },
                    { t:"14:41:38", k:"ATEN", label:"Chofer · 0.91 · activo", tone:"ok" },
                    { t:"14:39:11", k:"ALERTA", label:"4 canales AHD · activos", tone:"warn" },
                  ]
                : [
                    { t:"14:42:01", k:"DETECT", label:"Stop sign · driver compliant", tone:"ok" },
                    { t:"14:41:38", k:"ATTN", label:"Driver · 0.91 · active", tone:"ok" },
                    { t:"14:39:11", k:"ALERT", label:"4 AHD channels · live", tone:"warn" },
                  ]
              ).map((e,i) => (
                <div key={i} className="ovl-event on">
                  <span className="ovl-time">{e.t}</span>
                  <span className={`ovl-tag ${e.tone}`}>{e.k}</span>
                  <span className="ovl-evlabel">{e.label}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
        {/* Marquee strip */}
        <div className="marquee" style={{ marginTop:60 }}>
          <div className="marquee-track">
            {[...Array(3)].flatMap(() => (
              (isEs ? [
                { icon:"shield",  label:"ADAS · Carril · Distancia · Pare" },
                { icon:"brain",   label:"DMS · Fatiga · Bostezos · Celular" },
                { icon:"bolt",    label:"Edge AI · inferencia < 200ms" },
                { icon:"steering",label:"CAN-Bus · SAE J1939 · OBD-II" },
                { icon:"layers",  label:"4 canales AHD · 1080p / 30fps" },
                { icon:"sparkle", label:"IP65 · MIL-STD-810H · −20°C a +70°C" },
              ] : [
                { icon:"shield",  label:"ADAS · Lane · Distance · Stop sign" },
                { icon:"brain",   label:"DMS · Fatigue · Yawn · Phone" },
                { icon:"bolt",    label:"Edge AI · inference < 200ms" },
                { icon:"steering",label:"CAN-Bus · SAE J1939 · OBD-II" },
                { icon:"layers",  label:"4-ch AHD · 1080p / 30fps" },
                { icon:"sparkle", label:"IP65 · MIL-STD-810H · −20°C to +70°C" },
              ])
            )).map((m, i) => (
              <span key={i} className="marquee-item">
                <span className="marquee-icon"><MarqueeIcon name={m.icon} /></span>
                <span className="accent">{m.label}</span>
              </span>
            ))}
          </div>
        </div>
      </section>

      {/* ── IMAGE CAROUSEL ── */}
      <section className="section" id="specs">
        <div className="container">
          <div style={{ display:"grid", gridTemplateColumns:"1fr 1fr", gap:60, alignItems:"center" }}>
            {/* Left: copy */}
            <div>
              <h2 style={{ fontSize:"clamp(24px,2.5vw,38px)", fontWeight:600, lineHeight:1.1, letterSpacing:"-0.02em", marginBottom:16 }}>
                {isEs ? <>Grado vehicular.<br/><span style={{ color:"var(--accent)" }}>Sin compromisos.</span></> : <>Vehicle grade.<br/><span style={{ color:"var(--accent)" }}>No compromises.</span></>}
              </h2>
              <p style={{ fontSize:14, color:"var(--fog)", lineHeight:1.7, marginBottom:32 }}>
                {isEs
                  ? "Diseñada para operar 12 horas diarias en un vehículo de reparto: vibración constante, rangos de temperatura extremos y alimentación irregular. La misma plataforma que usan sistemas ADAS de flotas de transporte pesado."
                  : "Built to run 12 hours a day inside a delivery vehicle: constant vibration, extreme temperature swings, and irregular power. The same platform used by heavy-fleet ADAS systems worldwide."}
              </p>
              {/* Feature bullets */}
              <div style={{ display:"flex", flexDirection:"column", gap:10 }}>
                {(isEs ? [
                  "10.1\" IPS · 1000 nits · luz solar",
                  "IP65 · MIL-STD-810H · −20°C a +70°C",
                  "4 canales AHD · ADAS + DMS en NPU",
                  "CAN-Bus · LTE Cat.6 · GPS L1+L5",
                ] : [
                  "10.1\" IPS · 1000 nits · sunlight readable",
                  "IP65 · MIL-STD-810H · −20°C to +70°C",
                  "4-ch AHD · ADAS + DMS on-device NPU",
                  "CAN-Bus · LTE Cat.6 · GPS L1+L5",
                ]).map((f, i) => (
                  <div key={i} style={{ display:"flex", gap:10, alignItems:"center" }}>
                    <div style={{ width:16, height:16, borderRadius:2, background:"var(--accent)", flexShrink:0, display:"flex", alignItems:"center", justifyContent:"center" }}>
                      <svg viewBox="0 0 12 12" width="10" height="10"><polyline points="2,6 5,9 10,3" fill="none" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>
                    </div>
                    <span style={{ fontSize:13.5, color:"var(--ink)", fontWeight:500 }}>{f}</span>
                  </div>
                ))}
              </div>
            </div>

            {/* Right: carousel */}
            <HwCarousel isEs={isEs} />
          </div>
        </div>
      </section>

      {/* ── CAMERAS ── */}
      <section className="section section--mist" id="cameras">
        <div className="container">
          <div className="section-head">
            <div>
              <h2 style={{ fontSize:"clamp(24px,2.5vw,38px)", fontWeight:600, lineHeight:1.1, letterSpacing:"-0.02em" }}>
                {isEs ? <>Cuatro ojos.<br/><span style={{ color:"var(--accent)" }}>Un solo flujo.</span></> : <>Four eyes.<br/><span style={{ color:"var(--accent)" }}>One stream.</span></>}
              </h2>
            </div>
            <p style={{ fontSize:15, color:"var(--fog)", lineHeight:1.7, maxWidth:480 }}>
              {isEs
                ? "Las cuatro cámaras graban y procesan simultáneamente. La IA ve todo — el chofer, la ruta, los puntos ciegos y la carga. Los clips críticos se sincronizan a la nube en segundos."
                : "All four cameras record and process simultaneously. AI sees everything — the driver, the road, the blind spots, and the cargo. Critical clips sync to the cloud within seconds."}
            </p>
          </div>
          {/* Camera ecosystem animation */}
          <div style={{ marginTop:40, marginBottom:32 }}>
            <CameraEcosystemViz isEs={isEs} />
          </div>

          {/* Camera cards + product photo */}
          <div style={{ display:"flex", gap:20, alignItems:"flex-start", flexWrap:"wrap" }}>
            <div style={{
              flex:"0 0 200px",
              border:"1px solid var(--line)", borderRadius:8,
              overflow:"hidden", background:"white",
            }}>
              <img
                src="assets/hw-camera.png"
                alt={isEs ? "Cámara vehicular AHD" : "AHD vehicle camera"}
                style={{ width:"100%", display:"block" }}
              />
              <div style={{
                padding:"10px 14px",
                fontFamily:"var(--font-mono)", fontSize:10, letterSpacing:"0.07em",
                color:"var(--mist)", borderTop:"1px solid var(--line-soft)",
              }}>{isEs ? "CÁMARA AHD · 1080p" : "AHD CAMERA · 1080p"}</div>
            </div>
            <div style={{ flex:1, display:"grid", gridTemplateColumns:"repeat(2,1fr)", gap:16, minWidth:0 }}>
              {cameras.map((c,i) => <CameraCard key={i} {...c} />)}
            </div>
          </div>
        </div>
      </section>

      {/* ── ARCHITECTURE ── */}
      <section className="section section--ink" id="arch">
        <div className="container">
          <div style={{ display:"grid", gridTemplateColumns:"1fr 1fr", gap:60, alignItems:"center" }}>
            <div>
              <h2 style={{ fontSize:"clamp(24px,2.5vw,38px)", fontWeight:600, lineHeight:1.1, letterSpacing:"-0.02em", marginBottom:20, color:"var(--ink-2)" }}>
                {isEs ? <>Borde + nube,<br/><span style={{ color:"var(--accent-2)" }}>sin puntos de falla.</span></> : <>Edge + cloud,<br/><span style={{ color:"var(--accent-2)" }}>no single point of failure.</span></>}
              </h2>
              <p style={{ fontSize:14, color:"oklch(0.62 0.04 240)", lineHeight:1.7, marginBottom:24 }}>
                {isEs
                  ? "La IA de seguridad corre 100% en el dispositivo — sin latencia de red, sin interrupciones por cobertura. La telemetría y los clips suben cifrados en cuanto hay LTE. Si no hay señal, el tablet bufferea hasta 72 horas en almacenamiento local."
                  : "Safety AI runs 100% on-device — no network latency, no coverage gaps. Telemetry and clips upload encrypted as soon as LTE is available. No signal? The tablet buffers up to 72 hours locally."}
              </p>
              <div style={{ display:"flex", flexDirection:"column", gap:12 }}>
                {(isEs
                  ? [
                      "Inferencia ADAS + DMS en el NPU del dispositivo",
                      "Subida cifrada AES-256 cuando hay LTE",
                      "Buffer local de 72 hs sin cobertura",
                      "Actualización OTA de modelos sin parar la flota",
                    ]
                  : [
                      "ADAS + DMS inference on the on-device NPU",
                      "AES-256 encrypted upload on LTE",
                      "72-hour local buffer with no coverage",
                      "OTA model updates without stopping the fleet",
                    ]
                ).map((t,i) => (
                  <div key={i} style={{ display:"flex", gap:12, alignItems:"flex-start" }}>
                    <div style={{ width:18, height:18, borderRadius:2, background:"var(--accent)", flexShrink:0, marginTop:2, display:"flex", alignItems:"center", justifyContent:"center" }}>
                      <svg viewBox="0 0 12 12" width="10" height="10"><polyline points="2,6 5,9 10,3" fill="none" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>
                    </div>
                    <span style={{ fontSize:13.5, color:"oklch(0.70 0.04 240)", lineHeight:1.5 }}>{t}</span>
                  </div>
                ))}
              </div>
            </div>
            <div>
              <ArchDiagram isEs={isEs} />
            </div>
          </div>
        </div>
      </section>

      {/* ── INSTALL ── */}
      <section className="section" id="install">
        <div className="container">
          <div className="section-head">
            <div>
              <h2 style={{ fontSize:"clamp(24px,2.5vw,38px)", fontWeight:600, lineHeight:1.1, letterSpacing:"-0.02em" }}>
                {isEs ? <>20 minutos por vehículo.<br/><span style={{ color:"var(--accent)" }}>Sin parar la operación.</span></> : <>20 minutes per vehicle.<br/><span style={{ color:"var(--accent)" }}>Without stopping the operation.</span></>}
              </h2>
            </div>
            <p style={{ fontSize:15, color:"var(--fog)", lineHeight:1.7, maxWidth:440 }}>
              {isEs
                ? "Nuestro equipo de instalación certifica el vehículo y lo deja operativo. Sin obra, sin electricistas, sin downtime del vehículo."
                : "Our install team certifies each vehicle and leaves it fully operational. No construction, no electricians, no vehicle downtime."}
            </p>
          </div>
          <div className="steps" style={{ marginTop:40 }}>
            {installSteps.map((s,i) => (
              <div className="step" key={i}>
                <div className="step-num">{s.n}</div>
                <h4>{s.t}</h4>
                <p>{s.b}</p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ── CTA ── */}
      <section className="cta" id="hw-cta" style={{ padding:"80px 0" }}>
        <div className="container cta-inner">
          <h2>
            {isEs
              ? <>{" "}La flota que ve,<br/><span className="ink-accent">aprende</span>.</>
              : <>{" "}The fleet that sees,<br/><span className="ink-accent">learns</span>.</>}
          </h2>
          <div>
            <p style={{ marginBottom:20 }}>
              {isEs
                ? "Coordinamos una visita técnica, relevamos tu flota y te entregamos un presupuesto de hardware + software en 48 hs."
                : "We schedule a technical visit, survey your fleet, and deliver a hardware + software quote within 48 hours."}
            </p>
            <div style={{ display:"flex", gap:12, flexWrap:"wrap" }}>
              <a className="btn btn-primary" href="#">{isEs ? "Coordinar visita técnica →" : "Schedule technical visit →"}</a>
              <a className="btn btn-ghost" href="#">{isEs ? "Descargar ficha técnica" : "Download datasheet"}</a>
            </div>
          </div>
        </div>
      </section>
    </main>
  );
}

Object.assign(window, { HardwarePage });
