@php
    $manifestPath = public_path('build/manifest.json');
@endphp

@if (file_exists($manifestPath))
    @vite(['resources/css/app.css'])
@else
    @php
        $cssFiles = glob(public_path('build/assets/app-*.css')) ?: [];
        usort($cssFiles, fn ($a, $b) => filemtime($b) <=> filemtime($a));
        $css = $cssFiles[0] ?? null;
    @endphp

    @if ($css)
        <link rel="stylesheet" href="{{ str_replace(public_path(), '', $css) }}">
    @endif
@endif
