@php
use App\Helpers\VisitorHelper;
$activeBrand = app()->bound('brand') ? app('brand') : null;
\Carbon\Carbon::setLocale(app()->getLocale());
@endphp

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @hook('StoreHeadStart')
    <script>
    window.procpConsent = { marketing: @json(app(\App\Services\Consent\ConsentService::class)->hasMarketing()) };
    </script>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="api-token" content="{{ Auth::guard('client')->check() ? Auth::guard('client')->user()->createToken('api')->plainTextToken : '' }}">

    
    @php
        $seo = function_exists('seo_meta') ? seo_meta() : ['title' => null, 'description' => null, 'og_image' => null];
        $seoDescription = $seo['description'] ?: '';
        $brandName = $activeBrand?->name ?? $appName;
    @endphp

    <meta name="description" content="{{ $seoDescription }}">
    @if(! empty($seo['keywords']))
        <meta name="keywords" content="{{ $seo['keywords'] }}">
    @endif
    @if(! empty($seo['robots']))
        <meta name="robots" content="{{ $seo['robots'] }}">
    @endif
    <link rel="canonical" href="{{ $seo['canonical_url'] ?? url()->current() }}">
    <title>{{ $brandName }} - @yield('title')</title>

    
    @foreach(seo_hreflang_alternates() as $alt)
        <link rel="alternate" hreflang="{{ $alt['locale'] }}" href="{{ $alt['url'] }}">
    @endforeach

    
    @if($seo['title'])
        <meta property="og:title" content="{{ $seo['title'] }}">
        <meta name="twitter:title" content="{{ $seo['title'] }}">
    @endif
    @if($seo['description'])
        <meta property="og:description" content="{{ $seo['description'] }}">
        <meta name="twitter:description" content="{{ $seo['description'] }}">
    @endif
    @if($seo['og_image'])
        <meta property="og:image" content="{{ asset('storage/' . $seo['og_image']) }}">
        @if(! empty($seo['og_image_alt']))
            <meta property="og:image:alt" content="{{ $seo['og_image_alt'] }}">
            <meta name="twitter:image:alt" content="{{ $seo['og_image_alt'] }}">
        @endif
        <meta name="twitter:image" content="{{ asset('storage/' . $seo['og_image']) }}">
        <meta name="twitter:card" content="summary_large_image">
    @endif
    <meta property="og:url" content="{{ url()->current() }}">
    <meta property="og:type" content="website">
    <meta property="og:site_name" content="{{ $brandName }}">
    <meta property="og:locale" content="{{ app()->getLocale() }}_{{ strtoupper(app()->getLocale()) }}">

    
    @php $globalSeo = app(\App\Services\SeoService::class)->globalHead(); @endphp
    @foreach($globalSeo['metas'] as $seoMetaName => $seoMetaContent)
        <meta name="{{ $seoMetaName }}" content="{{ $seoMetaContent }}">
    @endforeach
    @if($globalSeo['theme_color'])
        <meta name="theme-color" content="{{ $globalSeo['theme_color'] }}">
    @endif
    @if($globalSeo['organization'])
        <script type="application/ld+json">{!! json_encode($globalSeo['organization'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}</script>
    @endif
    @if($globalSeo['website'])
        <script type="application/ld+json">{!! json_encode($globalSeo['website'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}</script>
    @endif

    <!-- Theme Detection Script - Prevent FOUC — store_theme key (admin ile karışmasın) -->
    <script>
        (function() {
            // Geriye uyum: eski 'theme' key'i varsa migrate et
            if (! localStorage.getItem('store_theme') && localStorage.getItem('theme')) {
                localStorage.setItem('store_theme', localStorage.getItem('theme'));
            }
            const savedTheme = localStorage.getItem('store_theme');
            const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
            const theme = savedTheme || (prefersDark ? 'dark' : 'light');
            document.documentElement.setAttribute('data-bs-theme', theme);
        })();
    </script>

    <!-- Scripts and Styles -->
    @vite(['resources/css/store/app.css', 'resources/css/store/tables.css', 'resources/js/store/app.js', 'resources/js/store/tracking.js'])

    
    @if(isset($themeAssets) && !empty($themeAssets['css']))
        @foreach($themeAssets['css'] as $css)
            <link rel="stylesheet" href="{{ asset($css) }}">
        @endforeach
    @endif

    
    @if($activeBrand)
    <style>
        :root {
            --brand-primary: {{ $activeBrand->primary_color ?? '#6366f1' }};
            --brand-secondary: {{ $activeBrand->secondary_color ?? '#4f46e5' }};
        }
        .btn-primary { background-color: var(--brand-primary) !important; border-color: var(--brand-primary) !important; }
        .text-primary { color: var(--brand-primary) !important; }
        .bg-primary { background-color: var(--brand-primary) !important; }
        .border-primary { border-color: var(--brand-primary) !important; }
        .btn-outline-primary { color: var(--brand-primary) !important; border-color: var(--brand-primary) !important; }
        .btn-outline-primary:hover { background-color: var(--brand-primary) !important; color: #fff !important; }
        a { color: var(--brand-primary); }
    </style>
    @if($activeBrand->custom_css)
    <style>{!! $activeBrand->custom_css !!}</style>
    @endif
    @endif

    @if($globalSeo['apple_touch_icon'])
        
        <link rel="apple-touch-icon" sizes="180x180" href="{{ $globalSeo['apple_touch_icon'] }}">
    @endif
    @if($activeBrand?->favicon)
        <link rel="icon" href="{{ $activeBrand->favicon }}">
    @else
        @unless($globalSeo['apple_touch_icon'])
            <link rel="apple-touch-icon" sizes="180x180" href="{{ asset('assets/apple-touch-icon.png') }}">
        @endunless
        <link rel="icon" type="image/png" sizes="32x32" href="{{ asset('assets/favicon-32x32.png') }}">
        <link rel="icon" type="image/png" sizes="16x16" href="{{ asset('assets/favicon-16x16.png') }}">
        <link rel="shortcut icon" href="{{ asset('assets/favicon.ico') }}">
        <link rel="manifest" href="{{ asset('assets/site.webmanifest') }}">
    @endif

    @stack('styles')
    @hook('ClientAreaHeadOutput')
</head>
<body>
    @hook('ClientAreaHeaderOutput')
    @include('partials.impersonation-banner')
    <div class="min-vh-100 d-flex flex-column">
        <!-- Navigation -->
        @unless(request()->routeIs('store.auth.login') || request()->routeIs('store.auth.register'))
        @php
            $isSwitched = auth('client')->check() && session('active_client_id') && session('active_client_id') != auth('client')->id();
            $permissions = session('active_permissions', []);
            $P = \App\Enums\ClientPermission::class;
            $hasServiceAccess = function() use ($permissions, $P) {
                if (in_array($P::VIEW_SERVICES, $permissions)) return true;
                return collect($permissions)->contains(fn($p) => str_starts_with($p, 'view_service'));
            };
            $hasDomainAccess = function() use ($permissions, $P) {
                if (in_array($P::VIEW_DOMAINS, $permissions)) return true;
                return collect($permissions)->contains(fn($p) => str_starts_with($p, 'view_domain'));
            };
        @endphp

        
        <nav class="navbar navbar-expand-lg navbar-light">
            <div class="container">
                <a class="navbar-brand" href="{{ route('store.index') }}">
                    @if($activeBrand?->logo)
                        <img src="{{ $activeBrand->logo }}" alt="{{ $activeBrand->name }}" style="max-height: 36px;">
                    @elseif($companyLogo)
                        <img src="{{ $companyLogo }}" alt="{{ $appName }}" style="max-height: 36px;">
                    @else
                        {{ $activeBrand?->name ?? $appName }}
                    @endif
                </a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarNav">
                    
                    @menu('header_primary')

                    
                    
                    <ul class="navbar-nav align-items-center ms-auto">
                        @guest('client')
                        <li class="nav-item">
                            
                            <a class="nav-link" href="{{ lroute('store.auth.login') }}">
                                <i class="fas fa-sign-in-alt"></i> {{ __('store.nav_login') }}
                            </a>
                        </li>
                        @endguest
                        @if($enableLanguageMenu ?? true)
                        @auth('client')
                        <li class="nav-item">
                            <span class="nav-link disabled d-flex align-items-center ms-2" tabindex="-1" aria-disabled="true">
                                
                                <i class="{{ $currentLanguageFlag ?? 'fi fi-un' }} me-1"></i> {{ strtoupper(app()->getLocale()) }}
                            </span>
                        </li>
                        @else
                        <li class="nav-item dropdown ms-2">
                            <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown">
                                <i class="{{ $currentLanguageFlag ?? 'fi fi-un' }} me-1"></i> {{ strtoupper(app()->getLocale()) }}
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end">
                                @foreach(($storeLanguages ?? []) as $lang)
                                <li>
                                    <form action="{{ route('store.locale.set') }}" method="POST">
                                        @csrf
                                        <input type="hidden" name="locale" value="{{ $lang['a2_iso'] }}">
                                        <button type="submit" class="dropdown-item d-flex align-items-center">
                                            <i class="{{ $lang['flag_class'] }} me-2"></i> {{ $lang['native_name'] }}
                                        </button>
                                    </form>
                                </li>
                                @endforeach
                            </ul>
                        </li>
                        @endauth
                        @endif
                        @auth('client')
                        <li class="nav-item">
                            <span class="nav-link disabled d-flex align-items-center ms-1" tabindex="-1" aria-disabled="true">
                                
                                <i class="{{ $currentCurrencyFlag ?? 'fi fi-un' }} me-1"></i> {{ $currentCurrency ?? 'USD' }}
                            </span>
                        </li>
                        @else
                        <li class="nav-item dropdown ms-1">
                            <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown">
                                <i class="{{ $currentCurrencyFlag ?? 'fi fi-un' }} me-1"></i> {{ $currentCurrency ?? 'USD' }}
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end">
                                @foreach(($storeCurrencies ?? []) as $cur)
                                <li>
                                    <form action="{{ route('store.currency.set') }}" method="POST">
                                        @csrf
                                        <input type="hidden" name="currency" value="{{ $cur['code'] }}">
                                        <button type="submit" class="dropdown-item d-flex align-items-center">
                                            <i class="{{ $cur['flag_class'] }} me-2"></i> {{ $cur['name'] }} ({{ $cur['code'] }})
                                        </button>
                                    </form>
                                </li>
                                @endforeach
                            </ul>
                        </li>
                        @endauth
                        
                        <li class="nav-item ms-1">
                            <button type="button" class="nav-link btn btn-link theme-toggle-nav" id="themeToggle" aria-label="{{ __('store.nav_theme_toggle') }}">
                                <i class="fas fa-sun"></i>
                            </button>
                        </li>
                        @if(!$isSwitched)
                        <li class="nav-item ms-1">
                            <a class="nav-link position-relative" href="{{ lroute('store.basket.index') }}">
                                <i class="fas fa-shopping-cart"></i>
                                <span class="badge bg-primary position-absolute top-0 start-100 translate-middle" id="basketCount" style="display: none;">0</span>
                            </a>
                        </li>
                        @endif
                    </ul>
                </div>
            </div>
        </nav>

        
        @auth('client')
        <script>
            window.routes = window.routes || {};
            window.routes.accountList = '{{ route("store.auth.account-list") }}';
            window.routes.switchAccount = '{{ route("store.auth.switch-account") }}';
            window.csrfToken = '{{ csrf_token() }}';
            window.translations = window.translations || {};
            window.translations.switchAccountError = '{{ __("store.clientarea_nav_switch_account_error") }}';
            window.translations.switchAccountSuccess = '{{ __("store.clientarea_nav_switch_account_success") }}';
            window.translations.loadAccountsError = '{{ __("store.clientarea_nav_load_accounts_error") }}';
            window.translations.ownAccount = '{{ __("store.clientarea_nav_own_account") }}';
        </script>
        <nav class="navbar navbar-expand-lg navbar-dark bg-primary py-0">
            <div class="container">
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#clientAreaNav">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="clientAreaNav">
                    <ul class="navbar-nav me-auto">
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('store.auth.dashboard') ? 'active' : '' }}" href="{{ route('store.auth.dashboard') }}">
                                <i class="fas fa-home me-1"></i>{{ __('store.clientarea_nav_dashboard') }}
                            </a>
                        </li>
                        @if(!$isSwitched || $hasServiceAccess())
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('store.auth.services*') ? 'active' : '' }}" href="{{ route('store.auth.services') }}">
                                <i class="fas fa-server me-1"></i>{{ __('store.clientarea_nav_services') }}
                            </a>
                        </li>
                        @endif
                        @if(!$isSwitched || $hasDomainAccess())
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('store.auth.domains*') ? 'active' : '' }}" href="{{ route('store.auth.domains') }}">
                                <i class="fas fa-globe me-1"></i>{{ __('store.clientarea_nav_domains') }}
                            </a>
                        </li>
                        @endif
                        @if(!$isSwitched && auth('client')->user()->resellerProfile?->isActive())
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('store.auth.reseller*') ? 'active' : '' }}" href="{{ route('store.auth.reseller.dashboard') }}">
                                <i class="fas fa-crown me-1"></i>{{ __('store/reseller.nav_title') }}
                            </a>
                        </li>
                        @elseif(!$isSwitched && !app(\App\Services\Store\BrandContext::class)->isBranded())
                        
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('store.auth.reseller.apply') ? 'active' : '' }}" href="{{ route('store.auth.reseller.apply') }}">
                                <i class="fas fa-crown me-1"></i>{{ __('store/reseller.apply_nav') }}
                            </a>
                        </li>
                        @endif
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle {{ request()->routeIs('store.auth.invoices*') || request()->routeIs('store.auth.quotes*') || request()->routeIs('store.auth.add-funds*') || request()->routeIs('store.auth.affiliate*') ? 'active' : '' }}" href="#" role="button" data-bs-toggle="dropdown">
                                <i class="fas fa-coins me-1"></i>{{ __('store.clientarea_nav_financial') }}
                            </a>
                            <ul class="dropdown-menu">
                                @if(!$isSwitched || in_array($P::VIEW_INVOICES, $permissions))
                                <li><a class="dropdown-item" href="{{ route('store.auth.invoices') }}"><i class="fas fa-file-invoice me-2"></i>{{ __('store.clientarea_nav_invoices') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.quotes') }}"><i class="fas fa-file-alt me-2"></i>{{ __('store.quotes_title') }}</a></li>
                                @endif
                                @if(!$isSwitched)
                                @if(setting('enable_credit'))
                                <li><a class="dropdown-item" href="{{ route('store.auth.add-funds.index') }}"><i class="fas fa-wallet me-2"></i>{{ __('store.add_funds_title') }}</a></li>
                                @endif
                                <li><a class="dropdown-item" href="{{ route('store.auth.affiliate.dashboard') }}"><i class="fas fa-handshake me-2"></i>{{ __('store.affiliate_title') }}</a></li>
                                @endif
                            </ul>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle {{ request()->routeIs('store.auth.tickets*') || request()->routeIs('store.auth.contracts*') || request()->routeIs('store.auth.downloads*') || request()->routeIs('store.auth.emails*') ? 'active' : '' }}" href="#" role="button" data-bs-toggle="dropdown">
                                <i class="fas fa-life-ring me-1"></i>{{ __('store.clientarea_nav_support') }}
                            </a>
                            <ul class="dropdown-menu">
                                @if(!$isSwitched || in_array($P::VIEW_TICKETS, $permissions))
                                <li><a class="dropdown-item" href="{{ route('store.auth.tickets') }}"><i class="fas fa-ticket-alt me-2"></i>{{ __('store.clientarea_nav_tickets') }}</a></li>
                                @endif
                                @if(!$isSwitched || in_array($P::VIEW_INVOICES, $permissions))
                                <li><a class="dropdown-item" href="{{ route('store.auth.contracts') }}"><i class="fas fa-file-contract me-2"></i>{{ __('store.contracts_title') }}</a></li>
                                @endif
                                @if(!$isSwitched || $hasServiceAccess())
                                <li><a class="dropdown-item" href="{{ route('store.auth.downloads') }}"><i class="fas fa-download me-2"></i>{{ __('store.downloads_title') }}</a></li>
                                @endif
                                @if(!$isSwitched)
                                <li><a class="dropdown-item" href="{{ route('store.auth.emails') }}"><i class="fas fa-envelope me-2"></i>{{ __('store.email_history_title') }}</a></li>
                                @endif
                            </ul>
                        </li>
                    </ul>

                    
                    <ul class="navbar-nav">
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="accountSwitcher" role="button" data-bs-toggle="dropdown">
                                <i class="fas fa-user-circle me-1"></i>
                                <span id="currentAccountName">{{ auth('client')->user()->company_name ?: (auth('client')->user()->first_name . ' ' . auth('client')->user()->last_name) }}</span>
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end" id="accountList" style="min-width: 260px;">
                                
                                <li><h6 class="dropdown-header"><i class="fas fa-exchange-alt me-1"></i> {{ __('store.clientarea_nav_switch_account') }}</h6></li>
                                <li><hr class="dropdown-divider"></li>
                                <li class="text-center py-2">
                                    <div class="spinner-border spinner-border-sm" role="status">
                                        <span class="visually-hidden">Loading...</span>
                                    </div>
                                </li>
                                <li>
                                    <a class="dropdown-item" href="{{ route('store.index') }}">
                                        <i class="fas fa-store me-2"></i>{{ __('store.clientarea_nav_back_to_store') }}
                                    </a>
                                </li>
                                <li><hr class="dropdown-divider"></li>

                                
                                @if(!$isSwitched)
                                <li><h6 class="dropdown-header"><i class="fas fa-user-cog me-1"></i> {{ __('store.clientarea_nav_profile') }}</h6></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.index') }}"><i class="fas fa-user-edit me-2"></i>{{ __('store.clientarea_profile_navigation_edit_profile') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.saved-methods') }}"><i class="fas fa-credit-card me-2"></i>{{ __('store.clientarea_profile_navigation_payment_methods') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.billing-addresses.index') }}"><i class="fas fa-address-book me-2"></i>{{ __('store.clientarea_profile_navigation_billing_addresses') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.authorized-accounts') }}"><i class="fas fa-users me-2"></i>{{ __('store.clientarea_profile_navigation_authorized_accounts') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.my-authorizations') }}"><i class="fas fa-user-shield me-2"></i>{{ __('store.clientarea_profile_navigation_my_authorizations') }}</a></li>
                                @if(\App\Models\Setting::getValue('client_email_preferences', true))
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.communication-preferences') }}"><i class="fas fa-bell me-2"></i>{{ __('store.clientarea_profile_navigation_communication_preferences') }}</a></li>
                                @endif
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.account-activity') }}"><i class="fas fa-history me-2"></i>{{ __('store.clientarea_profile_navigation_account_activity') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.login-history') }}"><i class="fas fa-shield-alt me-2"></i>{{ __('store.login_history_title') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.profile.notifications') }}"><i class="fas fa-envelope me-2"></i>{{ __('store.clientarea_profile_navigation_notifications') }}</a></li>
                                <li><a class="dropdown-item" href="{{ route('store.auth.data-privacy') }}"><i class="fas fa-user-lock me-2"></i>{{ __('store.data_privacy_title') }}</a></li>
                                <li><hr class="dropdown-divider"></li>
                                @endif

                                
                                <li>
                                    <form action="{{ route('store.auth.logout') }}" method="POST">
                                        @csrf
                                        <button type="submit" class="dropdown-item text-danger">
                                            <i class="fas fa-sign-out-alt me-2"></i>{{ __('store.nav_logout') }}
                                        </button>
                                    </form>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        @endauth
        @endunless

        

        <!-- Flash Messages -->
        @if(session('success') || session('error') || session('warning') || session('info'))
        <div class="container mt-3">
            @if(session('success'))
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <i class="fas fa-check-circle me-2"></i>
                {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            @endif

            @if(session('error'))
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <i class="fas fa-exclamation-circle me-2"></i>
                {{ session('error') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            @endif

            @if(session('warning'))
            <div class="alert alert-warning alert-dismissible fade show" role="alert">
                <i class="fas fa-exclamation-triangle me-2"></i>
                {{ session('warning') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            @endif

            @if(session('info'))
            <div class="alert alert-info alert-dismissible fade show" role="alert">
                <i class="fas fa-info-circle me-2"></i>
                {{ session('info') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            @endif
        </div>
        @endif

        <!-- Page Content -->
        <main class="flex-grow-1">
            @hook('ClientAreaContentBefore')
            @yield('content')
            @hook('ClientAreaContentAfter')
        </main>

        <!-- Footer -->
        <footer class="footer">
            <div class="container">
                @menu('footer_primary', 'vertical')

                <div class="text-center mt-3">
                    <p class="mb-0">
                        @if($activeBrand?->footer_text)
                            {!! $activeBrand->footer_text !!}
                        @else
                            &copy; {{ date('Y') }} {{ $appName }}. {{ __('store.all_rights_reserved') }}
                        @endif
                    </p>
                </div>
            </div>
        </footer>
    </div>

    <!-- Visitor Tracking Script -->


    <script>
        // Global variables for JavaScript - global.js'den sonra yükle
        window.routes = {
            basketSummary: '{{ route("api.store.basket.summary") }}',
            basketUpdate: '{{ route("api.store.basket.update", ":index") }}',
            basketRemove: '{{ route("api.store.basket.remove", ":index") }}',
            basketApplyCoupon: '{{ route("api.store.basket.apply-coupon") }}',
            basketRemoveCoupon: '{{ route("api.store.basket.remove-coupon") }}'
        };

        // Common URLs for store-api.js
        window.addToBasketUrl = '{{ route("api.store.basket.add") }}';
        window.domainCheckUrl = '{{ route("api.store.domain.check") }}';
        window.calculateProductUrl = '{{ route("api.store.products.calculate", ":id") }}';
        window.csrfToken = '{{ csrf_token() }}';

        window.translations = {
            // Nav
            store_nav_basket: '{{ __("store.nav_basket") }}',
            store_nav_theme_switch_dark: '{{ __("store.nav_theme_switch_dark") }}',
            store_nav_theme_switch_light: '{{ __("store.nav_theme_switch_light") }}',

            // PRC-836 — checkbox CF gösterimi (sepet özet)
            common_yes                     : '{{ __("store.common_yes") }}',
            common_no                      : '{{ __("store.common_no") }}',

            // Basket
            store_basket_subtotal          : '{{ __("store.basket_subtotal") }}',
            store_basket_tax               : '{{ __("store.basket_tax") }}',
            store_basket_total             : '{{ __("store.basket_total") }}',
            store_basket_options           : '{{ __("store.basket_options") }}',
            store_basket_domain            : '{{ __("store.basket_domain") }}',
            store_basket_empty             : '{{ __("store.basket_empty") }}',
            store_basket_loading           : '{{ __("store.nav_basket_loading") }}',
            store_basket_period_month      : '{{ __("store.basket_period_type_month") }}',
            store_basket_period_year       : '{{ __("store.basket_period_type_year") }}',
            store_basket_delete            : '{{ __("store.buttons_delete") }}',
            store_basket_discount          : '{{ __("store.basket_discount") }}',
            store_basket_promo_code_applied: '{{ __("store.basket_promo_code_applied") }}',
            store_basket_promo_code_removed: '{{ __("store.basket_promo_code_removed") }}',
            store_basket_invalid_promo_code: '{{ __("store.basket_invalid_promo_code") }}',

            // Products
            store_products_configurable_options  : '{{ __("store.products_configurable_options") }}',
            store_products_select_option         : '{{ __("store.products_select_option") }}',
            store_products_config_option_required: '{{ __("store.products_config_option_required") }}',
            store_products_no_config_options     : '{{ __("store.products_no_config_options") }}',
            store_products_loading_config_options: '{{ __("store.products_loading_config_options") }}',
            store_products_calculating           : '{{ __("store.products_calculating") }}',
            store_products_free                  : '{{ __("store.products_free") }}',
            store_products_options               : '{{ __("store.products_options") }}',
            store_products_options_plural        : '{{ __("store.products_options_plural") }}',
            store_products_limit                 : '{{ __("store.products_limit") }}',
            store_products_period_month          : '{{ __("store.products_period_type_month") }}',
            store_products_period_year           : '{{ __("store.products_period_type_year") }}',
            store_products_pricing_options       : '{{ __("store.products_pricing_options") }}',
            store_products_currency              : '{{ __("store.products_currency") }}',
            store_products_period_1_month        : '{{ __("store.products_periods_1_month") }}',
            store_products_period_3_months       : '{{ __("store.products_periods_3_months") }}',
            store_products_period_6_months       : '{{ __("store.products_periods_6_months") }}',
            store_products_period_12_months      : '{{ __("store.products_periods_12_months") }}',
            store_products_period_24_months      : '{{ __("store.products_periods_24_months") }}',
            store_products_period_36_months      : '{{ __("store.products_periods_36_months") }}',
            store_products_min                   : '{{ __("store.products_min") }}',
            store_products_max                   : '{{ __("store.products_max") }}',
            store_products_price_label           : '{{ __("store.products_price_label") }}',
            store_products_tax                   : '{{ __("store.products_tax") }}',

            // Domain
            store_domain_registration_price  : '{{ __("store.domain_registration_price") }}',
            store_domain_transfer_price      : '{{ __("store.domain_transfer_price") }}',
            store_domain_transfer_code       : '{{ __("store.domain_transfer_code") }}',
            store_domain_nameservers         : '{{ __("store.domain_nameservers") }}',
            store_domain_existing_domain_free: '{{ __("store.domain_existing_domain_free") }}',
            store_domain_available           : '{{ __("store.domain_available") }}',
            store_domain_transferable        : '{{ __("store.domain_transferable") }}',
            store_domain_usable              : '{{ __("store.domain_usable") }}',
            store_domain_unavailable         : '{{ __("store.domain_unavailable") }}',
            store_domain_not_transferable    : '{{ __("store.domain_not_transferable") }}',
            store_domain_not_usable          : '{{ __("store.domain_not_usable") }}',
            store_domain_checking            : '{{ __("store.domain_checking") }}',
            store_domain_check               : '{{ __("store.domain_check") }}',
            store_domain_use_domain          : '{{ __("store.domain_use_domain") }}',

            // Validation
            store_validation_domain_required   : '{{ __("store.validation_domain_required") }}',
            store_validation_please_fill_fields: '{{ __("store.validation_please_fill_fields") }}',

            // Products - Additional
            store_products_adding_to_cart: '{{ __("store.products_adding_to_cart") }}',
            store_products_added_to_cart : '{{ __("store.products_added_to_cart") }}',
            store_products_add_to_cart   : '{{ __("store.products_add_to_cart") }}',

            // Messages
            store_messages_domain_selected_and_calculated: '{{ __("store.messages_domain_selected_and_calculated") }}',
            store_messages_error_occurred                : '{{ __("store.messages_error_occurred") }}',

            // Products - Additional Keys
            store_products_option                    : '{{ __("store.products_option") }}',
            store_products_pricing_selection_required: '{{ __("store.products_pricing_selection_required") }}',
            store_products_add_to_cart_error         : '{{ __("store.products_add_to_cart_error") }}',

            // Domain - Additional Keys
            store_domain_not_suitable: '{{ __("store.domain_not_suitable") }}',
            loadingAddresses         : '{{ __("store.checkout_loading_addresses") }}',
            errorLoadingAddresses    : '{{ __("store.checkout_error_loading_addresses") }}',
            errorSelectingAddress    : '{{ __("store.checkout_error_selecting_address") }}',
            errorDeletingAddress     : '{{ __("store.checkout_error_deleting_address") }}',
            errorSavingAddress       : '{{ __("store.checkout_error_saving_address") }}',
            confirmDeleteAddress     : '{{ __("store.checkout_confirm_delete_address") }}',
            loading                  : '{{ __("store.common_loading") }}',

            // Billing form translations
            billingForm: {
                addressTitle           : '{{ __("store.checkout_billing_form_address_title") }}',
                setAsDefault           : '{{ __("store.checkout_billing_form_set_as_default") }}',
                firstName              : '{{ __("store.checkout_billing_form_first_name") }}',
                lastName               : '{{ __("store.checkout_billing_form_last_name") }}',
                email                  : '{{ __("store.checkout_billing_form_email") }}',
                phone                  : '{{ __("store.checkout_billing_form_phone") }}',
                companyName            : '{{ __("store.checkout_billing_form_company_name") }}',
                taxId                  : '{{ __("store.checkout_billing_form_tax_id") }}',
                address1               : '{{ __("store.checkout_billing_form_address1") }}',
                address2               : '{{ __("store.checkout_billing_form_address2") }}',
                country                : '{{ __("store.checkout_billing_form_country") }}',
                selectCountry          : '{{ __("store.checkout_billing_form_select_country") }}',
                city                   : '{{ __("store.checkout_billing_form_city") }}',
                selectCity             : '{{ __("store.checkout_billing_form_select_city") }}',
                state                  : '{{ __("store.checkout_billing_form_state") }}',
                postcode               : '{{ __("store.checkout_billing_form_postcode") }}',
                addressDetails         : '{{ __("store.checkout_billing_form_address_details") }}',
                editAddress            : '{{ __("store.checkout_billing_form_edit_address") }}',
                addNewAddress          : '{{ __("store.checkout_billing_form_add_new_address") }}',
                additionalInformation  : '{{ __("store.checkout_billing_form_additional_information") }}',
                selectOption           : '{{ __("store.checkout_billing_form_select_option") }}',
                checkThisOption        : '{{ __("store.checkout_billing_form_check_this_option") }}',
                savedAddresses         : '{{ __("store.checkout_billing_form_saved_addresses") }}',
                addNew                 : '{{ __("store.checkout_billing_form_add_new") }}',
                noSavedAddresses       : '{{ __("store.checkout_billing_form_no_saved_addresses") }}',
                untitledAddress        : '{{ __("store.checkout_billing_form_untitled_address") }}',
                default                : '{{ __("store.checkout_billing_form_default") }}',
                selectAddressToContinue: '{{ __("store.checkout_billing_form_select_address_to_continue") }}',
                cancel                 : '{{ __("store.checkout_billing_form_cancel") }}',
                save                   : '{{ __("store.checkout_billing_form_save") }}',
                update                 : '{{ __("store.checkout_billing_form_update") }}',
            },
        };

        // Routes yüklendikten sonra basket'i başlat
        if (window.initializeBasketAfterRoutes) {
            window.initializeBasketAfterRoutes();
        }
    </script>
    @unless(Route::is('store.basket.index'))
        @vite('resources/js/store/basket.js')
    @endunless

    @stack('scripts')
    @stack('captcha-scripts')

    
    @if(isset($themeAssets) && !empty($themeAssets['js']))
        @foreach($themeAssets['js'] as $js)
            <script src="{{ asset($js) }}"></script>
        @endforeach
    @endif

    
    @if($activeBrand?->custom_js)
    <script>{!! $activeBrand->custom_js !!}</script>
    @endif

    @auth('client')
        @unless(request()->routeIs('store.auth.login') || request()->routeIs('store.auth.register'))
            @vite('resources/js/store/account-switcher.js')
        @endunless
    @endauth

    @include('partials.consent-banner')
    @vite(['resources/js/store/consent.js', 'resources/css/store/consent.css'])
    @include('store._partials.chat-widget')
    @hook('ClientAreaFooterOutput')
</body>
</html>
