<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- SEO Basico -->
    <title><?= htmlspecialchars($pageTitle ?? 'Noticias de Hoy Online') ?></title>
    <meta name="description" content="<?= htmlspecialchars($pageDescription ?? '') ?>">
    <meta name="keywords" content="<?= htmlspecialchars($pageKeywords ?? '') ?>">
    <meta name="author" content="<?= htmlspecialchars($pageAuthor ?? 'Noticias de Hoy Online') ?>">
    <meta name="robots" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1">
    <meta name="googlebot" content="index, follow">
    <link rel="canonical" href="<?= htmlspecialchars($pageUrl ?? '') ?>">
    <meta name="theme-color" content="#2563eb">
    <meta name="application-name" content="Noticias de Hoy Online">
    <meta name="msapplication-TileColor" content="#2563eb">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <!-- Geo Meta -->
    <meta name="geo.region" content="PE-LIM">
    <meta name="geo.placename" content="Lima">
    <meta name="geo.position" content="-12.0464;-77.0428">
    <meta name="ICBM" content="-12.0464, -77.0428">

    <!-- hreflang -->
    <link rel="alternate" hreflang="es" href="<?= htmlspecialchars($pageUrl ?? '') ?>">
    <link rel="alternate" hreflang="es-pe" href="<?= htmlspecialchars($pageUrl ?? '') ?>">

    <!-- Open Graph -->
    <meta property="og:type" content="<?= $ogType ?? 'website' ?>">
    <meta property="og:title" content="<?= htmlspecialchars($pageTitle ?? 'Noticias de Hoy Online') ?>">
    <meta property="og:description" content="<?= htmlspecialchars($pageDescription ?? '') ?>">
    <meta property="og:url" content="<?= htmlspecialchars($pageUrl ?? '') ?>">
    <meta property="og:site_name" content="Noticias de Hoy Online">
    <meta property="og:locale" content="es_PE">
    <meta property="og:image" content="<?= htmlspecialchars($pageImage ?? 'https://noticiasdehoyonline.com/img/og-default.jpg') ?>">
    <meta property="og:image:width" content="1200">
    <meta property="og:image:height" content="630">
    <meta property="og:image:alt" content="<?= htmlspecialchars($pageTitle ?? 'Noticias de Hoy Online') ?>">
    <?php if ($ogType ?? '' === 'article'): ?>
    <meta property="article:published_time" content="<?= htmlspecialchars($articleDatePublished ?? '') ?>">
    <meta property="article:author" content="<?= htmlspecialchars($pageAuthor ?? 'Noticias de Hoy Online') ?>">
    <meta property="article:section" content="<?= htmlspecialchars($articleSection ?? '') ?>">
    <meta property="article:tag" content="<?= htmlspecialchars($pageKeywords ?? '') ?>">
    <?php endif; ?>

    <!-- Twitter Card -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@noticiasdehoyonline">
    <meta name="twitter:creator" content="@noticiasdehoyonline">
    <meta name="twitter:title" content="<?= htmlspecialchars($pageTitle ?? 'Noticias de Hoy Online') ?>">
    <meta name="twitter:description" content="<?= htmlspecialchars($pageDescription ?? '') ?>">
    <meta name="twitter:image" content="<?= htmlspecialchars($pageImage ?? 'https://noticiasdehoyonline.com/img/og-default.jpg') ?>">
    <meta name="twitter:image:alt" content="<?= htmlspecialchars($pageTitle ?? 'Noticias de Hoy Online') ?>">

    <!-- Preconnect / DNS Prefetch -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="dns-prefetch" href="//cdn.tailwindcss.com">
    <link rel="dns-prefetch" href="//picsum.photos">
    <link rel="dns-prefetch" href="//www.google-analytics.com">

    <!-- Tailwind CSS CDN -->
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                        serif: ['Georgia', 'serif'],
                    },
                    colors: {
                        primary: {
                            50: '#eff6ff',
                            100: '#dbeafe',
                            200: '#bfdbfe',
                            300: '#93c5fd',
                            400: '#60a5fa',
                            500: '#3b82f6',
                            600: '#2563eb',
                            700: '#1d4ed8',
                            800: '#1e40af',
                            900: '#1e3a8a',
                        },
                        accent: '#dc2626',
                    }
                }
            }
        }
    </script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">

    <style>
        .prose-content p { margin-bottom: 1.25rem; line-height: 1.8; color: #374151; }
        .prose-content h2 { font-size: 1.25rem; font-weight: 700; color: #111827; margin-top: 2rem; margin-bottom: 0.75rem; }
        .prose-content strong { font-weight: 600; color: #1f2937; }
        .prose-content blockquote { border-left: 4px solid #3b82f6; padding-left: 1rem; margin: 1.5rem 0; color: #4b5563; font-style: italic; }
        .line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
        .line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    </style>

    <!-- Structured Data: WebSite -->
    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "WebSite",
        "name": "Noticias de Hoy Online",
        "alternateName": "Noticiasdehoyonline",
        "url": "https://noticiasdehoyonline.com/",
        "description": "Las ultimas noticias de actualidad, tecnologia, deportes, economia y mas en Peru y el mundo.",
        "inLanguage": "es-PE",
        "potentialAction": {
            "@type": "SearchAction",
            "target": {
                "@type": "EntryPoint",
                "urlTemplate": "https://noticiasdehoyonline.com/buscar?q={search_term_string}"
            },
            "query-input": "required name=search_term_string"
        }
    }
    </script>

    <!-- Structured Data: Organization -->
    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "NewsMediaOrganization",
        "name": "Noticias de Hoy Online",
        "url": "https://noticiasdehoyonline.com/",
        "logo": {
            "@type": "ImageObject",
            "url": "https://noticiasdehoyonline.com/img/logo.png",
            "width": 300,
            "height": 60
        },
        "description": "Medio de noticias digitales con cobertura de actualidad, politica, economia, deportes, tecnologia, ciencia y entretenimiento.",
        "inLanguage": "es-PE",
        "areaServed": {
            "@type": "Country",
            "name": "Peru"
        },
        "sameAs": []
    }
    </script>

    <!-- BreadcrumbList JSON-LD (se sobreescribe en vistas internas) -->
    <?php if (!empty($breadcrumbs)): ?>
    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "BreadcrumbList",
        "itemListElement": <?= json_encode($breadcrumbs, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?>
    }
    </script>
    <?php endif; ?>
</head>
<body class="bg-gray-50 font-sans antialiased">

    <!-- Skip to content (accessibilidad) -->
    <a href="#contenido-principal" class="sr-only focus:not-sr-only focus:absolute focus:top-4 focus:left-4 bg-primary-600 text-white px-4 py-2 rounded-lg z-[100]">
        Saltar al contenido principal
    </a>

    <!-- Header -->
    <header class="bg-white shadow-sm sticky top-0 z-50" role="banner">
        <div class="max-w-7xl mx-auto">
            <!-- Barra superior -->
            <div class="border-b border-gray-100">
                <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-2 flex justify-between items-center text-xs text-gray-500">
                    <time id="fecha-actual" datetime="<?= date('Y-m-d') ?>"></time>
                    <span>Edicion Digital</span>
                </div>
            </div>

            <!-- Logo -->
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 text-center">
                <a href="/" class="inline-block" aria-label="Noticias de Hoy Online - Ir al inicio">
                    <h1 class="text-3xl md:text-4xl font-extrabold text-gray-900 tracking-tight">
                        NOTICIAS<span class="text-primary-600">DE HOY</span><span class="text-gray-500 font-semibold text-xl md:text-2xl ml-1">ONLINE</span>
                    </h1>
                    <p class="text-xs text-gray-400 tracking-widest uppercase mt-1">Informacion que importa</p>
                </a>
            </div>

            <!-- Navegacion -->
            <nav class="border-t border-gray-100" aria-label="Navegacion principal">
                <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                    <div class="flex justify-center space-x-1 overflow-x-auto py-1" role="menubar">
                        <a href="/" role="menuitem" class="px-4 py-2 text-sm font-medium text-primary-600 bg-primary-50 rounded-full whitespace-nowrap" aria-current="page">Inicio</a>
                        <a href="/politica" role="menuitem" class="px-4 py-2 text-sm font-medium text-gray-600 hover:text-primary-600 hover:bg-gray-50 rounded-full whitespace-nowrap transition">Politica</a>
                        <a href="/deportes" role="menuitem" class="px-4 py-2 text-sm font-medium text-gray-600 hover:text-primary-600 hover:bg-gray-50 rounded-full whitespace-nowrap transition">Deportes</a>
                    </div>
                </div>
            </nav>
        </div>
    </header>

    <!-- Contenido Principal -->
    <main id="contenido-principal" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8" role="main">
        <?= $content ?>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-400 mt-12" role="contentinfo">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <!-- Logo y descripcion -->
                <div class="md:col-span-1">
                    <h2 class="text-xl font-bold text-white mb-3">NOTICIAS<span class="text-primary-400">DE HOY</span> <span class="text-gray-500 font-semibold">ONLINE</span></h2>
                    <p class="text-sm leading-relaxed">Tu fuente confiable de noticias las 24 horas del dia. Informacion veraz, oportuna e imparcial.</p>
                </div>

                <!-- Secciones -->
                <nav aria-label="Secciones">
                    <h3 class="text-white font-semibold text-sm uppercase tracking-wider mb-4">Secciones</h3>
                    <ul class="space-y-2 text-sm" role="list">
                        <li><a href="/politica" class="hover:text-white transition">Politica</a></li>
                        <li><a href="/deportes" class="hover:text-white transition">Deportes</a></li>
                    </ul>
                </nav>

                <!-- Legal -->
                <nav aria-label="Legal">
                    <h3 class="text-white font-semibold text-sm uppercase tracking-wider mb-4">Legal</h3>
                    <ul class="space-y-2 text-sm" role="list">
                        <li><a href="/privacidad" class="hover:text-white transition">Politica de Privacidad</a></li>
                        <li><a href="/terminos" class="hover:text-white transition">Terminos de Uso</a></li>
                        <li><a href="/contacto" class="hover:text-white transition">Contacto</a></li>
                        <li><a href="/nosotros" class="hover:text-white transition">Nosotros</a></li>
                    </ul>
                </nav>
            </div>

            <div class="border-t border-gray-800 mt-10 pt-8 text-center text-xs">
                <p>&copy; <time datetime="<?= date('Y') ?>"><?= date('Y') ?></time> Noticiasdehoyonline.com. Todos los derechos reservados.</p>
            </div>
        </div>
    </footer>

    <script>
        const opciones = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
        const fecha = new Date().toLocaleDateString('es-PE', opciones);
        document.getElementById('fecha-actual').textContent = fecha.charAt(0).toUpperCase() + fecha.slice(1);
    </script>
</body>
</html>
