/* global React */

// Shared layout for short legal pages, mirrors PrivacyPage styling
// (privacy-hero / privacy-section / privacy-foot already in styles.css)
function LegalPageLayout({ eyebrow, title, lede, sections, lastUpdated, navigate }) {
  return (
    <div className="page privacy-page">
      <section className="section privacy-hero" style={{ paddingTop: 160, paddingBottom: 40 }}>
        <div className="container">
          <div className="text-center reveal" style={{ maxWidth: 820, margin: "0 auto" }}>
            <div className="eyebrow mb-16">{eyebrow}</div>
            <h1 className="privacy-hero__title">
              <em className="serif-italic">{title}</em>
            </h1>
            {lastUpdated && <p className="privacy-hero__updated">Last updated: {lastUpdated}</p>}
            {lede && (
              <p className="section__lede mt-32" style={{ margin: "32px auto 0" }}>{lede}</p>
            )}
          </div>
        </div>
      </section>

      <section className="section privacy-body" style={{ paddingTop: 24, paddingBottom: 100 }}>
        <div className="container">
          <div className="privacy-layout">
            <aside className="privacy-toc reveal">
              <div className="privacy-toc__label">On this page</div>
              <ul>
                {sections.map((s) => (
                  <li key={s.id}>
                    <a href={`#${s.id}`} onClick={(e) => {
                      e.preventDefault();
                      const el = document.getElementById(s.id);
                      if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 100, behavior: "smooth" });
                    }}>
                      <span>{s.h}</span>
                    </a>
                  </li>
                ))}
              </ul>
            </aside>

            <article className="privacy-content reveal delay-1">
              {sections.map((s) => (
                <section key={s.id} id={s.id} className="privacy-section">
                  <h2 className="privacy-section__h">{s.h}</h2>
                  <div className="privacy-section__body">{s.body}</div>
                </section>
              ))}

              <div className="privacy-foot">
                <p>
                  Questions about this policy? Reach out and we'll respond with care and clarity.
                </p>
                <a className="btn btn-primary mt-16" href="#/contact" onClick={(e) => { e.preventDefault(); navigate("/contact"); }}>
                  Contact Gene
                </a>
              </div>
            </article>
          </div>
        </div>
      </section>
    </div>
  );
}

// ───────── Terms of Use ─────────
function TermsPage({ navigate }) {
  const sections = [
    {
      id: "agreement",
      h: "Agreement to Terms",
      body: (
        <p>
          By accessing or using this website, you agree to the terms set forth below. If you do not
          agree, please discontinue use of the site. These terms apply to all visitors and users.
        </p>
      )
    },
    {
      id: "no-relationship",
      h: "No Therapeutic Relationship",
      body: (
        <p>
          Use of this website does not establish a therapist-client relationship. A formal therapeutic
          relationship begins only after an intake consultation, completion of required documentation,
          and mutual agreement to begin services.
        </p>
      )
    },
    {
      id: "informational",
      h: "Informational Purpose Only",
      body: (
        <p>
          All content on this website is provided for educational and informational purposes only and
          should not be considered medical, psychological, or mental health advice. The information
          presented is not a substitute for professional evaluation, diagnosis, or treatment.
        </p>
      )
    },
    {
      id: "responsibility",
      h: "User Responsibility",
      body: (
        <p>
          You agree to use this website responsibly. You will not misuse the site, attempt to access
          restricted areas, interfere with its operation, or use it in any way that violates applicable
          law or the rights of others.
        </p>
      )
    },
    {
      id: "ip",
      h: "Intellectual Property",
      body: (
        <>
          <p>
            All content on this website, including the I.O.U. framework
            (Innerstanding, Overstanding, Understanding), written materials, photography, illustrations,
            and visual elements, is the intellectual property of I.O.U. Counseling Services and is
            protected by copyright and trademark laws.
          </p>
          <p>
            Unauthorized use, reproduction, modification, or distribution of any content from this site
            without prior written permission is strictly prohibited.
          </p>
        </>
      )
    },
    {
      id: "liability",
      h: "Limitation of Liability",
      body: (
        <p>
          I.O.U. Counseling Services is not liable for any decisions made, actions taken, or outcomes
          experienced based on information provided on this website. Use of the site is at your own
          risk.
        </p>
      )
    },
    {
      id: "law",
      h: "Governing Law",
      body: (
        <p>
          These terms are governed by and construed in accordance with the laws of the State of
          Maryland, without regard to its conflict-of-laws principles. Any disputes shall be resolved
          in the courts of Maryland.
        </p>
      )
    },
    {
      id: "changes",
      h: "Changes to These Terms",
      body: (
        <p>
          We may update these terms from time to time. Continued use of the website following any
          changes constitutes acceptance of the revised terms.
        </p>
      )
    }
  ];

  return (
    <LegalPageLayout
      eyebrow="Legal"
      title="Terms of Use"
      lastUpdated="April 2026"
      lede="These terms govern your use of the I.O.U. Counseling Services website. Please read them carefully before continuing."
      sections={sections}
      navigate={navigate}
    />
  );
}

// ───────── Notice of Privacy Practices (HIPAA) ─────────
function HipaaPage({ navigate }) {
  const sections = [
    {
      id: "purpose",
      h: "Purpose of This Notice",
      body: (
        <p>
          This notice describes how your protected health information (PHI) may be used and disclosed
          by I.O.U. Counseling Services and how you can access this information. We are required by
          law to maintain the privacy of your PHI, provide you with this notice of our legal duties
          and privacy practices, and follow the terms currently in effect.
        </p>
      )
    },
    {
      id: "rights",
      h: "Your Rights",
      body: (
        <>
          <p>You have the following rights with respect to your protected health information:</p>
          <ul className="privacy-list">
            <li><strong>Access your records</strong>: inspect and obtain a copy of your medical record, in accordance with applicable Maryland and federal law.</li>
            <li><strong>Request corrections</strong>: request that information you believe to be inaccurate or incomplete be amended.</li>
            <li><strong>Request restrictions</strong>: request limits on certain uses or disclosures of your information.</li>
            <li><strong>Receive confidential communications</strong>: request that we communicate with you at an alternate address or by alternate means.</li>
            <li><strong>Receive an accounting</strong>: receive a list of certain disclosures we have made of your PHI.</li>
            <li><strong>Receive a paper copy</strong>: request a paper copy of this notice at any time.</li>
          </ul>
        </>
      )
    },
    {
      id: "responsibilities",
      h: "Our Responsibilities",
      body: (
        <>
          <p>We are required by law to:</p>
          <ul className="privacy-list">
            <li>Maintain the privacy and security of your protected health information.</li>
            <li>Provide you with this notice of our legal duties and privacy practices.</li>
            <li>Notify you promptly if a breach occurs that may have compromised the privacy or security of your information.</li>
            <li>Follow the duties and privacy practices described in this notice and to provide a copy upon request.</li>
            <li>Not use or share your information other than as described here unless you authorize us in writing. You may revoke an authorization at any time, except to the extent action has already been taken in reliance on it.</li>
          </ul>
        </>
      )
    },
    {
      id: "uses",
      h: "How Your Information May Be Used",
      body: (
        <>
          <p>We may use and disclose your protected health information for the following purposes:</p>
          <ul className="privacy-list">
            <li><strong>Treatment</strong>: to provide, coordinate, or manage your mental health care, including consultation with other treating providers.</li>
            <li><strong>Payment</strong>: to obtain payment for services rendered, including billing insurance and processing claims.</li>
            <li><strong>Healthcare operations</strong>: to support business activities such as quality improvement, training, and required regulatory reporting.</li>
            <li><strong>Required by law</strong>: when disclosure is mandated by federal, state, or local law (e.g., mandated reporting of abuse, response to court orders).</li>
            <li><strong>Public health and safety</strong>: to prevent serious threats to health or safety, or as required by public health authorities.</li>
          </ul>
        </>
      )
    },
    {
      id: "website",
      h: "Website Disclaimer",
      body: (
        <p>
          This website is <strong>not</strong> a secure method of communication. Email, contact forms,
          and text messages submitted through this site should not be used to share personal health
          information, clinical content, or anything urgent. Once you become a client, please use the
          secure client portal for any sensitive communication.
        </p>
      )
    },
    {
      id: "complaints",
      h: "Complaints",
      body: (
        <p>
          If you believe your privacy rights have been violated, you may file a complaint with
          I.O.U. Counseling Services or with the U.S. Department of Health &amp; Human Services
          Office for Civil Rights. We will not retaliate against you for filing a complaint.
        </p>
      )
    },
    {
      id: "contact",
      h: "Contact",
      body: (
        <>
          <p>For questions about this notice or to exercise your rights, please contact:</p>
          <div className="privacy-contact">
            <div><span>Practice</span> I.O.U. Counseling Services</div>
            <div><span>Provider</span> Gene Groves, LCPC, NCC</div>
            <div><span>Email</span> <a href="mailto:gene.groves@ioucounselingservices.com">gene.groves@ioucounselingservices.com</a></div>
            <div><span>Phone</span> <a href="tel:+12022868811">202-286-8811</a></div>
          </div>
        </>
      )
    }
  ];

  return (
    <LegalPageLayout
      eyebrow="HIPAA"
      title="Notice of Privacy Practices"
      lastUpdated="April 2026"
      lede="This notice describes how medical information about you may be used and disclosed and how you can access this information. Please review it carefully."
      sections={sections}
      navigate={navigate}
    />
  );
}

// ───────── Good Faith Estimate ─────────
function GoodFaithPage({ navigate }) {
  const sections = [
    {
      id: "overview",
      h: "Your Right to a Good Faith Estimate",
      body: (
        <>
          <p>
            Under the federal <strong>No Surprises Act</strong>, you have the right to receive a Good
            Faith Estimate explaining the expected cost of your medical or mental health care if you
            are uninsured or are not using insurance to pay for your services.
          </p>
          <p>
            This protection is intended to help you understand the cost of care upfront and to dispute
            charges that significantly exceed what was estimated.
          </p>
        </>
      )
    },
    {
      id: "your-rights",
      h: "Your Rights",
      body: (
        <ul className="privacy-list">
          <li>You may request a Good Faith Estimate before scheduling services, or at any time during the course of care.</li>
          <li>You will receive a written estimate at least one (1) business day before a scheduled service if you request it in advance.</li>
          <li>You may dispute a final bill if it is at least <strong>$400 more</strong> than the Good Faith Estimate, through the federal patient-provider dispute resolution process.</li>
          <li>You may keep a copy of your Good Faith Estimate for your records.</li>
        </ul>
      )
    },
    {
      id: "what-included",
      h: "What's Included",
      body: (
        <>
          <p>A Good Faith Estimate will typically include:</p>
          <ul className="privacy-list">
            <li>Your name and date of birth.</li>
            <li>A description of the service(s) expected to be provided.</li>
            <li>The expected cost of those services.</li>
            <li>The diagnosis code(s), service code(s), and provider information.</li>
            <li>Notice that the estimate is not a contract and that the actual cost may vary.</li>
          </ul>
        </>
      )
    },
    {
      id: "request",
      h: "How to Request an Estimate",
      body: (
        <>
          <p>
            To request a Good Faith Estimate, contact us using the information below. Please allow at
            least one business day for a written response if you have already scheduled an
            appointment, or up to three business days for a general inquiry.
          </p>
          <div className="privacy-contact">
            <div><span>Email</span> <a href="mailto:gene.groves@ioucounselingservices.com">gene.groves@ioucounselingservices.com</a></div>
            <div><span>Phone</span> <a href="tel:+12022868811">202-286-8811</a></div>
          </div>
        </>
      )
    },
    {
      id: "more-info",
      h: "More Information",
      body: (
        <p>
          For more information about your right to a Good Faith Estimate, visit{" "}
          <a href="https://www.cms.gov/nosurprises" target="_blank" rel="noopener noreferrer">
            cms.gov/nosurprises
          </a>{" "}
          or call <strong>1-800-985-3059</strong>.
        </p>
      )
    }
  ];

  return (
    <LegalPageLayout
      eyebrow="No Surprises Act"
      title="Good Faith Estimate"
      lastUpdated="April 2026"
      lede="Federal law gives you the right to know what your care will cost. Here's how that works at I.O.U. Counseling Services."
      sections={sections}
      navigate={navigate}
    />
  );
}

// ───────── Accessibility ─────────
function AccessibilityPage({ navigate }) {
  const sections = [
    {
      id: "commitment",
      h: "Our Commitment",
      body: (
        <p>
          I.O.U. Counseling Services is committed to making this website accessible to all individuals,
          including those with disabilities. We believe that the work of healing should be reachable , 
          and that begins with how you experience this site.
        </p>
      )
    },
    {
      id: "standards",
      h: "What We Strive For",
      body: (
        <ul className="privacy-list">
          <li>Content is readable, clear, and written in plain language wherever possible.</li>
          <li>Navigation is consistent, predictable, and operable by keyboard.</li>
          <li>Color contrast and typography support readability across devices.</li>
          <li>Imagery includes meaningful alternative text where appropriate.</li>
          <li>We follow the Web Content Accessibility Guidelines (WCAG) 2.1 Level AA as a working standard.</li>
        </ul>
      )
    },
    {
      id: "ongoing",
      h: "Ongoing Work",
      body: (
        <p>
          Accessibility is an ongoing effort, not a finished checkbox. We periodically review our site
          and make improvements as we learn, as standards evolve, and as our community shares feedback.
        </p>
      )
    },
    {
      id: "feedback",
      h: "Our Commitment",
      body: (
        <>
          <p>
            If you experience difficulty accessing any part of this website, or if you have a
            suggestion for how we could improve, please reach out. We will do our best to provide the
            information or service you need in an alternative format.
          </p>
          <div className="privacy-contact">
            <div><span>Email</span> <a href="mailto:gene.groves@ioucounselingservices.com">gene.groves@ioucounselingservices.com</a></div>
            <div><span>Phone</span> <a href="tel:+12022868811">202-286-8811</a></div>
          </div>
        </>
      )
    }
  ];

  return (
    <LegalPageLayout
      eyebrow="Accessibility"
      title="Accessibility Statement"
      lastUpdated="April 2026"
      lede="Everyone deserves a website they can actually use. Here's how we work to make sure this is one of them."
      sections={sections}
      navigate={navigate}
    />
  );
}

window.TermsPage = TermsPage;
window.HipaaPage = HipaaPage;
window.GoodFaithPage = GoodFaithPage;
window.AccessibilityPage = AccessibilityPage;
