// LegalPage.jsx
//
// Standard, reasonable SaaS legal boilerplate - NOT a substitute for real
// legal review. Written to be genuinely usable content (not a "coming
// soon" placeholder), grounded only in facts already established elsewhere
// on this site (AWS S3, dedicated VPS hosting, India-based/GST context,
// the AI Business Assistant's OpenAI-backed gpt-4o usage per
// chat-insight.service.ts, admin impersonation per Security & Trust,
// the Customer Portal's public no-login links, the Tally Sync Agent as
// a third-party integration) - no invented certifications, SLA numbers,
// or jurisdiction-specific claims (no named arbitration body or court
// city) beyond what's a reasonable default for an India-based company.
// A generated "On this page" nav (slugifyHeading) makes the now-longer
// documents actually navigable instead of one long scroll. Flagged to the
// site owner (in the build conversation, not on this page) as needing
// real legal counsel review before being relied upon.
//
// Loaded as a classic (non-module) Babel-transformed script - see
// index.html's header comment.

const LEGAL_DOCS = {
  "privacy-policy": {
    title: "Privacy Policy",
    sections: [
      {
        h: "Overview",
        p: "This policy explains what information SkelBiz collects through this website and our platform, how we use it, and the choices you have. It applies to visitors of this marketing site and to companies using the SkelBiz platform.",
      },
      {
        h: "Information We Collect",
        p: "When you submit a form on this site (demo request, contact, or early-access signup), we collect the information you provide - name, email, company name, phone number, and any message you include. If you use the SkelBiz platform itself, we collect the operational data you enter (orders, inventory, shipments) as part of delivering the service.",
      },
      {
        h: "How We Use Information",
        p: "Form submissions are used to respond to your inquiry and follow up about a demo or your question. Platform data is used solely to operate the service for your company and is not shared with other tenants - see our Security & Trust page for how that isolation works technically.",
      },
      {
        h: "How Our AI Assistant Uses Data",
        p: "If your company uses the AI Business Assistant module, your questions and the underlying business data needed to answer them - orders, shipments, vendor and broker records - are processed to generate a response, scoped strictly to your own company's data, the same tenant isolation enforced everywhere else on the platform. We do not authorize our AI service provider to use your data to train their models.",
      },
      {
        h: "Third-Party Service Providers",
        p: "We store files and documents on Amazon S3, run our infrastructure on a dedicated, secured VPS, and use a third-party AI service provider (currently OpenAI) to power the AI Business Assistant module when your company uses it. These providers process data on our behalf under their own security and compliance terms; we do not sell data to third parties for marketing purposes.",
      },
      {
        h: "International Data Transfers",
        p: "Some of our third-party providers - including cloud storage and our AI service provider - may process data on servers located outside India. Where that happens, we work with providers that maintain appropriate security safeguards for that data.",
      },
      {
        h: "Security Measures",
        p: "Our approach to access control, multi-tenant data isolation, and infrastructure security is documented in full on our Security & Trust page - JWT-based authentication, per-company role permissions enforced at the API level, and strict tenant scoping so one company's data is never queryable from another's session.",
      },
      {
        h: "Admin Impersonation & Support Access",
        p: "For support purposes, an Admin-level team member can access your company's data through an explicit, header-based impersonation mechanism - never silently, and never bypassing the same company-scoping every other request goes through. See our Security & Trust page for how this works technically.",
      },
      {
        h: "Data Retention",
        p: "We retain form submissions for as long as reasonably needed to respond to your inquiry, and platform data for as long as your company's account is active plus a reasonable period afterward, unless you request earlier deletion.",
      },
      {
        h: "Your Rights",
        p: "You can request access to, correction of, or deletion of your personal information by reaching out through our Contact page. We'll respond directly.",
      },
      {
        h: "Marketing Communications",
        p: "Submitting a form on this site doesn't enroll you in a recurring newsletter or marketing sequence. We'll respond to what you actually asked - a demo request, a question, or an early-access notification - not a broader mailing list.",
      },
      {
        h: "Cookies",
        p: "This marketing site does not use tracking or advertising cookies - no analytics, no ad pixels. The one piece of local storage it sets remembers that you've dismissed the privacy notice banner, so it doesn't need to keep asking. That's it.",
      },
      {
        h: "Children's Privacy",
        p: "This website and the SkelBiz platform are intended for business use and are not directed at children. We don't knowingly collect personal information from children.",
      },
      {
        h: "Changes to This Policy",
        p: "We may update this policy as the platform evolves. Material changes will be reflected here with an updated date.",
      },
    ],
  },
  "terms-of-service": {
    title: "Terms of Service",
    sections: [
      {
        h: "Acceptance of Terms",
        p: "By accessing this website or using the SkelBiz platform, you agree to these terms. If you're using SkelBiz on behalf of a company, you're confirming you have the authority to bind that company to these terms.",
      },
      {
        h: "Description of Service",
        p: "SkelBiz is a manufacturing operations platform covering sales, purchase, multi-warehouse inventory, a configurable production workflow engine, and related modules, licensed to companies on a subscription basis scoped during onboarding.",
      },
      {
        h: "Account Responsibilities",
        p: "You're responsible for the accuracy of data entered into the platform and for maintaining the confidentiality of your account credentials. Role-based access within your company is your company's responsibility to configure appropriately.",
      },
      {
        h: "Acceptable Use",
        p: "You agree not to use the platform to store or process unlawful content, attempt to breach tenant isolation or security controls, or resell access without a separate agreement with us.",
      },
      {
        h: "Early Access & Beta Features",
        p: "Some pages on this site let you register interest in features that aren't part of the licensed service yet - see our Resources and Developers pages. Registering interest doesn't create an obligation for us to build or deliver a specific feature or timeline, and early-access or beta features, once available, may change or be discontinued before general release.",
      },
      {
        h: "The Customer Portal & Public Links",
        p: "The Customer Portal issues a shareable link scoped to a single shipment, accessible without login. You're responsible for sharing that link only with the intended recipient - anyone with the link can view and act on that shipment's confirmation status.",
      },
      {
        h: "Third-Party Integrations",
        p: "Where the platform integrates with a third-party system you run yourself - for example, Tally ERP via our sync agent - that integration depends on the availability, configuration, and behavior of your own third-party environment, which is outside our control. We'll work with you on setup and rollout, but can't guarantee outcomes that depend on software we don't operate.",
      },
      {
        h: "Pricing & Payment",
        p: "Pricing is scoped per company (see our Pricing page) and confirmed in a separate agreement before billing begins - nothing on this website constitutes a binding price quote.",
      },
      {
        h: "Service Availability",
        p: "We're an early-stage platform and don't currently offer a formal uptime SLA. We make reasonable efforts to keep the service available and will communicate directly about any planned maintenance or significant disruption.",
      },
      {
        h: "Intellectual Property",
        p: "SkelBiz retains all rights to the platform itself. You retain all rights to the operational data you enter into it.",
      },
      {
        h: "Limitation of Liability",
        p: "The platform is provided on an \"as is\" basis. To the maximum extent permitted by law, SkelBiz is not liable for indirect or consequential damages arising from use of the service.",
      },
      {
        h: "Force Majeure",
        p: "Neither party is liable for delay or failure to perform caused by circumstances beyond its reasonable control.",
      },
      {
        h: "Termination",
        p: "Either party may terminate service per the terms agreed during onboarding. On termination, we'll provide a reasonable window to export your data.",
      },
      {
        h: "Assignment",
        p: "You may not assign these terms without our consent. We may assign these terms in connection with a merger, acquisition, or sale of assets.",
      },
      {
        h: "Dispute Resolution",
        p: "If a disagreement comes up, we'll first try to resolve it directly - reach out through our Contact page. That's consistent with how we handle every other conversation on this site: a real person, not a ticket queue.",
      },
      {
        h: "Governing Law",
        p: "These terms are governed by the laws of India, without regard to conflict-of-law principles.",
      },
      {
        h: "Severability & Entire Agreement",
        p: "If any provision of these terms is found unenforceable, the remaining provisions stay in effect. These terms, together with any separate agreement confirmed during onboarding, are the entire agreement between you and SkelBiz regarding the service.",
      },
      {
        h: "Changes to These Terms",
        p: "We may update these terms as the platform evolves. Material changes will be reflected here with an updated date.",
      },
    ],
  },
};

function slugifyHeading(h) {
  return h
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, "-")
    .replace(/(^-|-$)/g, "");
}

function LegalPage({ slug }) {
  const doc = LEGAL_DOCS[slug];

  useDocumentMeta(
    doc ? `${doc.title} - SkelBiz` : "SkelBiz",
    doc ? `SkelBiz ${doc.title}.` : "SkelBiz manufacturing operations platform."
  );

  if (!doc) {
    return <EarlyAccessGate path={`/${slug}`} />;
  }

  return (
    <section className="mx-auto max-w-3xl px-6 py-20">
      <h1 className="text-3xl font-bold text-brand-navy sm:text-4xl">{doc.title}</h1>
      <p className="mt-2 text-sm text-slate-500">
        Last updated {new Date().toLocaleDateString("en-US", { year: "numeric", month: "long" })}
      </p>

      <div className="mt-8 rounded-card border border-slate-200 bg-surface-card p-6 shadow-card">
        <h2 className="text-sm font-semibold uppercase tracking-wide text-brand-steel">On this page</h2>
        <ul className="mt-3 grid grid-cols-1 gap-x-6 gap-y-1.5 sm:grid-cols-2">
          {doc.sections.map((s) => (
            <li key={s.h}>
              <a href={`#${slugifyHeading(s.h)}`} className="text-sm text-emerald-700 hover:text-emerald-800 hover:underline">
                {s.h}
              </a>
            </li>
          ))}
        </ul>
      </div>

      <div className="mt-10 space-y-8">
        {doc.sections.map((s) => (
          <div key={s.h} id={slugifyHeading(s.h)} className="scroll-mt-24">
            <h2 className="text-lg font-semibold text-brand-navy">{s.h}</h2>
            <p className="mt-2 text-sm leading-relaxed text-slate-600">{s.p}</p>
          </div>
        ))}
      </div>
      <p className="mt-12 text-sm text-slate-500">
        Questions about this {doc.title.toLowerCase()}? <a href="/contact/" className="font-semibold text-emerald-700 hover:text-emerald-800">Contact us</a>.
      </p>
    </section>
  );
}
