{{-- Painel Publishing Grupo OLX — métricas objetivas, sem gráficos --}}
<section aria-label="Painel Grupo OLX" class="mb-8 rounded-xl border border-slate-200 bg-white shadow-sm">
    <div class="flex flex-wrap items-start justify-between gap-3 border-b border-slate-200 px-6 py-4">
        <div>
            <h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">Grupo OLX · VRSync</h2>
            <p class="mt-1 text-sm text-slate-600">Status do feed oficial para OLX, ZAP Imóveis e Viva Real.</p>
        </div>
        @if ($dashboard->available && $dashboard->xmlValid)
            <span class="inline-flex rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1 text-xs font-semibold text-emerald-800">
                Pronto para importação
            </span>
        @elseif ($dashboard->available)
            <span class="inline-flex rounded-full border border-red-200 bg-red-50 px-3 py-1 text-xs font-semibold text-red-800">
                XML com erros
            </span>
        @else
            <span class="inline-flex rounded-full border border-slate-200 bg-slate-50 px-3 py-1 text-xs font-semibold text-slate-700">
                Aguardando geração
            </span>
        @endif
    </div>

    <dl class="grid gap-0 divide-y divide-slate-100 sm:grid-cols-2 sm:divide-x sm:divide-y-0 lg:grid-cols-3">
        <div class="px-6 py-4">
            <dt class="text-xs font-medium uppercase tracking-wide text-slate-500">XML válido</dt>
            <dd @class([
                'mt-1 text-base font-medium',
                'text-emerald-700' => $dashboard->xmlValid,
                'text-red-700' => $dashboard->available && ! $dashboard->xmlValid,
                'text-slate-700' => ! $dashboard->available,
            ])>
                {{ $dashboard->xmlValidLabel() }}
            </dd>
        </div>

        <div class="px-6 py-4">
            <dt class="text-xs font-medium uppercase tracking-wide text-slate-500">Última geração</dt>
            <dd class="mt-1 text-base font-medium text-slate-900">
                {{ $dashboard->lastGeneratedAtLabel() ?? '—' }}
            </dd>
        </div>

        <div class="px-6 py-4">
            <dt class="text-xs font-medium uppercase tracking-wide text-slate-500">Quantidade de anúncios</dt>
            <dd class="mt-1 text-base font-medium text-slate-900">
                {{ $dashboard->listingCount }}
            </dd>
        </div>

        <div class="px-6 py-4">
            <dt class="text-xs font-medium uppercase tracking-wide text-slate-500">Tamanho do XML</dt>
            <dd class="mt-1 text-base font-medium text-slate-900">
                {{ $dashboard->xmlSizeLabel() }}
            </dd>
        </div>

        <div class="px-6 py-4">
            <dt class="text-xs font-medium uppercase tracking-wide text-slate-500">Tempo de geração</dt>
            <dd class="mt-1 text-base font-medium text-slate-900">
                {{ $dashboard->generationDurationLabel() }}
            </dd>
        </div>

        <div class="px-6 py-4">
            <dt class="text-xs font-medium uppercase tracking-wide text-slate-500">URL pública</dt>
            <dd class="mt-1 break-all text-sm">
                <a
                    href="{{ $dashboard->publicUrl }}"
                    target="_blank"
                    rel="noopener noreferrer"
                    class="font-medium text-emerald-700 hover:text-emerald-600 hover:underline"
                >
                    {{ $dashboard->publicUrl }}
                </a>
            </dd>
        </div>
    </dl>

    <div class="border-t border-slate-200 px-6 py-4">
        <h3 class="text-xs font-medium uppercase tracking-wide text-slate-500">Erros</h3>
        @if ($dashboard->hasErrors())
            <ul class="mt-2 space-y-1 text-sm text-red-700">
                @foreach ($dashboard->errors as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        @else
            <p class="mt-2 text-sm text-slate-500">Nenhum erro registrado.</p>
        @endif
    </div>
</section>
