import type { Metadata } from "next";
import Link from "next/link";
import { LegalPageLayout } from "@/components/LegalPageLayout";
import { LEGAL_OPERATOR } from "@/lib/legal/constants";

export const metadata: Metadata = {
  title: "Terms of Service | Songs2YT",
  description: "Terms and conditions for using the Songs2YT hosted service.",
};

export default function TermsPage() {
  return (
    <LegalPageLayout
      title="Terms of Service"
      description="Please read these terms carefully before using Songs2YT."
    >
      <h2>1. Agreement</h2>
      <p>
        These Terms of Service (&quot;Terms&quot;) govern your access to and use of the Songs2YT
        website and hosted cloud service (the &quot;Service&quot;) operated by{" "}
        {LEGAL_OPERATOR.legalName} (&quot;we&quot;, &quot;us&quot;). By creating an account or using
        the Service, you agree to these Terms.
      </p>
      <p>
        If you do not agree, do not use the Service. If you self-host the open-source software on
        your own infrastructure without using our hosted Service, these Terms apply only to the
        extent you use our website, support channels, or paid services we provide.
      </p>

      <h2>2. The Service</h2>
      <p>
        Songs2YT converts user-provided images and audio files into videos and can upload them to
        YouTube using your connected Google/YouTube account. Features, limits, and availability
        depend on your plan.
      </p>
      <ul>
        <li>
          <strong>Bedroom Producer (Free):</strong> limited quota, 720p, MP3, optional watermark
        </li>
        <li>
          <strong>Independent Artist (Pro):</strong> expanded limits and features as described on
          our pricing page
        </li>
        <li>
          <strong>Enterprise:</strong> custom terms as agreed in writing
        </li>
      </ul>
      <p>
        We may modify features, limits, or pricing with reasonable notice where required. The
        open-source software is provided separately under its applicable open-source license.
      </p>

      <h2>3. Eligibility and accounts</h2>
      <ul>
        <li>You must be at least 16 years old or the age required in your jurisdiction</li>
        <li>You must have a valid Google account and authorized access to the YouTube channel you connect</li>
        <li>You are responsible for maintaining the security of your account and OAuth connection</li>
        <li>You must provide accurate information and promptly update it if it changes</li>
      </ul>

      <h2>4. Your content and responsibilities</h2>
      <p>You retain ownership of content you upload. You grant us a limited license to host, process, encode, transmit, and upload your content solely to provide the Service.</p>
      <p>You represent and warrant that:</p>
      <ul>
        <li>You own or have all necessary rights to the content you upload</li>
        <li>Your content and use of the Service comply with applicable law and YouTube policies</li>
        <li>Your content does not infringe third-party rights or contain unlawful material</li>
        <li>You have configured metadata (including &quot;Made for Kids&quot; and privacy settings) accurately</li>
      </ul>
      <p>
        You are solely responsible for content published to your YouTube channel through the
        Service.
      </p>

      <h2>5. Acceptable use</h2>
      <p>You agree not to:</p>
      <ul>
        <li>Use the Service for unlawful, harmful, or abusive purposes</li>
        <li>Upload malware, attempt unauthorized access, or interfere with the Service</li>
        <li>Circumvent quotas, plan limits, or technical restrictions</li>
        <li>Resell or commercially exploit the hosted Service without authorization</li>
        <li>Use the Service in a way that violates Google, YouTube, or third-party terms</li>
      </ul>
      <p>We may suspend or terminate access for violations or risks to the Service or other users.</p>

      <h2>6. YouTube and third-party services</h2>
      <p>
        The Service integrates with Google OAuth and the YouTube API. Your use of those services is
        subject to Google&apos;s and YouTube&apos;s terms and policies. We are not responsible for
        changes, outages, quota limits, or enforcement actions taken by YouTube.
      </p>

      <h2>7. Open-source software</h2>
      <p>
        Portions of Songs2YT are available as open-source software. Self-hosting is permitted under
        the applicable open-source license. The hosted Service, enterprise features, managed
        infrastructure, and certain premium capabilities may require a separate commercial license
        or subscription.
      </p>

      <h2>8. Fees and billing</h2>
      <p>
        Paid plans are billed according to the pricing displayed at the time of purchase. Taxes may
        apply. Subscriptions renew automatically unless cancelled in accordance with our{" "}
        <Link href="/refund">Refund Policy</Link>. Failure to pay may result in downgrade or
        suspension.
      </p>

      <h3>8.1 Pro plan quota</h3>
      <p>
        Independent Artist (Pro) subscribers receive a monthly video quota that resets on the{" "}
        <strong>1st day of each calendar month</strong> (UTC). Unused quota does not roll over to
        the next month unless we expressly grant an extension in writing.
      </p>
      <p>
        Pro subscribers may contact{" "}
        <a href={`mailto:${LEGAL_OPERATOR.email}`}>{LEGAL_OPERATOR.email}</a> to request a manual
        quota reset or temporary extension. Each Pro account is entitled to up to{" "}
        <strong>five (5) manual monthly quota resets per calendar year</strong>. We review requests
        in good faith and may decline requests that are abusive, repetitive without cause, or
        inconsistent with fair use. Approved resets do not increase the annual limit of five
        requests.
      </p>

      <h3>8.2 Pro API access</h3>
      <p>
        Independent Artist (Pro) subscribers may generate an API key in account settings to upload
        files and create batch video jobs programmatically. API access requires an active Pro
        subscription, a connected YouTube account, and compliance with the same quota, file-type, and
        resolution limits as the web interface. API keys are personal, must be kept confidential, and
        may be revoked by you or by us if misused. We may apply rate limits and suspend API access
        for abuse, security incidents, or plan downgrades.
      </p>

      <h2>9. Availability and support</h2>
      <p>
        We strive for high availability but do not guarantee uninterrupted access. Maintenance,
        updates, and outages may occur. Support levels depend on your plan. Self-hosted DIY
        deployments without a paid setup are community-supported unless otherwise agreed in
        writing.
      </p>

      <h2>10. Disclaimer of warranties</h2>
      <p>
        THE SERVICE IS PROVIDED &quot;AS IS&quot; AND &quot;AS AVAILABLE&quot; TO THE MAXIMUM EXTENT
        PERMITTED BY LAW. WE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. WE DO NOT WARRANT THAT ENCODING,
        UPLOADS, OR METADATA TRANSFER WILL BE ERROR-FREE OR UNINTERRUPTED.
      </p>

      <h2>11. Limitation of liability</h2>
      <p>
        TO THE MAXIMUM EXTENT PERMITTED BY LAW, WE SHALL NOT BE LIABLE FOR INDIRECT, INCIDENTAL,
        SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS, REVENUE, DATA, OR
        GOODWILL. OUR TOTAL LIABILITY FOR ANY CLAIM ARISING OUT OF THESE TERMS OR THE SERVICE IS
        LIMITED TO THE AMOUNT YOU PAID US IN THE TWELVE (12) MONTHS BEFORE THE EVENT GIVING RISE TO
        THE CLAIM, OR EUR 100 IF YOU USE THE FREE PLAN ONLY.
      </p>
      <p>
        Some jurisdictions do not allow certain limitations, so some of the above may not apply to
        you.
      </p>

      <h2>12. Indemnification</h2>
      <p>
        You agree to indemnify and hold us harmless from claims arising out of your content, your
        use of the Service, or your violation of these Terms or applicable law.
      </p>

      <h2>13. Termination</h2>
      <p>
        You may stop using the Service at any time. We may suspend or terminate your access if you
        breach these Terms, create risk or legal exposure, or where required by law. Upon
        termination, your right to use the hosted Service ends. Provisions that by nature should
        survive will survive.
      </p>

      <h2>14. Governing law</h2>
      <p>
        These Terms are governed by the laws of [Your jurisdiction / country], excluding conflict
        of law rules. Courts in [Your jurisdiction] shall have exclusive jurisdiction unless
        mandatory consumer protection laws in your country provide otherwise.
      </p>

      <h2>15. Changes</h2>
      <p>
        We may update these Terms from time to time. Continued use after changes become effective
        constitutes acceptance of the revised Terms, where permitted by law.
      </p>

      <h2>16. Contact</h2>
      <p>
        Questions about these Terms:{" "}
        <a href={`mailto:${LEGAL_OPERATOR.email}`}>{LEGAL_OPERATOR.email}</a>
      </p>
    </LegalPageLayout>
  );
}
