/* Jurisdiction state, disclosure banners, and config for NY + Utah anchors.
   v2 anchors per Legal_OS_Two_Sided_Specification: Utah (sandbox-authorized) + NY (Dacey-protected educational). */

const JURISDICTIONS = {
  utah: {
    id: 'utah',
    code: 'UT',
    name: 'Utah',
    courtName: 'Utah State Court',
    smallClaimsCap: 15000,
    smallClaimsCapLabel: '$15,000',
    smallClaimsForm: 'Form 600S. Affidavit and Summons',
    accentColor: '#5BA773',
    posture: 'sandbox',
    postureLabel: 'Sandbox-authorized',
    postureFull: 'Authorized · Utah Office of Legal Services Innovation',
    sandboxOrder: 'Utah Supreme Court Standing Order 15',
    disclosureShort: 'AllLaw operates in Utah under authorization from the Utah Office of Legal Services Innovation.',
    disclosureLong: 'AllLaw Studio operates in Utah under authorization from the Utah Office of Legal Services Innovation, established by Utah Supreme Court Standing Order 15. We are a non-attorney service provider; this authorization permits us to provide certain legal services without traditional attorney supervision, subject to consumer protections and ongoing reporting.',
    expandedFeatures: ['Predictive case strength scoring', 'Auto-affirmed evidence-to-element matches', 'Case-specific judge simulation'],
  },
  ny: {
    id: 'ny',
    code: 'NY',
    name: 'New York',
    courtName: 'NY State Court',
    smallClaimsCap: 10000,
    smallClaimsCapLabel: '$10,000',
    smallClaimsForm: 'Statement of Claim · Civil Court',
    accentColor: '#6986BF',
    posture: 'educational',
    postureLabel: 'Educational framework',
    postureFull: 'Educational framing · Judiciary Law §§ 478, 484, 485',
    sandboxOrder: null,
    disclosureShort: 'AllLaw provides legal information and tools, not legal advice. We are not a law firm.',
    disclosureLong: 'AllLaw Studio is not a law firm and does not provide legal advice. The information, document templates, and case-organization tools we provide are educational in nature. You are responsible for selecting causes of action, characterizing evidence, and finalizing every document. For legal advice tailored to your situation, consult a licensed New York attorney.',
    expandedFeatures: [],
  },
};

/* Top-of-screen jurisdiction disclosure ribbon. Anchors brand, jurisdiction, and posture. */
const JurisdictionRibbon = ({ jx, onChange }) => {
  const j = JURISDICTIONS[jx];
  const isUtah = jx === 'utah';
  return (
    <div style={{
      display: 'flex', alignItems: 'center', gap: 14,
      padding: '8px 22px', borderBottom: `1px solid ${THEME.line}`,
      background: isUtah
        ? `linear-gradient(90deg, ${THEME.successSoft} 0%, transparent 60%)`
        : THEME.mode === 'dark' ? 'rgba(255,255,255,0.02)' : 'rgba(255,255,255,0.4)',
      fontSize: 11.5,
    }}>
      <div style={{
        display: 'flex', alignItems: 'center', gap: 6,
        padding: '3px 10px', borderRadius: 12,
        background: isUtah ? 'rgba(91,167,115,0.18)' : THEME.blueSoft,
        border: `1px solid ${isUtah ? 'rgba(91,167,115,0.4)' : THEME.blue + '40'}`,
        color: isUtah ? THEME.success : THEME.blue, fontWeight: 600,
      }}>
        <span style={{ width: 5, height: 5, borderRadius: 3, background: isUtah ? THEME.success : THEME.blue }}/>
        {j.postureLabel}
      </div>
      <span style={{ color: THEME.textDim, flex: 1, lineHeight: 1.4 }}>
        {j.disclosureShort}
      </span>
      <div style={{ display: 'flex', gap: 4, padding: 2, background: THEME.mode === 'dark' ? 'rgba(255,255,255,0.04)' : 'rgba(255,255,255,0.6)', borderRadius: 8, border: `1px solid ${THEME.line}` }}>
        {Object.values(JURISDICTIONS).map(jj => (
          <div key={jj.id} onClick={() => onChange && onChange(jj.id)} style={{
            padding: '3px 10px', borderRadius: 6, cursor: 'pointer', fontSize: 11, fontWeight: 600,
            background: jj.id === jx ? THEME.blue : 'transparent',
            color: jj.id === jx ? '#fff' : THEME.textDim,
          }}>{jj.code}</div>
        ))}
      </div>
    </div>
  );
};

/* Inline disclosure card. Used in handoff drawers, document export, etc. */
const NonAttorneyDisclosure = ({ jx, compact }) => {
  const j = JURISDICTIONS[jx];
  return (
    <div style={{
      padding: compact ? '10px 12px' : '14px 16px',
      borderRadius: 10,
      background: THEME.mode === 'dark' ? 'rgba(255,255,255,0.025)' : 'rgba(255,255,255,0.55)',
      border: `1px dashed ${THEME.line}`,
      fontSize: compact ? 11 : 12,
      color: THEME.textDim,
      lineHeight: 1.55,
      display: 'flex',
      gap: 10,
      alignItems: 'flex-start',
    }}>
      <Icon d={Icons.shield} size={compact ? 13 : 15} stroke={THEME.textMute}/>
      <div style={{ flex: 1 }}>
        <div style={{ color: THEME.text, fontWeight: 600, marginBottom: 3 }}>
          {jx === 'utah' ? 'Utah sandbox disclosure' : 'Non-attorney disclosure'}
        </div>
        {compact ? j.disclosureShort : j.disclosureLong}
      </div>
    </div>
  );
};

window.JURISDICTIONS = JURISDICTIONS;
window.JurisdictionRibbon = JurisdictionRibbon;
window.NonAttorneyDisclosure = NonAttorneyDisclosure;
