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

interface Props {
  supportEmail: string;
}

export default function PrivacyPageContent({ supportEmail }: Props) {
  const { t } = useLanguage();
  const fillSupport = (s: string) => s.replace(/\{support_email\}/g, supportEmail);

  const sections = [
    { title: t('landing.privacy.section.1.title', '1. Information We Collect'), content: t('landing.privacy.section.1.content', 'We collect information you provide directly to us, such as when you create an account (name, email, password), set up your restaurant profile (restaurant name, address, cuisine type, phone number), upload menus and knowledge base documents, and contact our support team. We also collect usage data automatically, including log data, device information, IP addresses, pages visited, and features used. Payment information is processed by our third-party payment processor and we do not store full card details.') },
    { title: t('landing.privacy.section.2.title', "2. Customer Data (Your Restaurant's Data)"), content: t('landing.privacy.section.2.content', 'When your AI agent interacts with your customers, we process that conversation data on your behalf. This "Customer Data" — including customer names, phone numbers, order details, and conversation transcripts — belongs to you. We act as a data processor, not a data controller, for Customer Data. We process it only to provide the Service and do not use it for our own purposes, including training our AI models, without your explicit consent.') },
    { title: t('landing.privacy.section.3.title', '3. How We Use Your Information'), content: t('landing.privacy.section.3.content', 'We use the information we collect to: provide, maintain, and improve the Service; process transactions and send related information; send technical notices, updates, security alerts, and support messages; respond to comments and questions; monitor and analyze usage patterns to improve the Service; detect and prevent fraud and abuse; and comply with legal obligations.') },
    { title: t('landing.privacy.section.4.title', '4. Information Sharing'), content: t('landing.privacy.section.4.content', 'We do not sell, trade, or rent your personal information to third parties for marketing purposes. We may share information with: service providers who assist in our operations (hosting, payment processing, analytics) under confidentiality agreements; business partners with your consent; law enforcement when required by law; and in connection with a merger, acquisition, or sale of assets (with notice to you).') },
    { title: t('landing.privacy.section.5.title', '5. Data Retention'), content: t('landing.privacy.section.5.content', 'We retain your account data for as long as your account is active or as needed to provide the Service. Conversation transcripts are retained for 90 days by default; you can configure this in your account settings. Call recordings (if enabled) are retained for 30 days unless you specify otherwise. Upon account cancellation, we delete your data within 30 days. You can request deletion at any time.') },
    { title: t('landing.privacy.section.6.title', '6. Security'), content: t('landing.privacy.section.6.content', 'We implement industry-standard security measures including TLS 1.3 encryption for data in transit, AES-256 encryption for data at rest, regular security audits, and role-based access controls. We are SOC 2 Type II certified. However, no method of transmission over the Internet is 100% secure, and we cannot guarantee absolute security.') },
    { title: t('landing.privacy.section.7.title', '7. Your Rights'), content: fillSupport(t('landing.privacy.section.7.content', 'Depending on your location, you may have rights to: access the personal information we hold about you; correct inaccurate data; request deletion of your data; restrict or object to processing; data portability; and withdraw consent. To exercise these rights, contact us at {support_email}. We will respond within 30 days.')) },
    { title: t('landing.privacy.section.8.title', '8. GDPR Compliance'), content: t('landing.privacy.section.8.content', 'For users in the European Economic Area (EEA), we process your data under the following legal bases: contract performance (to provide the Service you signed up for), legitimate interests (to improve the Service and prevent fraud), consent (for marketing communications), and legal obligation. You have the right to lodge a complaint with your local data protection authority.') },
    { title: t('landing.privacy.section.9.title', '9. Cookies'), content: t('landing.privacy.section.9.content', 'We use cookies and similar tracking technologies. For detailed information, please see our Cookie Policy. You can control cookie settings through your browser or our cookie consent tool.') },
    { title: t('landing.privacy.section.10.title', "10. Children's Privacy"), content: t('landing.privacy.section.10.content', 'The Service is not directed to children under 16. We do not knowingly collect personal information from children under 16. If we learn that we have collected such information, we will delete it promptly.') },
    { title: t('landing.privacy.section.11.title', '11. International Transfers'), content: t('landing.privacy.section.11.content', 'Your information may be transferred to and processed in countries other than your own. We ensure appropriate safeguards are in place for such transfers, including Standard Contractual Clauses where required.') },
    { title: t('landing.privacy.section.12.title', '12. Changes to This Policy'), content: t('landing.privacy.section.12.content', 'We may update this Privacy Policy from time to time. We will notify you of material changes by email or through the Service at least 30 days before they take effect. Continued use of the Service constitutes acceptance of the updated policy.') },
    { title: t('landing.privacy.section.13.title', '13. Contact Us'), content: fillSupport(t('landing.privacy.section.13.content', 'If you have questions about this Privacy Policy or our privacy practices, contact our Data Protection Officer at {support_email}. For requests related to your personal data, please use the privacy request form in your account settings.')) },
  ];

  return (
    <>
      <section className="py-16 sm:py-20 relative overflow-hidden">
        <div className="absolute inset-0 -z-10">
          <div className="absolute top-0 left-0 w-64 h-64 bg-teal-400/10 dark:bg-teal-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.privacy.hero.title', 'Privacy Policy')}</h1>
          <p className="text-gray-500 dark:text-gray-400 text-sm">{t('landing.legal.last_updated', 'Last updated')}: {t('landing.privacy.hero.date', 'April 1, 2026')}</p>
          <p className="mt-4 text-gray-600 dark:text-gray-400 leading-relaxed">
            {t('landing.privacy.hero.desc', 'At RestroAgent, your privacy matters. This policy explains how we collect, use, and protect your information when you use our platform.')}
          </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.privacy.footer.questions', 'Questions about your privacy or data?')}</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="/terms" className="hover:text-orange-500 transition-colors">{t('landing.legal.terms', 'Terms of Service')}</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>
    </>
  );
}
