{{--
    The controls on the trailing edge of every navbar: language, dashboard link
    for signed-in staff, the call-to-action, and the mobile menu trigger.

    Shared so a change to the CTA or the language switch lands in every navbar
    style at once instead of five near-identical copies drifting apart.

    @param string $linkClass  colour/typography for text controls
    @param string $ctaClass   extra classes for the CTA button
    @param bool   $compact    tighter spacing for the floating navbar
--}}
@php
    $linkClass = $linkClass ?? 'text-white/85 hover:text-white';
    $ctaClass = $ctaClass ?? '!py-2 !px-4';
    $compact = $compact ?? false;
    $ctaHref = safe_url($settings->navbar_cta_link ?? null) ?: ($navBase.'#section-contact');
    // null means "never configured" and keeps the default label; an explicitly
    // empty value means the site chose to have no call to action at all.
    $ctaBase = app()->getLocale() === 'ar'
        ? ($settings->navbar_cta_text ?? null)
        : ($settings->navbar_cta_text_en ?: ($settings->navbar_cta_text ?? null));
    $ctaText = $settings->navbar_cta_text === null ? __('سجّل الآن') : (string) $ctaBase;
@endphp

<div class="flex items-center {{ $compact ? 'gap-1.5' : 'gap-2 sm:gap-3' }}">
    @if ($settings->navbar_show_language ?? false)
        <div class="hidden sm:block">
            @include('website.partials.language-switcher', ['linkClass' => $linkClass])
        </div>
    @endif

    @auth
        <a href="{{ route('dashboard') }}"
           class="hidden sm:inline-flex items-center gap-1 rounded-lg px-3 py-2 text-sm font-medium transition {{ $linkClass }}">
            {{ __('لوحة التحكم') }}
        </a>
    @endauth

    @if (filled($ctaText))
        <a href="{{ $ctaHref }}" class="hidden sm:inline-flex site-btn site-btn--primary text-sm {{ $ctaClass }}">
            {{ $ctaText }}
        </a>
    @endif

    <button type="button"
            class="lg:hidden rounded-lg p-2 transition hover:bg-white/10 {{ $linkClass }}"
            onclick="document.getElementById('mobile-menu').classList.toggle('hidden')"
            aria-label="{{ __('القائمة') }}" aria-controls="mobile-menu">
        <svg class="{{ $compact ? 'w-5 h-5' : 'w-6 h-6' }}" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/>
        </svg>
    </button>
</div>
