<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="google-site-verification" content="wx0Dc0a6nFjQckNl2nMvY53Arh3oVwibay9h-oNhL1U" />
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <?php wp_head(); ?>
    <style>
        body { margin: 0; padding: 0; font-family: 'Inter', sans-serif; background-color: #1A0F0A; color: #fdfbf7; }
        
        /* Elegant Header Styling */
        .gk-site-header {
            position: sticky;
            top: 0;
            z-index: 1000;
            background: rgba(26, 15, 10, 0.95);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(197, 157, 95, 0.2);
            padding: 15px 5%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 4px 20px rgba(0,0,0,0.5);
        }
        
        .gk-logo {
            display: flex;
            align-items: center;
            text-decoration: none;
        }

        .gk-logo img {
            max-height: 60px;
            width: auto;
            transition: transform 0.3s;
        }
        .gk-logo img:hover { transform: scale(1.05); }

        .gk-site-title {
            font-size: 1.5rem;
            font-weight: 800;
            color: #C59D5F;
            margin: 0;
            text-decoration: none;
        }
        
        .gk-main-navigation {
            display: flex;
            align-items: center;
        }
        
        .gk-main-navigation ul {
            list-style: none;
            margin: 0;
            padding: 0;
            display: flex;
            gap: 25px;
        }
        
        .gk-main-navigation li {
            position: relative;
        }
        
        .gk-main-navigation a {
            text-decoration: none;
            color: #fdfbf7;
            font-weight: 600;
            font-size: 1.05rem;
            padding: 8px 0;
            transition: color 0.3s;
        }
        
        .gk-main-navigation a:hover, .gk-main-navigation .current-menu-item > a {
            color: #C59D5F;
        }
        
        /* Underline Hover Effect */
        .gk-main-navigation a::after {
            content: '';
            position: absolute;
            width: 0; height: 2px;
            bottom: 0; left: 0;
            background-color: #C59D5F;
            transition: width 0.3s;
        }
        .gk-main-navigation a:hover::after, .gk-main-navigation .current-menu-item > a::after { width: 100%; }

        /* Mobilā izvēlne - pagaidu paslēpšana (var pievienot hamburgeri vēlāk) */
        @media (max-width: 768px) {
            .gk-main-navigation ul { display: none; }
            .gk-btn-mobile { display: block; }
        }
    </style>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>

<header class="gk-site-header">
    <div class="gk-logo">
        <a href="<?php echo esc_url(home_url('/')); ?>">
            <img src="<?php echo get_template_directory_uri(); ?>/assets/images/logo.png" alt="Gardais Kumoss Logo" style="max-height: 80px;">
        </a>
    </div>
    
    <nav class="gk-main-navigation" style="display:flex; align-items:center; gap:30px;">
        <?php
if (has_nav_menu('primary')) {
    wp_nav_menu([
        'theme_location' => 'primary',
        'container' => false,
        'menu_id' => 'primary-menu'
    ]);
}
else {
    echo '<ul>';
    $lang_prefix = '';
    if (function_exists('pll_current_language') && function_exists('pll_default_language')) {
        if (pll_current_language() !== pll_default_language()) {
            $lang_prefix = '/' . pll_current_language();
        }
    }
    echo '<li><a href="' . esc_url(home_url($lang_prefix . '/')) . '">' . esc_html(gk_t('nav_home')) . '</a></li>';
    echo '<li><a href="' . esc_url(home_url($lang_prefix . '/menu/')) . '">' . esc_html(gk_t('nav_menu')) . '</a></li>';
    echo '<li><a href="' . esc_url(home_url($lang_prefix . '/cake-builder/')) . '" style="color:#C59D5F;">' . esc_html(gk_t('nav_builder')) . '</a></li>';
    echo '</ul>';
}

// Pievienojam Valodu pārslēdzēju un "Mans Konts" ikonu vienotā ietvarā
echo '<div class="gk-header-actions" style="display:flex; align-items:center; gap:20px;">';

// 1. Valodu pārslēdzējs (ja funkcija eksistē un Polylang ir aktīvs)
if (function_exists('gk_language_switcher')) {
    echo gk_language_switcher();
}

echo '</div>'; // Beidzas gk-header-actions
?>
    </nav>
</header>
<style>


/* Valodu Pārslēdzējs (Scoped CSS) */
.gk-language-switcher {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 12px;
    align-items: center;
}

.gk-language-switcher li {
    display: inline-block;
    line-height: 1;
}

.gk-language-switcher a {
    text-decoration: none;
    color: #cfd8dc;
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.gk-language-switcher a:hover {
    color: #C59D5F;
}

/* Polylang piešķir klasi current-lang aktīvajai valodai */
.gk-language-switcher li.current-lang a {
    color: #C59D5F;
    font-weight: 700;
}

.gk-language-switcher li:not(:last-child)::after {
    content: "|";
    color: rgba(255, 255, 255, 0.2);
    margin-left: 12px;
    font-size: 0.9rem;
    pointer-events: none;
}


</style>
