<?php
session_start();

// Sprache ermitteln (URL-Parameter hat immer Vorrang)
$supported_langs = ['de', 'en', 'fr', 'es'];
if (isset($_GET['lang']) && in_array($_GET['lang'], $supported_langs)) {
    $lang = $_GET['lang'];
} elseif (isset($_SESSION['lang']) && in_array($_SESSION['lang'], $supported_langs)) {
    $lang = $_SESSION['lang'];
} else {
    $lang = 'de';
}
$_SESSION['lang'] = $lang;

// Übersetzungen
$translations = [
    'de' => [
        'page_title' => 'RAR-Posting-Tool – Yoshi Tools',
        'title' => 'RAR-Posting-Tool',
        'subtitle' => 'RAR-Dateien ver- und entschlüsseln und Posting-Infos vorbereiten',
        'description' => 'Unser RAR-Posting-Tool vereinfacht die Arbeit mit verschlüsselten RAR-Archiven und automatisiert die Erstellung von Posting-Informationen.',
        'features_title' => 'Funktionen',
        'features' => [
            'RAR-Dateien mit Passwort verschlüsseln',
            'Verschlüsselte RAR-Archive entschlüsseln',
            'Automatische Posting-Info-Generierung',
            'Dateilisten und Größenangaben erstellen',
            'Hash-Werte (MD5, SHA1) berechnen',
            'NFO-Dateien generieren'
        ],
        'coming_soon' => 'Dieses Tool wird bald verfügbar sein!',
        'back' => '← Zurück zur Startseite'
    ],
    'en' => [
        'page_title' => 'RAR Posting Tool – Yoshi Tools',
        'title' => 'RAR Posting Tool',
        'subtitle' => 'Encrypt/decrypt RAR files and prepare posting details',
        'description' => 'Our RAR posting tool simplifies working with encrypted RAR archives and automates the creation of posting information.',
        'features_title' => 'Features',
        'features' => [
            'Encrypt RAR files with password',
            'Decrypt encrypted RAR archives',
            'Automatic posting info generation',
            'Create file lists and size information',
            'Calculate hash values (MD5, SHA1)',
            'Generate NFO files'
        ],
        'coming_soon' => 'This tool will be available soon!',
        'back' => '← Back to homepage'
    ],
    'fr' => [
        'page_title' => 'Outil de publication RAR – Yoshi Tools',
        'title' => 'Outil de publication RAR',
        'subtitle' => 'Chiffrer/déchiffrer des fichiers RAR et préparer les infos de publication',
        'description' => 'Notre outil de publication RAR simplifie le travail avec les archives RAR chiffrées et automatise la création des informations de publication.',
        'features_title' => 'Fonctionnalités',
        'features' => [
            'Chiffrer les fichiers RAR avec mot de passe',
            'Déchiffrer les archives RAR chiffrées',
            'Génération automatique des infos de publication',
            'Créer des listes de fichiers et informations de taille',
            'Calculer les valeurs de hachage (MD5, SHA1)',
            'Générer des fichiers NFO'
        ],
        'coming_soon' => 'Cet outil sera bientôt disponible !',
        'back' => '← Retour à la page d\'accueil'
    ],
    'es' => [
        'page_title' => 'Herramienta de publicación RAR – Yoshi Tools',
        'title' => 'Herramienta de publicación RAR',
        'subtitle' => 'Cifra/descifra archivos RAR y prepara los detalles para publicar',
        'description' => 'Nuestra herramienta de publicación RAR simplifica el trabajo con archivos RAR cifrados y automatiza la creación de información de publicación.',
        'features_title' => 'Características',
        'features' => [
            'Cifrar archivos RAR con contraseña',
            'Descifrar archivos RAR cifrados',
            'Generación automática de info de publicación',
            'Crear listas de archivos e información de tamaño',
            'Calcular valores hash (MD5, SHA1)',
            'Generar archivos NFO'
        ],
        'coming_soon' => '¡Esta herramienta estará disponible pronto!',
        'back' => '← Volver a la página principal'
    ]
];

$t = $translations[$lang];
?>
<!doctype html>
<html lang="<?php echo $lang; ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $t['page_title']; ?></title>
<style>
html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: url('assets/backgrounds/background2.png') center/cover no-repeat fixed;
  min-height: 100vh;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 24px;
}

.card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  color: #222;
}

.subtitle {
  color: #666;
  font-size: 15px;
  margin-bottom: 20px;
}

.description {
  color: #444;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.features-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 12px;
}

.features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
}

.features-list li {
  padding: 8px 0 8px 28px;
  position: relative;
  color: #444;
  font-size: 14px;
}

.features-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #56ab2f;
  font-weight: 700;
}

.coming-soon-badge {
  background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 20px;
}

/* Language Switcher */
.lang-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.lang-btn {
  width: 36px;
  height: 26px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  padding: 0;
  background: #fff;
  text-decoration: none;
  display: block;
}

.lang-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.lang-btn.active {
  border-color: #FFD700;
  box-shadow: 0 0 12px 3px rgba(255,215,0,0.6), 0 4px 12px rgba(0,0,0,0.3);
  transform: scale(1.15);
}

.lang-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.back-link {
  display: inline-block;
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.back-link:hover {
  text-decoration: underline;
}
</style>
</head>
<body>

<!-- Language Switcher -->
<div class="lang-switcher">
  <a href="produkt-rar.php?lang=de" class="lang-btn <?php echo $lang === 'de' ? 'active' : ''; ?>" title="Deutsch">
    <svg viewBox="0 0 5 3"><rect width="5" height="1" y="0" fill="#000"/><rect width="5" height="1" y="1" fill="#D00"/><rect width="5" height="1" y="2" fill="#FFCE00"/></svg>
  </a>
  <a href="produkt-rar.php?lang=en" class="lang-btn <?php echo $lang === 'en' ? 'active' : ''; ?>" title="English">
    <svg viewBox="0 0 60 30"><clipPath id="s"><path d="M0,0 v30 h60 v-30 z"/></clipPath><clipPath id="t"><path d="M30,15 h30 v15 z v15 h-30 z h-30 v-15 z v-15 h30 z"/></clipPath><g clip-path="url(#s)"><path d="M0,0 v30 h60 v-30 z" fill="#012169"/><path d="M0,0 L60,30 M60,0 L0,30" stroke="#fff" stroke-width="6"/><path d="M0,0 L60,30 M60,0 L0,30" clip-path="url(#t)" stroke="#C8102E" stroke-width="4"/><path d="M30,0 v30 M0,15 h60" stroke="#fff" stroke-width="10"/><path d="M30,0 v30 M0,15 h60" stroke="#C8102E" stroke-width="6"/></g></svg>
  </a>
  <a href="produkt-rar.php?lang=fr" class="lang-btn <?php echo $lang === 'fr' ? 'active' : ''; ?>" title="Français">
    <svg viewBox="0 0 3 2"><rect width="1" height="2" x="0" fill="#002395"/><rect width="1" height="2" x="1" fill="#fff"/><rect width="1" height="2" x="2" fill="#ED2939"/></svg>
  </a>
  <a href="produkt-rar.php?lang=es" class="lang-btn <?php echo $lang === 'es' ? 'active' : ''; ?>" title="Español">
    <svg viewBox="0 0 3 2"><rect width="3" height="2" fill="#AA151B"/><rect width="3" height="1" y="0.5" fill="#F1BF00"/></svg>
  </a>
</div>

<div class="container">
  <div class="card">
    <h1><?php echo $t['title']; ?></h1>
    <p class="subtitle"><?php echo $t['subtitle']; ?></p>

    <p class="description"><?php echo $t['description']; ?></p>

    <h2 class="features-title"><?php echo $t['features_title']; ?></h2>
    <ul class="features-list">
      <?php foreach ($t['features'] as $feature): ?>
        <li><?php echo $feature; ?></li>
      <?php endforeach; ?>
    </ul>

    <div class="coming-soon-badge">
      <?php echo $t['coming_soon']; ?>
    </div>

    <a href="index.html" class="back-link"><?php echo $t['back']; ?></a>
  </div>
</div>

</body>
</html>
