import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import Script from 'next/script'
import './globals.css'
import { Header } from '@/components/layout/Header'
import { Footer } from '@/components/layout/Footer'
import { FloatingButtons } from '@/components/ui/FloatingButtons'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
  title: 'Omitech - Soluciones de Telefonía Empresarial',
  description: 'LambiCall y LambiPhone: PBX en la nube y aplicación móvil para comunicaciones empresariales profesionales.',
  keywords: ['PBX', 'telefonía empresarial', 'VoIP', 'cloud PBX', 'LambiCall', 'LambiPhone'],
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="es">
      <head>
        <link rel="stylesheet" href="https://cdn.lambicom.com/widget.css" />
      </head>
      <body className={inter.className}>
        <Header />
        <main className="min-h-screen">
          {children}
        </main>
        <Footer />
        <FloatingButtons />
        {/* Lambicom Webchat Widget */}
        <Script
          id="lambicom-widget"
          strategy="afterInteractive"
          dangerouslySetInnerHTML={{
            __html: `
              (function(){
                var js = document.createElement('script');
                js.id = 'lambicom';
                js.src = 'https://cdn.lambicom.com/widget.js';
                js.async = true;
                js.onload = function() {
                  if (window.LambicomWidget && window.LambicomWidget.init) {
                    window.LambicomWidget.init({
                      widgetId: 'a1f90ad0-8f78-47d4-8c84-77c7eb21b12f',
                      tenantId: '00000000-0000-0000-0000-000000000001',
                      apiUrl: 'https://lambicom.com',
                      wsUrl: 'wss://lambicom.com'
                    });
                  }
                };
                document.head.appendChild(js);
              })();
            `,
          }}
        />
      </body>
    </html>
  )
}
