<!DOCTYPE html>
<html lang="bn">
@php
  /** @var \App\Models\GeneralSetting $settings */
  $gs = $settings ?? new \App\Models\GeneralSetting();

  $siteName = $gs->site_name ?? 'EARNING MARKETPLACE - DIGITAL BUSINESS PLATFORM';
  $siteDesc = $gs->site_description ?? 'Digital Business Platform';
  $siteLabel = app_site_label();
  $siteHost = app_base_host();
  $supportEmail = app_support_email();
  $shortSiteName = $siteLabel !== '' ? $siteLabel : $siteName;
  $alternateSiteName = trim((string) ($siteLabel !== '' ? $siteLabel : $siteHost));

  $pageTitle = trim($__env->yieldContent('title'));
  $fullTitle = $pageTitle ? ($pageTitle . ' - ' . $siteName) : $siteName;

  $metaDesc = trim($__env->yieldContent('meta_description')) ?: $siteDesc;
  $metaKeywords = trim($__env->yieldContent('meta_keywords')) ?: implode(', ', array_values(array_filter(array_unique([
    $siteName,
    $siteLabel,
    $siteHost,
    'Bangladesh',
    'ecommerce',
    'reseller',
    'online shop',
    'digital platform',
  ]))));
  $ogTitle  = trim($__env->yieldContent('og_title')) ?: $fullTitle;
  $ogDesc   = trim($__env->yieldContent('og_description')) ?: $siteDesc;
  $currentRouteName = \Illuminate\Support\Facades\Route::currentRouteName();
  $publicSeoRoutes = [
    'shop.index',
    'shop.search',
    'shop.product',
    'shop.category',
    'shop.categories.all',
    'shop.vendors.index',
    'shop.vendors.show',
    'policy.reselling',
  ];
  $robotsContent = trim($__env->yieldContent('meta_robots'));
  if ($robotsContent === '') {
    $robotsContent = in_array((string) $currentRouteName, $publicSeoRoutes, true)
      ? 'index,follow,max-image-preview:large,max-snippet:-1,max-video-preview:-1'
      : 'noindex,nofollow';
  }
  $canonicalUrl = trim($__env->yieldContent('canonical_url'));
  if ($canonicalUrl === '') {
    $canonicalQuery = request()->except([
      'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid'
    ]);
    $canonicalUrl = request()->url();
    if (!empty($canonicalQuery)) {
      $canonicalUrl .= '?' . \Illuminate\Support\Arr::query($canonicalQuery);
    }
  }
  $siteImageRaw = trim((string) (($gs->banner ?? null) ?: ($gs->logo ?? null) ?: ($gs->favicon ?? null) ?: ''));
  $defaultImage = $siteImageRaw !== ''
    ? (preg_match('/^https?:\/\//i', $siteImageRaw) ? $siteImageRaw : asset(ltrim($siteImageRaw, '/')))
    : asset('favicon.png');
  $metaImage = trim($__env->yieldContent('meta_image')) ?: $defaultImage;
  $twitterCard = trim($__env->yieldContent('twitter_card')) ?: 'summary_large_image';
  $sameAsLinks = \App\Models\GeneralSetting::socialProfileLinks($gs);
  $organizationSchema = [
    '@context' => 'https://schema.org',
    '@type' => 'Organization',
    '@id' => url('/') . '#organization',
    'name' => $siteName,
    'url' => url('/'),
    'description' => $siteDesc,
    'email' => $supportEmail,
  ];
  if ($alternateSiteName !== '' && strcasecmp($alternateSiteName, $siteName) !== 0) {
    $organizationSchema['alternateName'] = $alternateSiteName;
  }
  if ($defaultImage !== '') {
    $organizationSchema['logo'] = [
      '@type' => 'ImageObject',
      'url' => $defaultImage,
    ];
    $organizationSchema['image'] = $defaultImage;
  }
  if (count($sameAsLinks) > 0) {
    $organizationSchema['sameAs'] = $sameAsLinks;
  }
  $websiteSchema = [
    '@context' => 'https://schema.org',
    '@type' => 'WebSite',
    '@id' => url('/') . '#website',
    'name' => $siteName,
    'url' => url('/'),
    'description' => $siteDesc,
    'inLanguage' => 'bn-BD',
    'publisher' => ['@id' => url('/') . '#organization'],
    'potentialAction' => [
      '@type' => 'SearchAction',
      'target' => route('shop.search') . '?q={search_term_string}',
      'query-input' => 'required name=search_term_string',
    ],
  ];
  if ($alternateSiteName !== '' && strcasecmp($alternateSiteName, $siteName) !== 0) {
    $websiteSchema['alternateName'] = $alternateSiteName;
  }
  $googleAnalyticsId = $gs->google_analytics_id;
  $googleTagManagerId = $gs->google_tag_manager_id;
  $facebookPixelId = $gs->facebook_pixel_id;
  $customHeadTrackingCode = $gs->custom_head_tracking_code;
  $customBodyTrackingCode = $gs->custom_body_tracking_code;

  $authUser = auth()->user();
  $currentRoute = $currentRouteName;
  $currentPath = trim((string) request()->path(), '/');
  $fallbackProjectPrefixes = [
    'welcome-offer',
    'typing-job',
    'quiz-job',
    'leadership',
    'offers',
    'buy-offer',
    'orders',
    'course',
    'targets',
    'in',
    'instagram/submit',
    'fb/marketing',
    'telegram-sell',
    'telegram-sell-info',
    'micro-jobs',
    'user/jobs',
    'user/gmail-sales-history',
    'my-job-history',
    'jobs',
    'drive-packs',
    'dg-services',
    'recharge',
    'salary',
    'claim-salary',
    'shop',
    'search',
    'product',
    'category',
    'checkout',
    'pd-orders',
    'gmail-sell',
  ];
  $projectPathPrefixes = [];
  $matchedProject = null;
  $matchedProjectPathLen = -1;
  try {
    if (\Illuminate\Support\Facades\Schema::hasTable('dashboard_projects')) {
      $projects = \App\Models\DashboardProject::query()
        ->select(['id','title','link','is_active','allowed_for_inactive','inactive_popup_title','inactive_popup_message'])
        ->get();

      foreach ($projects as $project) {
        $link = trim((string) $project->link);
        if ($link === '' || $link === '#') {
          continue;
        }
        if (str_starts_with(strtolower($link), 'javascript:')) {
          continue;
        }

        foreach (\App\Support\DashboardProjectPathRegistry::pathPrefixesForLink($link) as $path) {
          if ($path === '') {
            continue;
          }

          $projectPathPrefixes[] = $path;

          if (\App\Support\DashboardProjectPathRegistry::pathMatchesPrefix($currentPath, $path)) {
            $pathLen = strlen($path);
            if ($pathLen > $matchedProjectPathLen) {
              $matchedProjectPathLen = $pathLen;
              $matchedProject = $project;
            }
          }
        }
      }
    }
  } catch (\Throwable $e) {
    $projectPathPrefixes = [];
  }
  if (count($projectPathPrefixes) === 0) {
    $projectPathPrefixes = $fallbackProjectPrefixes;
  } else {
    $projectPathPrefixes = array_values(array_unique(array_merge($projectPathPrefixes, $fallbackProjectPrefixes)));
  }
  $isProjectPath = false;
  foreach ($projectPathPrefixes as $prefix) {
    if ($currentPath === $prefix || str_starts_with($currentPath, $prefix . '/')) {
      $isProjectPath = true;
      break;
    }
  }
  $inactivePopupExcludedRoutes = [
    'dashboard',
    'activation.form',
    'activation.submit',
    'activation.success',
  ];
  $inactiveGlobalAllow = false;
  try {
    if (\Illuminate\Support\Facades\Schema::hasTable('settings')) {
      $inactiveGlobalAllow = (int) (\App\Models\Setting::query()
        ->where('key', 'inactive_global_allow')
        ->orderByDesc('id')
        ->value('value') ?? 0) === 1;
    }
  } catch (\Throwable $e) {
    $inactiveGlobalAllow = false;
  }
  $inactivePopupTitle = 'অ্যাকাউন্ট ভেরিফাই করুন';
  $inactivePopupMessage = 'প্রজেক্টে সম্পূর্ণ কাজ করতে আপনার অ্যাকাউন্ট ভেরিফাই করা প্রয়োজন।';
  $inactiveAllowedForProject = false;
  if ($matchedProject) {
    $inactiveAllowedForProject =
      (int) ($matchedProject->allowed_for_inactive ?? 0) === 1
      || (int) ($matchedProject->is_active ?? 0) === 1;
    $customTitle = trim((string) ($matchedProject->inactive_popup_title ?? ''));
    $customMessage = trim((string) ($matchedProject->inactive_popup_message ?? ''));
    if ($customTitle !== '') {
      $inactivePopupTitle = $customTitle;
    }
    if ($customMessage !== '') {
      $inactivePopupMessage = $customMessage;
    }
  }
  $showInactiveVerifyPopup = $authUser
    && (int) ($authUser->is_active ?? 0) === 0
    && $isProjectPath
    && !in_array((string) $currentRoute, $inactivePopupExcludedRoutes, true)
    && !($inactiveGlobalAllow || $inactiveAllowedForProject);
  $inactiveLockClass = $showInactiveVerifyPopup ? 'inactive-lock' : '';
@endphp
<head>
  <meta charset="UTF-8" />
  <title>{{ $fullTitle }}</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />

  <meta name="application-name" content="{{ $siteName }}" />
  <meta name="apple-mobile-web-app-title" content="{{ $shortSiteName }}" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="description" content="{{ $metaDesc }}" />
  <meta name="keywords" content="{{ $metaKeywords }}" />
  <meta name="robots" content="{{ $robotsContent }}" />
  <link rel="canonical" href="{{ $canonicalUrl }}" />
  <link rel="manifest" href="{{ route('seo.manifest') }}" />
  <meta property="og:title" content="{{ $ogTitle }}" />
  <meta property="og:description" content="{{ $ogDesc }}" />
  <meta property="og:type" content="website" />
  <meta property="og:url" content="{{ $canonicalUrl }}" />
  <meta property="og:image" content="{{ $metaImage }}" />
  <meta property="og:image:alt" content="{{ $siteName }}" />
  <meta property="og:site_name" content="{{ $siteName }}" />
  <meta property="og:locale" content="bn_BD" />
  <meta name="twitter:card" content="{{ $twitterCard }}" />
  <meta name="twitter:title" content="{{ $ogTitle }}" />
  <meta name="twitter:description" content="{{ $ogDesc }}" />
  <meta name="twitter:image" content="{{ $metaImage }}" />
  <meta name="theme-color" content="{{ $gs->icon_color ?? '#2563eb' }}" />
  @foreach(\App\Models\GeneralSetting::verificationTokens($gs->google_site_verification) as $googleVerificationToken)
    <meta name="google-site-verification" content="{{ $googleVerificationToken }}" />
  @endforeach
  @foreach(\App\Models\GeneralSetting::verificationTokens($gs->bing_site_verification) as $bingVerificationToken)
    <meta name="msvalidate.01" content="{{ $bingVerificationToken }}" />
  @endforeach

  <meta name="csrf-token" content="{{ csrf_token() }}" />
  <meta name="referrer" content="strict-origin-when-cross-origin" />
  <script type="application/ld+json">{!! json_encode($organizationSchema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) !!}</script>
  <script type="application/ld+json">{!! json_encode($websiteSchema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) !!}</script>
  @yield('structured_data')
  @if($googleTagManagerId)
    <script>
      (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});
      var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
      j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
      f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','{{ $googleTagManagerId }}');
    </script>
  @endif
  @if($googleAnalyticsId && !$googleTagManagerId)
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ $googleAnalyticsId }}"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', '{{ $googleAnalyticsId }}');
    </script>
  @endif
  @if($facebookPixelId)
    <script>
      !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
      n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', '{{ $facebookPixelId }}');
      fbq('track', 'PageView');
    </script>
  @endif
  @if($customHeadTrackingCode)
    {!! $customHeadTrackingCode !!}
  @endif

  <link
    href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
    rel="stylesheet"
    integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
    crossorigin="anonymous">

  <script>
    window.tailwind = window.tailwind || {};
    tailwind.config = { corePlugins: { preflight: false } };
  </script>
  <script src="https://cdn.tailwindcss.com"></script>

  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Bengali:wght@400;600;700;800&display=swap" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"/>

  @includeIf('partials.favicon')

  <style>
    :root{
      --header-h: 60px;
      --bg: #f8fafc;
      --ink:#0f172a;
      --pri:#2563eb;
      --pri2:#1d4ed8;
    }
    html, body{
      margin:0; min-height:100%;
      background:var(--bg);
      color:var(--ink);
      font-family:'Noto Sans Bengali',system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
      scroll-behavior:smooth;
      overflow-x:hidden;
    }
    body.inactive-lock{
      overflow:hidden;
    }
    body.inactive-lock #fixed-header,
    body.inactive-lock .main-content-shell,
    body.inactive-lock footer,
    body.inactive-lock #sidebar,
    body.inactive-lock #sidebar-backdrop,
    body.inactive-lock .skip-link{
      visibility:hidden;
    }
    body.inactive-lock .verify-modal{
      display:flex;
    }
    a, a:hover, a:focus, a:active, a:visited{ text-decoration:none !important; color:inherit; }
    *, *::before, *::after{
      box-sizing:border-box;
      -webkit-tap-highlight-color:transparent;
    }
    :focus{ outline:none; }
    :focus-visible{ outline:2px solid rgba(37,99,235,.35); outline-offset:2px; border-radius:10px; }
    .skip-link{ position:absolute; left:-9999px; top:auto; }
    .skip-link:focus{ left:8px; top:8px; background:#111; color:#fff; padding:8px 12px; z-index:9999; border-radius:6px; }
    .main-content-shell{
      width:100%;
      padding-left:10px;
      padding-right:10px;
      padding-top:70px;
      padding-bottom:120px;
      padding-left:max(10px, env(safe-area-inset-left));
      padding-right:max(10px, env(safe-area-inset-right));
      padding-bottom:calc(120px + env(safe-area-inset-bottom));
      overflow-x:clip;
    }

    .tutorial-modal{
      position:fixed;
      inset:0;
      z-index:1200;
      display:none;
      align-items:center;
      justify-content:center;
      padding:14px;
      background:rgba(2,6,23,.7);
    }
    .tutorial-card{
      width:min(920px, 100%);
      max-height:90vh;
      background:#fff;
      border-radius:14px;
      overflow:hidden;
      box-shadow:0 18px 50px rgba(0,0,0,.35);
      display:flex;
      flex-direction:column;
    }
    .tutorial-head{
      padding:12px 14px;
      border-bottom:1px solid #e2e8f0;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
    }
    .tutorial-title{
      margin:0;
      font-size:15px;
      font-weight:900;
      color:#0f172a;
      line-height:1.3;
    }
    .tutorial-close{
      width:34px;
      height:34px;
      border:0;
      border-radius:10px;
      background:#e2e8f0;
      color:#0f172a;
      font-size:18px;
      cursor:pointer;
      display:inline-flex;
      align-items:center;
      justify-content:center;
    }
    .tutorial-body{
      padding:10px;
      overflow:auto;
      background:#0b1220;
    }
    .tutorial-frame-wrap{
      width:100%;
      aspect-ratio:16/9;
      background:#000;
      border-radius:10px;
      overflow:hidden;
    }
    .tutorial-frame-wrap iframe,
    .tutorial-frame-wrap video{
      width:100%;
      height:100%;
      border:0;
      display:block;
    }

    .verify-modal{
      position:fixed;
      inset:0;
      z-index:1400;
      display:none;
      align-items:center;
      justify-content:center;
      padding:16px;
      background:rgba(2,6,23,.62);
    }
    .verify-card{
      width:min(380px,100%);
      background:#fff;
      border-radius:16px;
      border:2px solid rgba(37,99,235,.55);
      box-shadow:0 18px 40px rgba(2,6,23,.22);
      overflow:hidden;
    }
    .verify-head{
      height:52px;
      background:linear-gradient(90deg,#2563eb,#1d4ed8);
    }
    .verify-body{
      padding:14px;
      text-align:center;
    }
    .verify-title{
      margin:0;
      font-size:18px;
      font-weight:900;
      color:#0f172a;
    }
    .verify-text{
      margin:8px 0 0;
      font-size:13px;
      font-weight:700;
      color:#475569;
      line-height:1.45;
    }
    .verify-action{
      margin-top:12px;
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:6px;
      width:100%;
      border:0;
      border-radius:12px;
      padding:11px 12px;
      background:linear-gradient(90deg,#2563eb,#1d4ed8);
      color:#fff !important;
      font-weight:900;
      text-decoration:none !important;
    }
  </style>

  @stack('head')
  @stack('styles')
</head>
<body class="min-h-screen {{ $inactiveLockClass }}">
  @if($googleTagManagerId)
    <noscript>
      <iframe src="https://www.googletagmanager.com/ns.html?id={{ $googleTagManagerId }}"
              height="0" width="0" style="display:none;visibility:hidden"></iframe>
    </noscript>
  @endif
  @if($facebookPixelId)
    <noscript>
      <img height="1" width="1" style="display:none"
           src="https://www.facebook.com/tr?id={{ $facebookPixelId }}&ev=PageView&noscript=1"
           alt="">
    </noscript>
  @endif
  @if($customBodyTrackingCode)
    {!! $customBodyTrackingCode !!}
  @endif
  <a href="#main-content" class="skip-link">Skip to content</a>

  <header id="fixed-header" class="fixed inset-x-0 top-0 z-50 h-[60px] bg-white/95 backdrop-blur border-bottom border-1 border-slate-200">
    @includeIf('partials.header', ['siteName' => $siteName, 'siteDesc' => $siteDesc])
  </header>

  @includeIf('partials.sidebar')

  @include('layout.partial.flash-messages', ['topOffset' => '74px'])

  <main id="main-content" class="main-content-shell">
    @yield('content')
  </main>

  @includeIf('partials.footer')

  <div id="projectTutorialModal" class="tutorial-modal" aria-hidden="true">
    <div class="tutorial-card" role="dialog" aria-modal="true" aria-labelledby="projectTutorialTitle">
      <div class="tutorial-head">
        <h3 id="projectTutorialTitle" class="tutorial-title">প্রজেক্ট ভিডিও</h3>
        <button type="button" class="tutorial-close" id="projectTutorialClose" aria-label="Close">×</button>
      </div>
      <div class="tutorial-body">
        <div class="tutorial-frame-wrap" id="projectTutorialFrameWrap"></div>
      </div>
    </div>
  </div>

  @if($showInactiveVerifyPopup)
    <div id="inactiveVerifyModal" class="verify-modal" aria-hidden="false">
      <div class="verify-card" role="dialog" aria-modal="true" aria-labelledby="inactiveVerifyTitle">
        <div class="verify-head"></div>
        <div class="verify-body">
          <h3 id="inactiveVerifyTitle" class="verify-title">{{ $inactivePopupTitle }}</h3>
          <p class="verify-text">{{ $inactivePopupMessage }}</p>
          <a href="{{ route('activation.form') }}" class="verify-action">
            <i class="fa-solid fa-circle-check"></i>
            <span>ভেরিফাই করুন</span>
          </a>
        </div>
      </div>
    </div>
  @endif

  <script
    src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
    integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
    crossorigin="anonymous"></script>

  <script>
    function toggleSidebar(){
      const sb = document.getElementById('sidebar');
      const bd = document.getElementById('sidebar-backdrop');
      if (sb) sb.style.transform = 'translateX(0)';
      if (bd){ bd.style.display='block'; bd.style.opacity=1; }
      document.body.style.overflow='hidden';
    }

    function closeSidebar(){
      const sb = document.getElementById('sidebar');
      const bd = document.getElementById('sidebar-backdrop');
      if (sb) sb.style.transform = 'translateX(-100%)';
      if (bd){ bd.style.opacity=0; bd.style.display='none'; }
      document.body.style.overflow='';
    }

    window.addEventListener('keydown', e => {
      if (e.key === 'Escape') {
        closeSidebar();
      }
    });

    (function(){
      const fh = document.getElementById('fixed-header');
      const main = document.getElementById('main-content');
      if(!fh || !main) return;
      const apply = () => {
        const h = fh.getBoundingClientRect().height || 60;
        main.style.paddingTop = (h + 10) + 'px';
      };
      apply();
      window.addEventListener('resize', apply);
    })();
  </script>

  <script>
    (() => {
      const modal = document.getElementById('projectTutorialModal');
      const closeBtn = document.getElementById('projectTutorialClose');
      const titleEl = document.getElementById('projectTutorialTitle');
      const frameWrap = document.getElementById('projectTutorialFrameWrap');

      if (!modal || !closeBtn || !titleEl || !frameWrap) return;

      const closeModal = () => {
        frameWrap.innerHTML = '';
        modal.style.display = 'none';
        modal.setAttribute('aria-hidden', 'true');
        document.body.style.overflow = '';
      };

      const openModal = (title, type, src) => {
        if (!type || !src) return;
        const safeTitle = (title || '').trim() || 'প্রজেক্ট ভিডিও';

        titleEl.textContent = safeTitle;
        frameWrap.innerHTML = '';

        if (type === 'video') {
          const video = document.createElement('video');
          video.src = src;
          video.controls = true;
          video.playsInline = true;
          frameWrap.appendChild(video);
        } else {
          const iframe = document.createElement('iframe');
          iframe.src = src;
          iframe.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
          iframe.allowFullscreen = true;
          iframe.referrerPolicy = 'strict-origin-when-cross-origin';
          frameWrap.appendChild(iframe);
        }

        modal.style.display = 'flex';
        modal.setAttribute('aria-hidden', 'false');
        document.body.style.overflow = 'hidden';
      };

      document.addEventListener('click', (e) => {
        const trigger = e.target.closest('.project-tutorial-trigger');
        if (!trigger) return;

        const src = (trigger.dataset.tutorialSrc || '').trim();
        const type = (trigger.dataset.tutorialType || '').trim();
        const title = (trigger.dataset.tutorialTitle || '').trim();

        if (!src || !type) {
          e.preventDefault();
          return;
        }

        e.preventDefault();
        openModal(title, type, src);
      });

      closeBtn.addEventListener('click', closeModal);
      modal.addEventListener('click', (e) => {
        if (e.target === modal) closeModal();
      });
      window.addEventListener('keydown', (e) => {
        if (e.key === 'Escape' && modal.style.display === 'flex') {
          closeModal();
        }
      });
    })();
  </script>

  
  


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