<!DOCTYPE html>
<html lang="{{ dynamic_lang }}" prefix="og: http://ogp.me/ns#">
<head>
    <!-- Metadatos Esenciales -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <!-- Title Tag Optimizado -->
    <title>{{ page_title }} | {{ site_name }}</title>

    <!-- Meta Description Dinámica -->
    <meta name="description" content="{{ meta_description|truncate:160 }}">

    <!-- Open Graph / Facebook -->
    <meta property="og:type" content="{{ og_type }}">
    <meta property="og:url" content="{{ canonical_url }}">
    <meta property="og:title" content="{{ og_title|truncate:60 }}">
    <meta property="og:description" content="{{ og_description|truncate:160 }}">
    <meta property="og:image" content="{{ og_image_url }}">
    <meta property="og:site_name" content="{{ site_name }}">

    <!-- Twitter Card -->
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:creator" content="{{ twitter_handle }}">
    <!-- ... otros meta twitter ... -->

    <!-- Robots Directives -->
    <meta name="robots" content="{{ index_status }}, {{ follow_status }}, max-image-preview:large">

    <!-- Idioma y Geolocalización -->
    <meta name="language" content="{{ main_language }}">
    <meta name="geo.region" content="{{ geo_region }}">
    <meta name="geo.placename" content="{{ geo_placename }}">

    <!-- Enlaces Canónicos y Alternativos -->
    <link rel="canonical" href="{{ canonical_url }}">
    {% for alternate in alternate_langs %}
    <link rel="alternate" hreflang="{{ alternate.code }}" href="{{ alternate.url }}">
    {% endfor %}

    <!-- Preconexiones y Preloads -->
    <link rel="preconnect" href="https://www.googletagmanager.com">
    <link rel="dns-prefetch" href="//fonts.googleapis.com">

    <!-- Favicon Moderno (SVG + PNG fallback) -->
    <link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">

    <!-- CSS Crítico Inline -->
    <style>/* CSS mínimo para above-the-fold */</style>

    <!-- Schema.org JSON-LD -->
    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "WebSite",
        "name": "{{ site_name }}",
        "url": "{{ base_url }}",
        "potentialAction": {
            "@type": "SearchAction",
            "target": "{{ search_url }}?q={search_term_string}",
            "query-input": "required name=search_term_string"
        }
    }
    </script>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
