{{--
    Override of vendor/filament/filament/resources/views/components/logo.blade.php.

    Stock Filament shows EITHER the brand logo OR the brand name as text —
    never both (an uploaded mark just replaces the name outright, everywhere
    the logo component is used: sidebar header, topbar, and the login page's
    hero mark, since all three render <x-filament-panels::logo />). A tenant
    who uploads a mark still wants their business name legible next to it, so
    this override adds the name back in whenever an actual logo (image or
    Htmlable) is being rendered. The text-only fallback (no logo at all) is
    untouched — Filament's own single-name rendering already covers that case.
--}}
@php
    $brandName = filament()->getBrandName();
    $brandLogo = filament()->getBrandLogo();
    $brandLogoHeight = filament()->getBrandLogoHeight() ?? '1.5rem';
    $darkModeBrandLogo = filament()->getDarkModeBrandLogo();
    $hasDarkModeBrandLogo = filled($darkModeBrandLogo);

    $getLogoClasses = fn (bool $isDarkMode): string => \Illuminate\Support\Arr::toCssClasses([
        'fi-logo',
        'fi-logo-light' => $hasDarkModeBrandLogo && (! $isDarkMode),
        'fi-logo-dark' => $isDarkMode,
    ]);

    $logoStyles = 'height: ' . e($brandLogoHeight);
@endphp

<style>
    .fi-logo-with-name { display: inline-flex; align-items: center; gap: 0.625rem; min-width: 0; }
    .fi-logo-with-name-text {
        font-size: 0.9375rem;
        font-weight: 600;
        line-height: 1.25;
        color: var(--sidebar-foreground, inherit);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 14rem;
    }
    .fi-simple-header .fi-logo-with-name { flex-direction: column; gap: 0.5rem; }
    .fi-simple-header .fi-logo-with-name-text { font-size: 1.125rem; font-weight: 700; max-width: 100%; }
    @media (max-width: 30rem) {
        .fi-topbar .fi-logo-with-name-text { display: none; }
    }
</style>

@capture($content, $logo, $isDarkMode = false)
    @if ($logo instanceof \Illuminate\Contracts\Support\Htmlable)
        <div class="fi-logo-with-name">
            <div
                {{
                    $attributes
                        ->class([$getLogoClasses($isDarkMode)])
                        ->style([$logoStyles])
                }}
            >
                {{ $logo }}
            </div>
            <span class="fi-logo-with-name-text">{{ $brandName }}</span>
        </div>
    @elseif (filled($logo))
        <div class="fi-logo-with-name">
            <img
                alt="{{ __('filament-panels::layout.logo.alt', ['name' => $brandName]) }}"
                src="{{ $logo }}"
                {{
                    $attributes
                        ->class([$getLogoClasses($isDarkMode)])
                        ->style([$logoStyles])
                }}
            />
            <span class="fi-logo-with-name-text">{{ $brandName }}</span>
        </div>
    @else
        <div
            {{
                $attributes->class([
                    $getLogoClasses($isDarkMode),
                ])
            }}
        >
            {{ $brandName }}
        </div>
    @endif
@endcapture

{{ $content($brandLogo) }}

@if ($hasDarkModeBrandLogo)
    {{ $content($darkModeBrandLogo, isDarkMode: true) }}
@endif
