import { setRequestLocale } from 'next-intl/server';
import Link from 'next/link';
import type { Metadata } from 'next';

type Props = {
  params: Promise<{ locale: string }>;
};

const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://damjan-savic.com';

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { locale } = await params;

  const titles: Record<string, string> = {
    de: 'Datenschutzerklärung | Damjan Savić - KI Entwickler Köln',
    en: 'Privacy Policy | Damjan Savić - AI Developer',
    sr: 'Politika privatnosti | Damjan Savić - AI Developer',
  };

  const descriptions: Record<string, string> = {
    de: 'Datenschutzerklärung für die Portfolio-Website von Damjan Savić. Informationen zu Datenverarbeitung, Cookies, Google Analytics, Supabase und Ihren DSGVO-Rechten.',
    en: 'Privacy policy for Damjan Savić portfolio website. Information about data processing, cookies, Google Analytics, Supabase and your GDPR rights.',
    sr: 'Politika privatnosti za portfolio veb sajt Damjana Savića. Informacije o obradi podataka, kolačićima, Google Analytics, Supabase i vašim GDPR pravima.',
  };

  const localePath = locale === 'de' ? '/privacy' : `/${locale}/privacy`;

  return {
    title: titles[locale] || titles.de,
    description: descriptions[locale] || descriptions.de,
    alternates: {
      canonical: `${BASE_URL}${localePath}`,
      languages: {
        'x-default': `${BASE_URL}/privacy`,
        de: `${BASE_URL}/privacy`,
        en: `${BASE_URL}/en/privacy`,
        sr: `${BASE_URL}/sr/privacy`,
      },
    },
    openGraph: {
      title: titles[locale] || titles.de,
      description: descriptions[locale] || descriptions.de,
      url: `${BASE_URL}${localePath}`,
      type: 'website',
      locale: locale === 'de' ? 'de_DE' : locale === 'sr' ? 'sr_RS' : 'en_US',
      alternateLocale: ['de_DE', 'en_US', 'sr_RS'].filter(l => l !== (locale === 'de' ? 'de_DE' : locale === 'sr' ? 'sr_RS' : 'en_US')),
    },
    robots: {
      index: true,
      follow: true,
    },
  };
}

type PrivacyContent = {
  title: string;
  lastUpdated: string;
  intro: { title: string; content: string };
  controller: { title: string; content: string[] };
  dataCollection: {
    title: string;
    sections: { title: string; content: string; items?: string[] }[];
  };
  cookies: {
    title: string;
    intro: string;
    types: { name: string; purpose: string; duration: string }[];
    management: string;
  };
  thirdParty: {
    title: string;
    services: { name: string; purpose: string; dataProcessed: string; privacy: string }[];
  };
  legalBasis: { title: string; content: string; bases: { basis: string; description: string }[] };
  rights: {
    title: string;
    intro: string;
    items: { right: string; description: string }[];
    contact: string;
  };
  dataRetention: { title: string; content: string };
  dataSecurity: { title: string; content: string };
  changes: { title: string; content: string };
  contact: { title: string; content: string[] };
};

export default async function PrivacyPage({ params }: Props) {
  const { locale } = await params;
  setRequestLocale(locale);

  const content: Record<string, PrivacyContent> = {
    de: {
      title: 'Datenschutzerklärung',
      lastUpdated: 'Zuletzt aktualisiert: Januar 2025',
      intro: {
        title: 'Einleitung',
        content: 'Der Schutz Ihrer persönlichen Daten ist mir ein wichtiges Anliegen. In dieser Datenschutzerklärung informiere ich Sie darüber, wie ich Ihre personenbezogenen Daten bei der Nutzung dieser Website verarbeite. Diese Datenschutzerklärung entspricht den Anforderungen der Datenschutz-Grundverordnung (DSGVO) und des Bundesdatenschutzgesetzes (BDSG).',
      },
      controller: {
        title: 'Verantwortlicher',
        content: [
          'Damjan Savić',
          'Fullstack Developer & Digital Solutions Consultant',
          'E-Mail: info@damjan-savic.com',
          'Website: https://damjan-savic.com',
        ],
      },
      dataCollection: {
        title: 'Datenerfassung auf dieser Website',
        sections: [
          {
            title: 'Automatisch erfasste Daten',
            content: 'Beim Besuch dieser Website werden automatisch technische Daten erfasst:',
            items: [
              'IP-Adresse (anonymisiert)',
              'Datum und Uhrzeit des Zugriffs',
              'Browsertyp und -version',
              'Betriebssystem',
              'Referrer-URL (zuvor besuchte Seite)',
              'Aufgerufene Seiten auf dieser Website',
            ],
          },
          {
            title: 'Kontaktformular und Chatbot',
            content: 'Wenn Sie das Kontaktformular oder den KI-Chatbot nutzen, werden folgende Daten verarbeitet:',
            items: [
              'Ihre Nachricht und Anfrage',
              'E-Mail-Adresse (bei Kontaktformular)',
              'Zeitpunkt der Anfrage',
              'Anonyme Besucher-ID (für Chat-Verlauf)',
            ],
          },
        ],
      },
      cookies: {
        title: 'Cookies und lokaler Speicher',
        intro: 'Diese Website verwendet Cookies und lokalen Browserspeicher, um die Funktionalität zu gewährleisten und die Nutzererfahrung zu verbessern.',
        types: [
          { name: 'Technisch notwendige Cookies', purpose: 'Spracheinstellungen, Session-Management', duration: 'Sitzung oder bis zu 1 Jahr' },
          { name: 'Analyse-Cookies (Google Analytics)', purpose: 'Websitestatistiken, Nutzerverhalten', duration: 'Bis zu 2 Jahre' },
          { name: 'Lokaler Speicher', purpose: 'Chatbot-Besucher-ID, Theme-Einstellungen', duration: 'Unbegrenzt (bis manuell gelöscht)' },
        ],
        management: 'Sie können Cookies in Ihren Browsereinstellungen verwalten oder deaktivieren. Beachten Sie, dass das Deaktivieren bestimmter Cookies die Funktionalität der Website beeinträchtigen kann.',
      },
      thirdParty: {
        title: 'Drittanbieter-Dienste',
        services: [
          {
            name: 'Google Analytics',
            purpose: 'Analyse des Nutzerverhaltens und der Website-Performance zur Verbesserung meiner Dienste.',
            dataProcessed: 'Anonymisierte IP-Adressen, Seitenaufrufe, Verweildauer, Geräte- und Browserinformationen, Standort (auf Länderebene).',
            privacy: 'https://policies.google.com/privacy',
          },
          {
            name: 'Supabase',
            purpose: 'Speicherung von Chat-Verläufen und Kontaktanfragen in einer sicheren Datenbank.',
            dataProcessed: 'Chatnachrichten, anonyme Besucher-IDs, Zeitstempel, Kontaktformular-Daten.',
            privacy: 'https://supabase.com/privacy',
          },
          {
            name: 'Deepseek API',
            purpose: 'KI-gestützter Chatbot für Besucheranfragen und Portfolio-Informationen.',
            dataProcessed: 'Chatnachrichten werden an Deepseek übermittelt, um KI-Antworten zu generieren.',
            privacy: 'https://www.deepseek.com/privacy',
          },
          {
            name: 'Vercel',
            purpose: 'Hosting der Website und Bereitstellung von Edge-Funktionen.',
            dataProcessed: 'Server-Logs, IP-Adressen (für Sicherheit und Performance).',
            privacy: 'https://vercel.com/legal/privacy-policy',
          },
        ],
      },
      legalBasis: {
        title: 'Rechtsgrundlagen der Verarbeitung',
        content: 'Die Verarbeitung Ihrer personenbezogenen Daten erfolgt auf folgenden Rechtsgrundlagen gemäß DSGVO:',
        bases: [
          { basis: 'Art. 6 Abs. 1 lit. a DSGVO', description: 'Einwilligung – für Analytics und nicht-essenzielle Cookies' },
          { basis: 'Art. 6 Abs. 1 lit. b DSGVO', description: 'Vertragserfüllung – für die Bearbeitung von Kontaktanfragen' },
          { basis: 'Art. 6 Abs. 1 lit. f DSGVO', description: 'Berechtigte Interessen – für technisch notwendige Datenverarbeitung und Website-Sicherheit' },
        ],
      },
      rights: {
        title: 'Ihre Rechte',
        intro: 'Gemäß DSGVO haben Sie folgende Rechte bezüglich Ihrer personenbezogenen Daten:',
        items: [
          { right: 'Auskunftsrecht (Art. 15 DSGVO)', description: 'Sie können Auskunft über Ihre bei mir gespeicherten personenbezogenen Daten verlangen.' },
          { right: 'Recht auf Berichtigung (Art. 16 DSGVO)', description: 'Sie können die Berichtigung unrichtiger oder Vervollständigung Ihrer Daten verlangen.' },
          { right: 'Recht auf Löschung (Art. 17 DSGVO)', description: 'Sie können die Löschung Ihrer Daten verlangen, sofern keine Aufbewahrungspflichten bestehen.' },
          { right: 'Recht auf Einschränkung (Art. 18 DSGVO)', description: 'Sie können die Einschränkung der Verarbeitung Ihrer Daten verlangen.' },
          { right: 'Recht auf Datenübertragbarkeit (Art. 20 DSGVO)', description: 'Sie können Ihre Daten in einem gängigen Format erhalten.' },
          { right: 'Widerspruchsrecht (Art. 21 DSGVO)', description: 'Sie können der Verarbeitung Ihrer Daten jederzeit widersprechen.' },
          { right: 'Recht auf Widerruf (Art. 7 Abs. 3 DSGVO)', description: 'Sie können Ihre Einwilligung jederzeit mit Wirkung für die Zukunft widerrufen.' },
          { right: 'Beschwerderecht (Art. 77 DSGVO)', description: 'Sie haben das Recht, sich bei einer Aufsichtsbehörde zu beschweren.' },
        ],
        contact: 'Zur Ausübung Ihrer Rechte kontaktieren Sie mich bitte unter: info@damjan-savic.com',
      },
      dataRetention: {
        title: 'Speicherdauer',
        content: 'Personenbezogene Daten werden nur so lange gespeichert, wie es für den jeweiligen Zweck erforderlich ist. Kontaktanfragen werden in der Regel nach 3 Jahren gelöscht, sofern keine längeren Aufbewahrungspflichten bestehen. Chat-Verläufe werden nach 24 Stunden automatisch gelöscht oder anonymisiert. Analytics-Daten werden gemäß den Google Analytics-Richtlinien gespeichert (bis zu 26 Monate).',
      },
      dataSecurity: {
        title: 'Datensicherheit',
        content: 'Diese Website verwendet SSL/TLS-Verschlüsselung für eine sichere Datenübertragung. Ich setze technische und organisatorische Maßnahmen ein, um Ihre Daten vor unbefugtem Zugriff, Verlust oder Missbrauch zu schützen. Alle Drittanbieter-Dienste werden sorgfältig ausgewählt und müssen angemessene Datenschutzstandards einhalten.',
      },
      changes: {
        title: 'Änderungen dieser Datenschutzerklärung',
        content: 'Ich behalte mir vor, diese Datenschutzerklärung bei Bedarf anzupassen, etwa bei Änderungen der Rechtslage oder bei neuen Funktionen auf der Website. Die aktuelle Version finden Sie stets auf dieser Seite.',
      },
      contact: {
        title: 'Kontakt',
        content: [
          'Bei Fragen zum Datenschutz erreichen Sie mich unter:',
          'Damjan Savić',
          'E-Mail: info@damjan-savic.com',
        ],
      },
    },
    en: {
      title: 'Privacy Policy',
      lastUpdated: 'Last updated: January 2025',
      intro: {
        title: 'Introduction',
        content: 'The protection of your personal data is important to me. In this privacy policy, I inform you about how I process your personal data when using this website. This privacy policy complies with the requirements of the General Data Protection Regulation (GDPR) and the German Federal Data Protection Act (BDSG).',
      },
      controller: {
        title: 'Data Controller',
        content: [
          'Damjan Savić',
          'Fullstack Developer & Digital Solutions Consultant',
          'Email: info@damjan-savic.com',
          'Website: https://damjan-savic.com',
        ],
      },
      dataCollection: {
        title: 'Data Collection on This Website',
        sections: [
          {
            title: 'Automatically Collected Data',
            content: 'When visiting this website, technical data is automatically collected:',
            items: [
              'IP address (anonymized)',
              'Date and time of access',
              'Browser type and version',
              'Operating system',
              'Referrer URL (previously visited page)',
              'Pages visited on this website',
            ],
          },
          {
            title: 'Contact Form and Chatbot',
            content: 'When you use the contact form or AI chatbot, the following data is processed:',
            items: [
              'Your message and inquiry',
              'Email address (for contact form)',
              'Time of inquiry',
              'Anonymous visitor ID (for chat history)',
            ],
          },
        ],
      },
      cookies: {
        title: 'Cookies and Local Storage',
        intro: 'This website uses cookies and local browser storage to ensure functionality and improve user experience.',
        types: [
          { name: 'Technically necessary cookies', purpose: 'Language settings, session management', duration: 'Session or up to 1 year' },
          { name: 'Analytics cookies (Google Analytics)', purpose: 'Website statistics, user behavior', duration: 'Up to 2 years' },
          { name: 'Local storage', purpose: 'Chatbot visitor ID, theme settings', duration: 'Unlimited (until manually deleted)' },
        ],
        management: 'You can manage or disable cookies in your browser settings. Note that disabling certain cookies may affect the functionality of the website.',
      },
      thirdParty: {
        title: 'Third-Party Services',
        services: [
          {
            name: 'Google Analytics',
            purpose: 'Analysis of user behavior and website performance to improve my services.',
            dataProcessed: 'Anonymized IP addresses, page views, time on site, device and browser information, location (country level).',
            privacy: 'https://policies.google.com/privacy',
          },
          {
            name: 'Supabase',
            purpose: 'Storage of chat histories and contact requests in a secure database.',
            dataProcessed: 'Chat messages, anonymous visitor IDs, timestamps, contact form data.',
            privacy: 'https://supabase.com/privacy',
          },
          {
            name: 'Deepseek API',
            purpose: 'AI-powered chatbot for visitor inquiries and portfolio information.',
            dataProcessed: 'Chat messages are transmitted to Deepseek to generate AI responses.',
            privacy: 'https://www.deepseek.com/privacy',
          },
          {
            name: 'Vercel',
            purpose: 'Website hosting and edge function delivery.',
            dataProcessed: 'Server logs, IP addresses (for security and performance).',
            privacy: 'https://vercel.com/legal/privacy-policy',
          },
        ],
      },
      legalBasis: {
        title: 'Legal Basis for Processing',
        content: 'The processing of your personal data is based on the following legal bases under GDPR:',
        bases: [
          { basis: 'Art. 6(1)(a) GDPR', description: 'Consent – for analytics and non-essential cookies' },
          { basis: 'Art. 6(1)(b) GDPR', description: 'Contract performance – for processing contact requests' },
          { basis: 'Art. 6(1)(f) GDPR', description: 'Legitimate interests – for technically necessary data processing and website security' },
        ],
      },
      rights: {
        title: 'Your Rights',
        intro: 'Under GDPR, you have the following rights regarding your personal data:',
        items: [
          { right: 'Right of Access (Art. 15 GDPR)', description: 'You can request information about your personal data stored with me.' },
          { right: 'Right to Rectification (Art. 16 GDPR)', description: 'You can request the correction of inaccurate data or completion of your data.' },
          { right: 'Right to Erasure (Art. 17 GDPR)', description: 'You can request the deletion of your data, provided there are no retention obligations.' },
          { right: 'Right to Restriction (Art. 18 GDPR)', description: 'You can request the restriction of processing of your data.' },
          { right: 'Right to Data Portability (Art. 20 GDPR)', description: 'You can receive your data in a common format.' },
          { right: 'Right to Object (Art. 21 GDPR)', description: 'You can object to the processing of your data at any time.' },
          { right: 'Right to Withdraw Consent (Art. 7(3) GDPR)', description: 'You can withdraw your consent at any time with effect for the future.' },
          { right: 'Right to Lodge a Complaint (Art. 77 GDPR)', description: 'You have the right to lodge a complaint with a supervisory authority.' },
        ],
        contact: 'To exercise your rights, please contact me at: info@damjan-savic.com',
      },
      dataRetention: {
        title: 'Data Retention',
        content: 'Personal data is only stored for as long as necessary for the respective purpose. Contact requests are typically deleted after 3 years, unless longer retention periods apply. Chat histories are automatically deleted or anonymized after 24 hours. Analytics data is stored according to Google Analytics policies (up to 26 months).',
      },
      dataSecurity: {
        title: 'Data Security',
        content: 'This website uses SSL/TLS encryption for secure data transmission. I implement technical and organizational measures to protect your data from unauthorized access, loss, or misuse. All third-party services are carefully selected and must comply with appropriate data protection standards.',
      },
      changes: {
        title: 'Changes to This Privacy Policy',
        content: 'I reserve the right to adapt this privacy policy as needed, for example in the event of changes in the legal situation or new features on the website. The current version can always be found on this page.',
      },
      contact: {
        title: 'Contact',
        content: [
          'For questions about data protection, you can reach me at:',
          'Damjan Savić',
          'Email: info@damjan-savic.com',
        ],
      },
    },
    sr: {
      title: 'Politika privatnosti',
      lastUpdated: 'Poslednje ažuriranje: Januar 2025',
      intro: {
        title: 'Uvod',
        content: 'Zaštita vaših ličnih podataka je za mene važna. U ovoj politici privatnosti vas informišem o tome kako obrađujem vaše lične podatke prilikom korišćenja ove web stranice. Ova politika privatnosti je u skladu sa zahtevima Opšte uredbe o zaštiti podataka (GDPR) i nemačkog Saveznog zakona o zaštiti podataka (BDSG).',
      },
      controller: {
        title: 'Rukovalac podataka',
        content: [
          'Damjan Savić',
          'Fullstack Developer & Digital Solutions Consultant',
          'Email: info@damjan-savic.com',
          'Website: https://damjan-savic.com',
        ],
      },
      dataCollection: {
        title: 'Prikupljanje podataka na ovoj web stranici',
        sections: [
          {
            title: 'Automatski prikupljeni podaci',
            content: 'Prilikom posete ovoj web stranici, automatski se prikupljaju tehnički podaci:',
            items: [
              'IP adresa (anonimizirana)',
              'Datum i vreme pristupa',
              'Tip i verzija pretraživača',
              'Operativni sistem',
              'Referrer URL (prethodno posećena stranica)',
              'Stranice posećene na ovoj web stranici',
            ],
          },
          {
            title: 'Kontakt forma i Chatbot',
            content: 'Kada koristite kontakt formu ili AI chatbot, obrađuju se sledeći podaci:',
            items: [
              'Vaša poruka i upit',
              'Email adresa (za kontakt formu)',
              'Vreme upita',
              'Anonimni ID posetioca (za istoriju četa)',
            ],
          },
        ],
      },
      cookies: {
        title: 'Kolačići i lokalno skladište',
        intro: 'Ova web stranica koristi kolačiće i lokalno skladište pretraživača kako bi se obezbedila funkcionalnost i poboljšalo korisničko iskustvo.',
        types: [
          { name: 'Tehnički neophodni kolačići', purpose: 'Jezička podešavanja, upravljanje sesijom', duration: 'Sesija ili do 1 godine' },
          { name: 'Analitički kolačići (Google Analytics)', purpose: 'Statistika web stranice, ponašanje korisnika', duration: 'Do 2 godine' },
          { name: 'Lokalno skladište', purpose: 'ID posetioca chatbota, podešavanja teme', duration: 'Neograničeno (dok se ručno ne obriše)' },
        ],
        management: 'Možete upravljati kolačićima ili ih onemogućiti u podešavanjima pretraživača. Imajte na umu da onemogućavanje određenih kolačića može uticati na funkcionalnost web stranice.',
      },
      thirdParty: {
        title: 'Usluge trećih strana',
        services: [
          {
            name: 'Google Analytics',
            purpose: 'Analiza ponašanja korisnika i performansi web stranice radi poboljšanja mojih usluga.',
            dataProcessed: 'Anonimizovane IP adrese, pregledi stranica, vreme na sajtu, informacije o uređaju i pretraživaču, lokacija (nivo zemlje).',
            privacy: 'https://policies.google.com/privacy',
          },
          {
            name: 'Supabase',
            purpose: 'Skladištenje istorije četova i kontakt zahteva u sigurnoj bazi podataka.',
            dataProcessed: 'Poruke iz četa, anonimni ID-jevi posetilaca, vremenske oznake, podaci iz kontakt forme.',
            privacy: 'https://supabase.com/privacy',
          },
          {
            name: 'Deepseek API',
            purpose: 'AI chatbot za upite posetilaca i informacije o portfoliju.',
            dataProcessed: 'Poruke iz četa se šalju Deepseek-u radi generisanja AI odgovora.',
            privacy: 'https://www.deepseek.com/privacy',
          },
          {
            name: 'Vercel',
            purpose: 'Hosting web stranice i isporuka edge funkcija.',
            dataProcessed: 'Serverski logovi, IP adrese (za sigurnost i performanse).',
            privacy: 'https://vercel.com/legal/privacy-policy',
          },
        ],
      },
      legalBasis: {
        title: 'Pravni osnov za obradu',
        content: 'Obrada vaših ličnih podataka se zasniva na sledećim pravnim osnovama prema GDPR:',
        bases: [
          { basis: 'Član 6(1)(a) GDPR', description: 'Pristanak – za analitiku i kolačiće koji nisu neophodni' },
          { basis: 'Član 6(1)(b) GDPR', description: 'Izvršenje ugovora – za obradu kontakt zahteva' },
          { basis: 'Član 6(1)(f) GDPR', description: 'Legitimni interesi – za tehnički neophodnu obradu podataka i sigurnost web stranice' },
        ],
      },
      rights: {
        title: 'Vaša prava',
        intro: 'Prema GDPR, imate sledeća prava u vezi sa vašim ličnim podacima:',
        items: [
          { right: 'Pravo na pristup (Član 15 GDPR)', description: 'Možete zatražiti informacije o vašim ličnim podacima koji su kod mene uskladišteni.' },
          { right: 'Pravo na ispravku (Član 16 GDPR)', description: 'Možete zatražiti ispravku netačnih podataka ili dopunu vaših podataka.' },
          { right: 'Pravo na brisanje (Član 17 GDPR)', description: 'Možete zatražiti brisanje vaših podataka, ukoliko nema obaveze čuvanja.' },
          { right: 'Pravo na ograničenje (Član 18 GDPR)', description: 'Možete zatražiti ograničenje obrade vaših podataka.' },
          { right: 'Pravo na prenosivost podataka (Član 20 GDPR)', description: 'Možete dobiti vaše podatke u uobičajenom formatu.' },
          { right: 'Pravo na prigovor (Član 21 GDPR)', description: 'Možete se usprotiviti obradi vaših podataka u bilo kom trenutku.' },
          { right: 'Pravo na povlačenje pristanka (Član 7(3) GDPR)', description: 'Možete povući svoj pristanak u bilo kom trenutku sa dejstvom za budućnost.' },
          { right: 'Pravo na žalbu (Član 77 GDPR)', description: 'Imate pravo da podnesete žalbu nadzornom organu.' },
        ],
        contact: 'Da biste ostvarili svoja prava, kontaktirajte me na: info@damjan-savic.com',
      },
      dataRetention: {
        title: 'Zadržavanje podataka',
        content: 'Lični podaci se čuvaju samo onoliko dugo koliko je potrebno za odgovarajuću svrhu. Kontakt zahtevi se obično brišu nakon 3 godine, osim ako se primenjuju duži rokovi čuvanja. Istorija četova se automatski briše ili anonimizuje nakon 24 sata. Analitički podaci se čuvaju prema politikama Google Analytics-a (do 26 meseci).',
      },
      dataSecurity: {
        title: 'Sigurnost podataka',
        content: 'Ova web stranica koristi SSL/TLS enkripciju za siguran prenos podataka. Primenjujem tehničke i organizacione mere za zaštitu vaših podataka od neovlašćenog pristupa, gubitka ili zloupotrebe. Sve usluge trećih strana su pažljivo odabrane i moraju se pridržavati odgovarajućih standarda zaštite podataka.',
      },
      changes: {
        title: 'Izmene ove politike privatnosti',
        content: 'Zadržavam pravo da prilagodim ovu politiku privatnosti po potrebi, na primer u slučaju promena u pravnoj situaciji ili novih funkcija na web stranici. Aktuelna verzija se uvek može naći na ovoj stranici.',
      },
      contact: {
        title: 'Kontakt',
        content: [
          'Za pitanja o zaštiti podataka, možete me kontaktirati na:',
          'Damjan Savić',
          'Email: info@damjan-savic.com',
        ],
      },
    },
  };

  const c = content[locale] || content.de;

  return (
    <main className="min-h-screen py-16 sm:py-20 lg:py-24">
      <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
        {/* Breadcrumb */}
        <nav className="mb-8">
          <Link
            href={`/${locale}`}
            className="text-zinc-400 hover:text-white transition-colors"
          >
            Home
          </Link>
          <span className="mx-2 text-zinc-600">/</span>
          <span className="text-white">{c.title}</span>
        </nav>

        <h1 className="text-4xl font-bold text-white mb-2">{c.title}</h1>
        <p className="text-zinc-400 mb-8">{c.lastUpdated}</p>

        <div className="prose prose-invert max-w-none space-y-8">
          {/* Introduction */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.intro.title}</h2>
            <p className="text-zinc-300">{c.intro.content}</p>
          </section>

          {/* Data Controller */}
          <section className="bg-zinc-900/50 p-6 rounded-xl ring-1 ring-zinc-800">
            <h2 className="text-2xl font-semibold text-white mb-4">{c.controller.title}</h2>
            <div className="text-zinc-300 space-y-1">
              {c.controller.content.map((line, index) => (
                <p key={index}>{line}</p>
              ))}
            </div>
          </section>

          {/* Data Collection */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.dataCollection.title}</h2>
            {c.dataCollection.sections.map((section, index) => (
              <div key={index} className="mb-6">
                <h3 className="text-xl font-medium text-white mb-2">{section.title}</h3>
                <p className="text-zinc-300 mb-2">{section.content}</p>
                {section.items && (
                  <ul className="list-disc list-inside text-zinc-300 space-y-1 ml-4">
                    {section.items.map((item, itemIndex) => (
                      <li key={itemIndex}>{item}</li>
                    ))}
                  </ul>
                )}
              </div>
            ))}
          </section>

          {/* Cookies */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.cookies.title}</h2>
            <p className="text-zinc-300 mb-4">{c.cookies.intro}</p>
            <div className="overflow-x-auto">
              <table className="w-full text-left border-collapse">
                <thead>
                  <tr className="border-b border-zinc-700">
                    <th className="py-2 pr-4 text-white font-semibold">Cookie</th>
                    <th className="py-2 pr-4 text-white font-semibold">{locale === 'de' ? 'Zweck' : locale === 'sr' ? 'Svrha' : 'Purpose'}</th>
                    <th className="py-2 text-white font-semibold">{locale === 'de' ? 'Dauer' : locale === 'sr' ? 'Trajanje' : 'Duration'}</th>
                  </tr>
                </thead>
                <tbody>
                  {c.cookies.types.map((cookie, index) => (
                    <tr key={index} className="border-b border-zinc-800">
                      <td className="py-3 pr-4 text-zinc-300">{cookie.name}</td>
                      <td className="py-3 pr-4 text-zinc-400">{cookie.purpose}</td>
                      <td className="py-3 text-zinc-400">{cookie.duration}</td>
                    </tr>
                  ))}
                </tbody>
              </table>
            </div>
            <p className="text-zinc-400 mt-4 text-sm">{c.cookies.management}</p>
          </section>

          {/* Third-Party Services */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.thirdParty.title}</h2>
            <div className="space-y-6">
              {c.thirdParty.services.map((service, index) => (
                <div key={index} className="bg-zinc-900/30 p-5 rounded-lg ring-1 ring-zinc-800">
                  <h3 className="text-xl font-medium text-white mb-2">{service.name}</h3>
                  <p className="text-zinc-300 mb-2">
                    <strong className="text-zinc-200">{locale === 'de' ? 'Zweck:' : locale === 'sr' ? 'Svrha:' : 'Purpose:'}</strong> {service.purpose}
                  </p>
                  <p className="text-zinc-300 mb-2">
                    <strong className="text-zinc-200">{locale === 'de' ? 'Verarbeitete Daten:' : locale === 'sr' ? 'Obrađeni podaci:' : 'Data processed:'}</strong> {service.dataProcessed}
                  </p>
                  <p className="text-zinc-400 text-sm">
                    <strong className="text-zinc-300">{locale === 'de' ? 'Datenschutz:' : locale === 'sr' ? 'Privatnost:' : 'Privacy:'}</strong>{' '}
                    <a
                      href={service.privacy}
                      target="_blank"
                      rel="noopener noreferrer"
                      className="text-orange-500 hover:text-orange-400 underline"
                    >
                      {service.privacy}
                    </a>
                  </p>
                </div>
              ))}
            </div>
          </section>

          {/* Legal Basis */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.legalBasis.title}</h2>
            <p className="text-zinc-300 mb-4">{c.legalBasis.content}</p>
            <ul className="space-y-2">
              {c.legalBasis.bases.map((item, index) => (
                <li key={index} className="text-zinc-300">
                  <strong className="text-white">{item.basis}:</strong> {item.description}
                </li>
              ))}
            </ul>
          </section>

          {/* User Rights */}
          <section className="bg-zinc-900/50 p-6 rounded-xl ring-1 ring-zinc-800">
            <h2 className="text-2xl font-semibold text-white mb-4">{c.rights.title}</h2>
            <p className="text-zinc-300 mb-4">{c.rights.intro}</p>
            <ul className="space-y-3">
              {c.rights.items.map((item, index) => (
                <li key={index} className="text-zinc-300">
                  <strong className="text-white">{item.right}</strong>
                  <br />
                  <span className="text-zinc-400">{item.description}</span>
                </li>
              ))}
            </ul>
            <p className="text-orange-500 mt-4 font-medium">{c.rights.contact}</p>
          </section>

          {/* Data Retention */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.dataRetention.title}</h2>
            <p className="text-zinc-300">{c.dataRetention.content}</p>
          </section>

          {/* Data Security */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.dataSecurity.title}</h2>
            <p className="text-zinc-300">{c.dataSecurity.content}</p>
          </section>

          {/* Changes */}
          <section>
            <h2 className="text-2xl font-semibold text-white mb-4">{c.changes.title}</h2>
            <p className="text-zinc-300">{c.changes.content}</p>
          </section>

          {/* Contact */}
          <section className="bg-zinc-900/50 p-6 rounded-xl ring-1 ring-zinc-800">
            <h2 className="text-2xl font-semibold text-white mb-4">{c.contact.title}</h2>
            <div className="text-zinc-300 space-y-1">
              {c.contact.content.map((line, index) => (
                <p key={index}>{line}</p>
              ))}
            </div>
          </section>

          {/* Link to Imprint */}
          <section>
            <p className="text-zinc-400">
              {locale === 'de'
                ? 'Weitere rechtliche Informationen finden Sie im'
                : locale === 'sr'
                  ? 'Dodatne pravne informacije možete pronaći u'
                  : 'For more legal information, please see the'}{' '}
              <Link
                href={`/${locale}/imprint`}
                className="text-orange-500 hover:text-orange-400 underline"
              >
                {locale === 'de' ? 'Impressum' : locale === 'sr' ? 'Pravno obaveštenje' : 'Legal Notice'}
              </Link>
              .
            </p>
          </section>
        </div>
      </div>
    </main>
  );
}
