/* Klipzy.lv — Legal pages: Noteikumi, Privātuma politika, Drošība (LV/EN) */

const LEGAL_PAGES = [
  { key: 'terms', label: 'Noteikumi', labelEn: 'Terms', icon: 'file' },
  { key: 'privacy', label: 'Privātuma politika', labelEn: 'Privacy Policy', icon: 'shield' },
  { key: 'security', label: 'Drošība', labelEn: 'Security', icon: 'lock' },
];

function LegalLayout({ go, page, title, subtitle, updated, sections, children }) {
  const lang = useLang();
  const L = (lv, en) => (lang === 'en' ? en : lv);
  const [active, setActive] = useState(sections[0] && sections[0].id);

  // Scroll-spy: highlight the TOC entry whose section is currently in view.
  useEffect(() => {
    const sc = document.querySelector('.app-scroll');
    if (!sc) return;
    const onScroll = () => {
      let cur = sections[0] && sections[0].id;
      for (const s of sections) {
        const el = document.getElementById(s.id);
        if (el && el.offsetTop - 120 <= sc.scrollTop) cur = s.id;
      }
      setActive(cur);
    };
    sc.addEventListener('scroll', onScroll, { passive: true });
    onScroll();
    return () => sc.removeEventListener('scroll', onScroll);
  }, [sections]);

  const jump = (id) => {
    const el = document.getElementById(id);
    const sc = document.querySelector('.app-scroll');
    if (el && sc) sc.scrollTo({ top: el.offsetTop - 96, behavior: 'smooth' });
    setActive(id);
  };

  return (
    <div className="app-scroll fade-in" style={{ height: '100%' }}>
      <PublicNav go={go} route="legal" />

      {/* header band */}
      <div style={{ borderBottom: '1px solid var(--border)', background: 'linear-gradient(180deg, var(--accent-tint) 0%, #fff 100%)' }}>
        <div className="container" style={{ padding: '46px 28px 30px' }}>
          <button className="btn btn-ghost btn-sm" style={{ paddingLeft: 6, color: 'var(--muted)', marginBottom: 16 }} onClick={() => go('landing')}><Icon d={I.arrowL} size={16} /> {L('Sākums', 'Home')}</button>
          <h1 style={{ fontSize: 40, letterSpacing: '-0.035em', lineHeight: 1.05 }}>{title}</h1>
          <p className="muted" style={{ fontSize: 16.5, marginTop: 12, maxWidth: 640, lineHeight: 1.55 }}>{subtitle}</p>
          <div style={{ display: 'flex', gap: 8, marginTop: 22, flexWrap: 'wrap' }}>
            {LEGAL_PAGES.map((p) => (
              <button key={p.key} className={'legal-tab' + (p.key === page ? ' on' : '')} onClick={() => go('legal', { page: p.key })}>
                <Icon d={I[p.icon]} size={15} /> {L(p.label, p.labelEn)}
              </button>
            ))}
          </div>
        </div>
      </div>

      <div className="container" style={{ padding: '0 28px 80px' }}>
        <div className="r-rail legal-rail" style={{ display: 'grid', gridTemplateColumns: '240px 1fr', gap: 46, alignItems: 'start', paddingTop: 40 }}>
          {/* TOC */}
          <aside className="legal-toc" style={{ position: 'sticky', top: 84 }}>
            <div className="eyebrow" style={{ marginBottom: 14 }}>{L('Saturs', 'Contents')}</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
              {sections.map((s) => (
                <a key={s.id} onClick={() => jump(s.id)} className={'legal-toc-link' + (active === s.id ? ' on' : '')}>{s.title}</a>
              ))}
            </div>
            <div className="card" style={{ padding: 16, marginTop: 22, fontSize: 12.5, color: 'var(--muted)', lineHeight: 1.5 }}>
              {L('Pēdējoreiz atjaunināts', 'Last updated')}<br /><span style={{ color: 'var(--text)', fontWeight: 540 }}>{updated}</span>
            </div>
          </aside>

          {/* body */}
          <article className="legal-body">
            {sections.map((s) => (
              <section key={s.id} id={s.id} style={{ marginBottom: 40, scrollMarginTop: 96 }}>
                <h2 className="legal-h2">{s.title}</h2>
                {s.body}
              </section>
            ))}
            {children}

            <div className="card" style={{ padding: '22px 26px', marginTop: 40, display: 'flex', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
              <div style={{ flex: 1, minWidth: 220 }}>
                <div style={{ fontSize: 15.5, fontWeight: 560 }}>{L('Ir jautājumi?', 'Have questions?')}</div>
                <p className="muted" style={{ fontSize: 13.5, marginTop: 4, lineHeight: 1.5 }}>{L('Raksti mums uz ', 'Write to us at ')}<a href="mailto:info@klipzy.lv" style={{ color: 'var(--accent)' }}>info@klipzy.lv</a>{L(' — atbildam 2 darba dienu laikā.', ' — we reply within 2 business days.')}</p>
              </div>
              <button className="btn btn-secondary" onClick={() => go('legal', { page: page === 'security' ? 'terms' : page === 'terms' ? 'privacy' : 'security' })}>
                {L('Nākamā sadaļa', 'Next section')} <Icon d={I.arrowR} size={16} />
              </button>
            </div>
          </article>
        </div>
      </div>
      <Footer go={go} />
    </div>
  );
}

/* Small helpers for legal typography */
function LP({ children }) { return <p className="legal-p">{children}</p>; }
function LUL({ items }) { return <ul className="legal-ul">{items.map((it, i) => <li key={i}>{it}</li>)}</ul>; }
function LNote({ children }) {
  return <div className="legal-note"><Icon d={I.info} size={16} /><div>{children}</div></div>;
}

/* ============================ NOTEIKUMI ============================ */
function LegalTerms({ go }) {
  const lang = useLang();
  const en = lang === 'en';
  const sectionsLv = [
    { id: 't-intro', title: '1. Vispārīgie noteikumi', body: (<>
      <LP>Šie lietošanas noteikumi ("Noteikumi") nosaka kārtību, kādā lietotāji izmanto platformu Klipzy.lv ("Platforma", "Klipzy"), ko pārvalda SIA SERPA Media Group, reģistrēta Latvijas Republikā. Reģistrējoties vai lietojot Platformu, tu piekrīti šiem Noteikumiem pilnā apmērā.</LP>
      <LP>Platforma savieno satura veidotājus ("Klipotāji") ar zīmoliem un uzņēmumiem ("Zīmoli"), lai izplatītu īsformāta video klipus platformās TikTok, Instagram un YouTube. Klipzy darbojas kā starpnieks un tehnisks pakalpojumu sniedzējs.</LP>
      <LNote>Platforma pašlaik ir pieejama tikai Latvijas tirgū un personām, kas sasniegušas 18 gadu vecumu.</LNote>
    </>) },
    { id: 't-accounts', title: '2. Konti un reģistrācija', body: (<>
      <LP>Lai izmantotu Platformas funkcijas, nepieciešams izveidot kontu, izvēloties Klipotāja vai Zīmola lomu. Tu apņemies sniegt patiesu un aktuālu informāciju un uzturēt tās precizitāti.</LP>
      <LUL items={[
        'Katrs lietotājs atbild par sava konta un paroles drošību, kā arī par visām darbībām, kas veiktas ar viņa kontu.',
        'Klipotājiem var būt nepieciešama tālruņa numura un sociālo tīklu konta verifikācija, izmantojot unikālu kodu profila aprakstā.',
        'Aizliegts izveidot vairākus kontus krāpnieciskos nolūkos vai apiet ierobežojumus.',
        'Klipzy patur tiesības apturēt vai slēgt kontus, kas pārkāpj šos Noteikumus.',
      ]} />
    </>) },
    { id: 't-clippers', title: '3. Klipotāju pienākumi', body: (<>
      <LP>Klipotāji veido un publicē video klipus atbilstoši Zīmola kampaņas vadlīnijām. Iesniedzot klipu, tu apliecini, ka:</LP>
      <LUL items={[
        'saturs ir tavs oriģināldarbs vai tev ir visas nepieciešamās tiesības to izmantot;',
        'klips atbilst kampaņas vadlīnijām, kā arī attiecīgās sociālās platformas noteikumiem;',
        'skatījumi ir iegūti organiski — mākslīga skatījumu, botu vai maksas trafika izmantošana ir stingri aizliegta;',
        'saturs nav maldinošs, aizskarošs, nelikumīgs vai autortiesības pārkāpjošs.',
      ]} />
      <LNote>Skatījumi, kas iegūti ar botiem vai mākslīgu manipulāciju, tiek anulēti, un attiecīgie maksājumi netiek izmaksāti.</LNote>
    </>) },
    { id: 't-brands', title: '4. Zīmolu pienākumi', body: (<>
      <LP>Zīmoli izveido kampaņas, nosakot cenu par 1000 skatījumiem (CPM), kopējo budžetu, darbības periodu un satura vadlīnijas. Zīmols apņemas:</LP>
      <LUL items={[
        'nodrošināt kampaņas budžetu kontā pirms kampaņas palaišanas;',
        'sniegt skaidras un likumīgas satura vadlīnijas;',
        'nepieprasīt saturu, kas pārkāpj likumus vai trešo personu tiesības;',
        'godīgi izskatīt un apstiprināt vai noraidīt iesniegtos klipus saprātīgā termiņā.',
      ]} />
      <LP>Kampaņas ilgums nedrīkst pārsniegt 30 dienas. Budžets tiek rezervēts kampaņas laikā un izlietots atbilstoši reālajiem, verificētajiem skatījumiem.</LP>
    </>) },
    { id: 't-payments', title: '5. Maksājumi un komisijas', body: (<>
      <LP>Klipzy darbojas pēc principa "maksā tikai par rezultātu" — Zīmoli maksā par reāliem, verificētiem skatījumiem, ko klipi saņem attiecīgajās platformās.</LP>
      <LUL items={[
        'Platformas komisija ir 1% no darījuma summas (budžeta papildināšanas un izmaksas).',
        'Skatījumi tiek automātiski pārbaudīti serverī regulāros ciklos (parasti ik pēc 24 stundām; kampaņām ar zemu atlikušo budžetu — biežāk).',
        'Klipotāju nopelnītie līdzekļi tiek izmaksāti automātiski pēc skatījumu verifikācijas.',
        'Izmaksas ir pieejamas standarta režīmā (līdz 7 dienām) vai kā tūlītēja izmaksa par papildu maksu.',
      ]} />
      <LNote>Klipzy neuzglabā maksājumu karšu datus — maksājumus apstrādā sertificēti trešo pušu maksājumu pakalpojumu sniedzēji.</LNote>
    </>) },
    { id: 't-ip', title: '6. Intelektuālais īpašums', body: (<>
      <LP>Klipotājs saglabā autortiesības uz savu radīto saturu. Iesniedzot klipu kampaņā, Klipotājs piešķir Zīmolam un Klipzy neekskluzīvu licenci izmantot klipu saistībā ar attiecīgo kampaņu un tās veicināšanu.</LP>
      <LP>Klipzy zīmols, logotips, dizains un platformas programmatūra ir Klipzy īpašums, un to izmantošana bez atļaujas ir aizliegta.</LP>
    </>) },
    { id: 't-liability', title: '7. Atbildības ierobežojums', body: (<>
      <LP>Platforma tiek nodrošināta "kāda tā ir". Klipzy dara visu iespējamo, lai nodrošinātu precīzu skatījumu uzskaiti, taču neatbild par trešo pušu platformu (TikTok, Instagram, YouTube) datu pieejamību, izmaiņām vai kļūdām.</LP>
      <LP>Klipzy neatbild par netiešiem zaudējumiem, negūto peļņu vai kaitējumu, kas radies, izmantojot Platformu, ciktāl to pieļauj piemērojamie tiesību akti.</LP>
    </>) },
    { id: 't-changes', title: '8. Noteikumu izmaiņas un piemērojamie likumi', body: (<>
      <LP>Klipzy patur tiesības grozīt šos Noteikumus. Par būtiskām izmaiņām lietotāji tiek informēti e-pastā vai Platformā. Turpinot lietot Platformu pēc izmaiņām, tu piekrīti atjauninātajiem Noteikumiem.</LP>
      <LP>Šos Noteikumus regulē Latvijas Republikas tiesību akti. Strīdi tiek risināti Latvijas Republikas tiesās.</LP>
    </>) },
  ];
  const sectionsEn = [
    { id: 't-intro', title: '1. General terms', body: (<>
      <LP>These terms of use ("Terms") govern how users access the Klipzy.lv platform ("Platform", "Klipzy"), operated by SIA SERPA Media Group, registered in the Republic of Latvia. By registering or using the Platform, you agree to these Terms in full.</LP>
      <LP>The Platform connects content creators ("Clippers") with brands and companies ("Brands") to distribute short-form video clips on TikTok, Instagram and YouTube. Klipzy acts as an intermediary and technical service provider.</LP>
      <LNote>The Platform is currently available only in the Latvian market and to persons aged 18 and over.</LNote>
    </>) },
    { id: 't-accounts', title: '2. Accounts and registration', body: (<>
      <LP>To use the Platform's features you must create an account, choosing the Clipper or Brand role. You agree to provide truthful, current information and keep it accurate.</LP>
      <LUL items={[
        'Each user is responsible for the security of their account and password, and for all activity carried out under their account.',
        'Clippers may be required to verify a phone number and social media account using a unique code in the profile description.',
        'Creating multiple accounts for fraudulent purposes or to bypass restrictions is prohibited.',
        'Klipzy reserves the right to suspend or close accounts that violate these Terms.',
      ]} />
    </>) },
    { id: 't-clippers', title: '3. Clipper obligations', body: (<>
      <LP>Clippers create and publish video clips according to the Brand's campaign guidelines. By submitting a clip, you confirm that:</LP>
      <LUL items={[
        'the content is your original work or you hold all necessary rights to use it;',
        'the clip complies with the campaign guidelines and the rules of the relevant social platform;',
        'views are obtained organically — artificial views, bots or paid traffic are strictly prohibited;',
        'the content is not misleading, offensive, unlawful or infringing on copyright.',
      ]} />
      <LNote>Views obtained via bots or artificial manipulation are voided, and the related payments are not paid out.</LNote>
    </>) },
    { id: 't-brands', title: '4. Brand obligations', body: (<>
      <LP>Brands create campaigns, setting the price per 1,000 views (CPM), total budget, run period and content guidelines. The Brand undertakes to:</LP>
      <LUL items={[
        'fund the campaign budget in the account before the campaign is launched;',
        'provide clear and lawful content guidelines;',
        'not request content that breaks laws or infringes third-party rights;',
        'fairly review and approve or reject submitted clips within a reasonable time.',
      ]} />
      <LP>A campaign may not run longer than 30 days. The budget is reserved during the campaign and spent according to real, verified views.</LP>
    </>) },
    { id: 't-payments', title: '5. Payments and fees', body: (<>
      <LP>Klipzy works on a "pay only for results" principle — Brands pay for real, verified views that clips receive on the respective platforms.</LP>
      <LUL items={[
        'The platform fee is 1% of the transaction amount (budget top-ups and payouts).',
        'Views are verified automatically on the server in regular cycles (usually every 24 hours; more often for campaigns with low remaining budget).',
        "Clippers' earned funds are paid out automatically after view verification.",
        'Payouts are available in standard mode (up to 7 days) or as an instant payout for an additional fee.',
      ]} />
      <LNote>Klipzy does not store payment card data — payments are processed by certified third-party payment service providers.</LNote>
    </>) },
    { id: 't-ip', title: '6. Intellectual property', body: (<>
      <LP>The Clipper retains copyright to the content they create. By submitting a clip to a campaign, the Clipper grants the Brand and Klipzy a non-exclusive license to use the clip in connection with that campaign and its promotion.</LP>
      <LP>The Klipzy brand, logo, design and platform software are the property of Klipzy, and their use without permission is prohibited.</LP>
    </>) },
    { id: 't-liability', title: '7. Limitation of liability', body: (<>
      <LP>The Platform is provided "as is". Klipzy makes every effort to ensure accurate view counting but is not responsible for the availability, changes or errors of third-party platform (TikTok, Instagram, YouTube) data.</LP>
      <LP>Klipzy is not liable for indirect losses, lost profit or damage arising from use of the Platform, to the extent permitted by applicable law.</LP>
    </>) },
    { id: 't-changes', title: '8. Changes to terms and applicable law', body: (<>
      <LP>Klipzy reserves the right to amend these Terms. Users are informed of material changes by email or on the Platform. By continuing to use the Platform after changes, you agree to the updated Terms.</LP>
      <LP>These Terms are governed by the laws of the Republic of Latvia. Disputes are resolved in the courts of the Republic of Latvia.</LP>
    </>) },
  ];
  return <LegalLayout go={go} page="terms" title={en ? 'Terms of use' : 'Lietošanas noteikumi'}
    subtitle={en ? 'Terms that apply to using the Klipzy platform for clippers and brands.' : 'Noteikumi, kas attiecas uz Klipzy platformas lietošanu klipotājiem un zīmoliem.'}
    updated={en ? 'July 14, 2026' : '2026. gada 14. jūlijā'} sections={en ? sectionsEn : sectionsLv} />;
}

/* ======================= PRIVĀTUMA POLITIKA ======================= */
function LegalPrivacy({ go }) {
  const lang = useLang();
  const en = lang === 'en';
  const sectionsLv = [
    { id: 'p-intro', title: '1. Ievads', body: (<>
      <LP>Šī privātuma politika izskaidro, kā Klipzy.lv apstrādā tavus personas datus atbilstoši Vispārīgajai datu aizsardzības regulai (GDPR) un Latvijas Republikas normatīvajiem aktiem. Klipzy ir datu pārzinis attiecībā uz Platformā apstrādātajiem datiem.</LP>
    </>) },
    { id: 'p-collect', title: '2. Kādus datus mēs vācam', body: (<>
      <LP>Mēs vācam tikai tos datus, kas nepieciešami pakalpojuma sniegšanai:</LP>
      <LUL items={[
        'Konta dati — vārds, e-pasta adrese, tālruņa numurs, izvēlētā loma un parole (šifrētā veidā).',
        'Profila un sociālo tīklu dati — TikTok/Instagram/YouTube lietotājvārdi un publiski pieejamā statistika, ko izmantojam skatījumu verifikācijai.',
        'Darījumu dati — kampaņas, iesniegtie klipi, skatījumu skaits, ieņēmumi un izmaksu vēsture.',
        'Tehniskie dati — IP adrese, pārlūka tips un lietošanas žurnāli drošības nolūkos.',
      ]} />
      <LNote>Mēs neuzglabājam pilnus maksājumu karšu datus — tos apstrādā sertificēti maksājumu pakalpojumu sniedzēji.</LNote>
    </>) },
    { id: 'p-use', title: '3. Kā mēs izmantojam datus', body: (<>
      <LUL items={[
        'lai izveidotu un pārvaldītu tavu kontu un nodrošinātu Platformas funkcijas;',
        'lai verificētu klipu skatījumus un aprēķinātu maksājumus;',
        'lai apstrādātu darījumus un izmaksas;',
        'lai nodrošinātu drošību, novērstu krāpšanu un ļaunprātīgu izmantošanu;',
        'lai sazinātos ar tevi par pakalpojumu un juridiskiem paziņojumiem.',
      ]} />
    </>) },
    { id: 'p-legal', title: '4. Apstrādes tiesiskais pamats', body: (<>
      <LP>Mēs apstrādājam personas datus, pamatojoties uz līguma izpildi (pakalpojuma sniegšana), juridisku pienākumu izpildi, mūsu leģitīmajām interesēm (drošība un krāpšanas novēršana), kā arī tavu piekrišanu, ja tāda ir nepieciešama.</LP>
    </>) },
    { id: 'p-share', title: '5. Datu koplietošana', body: (<>
      <LP>Mēs nepārdodam tavus personas datus. Datus varam nodot tikai:</LP>
      <LUL items={[
        'starp Klipotāju un Zīmolu tādā apjomā, kas nepieciešams kampaņas izpildei (piemēram, publiskais lietotājvārds un skatījumu statistika);',
        'uzticamiem pakalpojumu sniedzējiem (mākoņa infrastruktūra, maksājumu apstrāde, skatījumu datu ieguve) uz datu apstrādes līguma pamata;',
        'kompetentām iestādēm, ja to pieprasa likums.',
      ]} />
    </>) },
    { id: 'p-rights', title: '6. Tavas tiesības', body: (<>
      <LP>Saskaņā ar GDPR tev ir tiesības:</LP>
      <LUL items={[
        'piekļūt saviem datiem un saņemt to kopiju;',
        'labot neprecīzus datus;',
        'pieprasīt datu dzēšanu ("tiesības tikt aizmirstam");',
        'ierobežot vai iebilst pret apstrādi;',
        'saņemt datus pārnesamā formātā;',
        'iesniegt sūdzību Datu valsts inspekcijai.',
      ]} />
      <LP>Lai izmantotu savas tiesības, raksti uz <a href="mailto:privatums@klipzy.lv" style={{ color: 'var(--accent)' }}>privatums@klipzy.lv</a>.</LP>
    </>) },
    { id: 'p-retention', title: '7. Datu glabāšana', body: (<>
      <LP>Mēs glabājam personas datus tik ilgi, cik nepieciešams pakalpojuma sniegšanai un juridisko pienākumu izpildei (piemēram, grāmatvedības dati atbilstoši likumā noteiktajiem termiņiem). Pēc konta slēgšanas dati tiek dzēsti vai anonimizēti, ja vien likums neparedz citādi.</LP>
    </>) },
    { id: 'p-cookies', title: '8. Sīkdatnes', body: (<>
      <LP>Platforma izmanto tikai funkcionāli nepieciešamās sīkdatnes un lokālo krātuvi, lai uzturētu tavu sesiju, valodas izvēli un iestatījumus. Mēs neizmantojam trešo pušu reklāmu izsekošanas sīkdatnes.</LP>
    </>) },
  ];
  const sectionsEn = [
    { id: 'p-intro', title: '1. Introduction', body: (<>
      <LP>This privacy policy explains how Klipzy.lv processes your personal data in accordance with the General Data Protection Regulation (GDPR) and the laws of the Republic of Latvia. Klipzy is the data controller for the data processed on the Platform.</LP>
    </>) },
    { id: 'p-collect', title: '2. What data we collect', body: (<>
      <LP>We collect only the data needed to provide the service:</LP>
      <LUL items={[
        'Account data — name, email address, phone number, chosen role and password (encrypted).',
        'Profile and social media data — TikTok/Instagram/YouTube usernames and publicly available statistics we use for view verification.',
        'Transaction data — campaigns, submitted clips, view counts, earnings and payout history.',
        'Technical data — IP address, browser type and usage logs for security purposes.',
      ]} />
      <LNote>We do not store full payment card data — it is processed by certified payment service providers.</LNote>
    </>) },
    { id: 'p-use', title: '3. How we use data', body: (<>
      <LUL items={[
        'to create and manage your account and provide the Platform features;',
        'to verify clip views and calculate payments;',
        'to process transactions and payouts;',
        'to ensure security, prevent fraud and abuse;',
        'to communicate with you about the service and legal notices.',
      ]} />
    </>) },
    { id: 'p-legal', title: '4. Legal basis for processing', body: (<>
      <LP>We process personal data based on performance of a contract (providing the service), compliance with legal obligations, our legitimate interests (security and fraud prevention), and your consent where required.</LP>
    </>) },
    { id: 'p-share', title: '5. Data sharing', body: (<>
      <LP>We do not sell your personal data. We may share data only:</LP>
      <LUL items={[
        'between Clipper and Brand to the extent needed to run a campaign (e.g. public username and view statistics);',
        'with trusted service providers (cloud infrastructure, payment processing, view data retrieval) under a data processing agreement;',
        'with competent authorities where required by law.',
      ]} />
    </>) },
    { id: 'p-rights', title: '6. Your rights', body: (<>
      <LP>Under the GDPR you have the right to:</LP>
      <LUL items={[
        'access your data and receive a copy of it;',
        'correct inaccurate data;',
        'request erasure of data ("right to be forgotten");',
        'restrict or object to processing;',
        'receive data in a portable format;',
        'lodge a complaint with the Data State Inspectorate.',
      ]} />
      <LP>To exercise your rights, write to <a href="mailto:privatums@klipzy.lv" style={{ color: 'var(--accent)' }}>privatums@klipzy.lv</a>.</LP>
    </>) },
    { id: 'p-retention', title: '7. Data retention', body: (<>
      <LP>We keep personal data as long as needed to provide the service and meet legal obligations (e.g. accounting data for statutory periods). After an account is closed, data is deleted or anonymized unless the law requires otherwise.</LP>
    </>) },
    { id: 'p-cookies', title: '8. Cookies', body: (<>
      <LP>The Platform uses only functionally necessary cookies and local storage to maintain your session, language choice and settings. We do not use third-party advertising tracking cookies.</LP>
    </>) },
  ];
  return <LegalLayout go={go} page="privacy" title={en ? 'Privacy Policy' : 'Privātuma politika'}
    subtitle={en ? 'How Klipzy collects, uses and protects your personal data in line with the GDPR.' : 'Kā Klipzy vāc, izmanto un aizsargā tavus personas datus atbilstoši GDPR.'}
    updated={en ? 'July 14, 2026' : '2026. gada 14. jūlijā'} sections={en ? sectionsEn : sectionsLv} />;
}

/* ============================= DROŠĪBA ============================= */
function LegalSecurity({ go }) {
  const lang = useLang();
  const en = lang === 'en';
  const cardsLv = [
    { icon: 'lock', title: 'Šifrēta datu pārraide', text: 'Visa saziņa starp tavu pārlūku un Platformu ir aizsargāta ar TLS/HTTPS šifrēšanu. Paroles tiek glabātas tikai kriptogrāfiski jauktā (hash) veidā — nekad kā vienkāršs teksts.' },
    { icon: 'shield', title: 'Droša autentifikācija', text: 'Kontu pieejai izmantojam nozares standarta autentifikācijas infrastruktūru ar sesiju pārvaldību. Klipotājiem pieejama tālruņa un sociālo tīklu verifikācija.' },
    { icon: 'eye', title: 'Krāpšanas novēršana', text: 'Skatījumi tiek automātiski pārbaudīti un salīdzināti ar publiskajiem platformu datiem. Botu trafiks, mākslīgi skatījumi un aizdomīga aktivitāte tiek atklāta un anulēta.' },
    { icon: 'wallet', title: 'Maksājumu drošība', text: 'Maksājumu karšu dati netiek glabāti mūsu serveros — tos apstrādā sertificēti (PCI-DSS) maksājumu pakalpojumu sniedzēji. Budžeti tiek droši rezervēti pirms kampaņas palaišanas.' },
  ];
  const cardsEn = [
    { icon: 'lock', title: 'Encrypted data transfer', text: 'All communication between your browser and the Platform is protected with TLS/HTTPS encryption. Passwords are stored only as cryptographic hashes — never as plain text.' },
    { icon: 'shield', title: 'Secure authentication', text: 'We use industry-standard authentication infrastructure with session management for account access. Phone and social media verification is available for clippers.' },
    { icon: 'eye', title: 'Fraud prevention', text: 'Views are checked automatically and compared against public platform data. Bot traffic, artificial views and suspicious activity are detected and voided.' },
    { icon: 'wallet', title: 'Payment security', text: 'Payment card data is not stored on our servers — it is processed by certified (PCI-DSS) payment service providers. Budgets are securely reserved before a campaign launches.' },
  ];
  const cards = en ? cardsEn : cardsLv;
  const sectionsLv = [
    { id: 's-approach', title: '1. Mūsu pieeja drošībai', body: (<>
      <LP>Drošība ir Klipzy pamatā. Mēs izmantojam nozares standarta praksi un uzticamu mākoņa infrastruktūru, lai aizsargātu lietotāju datus, darījumus un līdzekļus. Drošības pasākumi tiek regulāri pārskatīti un uzlaboti.</LP>
      <div className="legal-grid">
        {cards.map((c) => (
          <div key={c.title} className="card legal-sec-card">
            <div className="legal-sec-ico"><Icon d={I[c.icon]} size={20} /></div>
            <div style={{ fontSize: 15.5, fontWeight: 570, marginTop: 12 }}>{c.title}</div>
            <p className="muted" style={{ fontSize: 13.5, marginTop: 7, lineHeight: 1.55 }}>{c.text}</p>
          </div>
        ))}
      </div>
    </>) },
    { id: 's-infra', title: '2. Infrastruktūra un datu glabāšana', body: (<>
      <LP>Platforma darbojas uz uzticamas mākoņa infrastruktūras ar iebūvētu datu replikāciju un rezerves kopijām. Piekļuve datubāzēm ir ierobežota ar stingriem piekļuves noteikumiem, kas nodrošina, ka lietotāji piekļūst tikai saviem datiem.</LP>
      <LUL items={[
        'Datu piekļuves noteikumi tiek piemēroti servera līmenī, ne tikai lietotnē.',
        'Regulāras automātiskas rezerves kopijas aizsargā pret datu zudumu.',
        'Sensitīvi aprēķini (skatījumu verifikācija, izmaksas) tiek veikti drošā servera vidē, nevis lietotāja pārlūkā.',
      ]} />
    </>) },
    { id: 's-verify', title: '3. Skatījumu verifikācija', body: (<>
      <LP>Lai nodrošinātu, ka Zīmoli maksā tikai par reāliem rezultātiem, skatījumu skaits tiek iegūts tieši no sociālo platformu publiskajiem datiem automatizētos ciklos. Katrs iesniegtais klips tiek regulāri pārbaudīts, un skatījumu pieaugums tiek salīdzināts ar iepriekšējiem mērījumiem.</LP>
      <LNote>Mākslīgi palielinātie skatījumi tiek atklāti un neietekmē izmaksas — tas aizsargā gan Zīmolus, gan godīgos Klipotājus.</LNote>
    </>) },
    { id: 's-account', title: '4. Kā tu vari aizsargāt savu kontu', body: (<>
      <LUL items={[
        'Izmanto spēcīgu, unikālu paroli, ko neizmanto citos pakalpojumos.',
        'Nekad nedalies ar savu paroli vai verifikācijas kodiem.',
        'Pabeidz tālruņa un sociālo tīklu verifikāciju, lai palielinātu konta uzticamību.',
        'Ziņo par jebkādu aizdomīgu aktivitāti nekavējoties.',
      ]} />
    </>) },
    { id: 's-report', title: '5. Ievainojamību ziņošana', body: (<>
      <LP>Ja atklāj drošības ievainojamību, lūdzam atbildīgi to ziņot uz <a href="mailto:drosiba@klipzy.lv" style={{ color: 'var(--accent)' }}>drosiba@klipzy.lv</a>. Mēs izvērtējam katru ziņojumu un cenšamies novērst apstiprinātās problēmas pēc iespējas ātrāk. Lūdzam neizpaust ievainojamību publiski, pirms tā ir novērsta.</LP>
    </>) },
  ];
  const sectionsEn = [
    { id: 's-approach', title: '1. Our approach to security', body: (<>
      <LP>Security is at the core of Klipzy. We use industry-standard practices and trusted cloud infrastructure to protect user data, transactions and funds. Security measures are regularly reviewed and improved.</LP>
      <div className="legal-grid">
        {cards.map((c) => (
          <div key={c.title} className="card legal-sec-card">
            <div className="legal-sec-ico"><Icon d={I[c.icon]} size={20} /></div>
            <div style={{ fontSize: 15.5, fontWeight: 570, marginTop: 12 }}>{c.title}</div>
            <p className="muted" style={{ fontSize: 13.5, marginTop: 7, lineHeight: 1.55 }}>{c.text}</p>
          </div>
        ))}
      </div>
    </>) },
    { id: 's-infra', title: '2. Infrastructure and data storage', body: (<>
      <LP>The Platform runs on trusted cloud infrastructure with built-in data replication and backups. Database access is restricted with strict access rules ensuring users access only their own data.</LP>
      <LUL items={[
        'Data access rules are enforced at the server level, not only in the app.',
        'Regular automatic backups protect against data loss.',
        'Sensitive calculations (view verification, payouts) run in a secure server environment, not in the user\u2019s browser.',
      ]} />
    </>) },
    { id: 's-verify', title: '3. View verification', body: (<>
      <LP>To ensure Brands pay only for real results, view counts are retrieved directly from social platforms\u2019 public data in automated cycles. Each submitted clip is checked regularly, and view growth is compared against previous measurements.</LP>
      <LNote>Artificially inflated views are detected and do not affect payouts — this protects both Brands and honest Clippers.</LNote>
    </>) },
    { id: 's-account', title: '4. How you can protect your account', body: (<>
      <LUL items={[
        'Use a strong, unique password not used on other services.',
        'Never share your password or verification codes.',
        'Complete phone and social media verification to increase account trust.',
        'Report any suspicious activity immediately.',
      ]} />
    </>) },
    { id: 's-report', title: '5. Reporting vulnerabilities', body: (<>
      <LP>If you discover a security vulnerability, please report it responsibly to <a href="mailto:drosiba@klipzy.lv" style={{ color: 'var(--accent)' }}>drosiba@klipzy.lv</a>. We review every report and aim to fix confirmed issues as quickly as possible. Please do not disclose vulnerabilities publicly before they are fixed.</LP>
    </>) },
  ];
  return <LegalLayout go={go} page="security" title={en ? 'Security' : 'Drošība'}
    subtitle={en ? 'How we protect your data, transactions and funds on the Klipzy platform.' : 'Kā mēs aizsargājam tavus datus, darījumus un līdzekļus platformā Klipzy.'}
    updated={en ? 'July 14, 2026' : '2026. gada 14. jūlijā'} sections={en ? sectionsEn : sectionsLv} />;
}

function LegalPage({ go, params }) {
  const page = (params && params.page) || 'terms';
  if (page === 'privacy') return <LegalPrivacy go={go} />;
  if (page === 'security') return <LegalSecurity go={go} />;
  return <LegalTerms go={go} />;
}

Object.assign(window, { LegalPage });
