'use client';
import React from 'react';
import Link from 'next/link';
import { useLanguage } from '@client/contexts/LanguageContext';

export default function TermsPage() {
  const { t } = useLanguage();

  const sections = [
    { title: t('landing.terms.section.1.title', '1. Acceptance of Terms'), content: t('landing.terms.section.1.content', 'By accessing or using RestroAgent ("the Service"), you agree to be bound by these Terms of Service ("Terms"). If you do not agree to these Terms, you may not access or use the Service. These Terms apply to all visitors, users, and others who access the Service.') },
    { title: t('landing.terms.section.2.title', '2. Description of Service'), content: t('landing.terms.section.2.content', 'RestroAgent provides an AI-powered platform for restaurant management, including voice and chat order-taking agents, table booking management, customer communication tools, analytics, and related services. Features available to you depend on your subscription plan.') },
    { title: t('landing.terms.section.3.title', '3. Account Registration'), content: t('landing.terms.section.3.content', 'To use the Service, you must create an account. You agree to provide accurate, current, and complete information and to keep this information updated. You are responsible for maintaining the confidentiality of your account credentials and for all activities that occur under your account. You must notify us immediately of any unauthorized use of your account.') },
    { title: t('landing.terms.section.4.title', '4. Subscription Plans and Billing'), content: t('landing.terms.section.4.content', "RestroAgent offers paid subscription plans billed monthly or annually. By subscribing, you authorize us to charge your payment method on a recurring basis. All fees are non-refundable except as stated in our Refund Policy. We reserve the right to change pricing with 30 days' notice. Downgrading your plan may result in loss of features or data.") },
    { title: t('landing.terms.section.5.title', '5. Free Trial'), content: t('landing.terms.section.5.content', 'We offer a 14-day free trial for new accounts. No credit card is required to start a trial. At the end of the trial period, you must subscribe to a paid plan to continue using the Service. We may modify or discontinue the free trial at any time.') },
    { title: t('landing.terms.section.6.title', '6. Acceptable Use'), content: t('landing.terms.section.6.content', 'You agree not to use the Service to: (a) violate any applicable law or regulation; (b) infringe the rights of any third party; (c) transmit harmful, offensive, or misleading content; (d) attempt to gain unauthorized access to any part of the Service; (e) use the Service for any competitive intelligence or benchmarking purposes; or (f) reverse-engineer or attempt to extract the source code of the Service.') },
    { title: t('landing.terms.section.7.title', '7. Data and Privacy'), content: t('landing.terms.section.7.content', 'Your use of the Service is also governed by our Privacy Policy. You retain ownership of all data you upload or generate through the Service ("Customer Data"). You grant us a limited license to process Customer Data solely to provide the Service. We do not sell or share Customer Data with third parties for marketing purposes.') },
    { title: t('landing.terms.section.8.title', '8. Intellectual Property'), content: t('landing.terms.section.8.content', 'The Service, including its software, design, text, graphics, and other content, is owned by RestroAgent and protected by intellectual property laws. You may not copy, modify, distribute, sell, or lease any part of the Service without our written permission.') },
    { title: t('landing.terms.section.9.title', '9. Disclaimers'), content: t('landing.terms.section.9.content', 'THE SERVICE IS PROVIDED "AS IS" WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. WE DO NOT WARRANT THAT THE SERVICE WILL BE UNINTERRUPTED, ERROR-FREE, OR FREE OF VIRUSES. AI-GENERATED RESPONSES MAY CONTAIN ERRORS; YOU REMAIN RESPONSIBLE FOR VERIFYING ORDER ACCURACY.') },
    { title: t('landing.terms.section.10.title', '10. Limitation of Liability'), content: t('landing.terms.section.10.content', 'TO THE FULLEST EXTENT PERMITTED BY LAW, RESTROAGENT SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES ARISING FROM YOUR USE OF THE SERVICE. OUR TOTAL LIABILITY SHALL NOT EXCEED THE AMOUNT YOU PAID US IN THE TWELVE MONTHS PRECEDING THE CLAIM.') },
    { title: t('landing.terms.section.11.title', '11. Termination'), content: t('landing.terms.section.11.content', 'You may cancel your account at any time from your account settings. We may suspend or terminate your account if you violate these Terms. Upon termination, your right to use the Service ceases immediately and we will delete your data within 30 days in accordance with our Privacy Policy.') },
    { title: t('landing.terms.section.12.title', '12. Changes to Terms'), content: t('landing.terms.section.12.content', 'We may update these Terms from time to time. We will notify you of material changes by email or through the Service. Continued use of the Service after the effective date of changes constitutes acceptance of the new Terms.') },
    { title: t('landing.terms.section.13.title', '13. Governing Law'), content: t('landing.terms.section.13.content', 'These Terms are governed by and construed in accordance with applicable law. Any disputes shall be resolved through binding arbitration, except for disputes involving intellectual property rights which may be brought in a court of competent jurisdiction.') },
    { title: t('landing.terms.section.14.title', '14. Contact'), content: t('landing.terms.section.14.content', 'If you have questions about these Terms, please contact us at legal@restroagent.com or through our contact page.') },
  ];

  return (
    <>
      <section className="py-16 sm:py-20 relative overflow-hidden">
        <div className="absolute inset-0 -z-10">
          <div className="absolute top-0 right-0 w-64 h-64 bg-orange-400/10 dark:bg-orange-500/6 rounded-full blur-3xl" />
        </div>
        <div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8">
          <p className="text-xs font-semibold text-orange-500 uppercase tracking-widest mb-3">{t('landing.legal.badge', 'Legal')}</p>
          <h1 className="text-3xl sm:text-4xl font-bold text-gray-900 dark:text-white mb-4">{t('landing.terms.hero.title', 'Terms of Service')}</h1>
          <p className="text-gray-500 dark:text-gray-400 text-sm">{t('landing.legal.last_updated', 'Last updated')}: {t('landing.terms.hero.date', 'April 1, 2026')}</p>
          <p className="mt-4 text-gray-600 dark:text-gray-400 leading-relaxed">
            {t('landing.terms.hero.desc', 'Please read these Terms of Service carefully before using RestroAgent. These terms govern your use of our platform and services.')}
          </p>
        </div>
      </section>

      <section className="pb-20 sm:pb-24 max-w-3xl mx-auto px-4 sm:px-6 lg:px-8">
        <div className="space-y-8">
          {sections.map((section, i) => (
            <div key={i} className="p-6 rounded-2xl bg-white dark:bg-gray-900 border border-gray-100 dark:border-gray-800">
              <h2 className="text-base font-bold text-gray-900 dark:text-white mb-3">{section.title}</h2>
              <p className="text-sm text-gray-600 dark:text-gray-400 leading-relaxed">{section.content}</p>
            </div>
          ))}
        </div>

        <div className="mt-12 p-6 rounded-2xl bg-orange-50 dark:bg-orange-950/20 border border-orange-100 dark:border-orange-900/30 text-center">
          <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">{t('landing.terms.footer.questions', 'Have questions about our terms?')}</p>
          <Link href="/contact" className="inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-orange-500 hover:bg-orange-600 text-white font-semibold text-sm transition-all duration-200 hover:-translate-y-0.5 shadow-lg shadow-orange-500/25">
            {t('landing.legal.footer.contact_us', 'Contact Us')}
          </Link>
        </div>

        <div className="mt-8 flex flex-wrap gap-4 text-sm text-gray-500 dark:text-gray-400">
          <Link href="/privacy" className="hover:text-orange-500 transition-colors">{t('landing.legal.privacy', 'Privacy Policy')}</Link>
          <Link href="/cookie" className="hover:text-orange-500 transition-colors">{t('landing.legal.cookie', 'Cookie Policy')}</Link>
          <Link href="/refund" className="hover:text-orange-500 transition-colors">{t('landing.legal.refund', 'Refund Policy')}</Link>
        </div>
      </section>
    </>
  );
}
