<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>@yield('title', 'Protera — padangos, ratlankiai, akumuliatoriai') — {{ config('cms.name', 'Protera') }}</title>
    <meta name="description" content="@yield('description', 'Padangos, ratlankiai ir akumuliatoriai internetu. Greitas pristatymas visoje Lietuvoje.')">

    {{-- SystemFindings/task-16d — the eight third-party tags that used to stand
         here are gone. Bootstrap 5.3.3, bootstrap-icons 1.11.3, Manrope and
         noUiSlider 15.7.1 are npm dependencies of this theme now, pinned to the
         versions those URLs named, and they ride in the two bundles @cmsAssets
         emits below: web.css @imports bootstrap + icons + fonts.css, and
         catalog-browsing.js carries noUiSlider.

         🔑 Two of the eight were not just a CDN dependency:

         - Google Fonts (three tags — two `preconnect`, one stylesheet) handed
           every STOREFRONT VISITOR's IP to Google on every page view, before any
           consent. That is the GDPR half of finding #19, and it was on the public
           site rather than in the admin.

         - Alpine was loaded here AND bundled inside web.js, which calls
           Alpine.start(). Two instances, every catalogue page, since task-116b.
           Dropping this tag removes the duplicate; the bundled copy is the one
           the x-data components were already registered against. --}}

    {{-- Per-route package CSS (ViartasCore\Core\Services\Assets\AssetRegistry).
         task-116b: the Protera theme CSS/JS (web.css + catalog-browsing.css and
         their JS) now ship from the va-themes/protera package via @cmsAssets() — the
         provider declares them for the `web.*` route pattern. search-suggest +
         header-search + grid-frontend styles are bundled into web.css. The old
         @vite(['themes/Web/Protera/Resources/assets/...']) block was removed. --}}
    @cmsAssets('css')

    @stack('styles')
</head>
<body>

    {{-- Top utility bar: contact info + language switcher --}}
    <x-topbar />

    {{-- Main site header: logo, search, account, cart, nav --}}
    <x-site-header />

    {{--
        Email-verify reminder banner.

        Shown on every page as long as the authenticated user has not
        verified their email. Clicking "Siųsti iš naujo" POSTs to the
        verification resend endpoint and flashes a confirmation.

        The one-shot 'verify_email_sent' flash (set right after registration)
        is shown as a bolder success variant the first time, then the
        banner persists as a warning on subsequent pages.
    --}}
    @auth
        @if (!auth()->user()->hasVerifiedEmail())
            <div class="verify-banner {{ session('verify_email_sent') ? 'verify-banner--success' : '' }}">
                <div class="container d-flex flex-wrap align-items-center justify-content-center gap-3 py-2">
                    <span>
                        @if (session('verify_email_sent'))
                            <i class="bi bi-envelope-check-fill me-1"></i>
                            Patvirtinimo laiškas išsiųstas į <strong>{{ session('verify_email_sent') }}</strong>. Patikrinkite pašto dėžutę.
                        @else
                            <i class="bi bi-exclamation-triangle-fill me-1"></i>
                            Patvirtinkite el. pašto adresą — patikrinkite savo pašto dėžutę.
                        @endif
                    </span>
                    <form method="POST" action="{{ route(cms_route_name_for_current_locale('web.auth.verification.send')) }}" class="m-0">
                        @csrf
                        <button type="submit" class="btn btn-sm btn-outline-dark">
                            <i class="bi bi-arrow-repeat me-1"></i> Siųsti iš naujo
                        </button>
                    </form>
                </div>
            </div>
        @endif

        {{-- Verification resend confirmation --}}
        @if (session('resent'))
            <div class="verify-banner verify-banner--success">
                <div class="container py-2 text-center">
                    <i class="bi bi-check-circle-fill me-1"></i>
                    Naujas patvirtinimo laiškas išsiųstas.
                </div>
            </div>
        @endif
    @endauth

    {{--
        One-shot status flash — shown once right after login, password
        change, etc. Uses the 'status' session key which is Laravel's
        convention for transient success messages.
    --}}
    @if (session('status'))
        <div class="site-flash site-flash--success">
            <div class="container py-2 text-center">
                <i class="bi bi-check-circle-fill me-1"></i>
                {{ session('status') }}
            </div>
        </div>
    @endif

    {{-- Page content --}}
    @yield('content')

    {{-- Footer: links, contacts, map, trust badges --}}
    <x-site-footer />

    {{-- Floating back-to-top button --}}
    <button id="backTop" aria-label="Į viršų" style="display:none;"><i class="bi bi-arrow-up"></i></button>

    {{-- JS globals: locale + CSRF for AJAX --}}
    <script>
        window.Viartas = {
            locale: '{{ app()->getLocale() }}',
            csrfToken: '{{ csrf_token() }}',
        };
    </script>

    {{-- Per-route package JS (ViartasCore\Core\Services\Assets\AssetRegistry) --}}
    @cmsAssets('js')

    @stack('scripts')
</body>
</html>
