@extends('theme::layouts.web')

{{--
    ProductBrandGroup landing — Protera theme override (task-2 placeholder).

    Replaces the standalone Modules/ProductBrandGroups/Resources/views/web/default.blade.php
    fallback. Inherits topbar + site-header + site-footer + Vite-built CSS
    from theme::layouts.web.

    Once task-3 (ProductBrands) lands, this view will gain a brand grid
    fed by `$group->brands` (declared as a class_exists-guarded relation
    on the model). Until then it shows the [data-brand-list-empty]
    placeholder.

    Vars (passed by ProductBrandGroupSlugResolver::resolve()):
      - $group          ProductBrandGroup
      - $currentLocale  string
      - $defaultLocale  string
      - $locales        Collection<Locale>

    Test markers preserved verbatim:
      [data-product-brand-group-title], [data-brand-list],
      [data-brand-list-empty], [data-brand-card]

    Microdata wraps the group meta only — individual brand cards on the
    listing (when wired) will NOT be wrapped (each brand → BrandCategory
    page gets its own microdata wrapper on its own URL).
--}}

@section('title', $group->getTitle())
@section('description', $group->getTranslation('excerpt', $currentLocale) ?: '')

@section('content')
<main class="container py-5">
    <x-microdata::attributes :for="$group" tag="section" class="cms-product-brand-group">
        <header class="mb-4">
            <h1 class="mb-2" data-product-brand-group-title>
                <x-microdata::property
                    name="name"
                    :for="$group"
                    :value="$group->getTitle()" />
            </h1>

            @if ($group->getTranslation('excerpt', $currentLocale))
                <p class="lead text-muted mb-0">
                    <x-microdata::property
                        name="description"
                        :for="$group"
                        :value="$group->getTranslation('excerpt', $currentLocale)" />
                </p>
            @endif
        </header>

        @if ($group->getTranslation('content', $currentLocale))
            <div class="cms-product-brand-group-content mb-5">
                {!! $group->getTranslation('content', $currentLocale) !!}
            </div>
        @endif

        @if ($group->website_url)
            <p class="mb-5">
                <a href="{{ $group->website_url }}" target="_blank" rel="noopener nofollow"
                   class="btn btn-sm btn-outline-secondary">
                    <i class="bi bi-globe"></i>
                    {{ __('productbrandgroups::messages.visit_website') }}
                </a>
            </p>
        @endif
    </x-microdata::attributes>

    <hr>

    <section class="brand-list mt-4" data-brand-list>
        <h2 class="h4 mb-3">{{ __('productbrandgroups::messages.brands_list_heading') }}</h2>

        @php($brands = $group->brands ?? collect())
        @if($brands->isEmpty())
            <div class="alert alert-light text-center text-muted py-4 mb-0" data-brand-list-empty>
                <i class="bi bi-bookmark" style="font-size:32px;opacity:0.4;"></i>
                <p class="mb-0 mt-2">{{ __('productbrandgroups::messages.no_brands_yet') }}</p>
            </div>
        @else
            <div class="row g-3" data-brand-grid>
                @foreach($brands as $brand)
                    <div class="col-6 col-md-4 col-lg-3" data-brand-card data-brand-id="{{ $brand->id }}">
                        <div class="border rounded p-3 text-center h-100">
                            <div class="fw-semibold">{{ $brand->getTitle() }}</div>
                        </div>
                    </div>
                @endforeach
            </div>
        @endif
    </section>
</main>
@endsection
