/* ============================================================
   TECHIYAT — trust center
   ============================================================ */

const TRUST_PILLARS = [
  { ic:"eye", t:"Founder-controlled visibility", d:"You choose what's visible, when your identity is revealed, and who can request access — for every asset, every time." },
  { ic:"lock", t:"Approval-gated access", d:"Full profiles, cap tables, and IP inventories unlock only after you approve the request." },
  { ic:"users", t:"Verified buyer network", d:"Every acquirer is verified before they can browse. No anonymous tire-kickers." },
  { ic:"file", t:"Audit log of who viewed what", d:"A complete, timestamped trail of every view, request, and reveal." },
  { ic:"eyeOff", t:"Anonymous marketplace listings", d:"Listings are coded by default. Identity is never inferable from a public card." },
  { ic:"scale", t:"Grant & cap table sensitivity", d:"The most sensitive data is held back until the latest possible moment in a deal." },
  { ic:"trend", t:"Investor visibility controls", d:"Founders decide what their own investors can and cannot see inside the platform." },
  { ic:"handshake", t:"Founder approval before introductions", d:"No introduction happens without explicit founder sign-off — every single time." }
];

const AUDIT = [
  { who:"Verified buyer · MR", act:"Viewed anonymized card", obj:"TX-4471", time:"2 min ago", ic:"eye" },
  { who:"You", act:"Approved access request", obj:"TX-4471", time:"1 hr ago", ic:"check" },
  { who:"Agent", act:"Generated anonymous listing", obj:"TX-4471", time:"3 hrs ago", ic:"spark" },
  { who:"Verified buyer · KV", act:"Requested access", obj:"TX-2210", time:"yesterday", ic:"lock" },
  { who:"Investor · JV", act:"Viewed preservation score", obj:"TX-5108", time:"yesterday", ic:"trend" }
];

function Trust({ go }){
  const [reveal,setReveal] = useState("approval");
  return (
    <div className="fadein">
      <PageHd eyebrow="Confidential by design"
        title="Privacy & access"
        sub="Techiyat is confidential by design. Founders control what is visible, when identity is revealed, and who can request access.">
        <span className="chip green"><Icon name="shield" size={13}/> All controls active</span>
      </PageHd>

      {/* hero statement */}
      <div className="card mb24" style={{overflow:"hidden", background:"var(--pine)", color:"#fff", border:"none"}}>
        <div style={{display:"grid", gridTemplateColumns:"1.3fr 1fr"}}>
          <div style={{padding:"34px 36px"}}>
            <Icon name="shield" size={28} style={{color:"var(--amber-2)"}}/>
            <h2 className="serif mt16" style={{fontSize:28, color:"#fff", lineHeight:1.15, maxWidth:460}}>“Nothing about your company is shared without your explicit approval.”</h2>
            <p style={{fontSize:14.5, color:"rgba(238,243,239,.75)", lineHeight:1.6, marginTop:14, maxWidth:480}}>
              Preservation only works if founders feel safe. Every layer of Techiyat is built so that discretion is the
              default and you stay in control at every step.
            </p>
          </div>
          <div style={{padding:"34px 36px", borderLeft:"1px solid rgba(255,255,255,.1)"}} className="col gap12">
            <div className="eyebrow" style={{color:"var(--amber-2)"}}>Your current visibility</div>
            {window.TZ.CONFID.map((c,i)=>{
              const keys=["anon","hidden","approved","approval"];
              return (
                <button key={c.t} className="row gap10" onClick={()=>setReveal(keys[i])}
                  style={{background:reveal===keys[i]?"rgba(255,255,255,.1)":"transparent", border:"1px solid "+(reveal===keys[i]?"rgba(255,255,255,.2)":"rgba(255,255,255,.08)"), borderRadius:10, padding:"11px 13px", cursor:"pointer", textAlign:"left"}}>
                  <span style={{width:16,height:16,borderRadius:"50%", border:"1.5px solid "+(reveal===keys[i]?"var(--amber-2)":"rgba(255,255,255,.3)"), display:"grid", placeItems:"center", flex:"none"}}>
                    {reveal===keys[i] && <span style={{width:7,height:7,borderRadius:"50%",background:"var(--amber-2)"}}/>}
                  </span>
                  <span className="col" style={{gap:1}}>
                    <span style={{fontSize:13.5, fontWeight:600, color:"#fff"}}>{c.t}</span>
                    <span style={{fontSize:12, color:"rgba(238,243,239,.6)"}}>{c.d}</span>
                  </span>
                </button>
              );
            })}
          </div>
        </div>
      </div>

      {/* pillars */}
      <div className="grid g4 stagger mb24">
        {TRUST_PILLARS.map(p=>(
          <div key={p.t} className="card card-pad col" style={{gap:12}}>
            <div className="side-mark" style={{width:40,height:40,background:"var(--paper-sunken)",boxShadow:"none",border:"1px solid var(--line)"}}>
              <Icon name={p.ic} size={19} style={{color:"var(--pine)"}}/>
            </div>
            <h3 style={{fontSize:15}}>{p.t}</h3>
            <p style={{fontSize:13, color:"var(--sage)", lineHeight:1.5}}>{p.d}</p>
          </div>
        ))}
      </div>

      {/* audit log */}
      <div className="card" style={{overflow:"hidden"}}>
        <div className="card-hd between">
          <div className="row gap10"><Icon name="file" size={17} style={{color:"var(--pine)"}}/><h3 className="serif" style={{fontSize:16.5}}>Audit log — who viewed what</h3></div>
          <span className="muted" style={{fontSize:12.5}}>Live · timestamped</span>
        </div>
        <div>
          {AUDIT.map((a,i)=>(
            <div key={i} className="row gap14" style={{padding:"13px 20px", borderTop:i?"1px solid var(--line)":"none"}}>
              <div className="side-mark" style={{width:32,height:32,background:"var(--paper-sunken)",boxShadow:"none",border:"1px solid var(--line)",flex:"none"}}>
                <Icon name={a.ic} size={15} style={{color:"var(--pine)"}}/>
              </div>
              <span style={{fontSize:13.5, color:"var(--ink)", fontWeight:600}}>{a.who}</span>
              <span className="muted" style={{fontSize:13.5}}>{a.act}</span>
              <span className="mono grow" style={{fontSize:12.5, color:"var(--sage)"}}>{a.obj}</span>
              <span className="muted" style={{fontSize:12.5}}>{a.time}</span>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

/* ============================================================
   DASHBOARD (persona-specific home)
   ============================================================ */
/* Dashboard now lives in dashboard.jsx (persona tabs inside the dashboard) */

/* simple settings */
function Settings(){
  return (
    <div className="fadein">
      <PageHd eyebrow="Workspace" title="Settings" sub="Profile, notifications, and confidentiality defaults."/>
      <div className="grid g2">
        <div className="card card-pad col gap16">
          <h3 className="serif" style={{fontSize:17}}>Confidentiality defaults</h3>
          {["Anonymous listings by default","Require founder approval before full profile","Founder approval before introductions","Hide cap table until diligence"].map((t,i)=>(
            <div key={t} className="row between"><span style={{fontSize:13.5, color:"var(--ink-2)"}}>{t}</span>
              <span style={{width:36, height:20, borderRadius:20, background:i<3?"var(--moss)":"var(--line-strong)", position:"relative"}}>
                <span style={{position:"absolute", top:2, left:i<3?18:2, width:16, height:16, borderRadius:"50%", background:"#fff", boxShadow:"var(--shadow-sm)"}}/></span></div>
          ))}
        </div>
        <div className="card card-pad col gap14">
          <h3 className="serif" style={{fontSize:17}}>Notifications</h3>
          {["New matches to your interests","Runway-risk alerts","Access requests","Agent-generated drafts ready"].map(t=>(
            <label key={t} className="row gap10" style={{fontSize:13.5, color:"var(--ink-2)"}}><input type="checkbox" defaultChecked style={{accentColor:"var(--moss)", width:16, height:16}}/> {t}</label>
          ))}
        </div>
      </div>
    </div>
  );
}

Object.assign(window, { Trust, Settings });
