<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />

    <title>@yield('title')@if(isset($generalsetting) && $generalsetting) - {{$generalsetting->name}}@endif</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <!-- App favicon -->
    @if(isset($generalsetting->favicon))
    <link rel="shortcut icon" href="{{ asset(str_replace('public/', '', $generalsetting->favicon)) }}" type="image/x-icon" />
    @else
    <link rel="shortcut icon" href="{{asset('backEnd/assets/images/favicon.ico')}}" />
    @endif

    <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=Hind+Siliguri:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">

    <style>
        :root {
            --primary-font: 'Inter', 'Hind Siliguri', sans-serif;
            --title-font: 'Outfit', 'Hind Siliguri', sans-serif;
        }
        body, p, a, span, li, button, input, select, textarea {
            font-family: var(--primary-font) !important;
        }
        /* Fix for icons showing as boxes */
        i, .fa, .fas, .far, .fab, .fe, .mdi, [class^="fe-"], [class*=" fe-"], .menu-arrow {
            font-family: inherit; /* Fallback to theme defaults for icons */
        }
        h1, h2, h3, h4, h5, h6, .pro-user-name, .logo-lg {
            font-family: var(--title-font) !important;
        }
    </style>

    <!-- Bootstrap css -->
    <link href="{{asset('backEnd')}}/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="{{asset('backEnd')}}/assets/css/app.min.css" rel="stylesheet" type="text/css" />
    <link href="{{asset('backEnd')}}/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="{{asset('backEnd')}}/assets/css/toastr.min.css" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css" />
    <link href="{{asset('backEnd')}}/assets/css/custom.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link href="{{asset('backEnd')}}/assets/css/premium_admin.css" rel="stylesheet" type="text/css" />
    @yield('css')
    <style>
        .navbar-custom .dropdown-menu .noti-scroll{max-height:230px!important;overflow-y:auto!important}
    </style>
    <script src="{{asset('backEnd')}}/assets/js/head.js"></script>
  </head>

  <!-- body start -->
  <body data-layout-mode="default" data-theme="light" data-layout-width="fluid" data-topbar-color="dark" data-menu-position="fixed" data-leftbar-color="dark" data-leftbar-size="default" data-sidebar-user="false">
    <!-- Begin page -->
    <div id="wrapper">
      <!-- Topbar Start -->
      <div class="logo-box">
        @php
            $adminLogo = $generalsetting?->white_logo;
            if ($adminLogo && !str_starts_with($adminLogo, 'http')) {
                $adminLogo = str_replace('public/', '', $adminLogo);
            }
        @endphp
        <a href="{{url('panel/dashboard')}}" class="logo logo-dark text-center">
          <span class="logo-sm">
            <img src="{{asset($adminLogo ?? 'public/logo.png')}}" alt="" height="30" />
          </span>
          <span class="logo-lg">
            <img src="{{asset($adminLogo ?? 'public/logo.png')}}" alt="" height="50" />
          </span>
        </a>

        <a href="{{url('panel/dashboard')}}" class="logo logo-light text-center">
          <span class="logo-sm">
            <img src="{{asset($adminLogo ?? 'public/logo.png')}}" alt="" height="30" />
          </span>
          <span class="logo-lg">
            <img src="{{asset($adminLogo ?? 'public/logo.png')}}" alt="" height="50" />
          </span>
        </a>
      </div>

      <div class="navbar-custom">
          <ul class="list-unstyled topnav-menu m-0 d-flex align-items-center">
            <li>
              <button class="button-menu-mobile waves-effect waves-light border-0 bg-transparent">
                <i class="fa-solid fa-bars-staggered"></i>
              </button>
            </li>

            <li class="d-none d-lg-block">
                <div class="topbar-search-wrap">
                    <input type="text" id="admin_search_tools" placeholder="Search orders, customers, products..." autocomplete="off">
                    <button class="search-btn"><i data-feather="search"></i></button>
                </div>
            </li>

            <li class="ms-3 d-none d-md-block">
              <a class="btn btn-pos rounded-pill px-4 fw-bold" href="{{route('home')}}" target="_blank"> 
                <i data-feather="external-link" class="me-1"></i> Visit Store 
              </a>
            </li>
          </ul>

          <ul class="list-unstyled topnav-menu mb-0 d-flex align-items-center">
            
            <li class="dropdown d-none d-lg-inline-block">
              <a class="nav-link dropdown-toggle arrow-none waves-effect waves-light" data-toggle="fullscreen" href="#">
                <i data-feather="maximize" class="noti-icon"></i>
              </a>
            </li>

            <li class="dropdown notification-list topbar-dropdown">
              <a class="nav-link dropdown-toggle waves-effect waves-light" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false">
                <i data-feather="bell" class="noti-icon"></i>
                <span class="badge rounded-circle noti-icon-badge">{{$neworder}}</span>
              </a>
              <div class="dropdown-menu dropdown-menu-end dropdown-lg glass-dropdown">
                <div class="dropdown-item noti-title">
                  <h5 class="m-0 py-1">
                    <span class="float-end">
                      <a href="{{route('admin.orders',['slug'=>'pending'])}}" class="text-primary">
                        <small>Clear All</small>
                      </a>
                    </span>
                    Notifications
                  </h5>
                </div>
                <div class="noti-scroll">
                  @foreach($pendingorder as $porder)
                  <a href="{{route('admin.orders',['slug'=>'pending'])}}" class="dropdown-item notify-item">
                    <div class="notify-icon">
                      <img src="{{asset($porder->customer?$porder->customer->image:'')}}" class="img-fluid rounded-circle border shadow-sm" alt="" onerror="this.src='{{ asset('uploads/default/no-image.png') }}'" />
                    </div>
                    <p class="notify-details fw-bold text-dark mb-0">{{$porder->customer?$porder->customer->name:''}}</p>
                    <p class="text-muted mb-0 user-msg">
                      <small>New Order: #{{$porder->invoice_id}}</small>
                    </p>
                  </a>
                  @endforeach
                </div>
                <a href="{{route('admin.orders',['slug'=>'pending'])}}" class="dropdown-item text-center text-primary fw-bold notify-item notify-all border-top">
                  Manage All Orders <i data-feather="arrow-right"></i>
                </a>
              </div>
            </li>

            <li class="dropdown notification-list topbar-dropdown">
              @php
                  $adminUserImg = Auth::guard('admin')->user()->image;
                  if ($adminUserImg && !str_starts_with($adminUserImg, 'http')) {
                      $adminUserImg = str_replace('public/', '', $adminUserImg);
                  }
              @endphp
              <a class="nav-link dropdown-toggle nav-user me-0 waves-effect waves-light d-flex align-items-center" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false">
                <img src="{{asset($adminUserImg)}}" alt="user-image" class="rounded-circle border border-2 border-light shadow-sm" onerror="this.src='{{ asset('uploads/default/no-image.png') }}'" />
                <span class="pro-user-name ms-2 d-none d-md-inline"> {{Auth::guard('admin')->user()->name}} <i data-feather="chevron-down" style="width: 14px; height: 14px;"></i> </span>
              </a>
              <div class="dropdown-menu dropdown-menu-end profile-dropdown glass-dropdown">
                <div class="dropdown-header noti-title">
                  <h6 class="text-overflow m-0 fw-bold">Admin Portal</h6>
                </div>
                <a href="{{route('admin.profile')}}" class="dropdown-item notify-item">
                  <i data-feather="settings" class="me-2"></i> <span>Preferences</span>
                </a>
                <div class="dropdown-divider"></div>
                <a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();" class="dropdown-item notify-item">
                  <i data-feather="log-out" class="me-2 text-danger"></i> <span class="text-danger fw-bold">Sign Out</span>
                </a>
                <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">@csrf</form>
              </div>
            </li>
          </ul>
          <div class="clearfix"></div>
      </div>
      <!-- end Topbar -->

      <!-- ========== Left Sidebar Start ========== -->
      <div class="left-side-menu">
        <div class="h-100" data-simplebar>
          <!--- Sidemenu -->
          <div id="sidebar-menu">
            <ul id="side-menu">
<li>
  <a href="{{ url('panel/dashboard') }}">
    <i data-feather="airplay"></i>
    <span> Dashboard </span>
  </a>
</li>
              <li class="menu-title mt-2">Sales & Orders</li>
              @can('order-create')
<li>
  <a href="{{route('admin.order.create')}}">
    <i data-feather="cpu"></i>
    <span>POS System</span>
  </a>
</li>
@endcan

@php
  use Illuminate\Support\Facades\Auth;
  // ✅ Use admin guard for permission checks
  $user = Auth::guard('admin')->user();
  // $pending_reviews is already shared from AppServiceProvider
@endphp

{{-- ЁЯЫТ Orders --}}
@canany(['order-list', 'order-edit', 'order-create'])
<li>
  <a href="#sidebar-orders" data-bs-toggle="collapse">
    <i data-feather="shopping-cart"></i>
    <span> Orders </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-orders">
    <ul class="nav-second-level">
      @can('order-list')
      <li><a href="{{ route('admin.orders', ['slug'=>'all']) }}"><i data-feather="file-plus"></i> All Order</a></li>
      <li><a href="{{ route('admin.incomplete-orders.index') }}"><i data-feather="file-plus"></i> Incomplete Orders</a></li>
      @foreach($orderstatus as $value)
        <li><a href="{{ route('admin.orders', ['slug'=>$value->slug]) }}"><i data-feather="file-plus"></i>{{ $value->name }}</a></li>
      @endforeach
      @endcan
      @can('order-edit')
      <li><a href="{{ route('orderstatus.index') }}"><i data-feather="file-plus"></i> Order Status</a></li>
      @endcan
      @can('order-manage')
      <li>
        <a href="{{route('customers.ip_block')}}"><i data-feather="file-plus"></i> IP Block</a>
      </li>
      @endcan

    </ul>
  </div>
</li>
@endcanany

<li class="{{ request()->routeIs('admin.delivery-men.*') ? 'active' : '' }}">
    <a href="{{ route('admin.delivery-men.index') }}">
        <i data-feather="truck"></i>
        <span> Delivery Men </span>
    </a>
</li>

<li class="{{ request()->routeIs('admin.local-delivery.*') ? 'active' : '' }}">
    <a href="{{ route('admin.local-delivery.index') }}">
        <i data-feather="map-pin"></i>
        <span> Local Delivery </span>
    </a>
</li>
<li class="{{ request()->routeIs('admin.rider-revenue.*') ? 'active' : '' }}">
    <a href="{{ route('admin.rider-revenue.index') }}">
        <i data-feather="dollar-sign"></i>
        <span> Rider Revenue </span>
    </a>
</li>

{{-- Refunds --}}
@canany(['order-list', 'order-edit'])
<li class="{{ request()->routeIs('admin.refunds.*') ? 'active' : '' }}">
  <a href="#sidebar-refunds" data-bs-toggle="collapse">
    <i data-feather="rotate-ccw"></i>
    <span> Refunds </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse {{ request()->routeIs('admin.refunds.*') ? 'show' : '' }}" id="sidebar-refunds">
    <ul class="nav-second-level">
      <li><a href="{{ route('admin.refunds.index') }}"><i data-feather="list"></i> All Refunds</a></li>
      <li><a href="{{ route('admin.refunds.index', ['status' => 'pending']) }}"><i data-feather="clock"></i> Pending Refunds</a></li>
      <li><a href="{{ route('admin.refunds.index', ['status' => 'approved']) }}"><i data-feather="check-circle"></i> Approved Refunds</a></li>
      <li><a href="{{ route('admin.refunds.index', ['status' => 'processed']) }}"><i data-feather="check"></i> Processed Refunds</a></li>
    </ul>
  </div>
</li>
@endcanany



              @canany(['setting-list', 'setting-edit'])
              <li>
                <a href="{{ route('admin.order.restriction.setting.index') }}">
                  <i data-feather="clock"></i>
                  <span> Order Restriction</span>
                </a>
              </li>
              @endcanany

              <li class="menu-title mt-2">Catalog & Offers</li>
              @canany(['product-list', 'category-list', 'subcategory-list', 'childcategory-list'])
<li>
  <a href="#siebar-product" data-bs-toggle="collapse">
    <i data-feather="database"></i>
    <span> Products </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="siebar-product">
    <ul class="nav-second-level">
      @can('product-list')
      <li><a href="{{ route('products.index') }}"><i data-feather="package"></i> Manage Products</a></li>
      @endcan
      @can('product-create')
      <li><a href="{{ route('products.create') }}"><i data-feather="plus-circle"></i> Add Product</a></li>
      @endcan
      <li><hr class="dropdown-divider"></li>
      @can('category-list')
      <li><a href="{{ route('categories.index') }}"><i data-feather="file-plus"></i> Categories</a></li>
      @endcan
      @can('subcategory-list')
      <li><a href="{{ route('subcategories.index') }}"><i data-feather="file-plus"></i> Subcategories</a></li>
      @endcan
      @can('childcategory-list')
      <li><a href="{{ route('childcategories.index') }}"><i data-feather="file-plus"></i> Childcategories</a></li>
      @endcan
      @canany(['brand-list', 'brand-create', 'brand-edit'])
      <li><a href="{{ route('brands.index') }}"><i data-feather="file-plus"></i> Brands</a></li>
      @endcanany
      @canany(['color-list', 'color-create', 'color-edit'])
      <li><a href="{{ route('colors.index') }}"><i data-feather="file-plus"></i> Colors</a></li>
      @endcanany
      @canany(['size-list', 'size-create', 'size-edit'])
      <li><a href="{{ route('sizes.index') }}"><i data-feather="file-plus"></i> Sizes</a></li>
      @endcanany
    </ul>
  </div>
</li>
@endcanany

              <li>
                  <a href="{{ route('custom-offers.index') }}">
                      <i data-feather="gift"></i>
                      <span> Custom Offers </span>
                  </a>
              </li>

              @canany(['banner-list'])
              <li>
                  <a href="{{ route('banners.index') }}">
                    <i data-feather="image"></i>
                      <span> Banner & Sliders </span>
                  </a>
              </li>
              @endcanany

              @canany(['popup-list','popup-manage'])
              <li>
                  <a href="{{ route('admin.popup.index') }}">
                      <i data-feather="message-square"></i>
                      <span> Popup Offer </span>
                  </a>
              </li>
              @endcanany

              <li class="menu-title mt-2">Marketing & Analytics</li>
              @canany(['blog-list','blog-create','blog-edit','blog-delete'])
<li>
    <a href="#sidebar-blog" data-bs-toggle="collapse">
        <i data-feather="edit"></i>
        <span> Blog </span>
        <span class="menu-arrow"></span>
    </a>

    <div class="collapse" id="sidebar-blog">
        <ul class="nav-second-level">
            @can('blog-list')
            <li>
                <a href="{{ route('admin.blog.index') }}">
                    <i data-feather="list"></i>
                    All Blogs
                </a>
            </li>
            @endcan

            @can('blog-create')
            <li>
                <a href="{{ route('admin.blog.create') }}">
                    <i data-feather="plus-circle"></i>
                    Add New Blog
                </a>
            </li>
            @endcan
        </ul>
    </div>
</li>
@endcanany

@canany(['coupon-list', 'coupon-create', 'coupon-edit', 'coupon-delete'])
<li>
  <a href="#sidebar-coupon" data-bs-toggle="collapse">
    <i data-feather="gift"></i>
    <span> Coupons </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-coupon">
    <ul class="nav-second-level">
      <li><a href="{{ route('admin.coupons.index') }}"><i data-feather="list"></i> All Coupons</a></li>
      <li><a href="{{ route('admin.coupons.create') }}"><i data-feather="plus-circle"></i> Add New</a></li>
    </ul>
  </div>
</li>
@endcanany

@canany(['campaign-list', 'campaign-create'])
<li>
  <a href="#sidebar-landing-page" data-bs-toggle="collapse">
    <i data-feather="airplay"></i>
    <span> Landing Page </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-landing-page">
    <ul class="nav-second-level">
      <li><a href="{{ route('campaign.index') }}"><i data-feather="file-plus"></i> Campaign List</a></li>
      <li><a href="{{ route('campaign.create') }}"><i data-feather="file-plus"></i> Create New</a></li>
    </ul>
  </div>
</li>
@endcanany

@can('sms-send')
<li>
  <a href="{{ route('admin.sms.custom.page') }}">
    <i data-feather="send"></i>
    <span>Send Custom SMS</span>
  </a>
</li>
@endcan

@canany(['pixel-manage'])
<li>
  <a href="#sidebar-pixel-gtm" data-bs-toggle="collapse">
    <i data-feather="save"></i>
    <span> G. Pixel and GTM </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-pixel-gtm">
    <ul class="nav-second-level">
      <li><a href="{{ route('tagmanagers.index') }}"><i data-feather="file-plus"></i> Tag Manager</a></li>
      <li><a href="{{ route('pixels.index') }}"><i data-feather="file-plus"></i> Pixel Manage</a></li>
      <li><a href="{{ route('tiktok.pixels.index') }}"><i data-feather="film"></i> TikTok Pixel</a></li>
    </ul>
  </div>
</li>

<li>
  <a href="#sidebar-ads-analytics" data-bs-toggle="collapse">
    <i data-feather="trending-up"></i>
    <span> Live Ads Result </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse {{ request()->routeIs('admin.ads_analytics.*') ? 'show' : '' }}" id="sidebar-ads-analytics">
    <ul class="nav-second-level">
      <li><a href="{{ route('admin.ads_analytics.dashboard') }}"><i data-feather="layout"></i> Overview</a></li>
      <li><a href="{{ route('admin.ads_analytics.facebook') }}"><i data-feather="facebook"></i> Facebook Ads</a></li>
      <li><a href="{{ route('admin.ads_analytics.google') }}"><i data-feather="globe"></i> Google Ads</a></li>
      <li><a href="{{ route('admin.ads_analytics.tiktok') }}"><i data-feather="video"></i> TikTok Ads</a></li>
    </ul>
  </div>
</li>

<li>
  <a href="{{ route('admin.facebook_page.settings') }}">
    <i data-feather="share-2"></i>
    <span> Facebook Page Post </span>
  </a>
</li>
@endcanany


              <li class="menu-title mt-2">Procurement & Finance</li>
              @canany(['purchase-list', 'purchase-create', 'purchase-edit'])
<li>
  <a href="{{ route('purchases.index') }}">
    <i data-feather="file-text"></i>
    <span>Purchases</span>
  </a>
</li>
@endcanany
@canany(['supplier-list', 'supplier-create', 'supplier-edit'])
<li>
  <a href="{{ route('admin.suppliers.index') }}">
    <i data-feather="truck"></i>
    <span>Suppliers</span>
  </a>
</li>
@endcanany

@canany(['expense-list', 'expense-create', 'expense-edit'])
<li>
  <a href="{{ route('admin.expenses.index') }}">
    <i data-feather="credit-card"></i>
    <span>Expenses</span>
  </a>
</li>
@endcanany













              <li class="menu-title mt-2">Customer Relations</li>
              @can('review-list')
<li>
  <a href="#sidebar-product-review" data-bs-toggle="collapse">
    <i data-feather="star"></i>
    <span> Reviews </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-product-review">
    <ul class="nav-second-level">
      @can('review-list')
      <li><a href="{{ route('reviews.pending') }}"><i data-feather="file-plus"></i> Pending Reviews ({{ $pending_reviews }})</a></li>
      <li><a href="{{ route('reviews.index') }}"><i data-feather="file-plus"></i> All Reviews</a></li>
      @endcan
      @can('review-create')
      <li><a href="{{ route('reviews.pending') }}"><i data-feather="file-plus"></i> Create</a></li>
      @endcan
    </ul>
  </div>
</li>
@endcan





{{-- ЁЯУЭ Complaints --}}
@canany(['complaint-list', 'complaint-create', 'complaint-edit'])
<li class="{{ request()->routeIs('backEnd.complaints.*') ? 'active' : '' }}">
    <a href="{{ route('backEnd.complaints.index') }}">
        <i data-feather="alert-circle"></i>
        <span> Complaints </span>
    </a>
</li>
@endcanany
@can('contact-list')
<li class="{{ request()->routeIs('admin.contact.messages*') ? 'active' : '' }}">
    <a href="{{ route('admin.contact.messages') }}">
        <i data-feather="mail"></i>
        <span> Contact Messages </span>
    </a>
</li>
@endcan
<li class="{{ request()->routeIs('admin.newsletter.subscribers*') ? 'active' : '' }}">
    <a href="{{ route('admin.newsletter.subscribers') }}">
        <i data-feather="mail"></i>
        <span> Newsletter Subscribers </span>
    </a>
</li>

              <li class="menu-title mt-2">User & Access</li>
              @canany(['user-list', 'role-list', 'permission-list'])
<li>
  <a href="#sidebar-users" data-bs-toggle="collapse">
    <i data-feather="user"></i>
    <span> Users </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-users">
    <ul class="nav-second-level">
      @can('user-list')
      <li><a href="{{ route('users.index') }}"><i data-feather="file-plus"></i> User</a></li>
      @endcan
      @can('role-list')
      <li><a href="{{ route('roles.index') }}"><i data-feather="file-plus"></i> Roles</a></li>
      @endcan
      @can('permission-list')
      <li><a href="{{ route('permissions.index') }}"><i data-feather="file-plus"></i> Permissions</a></li>
      @endcan
      @canany(['customer-list', 'customer-create', 'customer-edit'])
      <li><a href="{{ route('customers.index') }}"><i data-feather="file-plus"></i> Customers</a></li>
      @endcanany
    </ul>
  </div>
</li>
@endcanany

              <li class="menu-title mt-2">Configuration</li>
              @canany(['setting-list', 'social-list', 'contact-list'])
<li>
  <a href="#siebar-sitesetting" data-bs-toggle="collapse">
    <i data-feather="settings"></i>
    <span> Site Setting </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="siebar-sitesetting">
    <ul class="nav-second-level">
      @can('setting-list')
      <li><a href="{{ route('settings.index') }}"><i data-feather="file-plus"></i> General Setting</a></li>
      @endcan
      @can('social-list')
      <li><a href="{{ route('socialmedias.index') }}"><i data-feather="file-plus"></i> Social Media</a></li>
      @endcan
      @can('contact-list')
      <li><a href="{{ route('contact.index') }}"><i data-feather="file-plus"></i> Contact</a></li>
      @endcan
      @canany(['page-list', 'page-create', 'page-edit'])
      <li><a href="{{ route('pages.index') }}"><i data-feather="file-plus"></i> Create Page</a></li>
      @endcanany
      @canany(['shipping-list', 'shipping-create', 'shipping-edit'])
      <li><a href="{{ route('shippingcharges.index') }}"><i data-feather="file-plus"></i> Shipping Charge</a></li>
      @endcanany
    </ul>
  </div>
</li>
@endcanany
{{-- ЁЯУз Email Settings --}}
@can('email-setting-list')
<li class="{{ request()->routeIs('email_setting*') ? 'active' : '' }}">
  <a href="{{ route('email_setting') }}">
    <i data-feather="mail"></i>
    <span>Email Settings</span>
  </a>
</li>
@endcan







{{-- ЁЯФМ API Integration --}}
@canany(['api-manage'])
<li>
  <a href="#sidebar-api-integration" data-bs-toggle="collapse">
    <i data-feather="save"></i>
    <span> API Integration </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-api-integration">
    <ul class="nav-second-level">
      <li><a href="{{ route('paymentgeteway.manage') }}"><i data-feather="file-plus"></i> Payment Gateway</a></li>
      <li><a href="{{ route('smsgeteway.manage') }}"><i data-feather="file-plus"></i> SMS Gateway</a></li>
      <li><a href="{{ route('courierapi.manage') }}"><i data-feather="file-plus"></i> Courier API</a></li>
      <li><a href="{{ route('googlemap.manage') }}"><i data-feather="map-pin"></i> Google Maps API</a></li>
      <li><a href="{{ route('admin.facebook_capi.edit') }}"><i data-feather="facebook"></i> Facebook CAPI</a></li>
    </ul>
  </div>
</li>
@endcanany

{{-- Cron Job Management --}}
@canany(['api-manage'])
<li>
  <a href="{{ route('admin.cron.index') }}">
    <i data-feather="clock"></i>
    <span> Cron Job </span>
  </a>
</li>
@endcanany




              <li class="menu-title mt-2">Reports</li>
              @canany(['report-view','order-report','purchase-report','expense-report','stock-report','profit-loss-report'])
<li>
  <a href="#sidebar-report" data-bs-toggle="collapse">
    <i data-feather="pie-chart"></i>
    <span> Reports </span>
    <span class="menu-arrow"></span>
  </a>
  <div class="collapse" id="sidebar-report">
    <ul class="nav-second-level">
      @canany(['order-report','report-view'])
      <li>
        <a href="{{ route('admin.reports.orders') }}">
          <i data-feather="file-text"></i> Order Report
        </a>
      </li>
      @endcanany

      @canany(['purchase-report','report-view'])
      <li>
        <a href="{{ route('admin.reports.purchases') }}">
          <i data-feather="shopping-bag"></i> Purchase Report
        </a>
      </li>
      @endcanany

      @canany(['expense-report','report-view'])
      <li>
        <a href="{{ route('admin.reports.expenses') }}">
          <i data-feather="trending-down"></i> Expense Report
        </a>
      </li>
      @endcanany

      @canany(['stock-report','report-view'])
      <li>
        <a href="{{ route('admin.reports.stock') }}">
          <i data-feather="archive"></i> Stock Report
        </a>
      </li>
      @endcanany

      @canany(['profit-loss-report','report-view'])
      <li>
        <a href="{{ route('admin.reports.profit_loss') }}">
          <i data-feather="activity"></i> Profit & Loss
        </a>
      </li>
      @endcanany
    </ul>
  </div>
</li>
@endcanany

{{-- SEO Settings --}}
@can('seo-manage') {{-- permission ржЖржЫрзЗ ржХрж┐ржирж╛ --}}
<li class="{{ request()->routeIs('admin.seo_settings.*') ? 'active' : '' }}">
  <a href="{{ route('admin.seo_settings.index') }}">
    <i data-feather="globe"></i>
    <span>SEO Settings</span>
  </a>
</li>
@endcan

			  
{{-- ЁЯЧ║ Sitemap Settings --}}
@can('sitemap-manage') {{-- ржкрж╛рж░ржорж┐рж╢ржи рж╕рж┐рж╕рзНржЯрзЗржо ржерж╛ржХрж▓рзЗ --}}
<li class="{{ request()->routeIs('admin.sitemap.*') ? 'active' : '' }}">
    <a href="{{ route('admin.sitemap.index') }}">
        <i data-feather="map"></i>
        <span> Sitemap Settings </span>
    </a>
</li>
@endcan



              <li class="menu-title mt-2">System Tools</li>
              <li>
  <a href="{{ route('admin.clear.cache') }}"
     onclick="return confirm('Are you sure you want to clear all cache?')">
    <i data-feather="refresh-cw"></i>
    <span>Clear Cache</span>
  </a>
</li>

<li>
  <a href="{{ route('error-log.index') }}">
    <i data-feather="file-text"></i>
    <span>Error Log</span>
  </a>
</li>

			  
            </ul>
          </div>
		  
		  
		  
          <!-- End Sidebar -->

          <div class="clearfix"></div>
        </div>
        <!-- Sidebar -left -->
      </div>
      <!-- Left Sidebar End -->

      <div class="content-page">
        <div class="content">
          @yield('content')
        </div>
        <!-- content -->

        <!-- end Footer -->
      </div>
    </div>
    <!-- END wrapper -->

    <!-- Right Sidebar -->
    <div class="right-bar">
      <div data-simplebar class="h-100">
        <!-- Nav tabs -->
        <ul class="nav nav-tabs nav-bordered nav-justified" role="tablist">
          <li class="nav-item">
            <a class="nav-link py-2" data-bs-toggle="tab" href="#chat-tab" role="tab">
              <i class="mdi mdi-message-text d-block font-22 my-1"></i>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link py-2" data-bs-toggle="tab" href="#tasks-tab" role="tab">
              <i class="mdi mdi-format-list-checkbox d-block font-22 my-1"></i>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link py-2 active" data-bs-toggle="tab" href="#settings-tab" role="tab">
              <i class="mdi mdi-cog-outline d-block font-22 my-1"></i>
            </a>
          </li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content pt-0">
          <div class="tab-pane" id="chat-tab" role="tabpanel">
            <form class="search-bar p-3">
              <div class="position-relative">
                <input type="text" class="form-control" placeholder="Search..." />
                <span class="mdi mdi-magnify"></span>
              </div>
            </form>
          </div>

          <div class="tab-pane" id="tasks-tab" role="tabpanel">
            <h6 class="fw-medium p-3 m-0 text-uppercase">Working Tasks</h6>
          </div>
          <div class="tab-pane active" id="settings-tab" role="tabpanel">
            <h6 class="fw-medium px-3 m-0 py-2 font-13 text-uppercase bg-light">
              <span class="d-block py-1">Theme Settings</span>
            </h6>

            <div class="p-3">
              <div class="alert alert-warning" role="alert"><strong>Customize </strong> the overall color scheme, sidebar menu, etc.</div>

              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Color Scheme</h6>
              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="layout-color" value="light" id="light-mode-check" checked />
                <label class="form-check-label" for="light-mode-check">Light Mode</label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="layout-color" value="dark" id="dark-mode-check" />
                <label class="form-check-label" for="dark-mode-check">Dark Mode</label>
              </div>

              <!-- Width -->
              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Width</h6>
              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="layout-width" value="fluid" id="fluid-check" checked />
                <label class="form-check-label" for="fluid-check">Fluid</label>
              </div>
              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="layout-width" value="boxed" id="boxed-check" />
                <label class="form-check-label" for="boxed-check">Boxed</label>
              </div>

              <!-- Menu positions -->
              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Menus (Leftsidebar and Topbar) Positon</h6>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="menu-position" value="fixed" id="fixed-check" checked />
                <label class="form-check-label" for="fixed-check">Fixed</label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="menu-position" value="scrollable" id="scrollable-check" />
                <label class="form-check-label" for="scrollable-check">Scrollable</label>
              </div>

              <!-- Left Sidebar-->
              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Left Sidebar Color</h6>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="leftbar-color" value="light" id="light-check" />
                <label class="form-check-label" for="light-check">Light</label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="leftbar-color" value="dark" id="dark-check" checked />
                <label class="form-check-label" for="dark-check">Dark</label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="leftbar-color" value="brand" id="brand-check" />
                <label class="form-check-label" for="brand-check">Brand</label>
              </div>

              <div class="form-check form-switch mb-3">
                <input type="checkbox" class="form-check-input" name="leftbar-color" value="gradient" id="gradient-check" />
                <label class="form-check-label" for="gradient-check">Gradient</label>
              </div>

              <!-- size -->
              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Left Sidebar Size</h6>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="leftbar-size" value="default" id="default-size-check" checked />
                <label class="form-check-label" for="default-size-check">Default</label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="leftbar-size" value="condensed" id="condensed-check" />
                <label class="form-check-label" for="condensed-check">Condensed <small>(Extra Small size)</small></label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="leftbar-size" value="compact" id="compact-check" />
                <label class="form-check-label" for="compact-check">Compact <small>(Small size)</small></label>
              </div>

              <!-- User info -->
              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Sidebar User Info</h6>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="sidebar-user" value="fixed" id="sidebaruser-check" />
                <label class="form-check-label" for="sidebaruser-check">Enable</label>
              </div>

              <!-- Topbar -->
              <h6 class="fw-medium font-14 mt-4 mb-2 pb-1">Topbar</h6>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="topbar-color" value="dark" id="darktopbar-check" checked />
                <label class="form-check-label" for="darktopbar-check">Dark</label>
              </div>

              <div class="form-check form-switch mb-1">
                <input type="checkbox" class="form-check-input" name="topbar-color" value="light" id="lighttopbar-check" />
                <label class="form-check-label" for="lighttopbar-check">Light</label>
              </div>

              <div class="d-grid mt-4">
                <button class="btn btn-primary" id="resetBtn">Reset to Default</button>
                <a href="https://1.envato.market/uboldadmin" class="btn btn-danger mt-3" target="_blank"><i class="mdi mdi-basket me-1"></i> Purchase Now</a>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- end slimscroll-menu-->
    </div>
    <!-- /Right-bar -->

    <!-- Right bar overlay-->
    <div class="rightbar-overlay"></div>

    <!-- Vendor js -->
    <script src="{{asset('backEnd/')}}/assets/js/vendor.min.js"></script>

    <!-- App js -->
    <script src="{{asset('backEnd/')}}/assets/js/app.min.js"></script>
    <!-- Feather Icons - Ensure library is loaded and initialized -->
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script>
        // Force Feather Icons initialization after all scripts load
        (function() {
            'use strict';
            
            function initFeather() {
                if (typeof feather !== 'undefined' && typeof feather.replace === 'function') {
                    try {
                        feather.replace();
                        return true;
                    } catch(e) {
                        console.error('Feather replace error:', e);
                        return false;
                    }
                }
                return false;
            }
            
            // Wait for scripts to load
            function waitForFeather(callback, maxAttempts) {
                maxAttempts = maxAttempts || 50;
                var attempts = 0;
                
                var checkInterval = setInterval(function() {
                    attempts++;
                    if (typeof feather !== 'undefined' && typeof feather.replace === 'function') {
                        clearInterval(checkInterval);
                        if (callback) callback();
                    } else if (attempts >= maxAttempts) {
                        clearInterval(checkInterval);
                        console.warn('Feather icons library not found after', maxAttempts, 'attempts');
                    }
                }, 100);
            }
            
            // Initialize when DOM is ready
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', function() {
                    waitForFeather(function() {
                        setTimeout(initFeather, 100);
                    });
                });
            } else {
                waitForFeather(function() {
                    setTimeout(initFeather, 100);
                });
            }
            
            // Also initialize on window load
            window.addEventListener('load', function() {
                waitForFeather(function() {
                    setTimeout(initFeather, 200);
                });
            });
            
            // jQuery ready handler
            if (typeof jQuery !== 'undefined') {
                jQuery(document).ready(function($) {
                    waitForFeather(function() {
                        setTimeout(initFeather, 150);
                    });
                    
                    // Reinitialize on menu collapse/expand
                    $(document).on('shown.bs.collapse hidden.bs.collapse', '[data-bs-toggle="collapse"]', function() {
                        setTimeout(initFeather, 100);
                    });
                    
                    // Watch sidebar for DOM changes
                    var sidebarEl = document.getElementById('sidebar-menu');
                    if (sidebarEl && typeof MutationObserver !== 'undefined') {
                        var observer = new MutationObserver(function() {
                            setTimeout(initFeather, 50);
                        });
                        observer.observe(sidebarEl, {
                            childList: true,
                            subtree: true
                        });
                    }
                });
            }
            
            // Fallback: Check periodically for unrendered icons
            setTimeout(function() {
                var checkInterval = setInterval(function() {
                    var unrendered = document.querySelectorAll('[data-feather]:not(svg)');
                    if (unrendered.length === 0) {
                        clearInterval(checkInterval);
                    } else {
                        initFeather();
                    }
                }, 500);
                
                // Stop checking after 10 seconds
                setTimeout(function() {
                    clearInterval(checkInterval);
                }, 10000);
            }, 1000);
        })();
    </script>
    <script src="{{asset('backEnd/')}}/assets/js/toastr.min.js"></script>
    <script src="{{asset('backEnd/')}}/assets/js/sweetalert.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    {!! Toastr::message() !!}
	<script>
@if(Session::has('success'))
    toastr.success("{{ Session::get('success') }}");
@endif
@if(Session::has('error') && !Session::has('demo_mode_blocked'))
    toastr.error("{{ Session::get('error') }}");
@endif
@if(Session::has('info'))
    toastr.info("{{ Session::get('info') }}");
@endif
@if(Session::has('warning'))
    toastr.warning("{{ Session::get('warning') }}");
@endif
@if(Session::has('demo_mode_blocked'))
    if (typeof Swal !== 'undefined') {
        Swal.fire({
            icon: 'info',
            title: '<strong style="font-size:1.4rem;color:#2c3e50;">ডেমো মুড সক্রিয়</strong>',
            html: '<div style="text-align:center;padding:10px 0;"><div style="width:70px;height:70px;margin:0 auto 15px;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);border-radius:50%;display:flex;align-items:center;justify-content:center;"><i class="fe-eye" style="font-size:32px;color:#fff;"></i></div><p style="font-size:1rem;color:#5a6c7d;margin-bottom:8px;line-height:1.6;">অ্যাডমিন প্যানেল থেকে কোন ডাটা পরিবর্তন বা সংযোজন করা যাবে না।</p><p style="font-size:0.9rem;color:#95a5a6;margin:0;">কাস্টমার সাইটে অর্ডার, ট্রাকিং ও অন্যান্য সেবা স্বাভাবিকভাবে কাজ করবে।</p></div>',
            confirmButtonText: 'বুঝেছি',
            confirmButtonColor: '#667eea',
            customClass: { popup: 'demo-mode-popup', confirmButton: 'demo-mode-btn' },
            width: '420px',
            backdrop: 'rgba(0,0,0,0.5)',
        });
    } else {
        toastr.info("ডেমো মুড চালু আছে। অ্যাডমিন প্যানেল থেকে কোন পরিবর্তন করা যাবে না।");
    }
@endif
</script>
    <style>
    .demo-mode-popup { border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
    .demo-mode-btn { padding: 10px 28px; font-weight: 600; border-radius: 8px; }
    </style>
    <script>
    function showDemoModeAlert(msg) {
        if (typeof Swal !== 'undefined') {
            Swal.fire({
                icon: 'info',
                title: '<strong style="font-size:1.4rem;color:#2c3e50;">ডেমো মুড সক্রিয়</strong>',
                html: '<div style="text-align:center;padding:10px 0;"><div style="width:70px;height:70px;margin:0 auto 15px;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);border-radius:50%;display:flex;align-items:center;justify-content:center;"><i class="fe-eye" style="font-size:32px;color:#fff;"></i></div><p style="font-size:1rem;color:#5a6c7d;margin-bottom:8px;line-height:1.6;">' + (msg || 'অ্যাডমিন প্যানেল থেকে কোন ডাটা পরিবর্তন বা সংযোজন করা যাবে না।') + '</p><p style="font-size:0.9rem;color:#95a5a6;margin:0;">কাস্টমার সাইটে অর্ডার, ট্রাকিং ও অন্যান্য সেবা স্বাভাবিকভাবে কাজ করবে।</p></div>',
                confirmButtonText: 'বুঝেছি',
                confirmButtonColor: '#667eea',
                customClass: { popup: 'demo-mode-popup', confirmButton: 'demo-mode-btn' },
                width: '420px',
                backdrop: 'rgba(0,0,0,0.5)',
            });
        }
    }
    $(document).ajaxComplete(function(event, xhr, settings) {
        if (xhr.status === 403) {
            try {
                var data = typeof xhr.responseJSON !== 'undefined' ? xhr.responseJSON : JSON.parse(xhr.responseText || '{}');
                if (data.demo_mode && typeof Swal !== 'undefined') {
                    showDemoModeAlert(data.message || '');
                }
            } catch (e) {}
        }
    });
    </script>
    <script type="text/javascript">
      $(document).on('click', '.delete-confirm', function (event) {
        event.preventDefault();
        var form = $(this).closest("form");
        @if(isset($demoMode) && $demoMode)
        showDemoModeAlert();
        return;
        @endif
        if (typeof Swal !== 'undefined') {
          Swal.fire({
            title: 'Are you sure?',
            text: "You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#d33',
            cancelButtonColor: '#3085d6',
            confirmButtonText: 'Yes, delete it!'
          }).then(function(result) {
            if (result.isConfirmed) { form.submit(); }
          });
        } else {
          if (confirm('Are you sure you want to delete this record?')) { form.submit(); }
        }
      });
      $(document).on('click', '.change-confirm', function (event) {
        event.preventDefault();
        var form = $(this).closest("form");
        @if(isset($demoMode) && $demoMode)
        showDemoModeAlert();
        return;
        @endif
        swal({
          title: `Are you sure you want to change this record?`,
          icon: "warning",
          buttons: true,
          dangerMode: true,
        }).then((willDelete) => {
          if (willDelete) {
            form.submit();
          }
        });
      });
      @if(isset($demoMode) && $demoMode)
      $(document).on('submit', 'form', function(e) {
        var action = (this.action || '').toLowerCase();
        if (action.indexOf('logout') !== -1) return;
        var method = ($(this).find('input[name="_method"]').val() || $(this).attr('method') || 'get').toLowerCase();
        if (method === 'get') return;
        e.preventDefault();
        showDemoModeAlert();
        return false;
      });
      document.addEventListener('click', function(e) {
        var el = e.target.closest ? e.target.closest('a[href*="destroy"], a[href*="bulk_destroy"], a[href*="/delete"], a.order_delete') : null;
        if (el && el.href && el.href.indexOf('#') !== 0) {
          e.preventDefault();
          e.stopPropagation();
          e.stopImmediatePropagation();
          showDemoModeAlert();
          return false;
        }
      }, true);
      @endif
    </script>
    <!--patho courier-->
    <script type="text/javascript">
        $(document).ready(function() {
            $('.pathaocity').change(function() {
                var id = $(this).val();
                if (id) {
                    $.ajax({
                        type: "GET",
                        url: "{{ url('panel/pathao-city') }}?city_id=" + id,
                        success: function(res) {
                            if (res && res.data && res.data.data) {
                                $(".pathaozone").empty();
                                $(".pathaozone").append('<option value="">Select..</option>');
                                $.each(res.data.data, function(index, zone) {
                                    $(".pathaozone").append('<option value="' + zone.zone_id + '">' + zone.zone_name + '</option>');
                                    $('.pathaozone').trigger("chosen:updated");
                                });
                            } else {
                                 $(".pathaoarea").empty();
                                $(".pathaozone").empty();
                            }
                        }
                    });
                } else {
                     $(".pathaoarea").empty();
                    $(".pathaozone").empty();
                }
            });
        });
    </script>
    <script type="text/javascript"> 
        $(document).ready(function() {
            $('.pathaozone').change(function() {
                var id = $(this).val();
                if (id) {
                    $.ajax({
                        type: "GET",
                        url: "{{ url('panel/pathao-zone') }}?zone_id=" + id,
                        success: function(res) {
                            if (res && res.data && res.data.data) {
                                $(".pathaoarea").empty();
                                $(".pathaoarea").append('<option value="">Select..</option>');
                                $.each(res.data.data, function(index, area) {
                                    $(".pathaoarea").append('<option value="' + area.area_id + '">' + area.area_name + '</option>');
                                    $('.pathaoarea').trigger("chosen:updated");
                                });
                            } else {
                                $(".pathaoarea").empty();
                            }
                        }
                    });
                } else {
                    $(".pathaoarea").empty();
                }
            });
        });
    </script>
    @yield('script')
    <script>
      // Admin Search Tools functionality
      $(document).on('keyup', '#admin_search_tools', function() {
          var value = $(this).val().toLowerCase();
          $("#side-menu li").filter(function() {
              var match = $(this).text().toLowerCase().indexOf(value) > -1;
              $(this).toggle(match);
              if(match) {
                  $(this).parents('.collapse').addClass('show');
                  $(this).parents('li').show();
              }
          });
          if(value === "") {
              $(".collapse").removeClass('show');
          }
      });

      // Ensure Feather Icons are rendered
      $(document).ready(function() {
          if (typeof feather !== 'undefined') {
              feather.replace();
          }
      });
      
      // Re-render on collapse
      $('.collapse').on('shown.bs.collapse', function () {
          if (typeof feather !== 'undefined') {
              feather.replace();
          }
      });
    </script>
  </body>
</html>
