/* ActiveFit360 marketing — legal pages (Privacy, HIPAA, Terms) */
const NS_lg = window.Activefit360DesignSystem_d87766;

/* body item: string = paragraph; {list:[...]} = bullets */
const AF_LEGAL = {
  privacy: {
    title: 'Privacy Policy',
    updated: 'Effective 2026',
    intro: 'ActiveFit360 LLC (“ActiveFit360”, “we”, “us”, or “our”) is committed to protecting the privacy of visitors to our website and services (the “Site”). This Privacy Policy explains how we collect, use, and share information, and your rights regarding it. By accessing or using the Site, you agree to be bound by this Privacy Policy.',
    sections: [
      { h: '1. Data We Collect', body: [
        'Personal Data: information that identifies you, which you provide when you make a purchase, create an appointment, subscribe to a newsletter, or contact us — such as your name, email address, phone number, mailing/billing address, and payment information. We may also collect demographic information you choose to share.',
        'Non-Personal Data: information that does not identify you but provides insight into your use of the Site, including connection and device information, pages visited, search terms, and similar “Log Data.” We use cookies and web beacons to collect some of this; you can set your browser to reject cookies, though some features may be limited.',
        'Health Information: when you schedule an appointment we may obtain Protected Health Information (“PHI”). We handle PHI in compliance with HIPAA and the HITECH Act. See our HIPAA Notice of Privacy Practices for details.',
        'Geolocation: you may allow us to access your location; you can change this in your device or browser settings.',
      ]},
      { h: '2. How We Use Data', body: [
        'We use information for legitimate business purposes, including to:',
        { list: [
          'operate, maintain, and provide the features of our Site',
          'create and manage your account and validate your login credentials',
          'respond to your requests and provide patient support',
          'send appointment information, confirmations, and follow-ups',
          'process purchases and provide requested services',
          'improve our content and services, and prevent or investigate fraud',
          'comply with legal obligations and enforce our agreements',
        ]},
        'Consent: marketing emails are opt-in. You can unsubscribe at any time via the link in our emails.',
      ]},
      { h: '3. How We Share Information', body: [
        'We may share your data with corporate affiliates, and with service providers who help us operate the Site (for example, hosting and payment processing) under contractual obligations to protect it and use it only for the services they provide.',
        'We may also disclose information to authorized third parties you direct us to, and in connection with a merger, sale, or other business transfer, or where required by law.',
        'Any data you voluntarily post to public areas of the Site may become available to the public.',
      ]},
      { h: '4. Information Security', body: [
        'We take reasonable steps to safeguard your Personal Data, including hosting with enterprise-grade providers using SSL/HTTPS encryption, firewalls, secure cloud environments, and two-factor authentication for backend systems. No internet transmission is ever completely secure, so any transmission is at your own risk. If you suspect a security issue, contact privacy@ActiveFit360.com immediately.',
      ]},
      { h: '5. Your Rights', body: [
        'You may change, update, or request deletion of the information you provided by emailing privacy@ActiveFit360.com. Depending on your jurisdiction (such as the EEA), you may also have rights to access, rectify, restrict, object to, or port your Personal Data.',
        'California residents may request information about disclosures of personal information for third-party direct marketing. We do not currently respond to “Do Not Track” browser signals.',
      ]},
      { h: '6. Retention', body: [
        'We retain Personal Data for as long as you use the Site or as necessary to fulfill the purposes described in this Policy, resolve disputes, and comply with applicable law. Following account deactivation, we may retain data for a reasonable period for archival purposes.',
      ]},
      { h: '7. Children’s Privacy', body: [
        'We do not knowingly collect Personal Data from anyone under the age of thirteen (13) without verifiable parental consent, in accordance with COPPA. If we learn we have done so, we will delete that information promptly.',
      ]},
      { h: '8. Changes & Contact', body: [
        'We may update this Privacy Policy at any time by posting an amended version on our Site. For questions, contact us at privacy@ActiveFit360.com.',
      ]},
    ],
  },

  hipaa: {
    title: 'HIPAA Notice of Privacy Practices',
    updated: 'Effective 2026',
    intro: 'This Notice describes how ActiveFit360 LLC may use and disclose your protected health information (PHI) to carry out treatment, payment, or healthcare operations, and for other purposes permitted or required by law. It also describes your rights regarding your health information. This Notice applies to physical therapy services provided in-home, virtually (telehealth), and on-site.',
    sections: [
      { h: 'How We Protect Your Privacy', body: [
        'We understand that your health information is personal, and we are committed to protecting it as required by HIPAA and state law. We maintain appropriate physical, electronic, and administrative safeguards to protect your information.',
      ]},
      { h: 'What Health Information We Collect', body: [
        { list: [
          'Your name, address, and contact information',
          'Medical history, treatment plans, and other health-related data',
          'Information about care received at home, virtually, or at physical locations',
          'Payment information, including insurance details and billing records',
        ]},
      ]},
      { h: 'How We Use & Disclose Your Health Information', body: [
        'Treatment: to provide physical therapy services in-home, virtually, or on-site, including sharing information with other providers involved in your care.',
        'Payment: to bill for services rendered, including communicating with your insurance company.',
        'Healthcare Operations: to manage and improve our services, assess staff performance, and ensure quality of care.',
      ]},
      { h: 'Special Considerations for In-Home & Virtual Care', body: [
        'In-Home Care: we may collect and document your address and relevant details to deliver services at your home, and coordinate with other professionals involved in your home care.',
        'Virtual Care: for telehealth sessions we use secure video technology. Information shared during virtual visits is treated with the same confidentiality as in-person visits, and telehealth session data is stored securely in compliance with HIPAA.',
      ]},
      { h: 'Your Rights Regarding Your Health Information', body: [
        'You have the right to:',
        { list: [
          'Inspect and obtain copies of your health information',
          'Request corrections if you believe information is incorrect',
          'Receive an accounting of disclosures of your health information',
          'Request restrictions on how we use or disclose your information',
          'Request confidential communications (e.g., to an alternative address)',
          'File a complaint if you believe your privacy rights have been violated',
        ]},
      ]},
      { h: 'How to Contact Us', body: [
        'If you have questions about this Notice or need to make a request regarding your health information, contact us at privacy@ActiveFit360.com.',
      ]},
    ],
  },

  terms: {
    title: 'Terms & Conditions',
    updated: 'Effective 2026',
    intro: 'ActiveFit360 provides this website and/or mobile application (the “Site”) under the following Terms and Conditions. By using this Site you agree to be bound by these Terms. If you do not agree, please do not use the Site. We may revise these Terms at any time by updating this posting. You must also read our Privacy Policy and HIPAA Notice of Privacy Practices.',
    sections: [
      { h: 'Registration & Security', body: [
        'You agree that all information you provide is true, accurate, and current. You are responsible for safeguarding your password and for all activity under your account. Notify us immediately if you suspect unauthorized use. We recommend you do not access the Site on public computers or store your password in your browser.',
      ]},
      { h: 'Copyright & Intellectual Property', body: [
        'All material on this Site is owned by ActiveFit360 or its licensors and is protected by U.S. copyright, trademark, and other intellectual property laws. We grant you a limited, non-exclusive, non-transferable, revocable license to access the Site and print content solely for personal, non-commercial purposes. You may not republish, reproduce, or create derivative works without our prior written permission.',
      ]},
      { h: 'Medical Information Disclaimer', body: [
        'Information on this Site is for informational purposes only and is not a substitute for medical advice. Always seek the advice of your physician or qualified healthcare provider before making treatment decisions, and never disregard professional advice because of something you read here. If you are in crisis or may have an emergency, call your doctor or 911 immediately.',
      ]},
      { h: 'Submissions', body: [
        'Remarks, suggestions, and ideas you communicate through this Site (other than PHI) may be treated as non-confidential and become the property of ActiveFit360. Any submissions that constitute PHI are treated confidentially and subject to our HIPAA Notice of Privacy Practices. Please do not send sensitive medical information by email or other Site functionality.',
      ]},
      { h: 'Opt-In Mobile Texts', body: [
        'When you provide your mobile number to us, you consent to receive text messages, which may be sent using an automatic telephone dialing system. Consent is not required to make a purchase or order a service. Email privacy@ActiveFit360.com to stop receiving text messages.',
      ]},
      { h: 'Disclaimer & Limitation of Liability', body: [
        'The information and materials on this Site are provided “as is” without warranties of any kind, express or implied. To the fullest extent permitted by law, ActiveFit360 disclaims all warranties, including merchantability and fitness for a particular purpose, and will not be liable for any damages arising from your use of, or inability to use, the Site.',
      ]},
      { h: 'Cancellation, Links & Jurisdiction', body: [
        'You may cancel your account at any time by emailing privacy@ActiveFit360.com. This Site may link to third-party sites we do not control or endorse. These Terms are governed by the laws of the State of Illinois; any action must be filed in the state or federal courts located in Will County, Illinois. If any provision is found invalid, the remaining provisions continue in full force. By using this Site, you accept these Terms.',
      ]},
    ],
  },
};
window.AF_LEGAL = AF_LEGAL;

function LegalPage({ which, onNavigate }) {
  const { Card } = NS_lg;
  const I = window.Icon;
  const doc = AF_LEGAL[which];
  const renderBody = (item, i) => {
    if (typeof item === 'string') return <p key={i} style={{ fontSize: 15.5, color: 'var(--text-body)', lineHeight: 1.7, margin: '0 0 12px' }}>{item}</p>;
    return (
      <ul key={i} style={{ listStyle: 'none', padding: 0, margin: '0 0 12px', display: 'flex', flexDirection: 'column', gap: 9 }}>
        {item.list.map(li => (
          <li key={li} style={{ display: 'flex', alignItems: 'flex-start', gap: 10, fontSize: 15.5, color: 'var(--text-body)', lineHeight: 1.55 }}>
            <I name="check" size={16} stroke={2.6} style={{ color: 'var(--green-600)', marginTop: 3, flexShrink: 0 }} />{li}</li>
        ))}
      </ul>
    );
  };
  return (
    <section style={{ padding: '32px var(--gutter) 0' }}>
      <div style={{ maxWidth: 820, margin: '0 auto' }}>
        <a href={window.AF_ROUTES.home} onClick={e => { e.preventDefault(); onNavigate('home'); }} style={{ display: 'inline-flex', alignItems: 'center', gap: 6, background: 'none', border: 'none', cursor: 'pointer', textDecoration: 'none', color: 'var(--text-muted)', fontFamily: 'var(--font-sans)', fontWeight: 700, fontSize: 14, padding: 0, marginBottom: 20 }}>
          <I name="chevron-left" size={16} /> Back to home</a>
        <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11.5, textTransform: 'uppercase', letterSpacing: '0.08em', color: 'var(--green-600)', marginBottom: 10 }}>{doc.updated} · Legal</div>
        <h1 style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 'clamp(30px,4vw,46px)', letterSpacing: '-0.02em', color: 'var(--ink-900)', margin: 0, lineHeight: 1.08 }}>{doc.title}</h1>
        <p style={{ fontSize: 16.5, color: 'var(--text-muted)', lineHeight: 1.7, margin: '18px 0 0' }}>{doc.intro}</p>

        <div style={{ display: 'flex', flexDirection: 'column', gap: 14, margin: '32px 0 0' }}>
          {doc.sections.map((s, i) => (
            <Card key={i} style={{ padding: 'clamp(22px,3vw,32px)' }}>
              <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 800, fontSize: 20, color: 'var(--ink-900)', margin: '0 0 14px' }}>{s.h}</h2>
              {s.body.map(renderBody)}
            </Card>
          ))}
        </div>

        <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginTop: 24, padding: '16px 20px', background: 'var(--color-primary-soft)', borderRadius: 'var(--radius-lg)', fontSize: 14.5, color: 'var(--green-800)' }}>
          <I name="mail" size={18} /> Questions? Contact us at <strong>privacy@ActiveFit360.com</strong>
        </div>

        <div style={{ display: 'flex', gap: 18, justifyContent: 'center', marginTop: 28, flexWrap: 'wrap' }}>
          {[['privacy', 'Privacy Policy'], ['terms', 'Terms & Conditions'], ['hipaa', 'HIPAA Notice']].filter(([k]) => k !== which).map(([k, label]) => (
            <a key={k} href={window.AF_ROUTES[k]} onClick={e => { e.preventDefault(); onNavigate(k); }} style={{ background: 'none', border: 'none', cursor: 'pointer', color: 'var(--green-700)', fontFamily: 'var(--font-sans)', fontWeight: 700, fontSize: 14.5, textDecoration: 'underline', padding: 0 }}>{label}</a>
          ))}
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { LegalPage });
