<?php
require_once dirname(__DIR__) . '/version.php';
if (!isset($product) || !is_array($product)) {
    http_response_code(404);
    exit;
}

$esc = static function ($value) {
    return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
};
$baseUrl = 'https://msmanuf.com/wp/productos/';
$canonical = $baseUrl . $product['slug'] . '.php';
$language = $product['lang'];
$translations = [
    'es' => [
        'locale' => 'es_AR', 'home' => '../index-es.php', 'all' => 'Todos los productos',
        'talk' => 'Hablemos de su proyecto', 'talkText' => 'Cuéntenos qué necesita mejorar. Nuestro equipo puede ayudarlo desde el análisis hasta la implementación.',
        'contact' => 'Solicitar una consulta', 'other' => 'Otros productos', 'version' => 'Versión',
        'privacy' => 'Política de privacidad', 'privacyUrl' => '../legal/politica-de-privacidad.php',
        'terms' => 'Términos de uso', 'termsUrl' => '../legal/terminos-de-uso.php',
        'skip' => 'Saltar al contenido principal',
        'products' => [
            'gestion-retail.php' => 'Gestión para retail',
            'plataforma-tarjetas-credito.php' => 'Plataforma de tarjetas de crédito',
            'workflow-digitalizacion.php' => 'Workflow y digitalización',
            'integracion-pos.php' => 'Integración POS'
        ]
    ],
    'en' => [
        'locale' => 'en_US', 'home' => '../index-en.php', 'all' => 'All products',
        'talk' => 'Let’s discuss your project', 'talkText' => 'Tell us what you need to improve. Our team can help from analysis through implementation.',
        'contact' => 'Request a consultation', 'other' => 'Other products', 'version' => 'Version',
        'privacy' => 'Privacy Policy', 'privacyUrl' => '../legal/privacy-policy.php',
        'terms' => 'Terms of Use', 'termsUrl' => '../legal/terms-of-use.php',
        'skip' => 'Skip to main content',
        'products' => [
            'retail-management.php' => 'Retail management',
            'credit-card-platform.php' => 'Credit card platform',
            'workflow-digitalization.php' => 'Workflow and digitalization',
            'pos-integration.php' => 'POS integration'
        ]
    ],
    'pt' => [
        'locale' => 'pt_BR', 'home' => '../index-pt.php', 'all' => 'Todos os produtos',
        'talk' => 'Vamos conversar sobre o seu projeto', 'talkText' => 'Conte o que precisa melhorar. Nossa equipe pode ajudar desde a análise até a implementação.',
        'contact' => 'Solicitar uma consulta', 'other' => 'Outros produtos', 'version' => 'Versão',
        'privacy' => 'Política de privacidade', 'privacyUrl' => '../legal/politica-de-privacidade.php',
        'terms' => 'Termos de uso', 'termsUrl' => '../legal/termos-de-uso.php',
        'skip' => 'Ir para o conteúdo principal',
        'products' => [
            'gestao-varejo.php' => 'Gestão para varejo',
            'plataforma-cartoes-credito.php' => 'Plataforma de cartões de crédito',
            'workflow-digitalizacao.php' => 'Workflow e digitalização',
            'integracao-pos.php' => 'Integração POS'
        ]
    ]
];
$ui = $translations[$language] ?? $translations['es'];
$schema = [
    '@context' => 'https://schema.org',
    '@type' => 'WebPage',
    'name' => $product['title'],
    'description' => $product['meta'],
    'inLanguage' => $language,
    'url' => $canonical,
    'about' => [
        '@type' => 'Product',
        'name' => $product['title'],
        'brand' => ['@type' => 'Organization', 'name' => 'MS Manufacturing Solutions']
    ]
];
?>
<!DOCTYPE html>
<html lang="<?php echo $esc($language); ?>">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="<?php echo $esc($product['meta']); ?>">
  <meta name="robots" content="index, follow, max-image-preview:large">
  <title><?php echo $esc($product['title']); ?> | MS</title>
  <link rel="canonical" href="<?php echo $esc($canonical); ?>">
  <?php foreach ($product['alternates'] as $code => $url): ?>
  <link rel="alternate" hreflang="<?php echo $esc($code); ?>" href="<?php echo $esc($url); ?>">
  <?php endforeach; ?>
  <meta property="og:type" content="website">
  <meta property="og:locale" content="<?php echo $esc($ui['locale']); ?>">
  <meta property="og:title" content="<?php echo $esc($product['title']); ?> | MS">
  <meta property="og:description" content="<?php echo $esc($product['meta']); ?>">
  <meta property="og:url" content="<?php echo $esc($canonical); ?>">
  <meta property="og:image" content="https://msmanuf.com/wp/img/og-ms-solutions.png">
  <meta name="twitter:card" content="summary_large_image">
  <script type="application/ld+json"><?php echo json_encode($schema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?></script>
  <link rel="icon" href="../img/ms-logo-192.png" type="image/png" sizes="192x192">
  <link rel="apple-touch-icon" href="../img/ms-logo-192.png">
  <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="../css/agency.min.css?v=20260902-2" rel="stylesheet">
  <link href="../css/seo.css?v=3.5.0" rel="stylesheet">
</head>
<body class="service-page">
  <a class="sr-only sr-only-focusable" href="#main-content"><?php echo $esc($ui['skip']); ?></a>
  <nav class="navbar navbar-dark fixed-top" id="mainNav">
    <div class="container">
      <a class="navbar-brand" href="<?php echo $esc($ui['home']); ?>"><img src="../img/logos/logoMS.png" alt="MS Manufacturing Solutions" width="200" height="30" decoding="async" fetchpriority="high"></a>
      <a class="btn btn-outline-light" href="<?php echo $esc($ui['home']); ?>#productos"><?php echo $esc($ui['all']); ?></a>
    </div>
  </nav>
  <header class="service-header">
    <div class="container">
      <p class="text-uppercase mb-3">MS Manufacturing Solutions</p>
      <h1><?php echo $esc($product['title']); ?></h1>
      <p class="lead mt-4"><?php echo $esc($product['lead']); ?></p>
    </div>
  </header>
  <main class="service-content" id="main-content">
    <div class="container"><div class="row">
      <article class="col-lg-8">
        <?php foreach ($product['sections'] as $section): ?>
          <section>
            <h2><?php echo $esc($section['title']); ?></h2>
            <?php foreach ($section['paragraphs'] as $paragraph): ?><p><?php echo $esc($paragraph); ?></p><?php endforeach; ?>
            <?php if (!empty($section['items'])): ?><ul>
              <?php foreach ($section['items'] as $item): ?><li><?php echo $esc($item); ?></li><?php endforeach; ?>
            </ul><?php endif; ?>
          </section>
        <?php endforeach; ?>
      </article>
      <aside class="col-lg-4 mt-4 mt-lg-0">
        <div class="service-cta">
          <h2 class="text-white mt-0"><?php echo $esc($ui['talk']); ?></h2>
          <p><?php echo $esc($ui['talkText']); ?></p>
          <a class="btn btn-primary btn-xl" href="<?php echo $esc($ui['home']); ?>#contact"><?php echo $esc($ui['contact']); ?></a>
        </div>
        <div class="service-list mt-4"><h2><?php echo $esc($ui['other']); ?></h2><ul>
          <?php foreach ($ui['products'] as $url => $title): if ($url === $product['slug'] . '.php') continue; ?>
            <li><a href="<?php echo $esc($url); ?>"><?php echo $esc($title); ?></a></li>
          <?php endforeach; ?>
        </ul></div>
      </aside>
    </div></div>
  </main>
  <footer class="legal-footer"><div class="container">
    <p>&copy; MS Manufacturing Solutions 2018&ndash;<?php echo date('Y'); ?> · <a href="mailto:info@msmanuf.com">info@msmanuf.com</a></p>
    <p><a href="<?php echo $esc($ui['privacyUrl']); ?>"><?php echo $esc($ui['privacy']); ?></a> · <a href="<?php echo $esc($ui['termsUrl']); ?>"><?php echo $esc($ui['terms']); ?></a></p>
    <p class="site-version"><?php echo $esc($ui['version']); ?> <?php echo SITE_VERSION; ?></p>
  </div></footer>
</body>
</html>
