{{--
    Protera footer link list template override.

    Renders a single <ul> with the seeded items — matches the legacy
    "Apie parduotuvę" / "Informacija pirkėjams" column markup. The
    surrounding <h5> heading + <div class="col-..."> wrapper stays in
    site-footer.blade.php so the contacts / map / trust badge columns
    keep their hardcoded layout.

    v17.80 (task-9): `type='section'` items break the flat <ul> and
    emit an inline `<li class="footer-section" data-menu-section>` with
    a `<span class="footer-section-label">` group heading. The wrapping
    `<li>` keeps the markup well-formed inside the parent `<ul>` and
    the `data-menu-section` attribute is the stable hook that the
    `tests/e2e/menus-public-render.spec.ts` smoke targets.
--}}
@props([
    'tree' => [],
    'menu' => null,
])

@php
    // Stable test hook — `data-menu="{slug}"` lets specs scope link
    // assertions to a single menu's <ul> without hardcoding fragile
    // class chains. Skipped silently if $menu wasn't passed (defensive
    // — every render path through MenuRenderer always supplies it).
    $menuSlug = $menu?->slug;
@endphp
<ul {{ $attributes->merge(['class' => '']) }} @if($menuSlug) data-menu="{{ $menuSlug }}" @endif>
    @foreach($tree as $node)
        @php
            $type = $node['type'] ?? 'custom';
            $label = trim((string) ($node['label'] ?? ''));
        @endphp
        @if($type === 'section')
            <li class="footer-section list-unstyled mt-3" data-menu-section>
                <span class="footer-section-label fw-semibold text-uppercase small">
                    @if(! empty($node['icon']))
                        <i class="bi {{ $node['icon'] }}"></i>
                    @endif
                    {{ $label !== '' ? $label : ($node['identifier'] ?? '') }}
                </span>
            </li>
        @else
            @php
                $url = $node['url'] ?? null;
            @endphp
            <li>
                <a href="{{ $url ?: '#' }}"
                   @class([($node['css_class'] ?? '') => ($node['css_class'] ?? '') !== ''])
                   @if($node['target'] ?? null) target="{{ $node['target'] }}" rel="noopener" @endif>
                    {{ $label !== '' ? $label : ($node['identifier'] ?? '') }}
                </a>
            </li>
        @endif
    @endforeach
</ul>
