<!doctype html>
<html lang="es">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, viewport-fit=cover" />
    <title>MARIS AI — Plataforma de Inteligencia y Análisis de Casos Marítimos</title>
    <meta name="description" content="Plataforma de inteligencia y análisis de casos complejos con gestión documental, evidencias, cronología, mapas, Knowledge Graph e hipótesis asistidas por IA." />
    
    <!-- PWA Manifest -->
    <link rel="manifest" href="/manifest.webmanifest" />
    <link rel="alternate" type="application/json" href="/manifest.json" />

    <!-- Icons & Favicon -->
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <link rel="icon" type="image/png" sizes="64x64" href="/favicon.png" />
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />

    <!-- PWA & Mobile Web Capabilities -->
    <meta name="theme-color" content="#0F4C81" />
    <meta name="mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="apple-mobile-web-app-title" content="MARIS AI" />
    <meta name="application-name" content="MARIS AI" />
    <meta name="format-detection" content="telephone=no" />
  </head>
  <body class="bg-slate-50 text-slate-900 antialiased selection:bg-blue-500 selection:text-white">
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
    <script>
      // Service Worker Registration with update checking
      if ('serviceWorker' in navigator) {
        window.addEventListener('load', () => {
          navigator.serviceWorker.register('/sw.js', { scope: '/' })
            .then((registration) => {
              console.log('[MARIS PWA] Service Worker registrado con éxito en scope:', registration.scope);
              
              // Check for SW updates
              registration.onupdatefound = () => {
                const installingWorker = registration.installing;
                if (installingWorker) {
                  installingWorker.onstatechange = () => {
                    if (installingWorker.state === 'installed' && navigator.serviceWorker.controller) {
                      console.log('[MARIS PWA] Nueva versión disponible en Cloudflare. Lista para activarse.');
                    }
                  };
                }
              };
            })
            .catch((error) => {
              console.warn('[MARIS PWA] Fallo en el registro del Service Worker:', error);
            });
        });
      }
    </script>
  </body>
</html>

