{{-- Шапка публичного сайта. Данные берутся из $siteSettings (View Composer). --}}
@php
    $phone      = $siteSettings['phone']      ?? '';
    $email      = $siteSettings['email']      ?? '';
    $telegram   = $siteSettings['telegram']   ?? '';
    $youtube    = $siteSettings['youtube']    ?? '';
    $vk         = $siteSettings['vk']         ?? '';
    $logoHeader = $siteSettings['logo_header'] ?? 'images/logos/logo_short_transparent.png';
    $hasTopbar  = $phone || $email || $telegram || $youtube || $vk;
@endphp

@if($hasTopbar)
<div class="topbar">
    <div class="container">
        <div class="topbar-l">
            @if($email)
                <span>&#128231; <a href="mailto:{{ $email }}">{{ $email }}</a></span>
            @endif
            @if($phone)
                <span>&#128222; <a href="tel:{{ preg_replace('/\D/', '', $phone) }}">{{ $phone }}</a></span>
            @endif
        </div>
        @if($telegram || $vk || $youtube)
        <div class="topbar-r">
            <div class="topbar-soc">
                @if($telegram)
                    <a href="{{ $telegram }}" target="_blank" rel="noopener" title="Telegram">TG</a>
                @endif
                @if($vk)
                    <a href="{{ $vk }}" target="_blank" rel="noopener" title="ВКонтакте">ВК</a>
                @endif
                @if($youtube)
                    <a href="{{ $youtube }}" target="_blank" rel="noopener" title="YouTube">YT</a>
                @endif
            </div>
        </div>
        @endif
    </div>
</div>
@endif

<nav class="navbar" id="navbar">
    <div class="container">
        <a href="{{ route('home') }}" class="logo">
            <img src="{{ asset($logoHeader) }}" alt="Логотип" class="logo-img"/>
        </a>

        <div class="nav-links" id="navLinks">
            <a href="{{ route('home') }}" class="{{ request()->routeIs('home') ? 'active' : '' }}">Главная</a>
            <a href="{{ route('catalog') }}" class="{{ request()->routeIs('catalog') ? 'active' : '' }}">Каталог</a>
            <a href="{{ route('services') }}" class="{{ request()->routeIs('services') ? 'active' : '' }}">Услуги</a>
            <a href="{{ route('contacts') }}" class="{{ request()->routeIs('contacts') ? 'active' : '' }}">Контакты</a>
        </div>

        <div class="nav-right">
            {{-- Избранное — иконка сердца с бейджем --}}
            <a href="{{ route('favorites') }}" class="nav-fav-btn{{ request()->routeIs('favorites') ? ' has-items' : '' }}" id="navFavBtn" title="Избранное">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
                </svg>
                <span class="nav-fav-count" id="favNavCount"></span>
            </a>

            {{-- Telegram — иконка --}}
            @if($telegram)
            <a href="{{ $telegram }}" target="_blank" rel="noopener" class="nav-icon-btn nav-icon-btn--tg" title="Написать в Telegram">
                <svg viewBox="0 0 24 24" fill="currentColor">
                    <path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.96 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/>
                </svg>
            </a>
            @endif

            {{-- Позвонить — иконка трубки --}}
            @if($phone)
            <a href="tel:{{ preg_replace('/\D/', '', $phone) }}" class="nav-icon-btn nav-icon-btn--call" title="{{ $phone }}">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.69 12 19.79 19.79 0 0 1 1.61 3.4 2 2 0 0 1 3.6 1.22h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.91 8.79a16 16 0 0 0 6.29 6.29l.96-.96a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z"/>
                </svg>
            </a>
            @endif

            <div class="burger" id="burger">
                <span></span><span></span><span></span>
            </div>
        </div>
    </div>
</nav>
