import Link from "next/link";
import { ArrowLeft } from "lucide-react";
import type { Metadata } from "next";

const LAST_UPDATED = "February 15, 2026";

export const metadata: Metadata = {
  title: "Terms of Service | LLMHosts",
  description:
    "LLMHosts Terms of Service - acceptance, service description, account registration, pricing, acceptable use, Hive Mode, and more.",
  alternates: {
    canonical: "https://llmhosts.com/legal/terms",
  },
};

const tocItems = [
  { id: "acceptance", label: "Acceptance of Terms" },
  { id: "service", label: "Service Description" },
  { id: "accounts", label: "Account Registration" },
  { id: "free-tier", label: "Free Tier" },
  { id: "paid-tiers", label: "Paid Tiers" },
  { id: "acceptable-use", label: "Acceptable Use" },
  { id: "hive-mode", label: "Hive Mode" },
  { id: "intellectual-property", label: "Intellectual Property" },
  { id: "data-handling", label: "Data Handling" },
  { id: "limitation", label: "Limitation of Liability" },
  { id: "termination", label: "Termination" },
  { id: "changes", label: "Changes to Terms" },
  { id: "governing-law", label: "Governing Law" },
  { id: "contact", label: "Contact" },
];

export default function TermsPage() {
  return (
    <div className="min-h-screen" style={{ background: "#080809" }}>
      <div className="mx-auto max-w-5xl px-4 py-12 sm:px-6 lg:px-8">
        {/* Back link */}
        <Link
          href="/"
          className="mb-8 inline-flex items-center gap-2 text-sm text-gray-400 hover:text-violet-400 transition-colors"
        >
          <ArrowLeft size={16} />
          Back to LLMHosts
        </Link>

        {/* Header */}
        <header className="mb-10">
          <h1
            className="text-3xl font-bold text-white sm:text-4xl"
            style={{ letterSpacing: "-0.03em" }}
          >
            Terms of Service
          </h1>
          <p className="mt-2 text-sm text-gray-400">
            Last updated: {LAST_UPDATED}
          </p>
        </header>

        <div className="flex flex-col gap-10 lg:flex-row lg:gap-12">
          {/* Sticky TOC */}
          <nav
            className="glass rounded-xl p-5 lg:w-52 lg:shrink-0 lg:sticky lg:top-8 lg:self-start"
            aria-label="Table of contents"
          >
            <h2 className="mb-4 text-xs font-semibold uppercase tracking-wider text-gray-400">
              On this page
            </h2>
            <ul className="space-y-2">
              {tocItems.map((item) => (
                <li key={item.id}>
                  <a
                    href={`#${item.id}`}
                    className="block text-sm text-gray-400 hover:text-violet-400 transition-colors"
                  >
                    {item.label}
                  </a>
                </li>
              ))}
            </ul>
          </nav>

          {/* Content */}
          <article className="min-w-0 flex-1 space-y-10 text-gray-300">
            <section id="acceptance">
              <h2 className="text-xl font-semibold text-white">
                Acceptance of Terms
              </h2>
              <p className="mt-3 leading-relaxed">
                By accessing or using LLMHosts (&ldquo;we,&rdquo;
                &ldquo;us,&rdquo; or &ldquo;our&rdquo;)—including our
                open-source CLI tool, SaaS dashboard, website, and any related
                services—you agree to be bound by these Terms of Service. If you
                do not agree to these terms, do not use our services. Your
                continued use constitutes acceptance of these terms and any
                future updates.
              </p>
            </section>

            <section id="service">
              <h2 className="text-xl font-semibold text-white">
                Service Description
              </h2>
              <p className="mt-3 leading-relaxed">
                LLMHosts turns your hardware into AI infrastructure accessible
                from anywhere. Our offering consists of:
              </p>
              <ul className="mt-4 list-disc space-y-2 pl-6 text-gray-300">
                <li>
                  <strong className="text-gray-100">CLI tool:</strong> A local
                  proxy, intelligent router, and semantic cache that runs
                  entirely on your machine. Install via{" "}
                  <code className="rounded bg-white/[0.06] px-1.5 py-0.5 text-violet-300">
                    pip install llmhosts
                  </code>
                  .
                </li>
                <li>
                  <strong className="text-gray-100">SaaS dashboard:</strong> A
                  web-based interface for cloud cost intelligence, usage
                  analytics, and multi-device coordination when you subscribe to
                  paid tiers.
                </li>
              </ul>
              <p className="mt-4 leading-relaxed">
                The open-source CLI operates locally without sending data to us.
                Only the optional SaaS dashboard collects account and usage data
                as described in our Privacy Policy.
              </p>
            </section>

            <section id="accounts">
              <h2 className="text-xl font-semibold text-white">
                Account Registration and Responsibilities
              </h2>
              <p className="mt-3 leading-relaxed">
                To use the SaaS dashboard or paid features, you must create an
                account. You agree to:
              </p>
              <ul className="mt-4 list-disc space-y-2 pl-6 text-gray-300">
                <li>
                  Provide accurate, current, and complete registration
                  information
                </li>
                <li>Maintain and update your information as needed</li>
                <li>Keep your password and account credentials secure</li>
                <li>
                  Accept responsibility for all activity under your account
                </li>
              </ul>
              <p className="mt-4 leading-relaxed">
                You must be at least 13 years of age to create an account. If
                you are registering on behalf of an organization, you represent
                that you have authority to bind that organization to these terms.
              </p>
            </section>

            <section id="free-tier">
              <h2 className="text-xl font-semibold text-white">Free Tier</h2>
              <p className="mt-3 leading-relaxed">
                The open-source LLMHosts CLI and core algorithms are free
                forever. On the free tier:
              </p>
              <ul className="mt-4 list-disc space-y-2 pl-6 text-gray-300">
                <li>
                  <strong className="text-gray-100">Unlimited local use:</strong>{" "}
                  Run inference on your own hardware without restrictions
                </li>
                <li>
                  <strong className="text-gray-100">No telemetry:</strong> The
                  CLI tool does not collect or transmit any data to us
                </li>
                <li>
                  <strong className="text-gray-100">No account required:</strong>{" "}
                  Use the CLI locally without signing up
                </li>
              </ul>
              <p className="mt-4 leading-relaxed">
                Optional dashboard features on the free tier may have limited
                functionality. Paid upgrades unlock cloud intelligence, global
                router data, and multi-device mesh capabilities.
              </p>
            </section>

            <section id="paid-tiers">
              <h2 className="text-xl font-semibold text-white">
                Paid Tiers: Subscription, Billing, and Cancellation
              </h2>
              <p className="mt-3 leading-relaxed">
                Paid plans (Pro at $29/month, Team at $99/seat/month, Enterprise
                at $299/user/month) are billed in advance on a monthly or annual
                basis, unless otherwise agreed.
              </p>
              <h3 className="mt-6 text-base font-semibold text-gray-100">
                Billing
              </h3>
              <p className="mt-2 leading-relaxed">
                Payment is processed via Stripe. You authorize us to charge the
                payment method on file for each billing cycle. Prices may change
                with 30 days&apos; notice; price changes apply to subsequent
                billing periods.
              </p>
              <h3 className="mt-6 text-base font-semibold text-gray-100">
                Cancellation
              </h3>
              <p className="mt-2 leading-relaxed">
                You may cancel your subscription at any time from your account
                settings or via the Stripe customer portal. Cancellation takes
                effect at the end of the current billing period. No refunds are
                provided for partial billing periods. Upon cancellation, you
                retain access to paid features until the end of the paid period.
              </p>
            </section>

            <section id="acceptable-use">
              <h2 className="text-xl font-semibold text-white">
                Acceptable Use
              </h2>
              <p className="mt-3 leading-relaxed">
                You agree not to use LLMHosts to:
              </p>
              <ul className="mt-4 list-disc space-y-2 pl-6 text-gray-300">
                <li>Generate, process, or transmit illegal content</li>
                <li>
                  Violate any applicable law, regulation, or third-party rights
                </li>
                <li>
                  Run cryptocurrency mining or similar resource-intensive tasks
                </li>
                <li>
                  Abuse, overload, or attempt to compromise our infrastructure
                </li>
                <li>Circumvent security measures or access controls</li>
                <li>Distribute malware or engage in phishing</li>
              </ul>
              <p className="mt-4 leading-relaxed">
                We reserve the right to suspend or terminate accounts that
                violate these policies. We may also cooperate with law
                enforcement when required by law.
              </p>
            </section>

            <section id="hive-mode">
              <h2 className="text-xl font-semibold text-white">Hive Mode</h2>
              <p className="mt-3 leading-relaxed">
                Hive Mode (available on Team and Enterprise plans) allows you to
                pool GPUs among trusted participants. When using Hive Mode:
              </p>
              <ul className="mt-4 list-disc space-y-2 pl-6 text-gray-300">
                <li>
                  You are responsible for the participants you add to your Hive
                  and their use of shared compute
                </li>
                <li>
                  PII detection prevents sensitive data from routing to external
                  nodes; we do not log prompt content or model outputs in transit
                </li>
                <li>
                  Shared compute routing respects privacy tiers; you configure
                  what data may leave your trusted network
                </li>
              </ul>
              <p className="mt-4 leading-relaxed">
                We provide the infrastructure and controls; you remain
                responsible for compliance with your own data policies and
                applicable laws.
              </p>
            </section>

            <section id="intellectual-property">
              <h2 className="text-xl font-semibold text-white">
                Intellectual Property
              </h2>
              <p className="mt-3 leading-relaxed">
                The LLMHosts open-source core is licensed under the MIT License.
                You may use, modify, and distribute the open-source code in
                accordance with that license.
              </p>
              <p className="mt-4 leading-relaxed">
                Our SaaS platform, dashboard, branding, and proprietary features
                remain our intellectual property. We grant you a limited,
                non-exclusive license to use the SaaS services for their
                intended purpose while your subscription is active.
              </p>
            </section>

            <section id="data-handling">
              <h2 className="text-xl font-semibold text-white">
                Data Handling
              </h2>
              <p className="mt-3 leading-relaxed">We collect:</p>
              <ul className="mt-4 list-disc space-y-2 pl-6 text-gray-300">
                <li>
                  Email, name, and account information (required for accounts)
                </li>
                <li>
                  Usage metrics when you opt in to telemetry (SaaS dashboard
                  only)
                </li>
                <li>
                  Payment information processed by Stripe (we do not store card
                  details)
                </li>
              </ul>
              <p className="mt-4 leading-relaxed">
                The open-source CLI has no telemetry and no data collection.
                Only the SaaS dashboard collects account data when you sign in.
                See our{" "}
                <Link
                  href="/legal/privacy"
                  className="text-violet-400 hover:text-violet-300 underline"
                >
                  Privacy Policy
                </Link>{" "}
                for full details.
              </p>
            </section>

            <section id="limitation">
              <h2 className="text-xl font-semibold text-white">
                Limitation of Liability
              </h2>
              <p className="mt-3 leading-relaxed">
                TO THE MAXIMUM EXTENT PERMITTED BY LAW, LLMHOST AND ITS
                AFFILIATES, OFFICERS, DIRECTORS, EMPLOYEES, AND AGENTS SHALL NOT
                BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL,
                OR PUNITIVE DAMAGES, INCLUDING LOSS OF PROFITS, DATA, OR
                GOODWILL, ARISING FROM YOUR USE OF OUR SERVICES.
              </p>
              <p className="mt-4 leading-relaxed">
                OUR TOTAL AGGREGATE LIABILITY FOR ANY CLAIMS ARISING FROM OR
                RELATED TO THESE TERMS OR OUR SERVICES SHALL NOT EXCEED THE
                AMOUNT YOU PAID US IN THE TWELVE (12) MONTHS PRECEDING THE
                CLAIM.
              </p>
              <p className="mt-4 leading-relaxed">
                These limitations apply even if we have been advised of the
                possibility of such damages. Some jurisdictions do not allow
                certain limitations of liability; in such cases, our liability
                will be limited to the fullest extent permitted by law.
              </p>
            </section>

            <section id="termination">
              <h2 className="text-xl font-semibold text-white">Termination</h2>
              <p className="mt-3 leading-relaxed">
                You may terminate your account at any time by canceling your
                subscription and closing your account from the dashboard.
              </p>
              <p className="mt-4 leading-relaxed">
                We may suspend or terminate your access immediately if you
                breach these terms, engage in abusive conduct, or receive a
                valid legal request. We will provide notice when reasonably
                practicable, except where prohibited by law.
              </p>
              <p className="mt-4 leading-relaxed">
                Upon termination, your right to use the SaaS services ends. We
                may retain account data as required by law or as described in
                our Privacy Policy.
              </p>
            </section>

            <section id="changes">
              <h2 className="text-xl font-semibold text-white">
                Changes to Terms
              </h2>
              <p className="mt-3 leading-relaxed">
                We may update these Terms of Service from time to time. We will
                notify you of material changes by email or through the dashboard.
                Your continued use of our services after the effective date of
                changes constitutes acceptance. If you do not agree, you must
                stop using our services and cancel your account.
              </p>
            </section>

            <section id="governing-law">
              <h2 className="text-xl font-semibold text-white">
                Governing Law
              </h2>
              <p className="mt-3 leading-relaxed">
                These terms are governed by the laws of the United States and
                the State of Delaware, without regard to conflict of law
                principles. Any disputes shall be resolved in the courts of
                Delaware.
              </p>
            </section>

            <section id="contact">
              <h2 className="text-xl font-semibold text-white">Contact</h2>
              <p className="mt-3 leading-relaxed">
                For questions about these Terms of Service, use our contact form.
              </p>
              <p className="mt-4">
                <Link
                  href="/contact"
                  className="text-violet-400 hover:text-violet-300 underline"
                >
                  Contact us
                </Link>
              </p>
            </section>
          </article>
        </div>

        {/* Footer links */}
        <footer className="mt-16 border-t border-white/[0.06] pt-8">
          <div className="flex flex-wrap gap-6 text-sm text-gray-400">
            <Link
              href="/legal/privacy"
              className="hover:text-violet-400 transition-colors"
            >
              Privacy Policy
            </Link>
            <Link href="/" className="hover:text-violet-400 transition-colors">
              Back to LLMHosts
            </Link>
          </div>
        </footer>
      </div>
    </div>
  );
}
