<nav class="sidebar sidebar-offcanvas" id="sidebar">
    <ul class="nav">

        @role('admin')

        @php
            $hostRoutes     = ['admin.hosts.all', 'admin.hosts.pending', 'admin.hosts.create', 'admin.hosts.edit', 'admin.hosts.details', 'admin.hosts.store', 'admin.hosts.update', 'admin.hosts.delete', 'admin.hosts.approve', 'admin.hosts.reject'];
            $listingRoutes  = ['admin.listings.all', 'admin.listings.featured', 'admin.listings.createlisting', 'admin.listings.edit', 'admin.listings.show', 'admin.listings.pending', 'admin.listings.store', 'admin.listings.update', 'admin.listings.delete', 'admin.listings.approve', 'admin.listings.reject', 'admin.listings.feature'];
            $campusRoutes   = ['admin.campuses.all', 'admin.campuses.add', 'admin.campuses.edit', 'admin.campuses.show', 'admin.campuses.store', 'admin.campuses.update', 'admin.campuses.delete', 'admin.campuses.approve', 'admin.campuses.reject', 'admin.campuses.requested'];
            $financeRoutes  = ['admin.subscriptions', 'admin.subscriptions.details', 'admin.subscriptions.plans', 'admin.payments', 'admin.payments.subscription', 'admin.payments.featured'];
            $userRoutes     = ['admin.users.students', 'admin.users.student.show', 'admin.users.student.edit', 'admin.users.student.update', 'admin.users.student.delete'];
            $settingRoutes  = ['admin.settings', 'admin.settings.general', 'admin.settings.payment', 'admin.settings.email', 'admin.settings.commission', 'admin.settings.featured', 'admin.settings.maintenance', 'admin.settings.backup', 'admin.settings.logs'];

            $InquiryRoutes  = ['admin.inquiry.list','admin.booktour.list','admin.wait.list','admin.demo.list'];

            
        @endphp

        <!-- Dashboard -->
        <li class="nav-item">
            <a class="nav-link {{ request()->routeIs('admin.dashboard') ? 'active' : '' }}"
                href="{{ route('admin.dashboard') }}">
                <i class="mdi mdi-home menu-icon"></i>
                <span class="menu-title">Dashboard</span>
            </a>
        </li>

        <!-- Campus Section -->
        <li class="nav-item">
            <a class="nav-link"
                data-bs-toggle="collapse" href="#campus-menu"
                aria-expanded="{{ request()->routeIs($campusRoutes) ? 'true' : 'false' }}"
                aria-controls="campus-menu">
                <i class="mdi mdi-school menu-icon"></i>
                <span class="menu-title">Campus</span>
                @if(\App\Helpers\AppHelper::requestedCampusCount() > 0)
                    <span class="badge badge-warning me-1">
                        {{ \App\Helpers\AppHelper::requestedCampusCount() }}
                    </span>
                @endif
                <i class="mdi mdi-chevron-down menu-arrow"></i>
            </a>
            <div class="collapse {{ request()->routeIs($campusRoutes) ? 'show' : '' }}" id="campus-menu">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.campuses.all') ? 'active' : '' }}"
                            href="{{ route('admin.campuses.all') }}">All Campuses</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->is('admin/campuses') && request()->get('status') == 'waiting' ? 'active' : '' }}"
                            href="{{ url('/admin/campuses?status=waiting') }}">
                            Requested Campus
                            @if(\App\Helpers\AppHelper::requestedCampusCount() > 0)
                                <span class="badge badge-warning">
                                    {{ \App\Helpers\AppHelper::requestedCampusCount() }}
                                </span>
                            @endif
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.campuses.add') ? 'active' : '' }}"
                            href="{{ route('admin.campuses.add') }}">Add Campus</a>
                    </li>
                </ul>
            </div>
        </li>

        <!-- Hosts Section -->
        <li class="nav-item">
            <a class="nav-link"
                data-bs-toggle="collapse" href="#hosts-menu"
                aria-expanded="{{ request()->routeIs($hostRoutes) ? 'true' : 'false' }}"
                aria-controls="hosts-menu">
                <i class="mdi mdi-account-tie menu-icon"></i>
                <span class="menu-title">Hosts</span>
                @if(\App\Helpers\AppHelper::pendingHostsCount() > 0)
                    <span class="badge badge-danger me-1">
                        {{ \App\Helpers\AppHelper::pendingHostsCount() }}
                    </span>
                @endif
                <i class="mdi mdi-chevron-down menu-arrow"></i>
            </a>
            <div class="collapse {{ request()->routeIs($hostRoutes) ? 'show' : '' }}" id="hosts-menu">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.hosts.all') ? 'active' : '' }}"
                            href="{{ route('admin.hosts.all') }}">
                            All Hosts
                            <span class="badge badge-info">
                                {{ \App\Helpers\AppHelper::totalHostsCount() }}
                            </span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.hosts.pending') ? 'active' : '' }}"
                            href="{{ route('admin.hosts.pending') }}">
                            Pending Requests
                            @if(\App\Helpers\AppHelper::pendingHostsCount() > 0)
                                <span class="badge badge-danger">
                                    {{ \App\Helpers\AppHelper::pendingHostsCount() }}
                                </span>
                            @endif
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.hosts.create') ? 'active' : '' }}"
                            href="{{ route('admin.hosts.create') }}">Create Host</a>
                    </li>
                </ul>
            </div>
        </li>

        <!-- Listings Section -->
        <li class="nav-item">
            <a class="nav-link"
                data-bs-toggle="collapse" href="#listings-menu"
                aria-expanded="{{ request()->routeIs($listingRoutes) ? 'true' : 'false' }}"
                aria-controls="listings-menu">
                <i class="mdi mdi-format-list-checks menu-icon"></i>
                <span class="menu-title">Listings</span>
                @if(\App\Helpers\AppHelper::totalListingsCount() > 0)
                    <span class="badge badge-info me-1">
                        {{ \App\Helpers\AppHelper::totalListingsCount() }}
                    </span>
                @endif
                <i class="mdi mdi-chevron-down menu-arrow"></i>
            </a>
            <div class="collapse {{ request()->routeIs($listingRoutes) ? 'show' : '' }}" id="listings-menu">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.listings.all') ? 'active' : '' }}"
                            href="{{ route('admin.listings.all') }}">
                            All Listings
                            <span class="badge badge-info">
                                {{ \App\Helpers\AppHelper::totalListingsCount() }}
                            </span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.listings.featured') ? 'active' : '' }}"
                            href="{{ route('admin.listings.featured') }}">
                            Featured Listings
                            @if(\App\Helpers\AppHelper::featuredListingsCount() > 0)
                                <span class="badge badge-success">
                                    {{ \App\Helpers\AppHelper::featuredListingsCount() }}
                                </span>
                            @endif
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.listings.createlisting') ? 'active' : '' }}"
                            href="{{ route('admin.listings.createlisting') }}">Add Listing</a>
                    </li>
                </ul>
            </div>
        </li>
<!-- Finance Section -->
<li class="nav-item">
    <a class="nav-link"
        data-bs-toggle="collapse" href="#finance-menu"
        aria-expanded="{{ request()->routeIs($financeRoutes) ? 'true' : 'false' }}"
        aria-controls="finance-menu">
        <i class="mdi mdi-currency-usd menu-icon"></i>
        <span class="menu-title">Finance</span>
        <i class="mdi mdi-chevron-down menu-arrow"></i>
    </a>
    <div class="collapse {{ request()->routeIs($financeRoutes) ? 'show' : '' }}" id="finance-menu">
        <ul class="nav flex-column sub-menu">
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('admin.subscriptions') ? 'active' : '' }}"
                    href="{{ route('admin.subscriptions') }}">
                    Subscriptions
                    @if(\App\Helpers\AppHelper::totalSubscriptionsCount() > 0)
                        <span class="badge badge-info">
                            {{ \App\Helpers\AppHelper::totalSubscriptionsCount() }}
                        </span>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('admin.payments.featured') ? 'active' : '' }}"
                    href="{{ route('admin.payments.featured') }}">
                    Featured Payments
                    @if(\App\Helpers\AppHelper::totalFeaturedPaymentsCount() > 0)
                        <span class="badge badge-success">
                            {{ \App\Helpers\AppHelper::totalFeaturedPaymentsCount() }}
                        </span>
                    @endif
                </a>
            </li>
                <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.payments.index') ? 'active' : '' }}"
                            href="{{ route('admin.payments.index') }}">Payments History</a>
                    </li>
        </ul>
    </div>
</li>

<!-- Inquiries -->
<li class="nav-item">
    <a class="nav-link"
        data-bs-toggle="collapse"
        href="#admin-inquiry-menu"
        aria-expanded="{{ request()->routeIs($InquiryRoutes) ? 'true' : 'false' }}"
        aria-controls="admin-inquiry-menu">
        <i class="mdi mdi-email menu-icon"></i>
        <span class="menu-title">Inquiries</span>
        @php
            $totalAdminInquiries = \App\Helpers\AppHelper::totalInquiriesCount()
                + \App\Helpers\AppHelper::totalBookedToursCount()
                + \App\Helpers\AppHelper::totalWaitlistCount()
                + \App\Helpers\AppHelper::totalDemoCount();
        @endphp
        @if($totalAdminInquiries > 0)
            <span class="badge badge-info me-1">{{ $totalAdminInquiries }}</span>
        @endif
        <i class="mdi mdi-chevron-down menu-arrow"></i>
    </a>
    <div class="collapse {{ request()->routeIs($InquiryRoutes) ? 'show' : '' }}" id="admin-inquiry-menu">
        <ul class="nav flex-column sub-menu">
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('admin.inquiry.list') ? 'active' : '' }}"
                    href="{{ route('admin.inquiry.list') }}">
                    Contact Inquiry
                    @if(\App\Helpers\AppHelper::totalInquiriesCount() > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::totalInquiriesCount() }}</span>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('admin.booktour.list') ? 'active' : '' }}"
                    href="{{ route('admin.booktour.list') }}">
                    Booked Tour
                    @if(\App\Helpers\AppHelper::totalBookedToursCount() > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::totalBookedToursCount() }}</span>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('admin.wait.list') ? 'active' : '' }}"
                    href="{{ route('admin.wait.list') }}">
                    Join Waitlist for booking
                    @if(\App\Helpers\AppHelper::totalWaitlistCount() > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::totalWaitlistCount() }}</span>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('admin.demo.list') ? 'active' : '' }}"
                    href="{{ route('admin.demo.list') }}">
                    Host demo list
                    @if(\App\Helpers\AppHelper::totalDemoCount() > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::totalDemoCount() }}</span>
                    @endif
                </a>
            </li>
        </ul>
    </div>
</li>

        <!-- Analytics -->
        <li class="nav-item">
            <a class="nav-link {{ request()->routeIs('admin.reports') ? 'active' : '' }}"
                href="{{ route('admin.reports') }}">
                <i class="mdi mdi-chart-bar menu-icon"></i>
                <span class="menu-title">Analytics</span>
            </a>
        </li>

        <!-- Users Section -->
        <li class="nav-item">
            <a class="nav-link"
                data-bs-toggle="collapse" href="#users-menu"
                aria-expanded="{{ request()->routeIs($userRoutes) ? 'true' : 'false' }}"
                aria-controls="users-menu">
                <i class="mdi mdi-account-group menu-icon"></i>
                <span class="menu-title">Users</span>
                @if(\App\Helpers\AppHelper::totalStudentsCount() > 0)
                    <span class="badge badge-info me-1">
                        {{ \App\Helpers\AppHelper::totalStudentsCount() }}
                    </span>
                @endif
                <i class="mdi mdi-chevron-down menu-arrow"></i>
            </a>
            <div class="collapse {{ request()->routeIs($userRoutes) ? 'show' : '' }}" id="users-menu">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('admin.users.students') ? 'active' : '' }}"
                            href="{{ route('admin.users.students') }}">
                            Students
                            <span class="badge badge-info">
                                {{ \App\Helpers\AppHelper::totalStudentsCount() }}
                            </span>
                        </a>
                    </li>
                </ul>
            </div>
        </li>

        <!-- Settings -->
        <li class="nav-item">
            <a class="nav-link {{ request()->routeIs($settingRoutes) ? 'active' : '' }}"
                href="{{ route('admin.settings') }}">
                <i class="mdi mdi-cog menu-icon"></i>
                <span class="menu-title">Settings</span>
            </a>
        </li>

        @endrole

        @php
            $subscribed = auth()->check() && auth()->user()->subscribed('default');
        @endphp

        @role('host')

        @php
            $authId            = auth()->id();
            $listingRoutes     = ['host.listings.all', 'host.listings.featured', 'host.listings.createlisting', 'host.listings.edit', 'host.listings.show', 'host.listings.pending'];
            $financeRoutes     = ['host.package', 'host.subscriptions', 'host.subscriptions.show','host.payments.featured'];
            $InquiryRoutes  = ['host.inquiry.list','host.booktour.list','host.wait.list'];
            $hostPendingCount  = \App\Helpers\AppHelper::hostPendingListingsCount($authId);
            $hostFeaturedCount = \App\Helpers\AppHelper::hostFeaturedListingsCount($authId);
            $hostTotalCount    = \App\Helpers\AppHelper::hostListingsCount($authId);
        @endphp

        {{-- DASHBOARD --}}
        <li class="nav-item">
            <a class="nav-link
                {{ request()->routeIs('host.dashboard') ? 'active' : '' }}
                {{ !$subscribed ? 'opacity-50 pointer-events-none' : '' }}"
                href="{{ route('host.dashboard') }}">
                <i class="mdi mdi-home menu-icon"></i>
                <span class="menu-title">Dashboard</span>
            </a>
        </li>

        {{-- LISTINGS --}}
        <li class="nav-item">
            <a class="nav-link
                {{ !$subscribed ? 'opacity-50 pointer-events-none' : '' }}"
                @if($subscribed)
                    data-bs-toggle="collapse"
                    href="#listings-menu"
                @else
                    href="#"
                @endif
                aria-expanded="{{ request()->routeIs($listingRoutes) ? 'true' : 'false' }}"
                aria-controls="listings-menu">
                <i class="mdi mdi-format-list-checks menu-icon"></i>
                <span class="menu-title">Listings</span>
                @if($hostTotalCount > 0)
                    <span class="badge badge-info me-1">{{ $hostTotalCount }}</span>
                @endif
                @if($hostPendingCount > 0)
                    <span class="badge badge-warning me-1">{{ $hostPendingCount }} pending</span>
                @endif
                <i class="mdi mdi-chevron-down menu-arrow"></i>
            </a>
            <div class="collapse {{ request()->routeIs($listingRoutes) ? 'show' : '' }}" id="listings-menu">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('host.listings.all') ? 'active' : '' }}"
                            href="{{ route('host.listings.all') }}">
                            All Listings
                            @if($hostTotalCount > 0)
                                <span class="badge badge-info">{{ $hostTotalCount }}</span>
                            @endif
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('host.listings.featured') ? 'active' : '' }}"
                            href="{{ route('host.listings.featured') }}">
                            Featured Listings
                            @if($hostFeaturedCount > 0)
                                <span class="badge badge-success">{{ $hostFeaturedCount }}</span>
                            @endif
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('host.listings.createlisting') ? 'active' : '' }}"
                            href="{{ route('host.listings.createlisting') }}">Add Listing</a>
                    </li>
                </ul>
            </div>
        </li>

        {{-- FINANCE --}}
        <li class="nav-item">
            <a class="nav-link"
                data-bs-toggle="collapse"
                href="#finance-menu"
                aria-expanded="{{ request()->routeIs($financeRoutes) ? 'true' : 'false' }}"
                aria-controls="finance-menu">
                <i class="mdi mdi-currency-usd menu-icon"></i>
                <span class="menu-title">Finance</span>
                <i class="mdi mdi-chevron-down menu-arrow"></i>
            </a>
            <div class="collapse {{ request()->routeIs($financeRoutes) ? 'show' : '' }}" id="finance-menu">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('host.package') ? 'active' : '' }}"
                            href="{{ route('host.package') }}">Manage Subscriptions</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('host.payments.featured') ? 'active' : '' }}"
                            href="{{ route('host.payments.featured') }}">
                            Featured Payments
                            {{-- @if(\App\Helpers\AppHelper::totalFeaturedPaymentsCount() > 0)
                                <span class="badge badge-success">
                                    {{ \App\Helpers\AppHelper::totalFeaturedPaymentsCount() }}
                                </span>
                            @endif --}}
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {{ request()->routeIs('host.subscriptions') ? 'active' : '' }}"
                            href="{{ route('host.subscriptions') }}">Payment History</a>
                    </li>
                </ul>
            </div>
        </li>



       {{-- INQUIRIES - Host --}}
<li class="nav-item">
    <a class="nav-link"
        data-bs-toggle="collapse"
        href="#host-inquiry-menu"
        aria-expanded="{{ request()->routeIs($InquiryRoutes) ? 'true' : 'false' }}"
        aria-controls="host-inquiry-menu">
        <i class="mdi mdi-email menu-icon"></i>
        <span class="menu-title">Inquiries</span>
        @php
            $totalHostInquiries = \App\Helpers\AppHelper::hostInquiriesCount($authId)
                + \App\Helpers\AppHelper::hostBookedToursCount($authId)
                + \App\Helpers\AppHelper::hostWaitlistCount($authId);
        @endphp
        @if($totalHostInquiries > 0)
            <span class="badge badge-info me-1">{{ $totalHostInquiries }}</span>
        @endif
        <i class="mdi mdi-chevron-down menu-arrow"></i>
    </a>
    <div class="collapse {{ request()->routeIs($InquiryRoutes) ? 'show' : '' }}" id="host-inquiry-menu">
        <ul class="nav flex-column sub-menu">
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('host.inquiry.list') ? 'active' : '' }}"
                    href="{{ route('host.inquiry.list') }}">
                    Contact Inquiry
                    @if(\App\Helpers\AppHelper::hostInquiriesCount($authId) > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::hostInquiriesCount($authId) }}</span>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('host.booktour.list') ? 'active' : '' }}"
                    href="{{ route('host.booktour.list') }}">
                    Booked Tour
                    @if(\App\Helpers\AppHelper::hostBookedToursCount($authId) > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::hostBookedToursCount($authId) }}</span>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link {{ request()->routeIs('host.wait.list') ? 'active' : '' }}"
                    href="{{ route('host.wait.list') }}">
                    Join Waitlist for booking
                    @if(\App\Helpers\AppHelper::hostWaitlistCount($authId) > 0)
                        <span class="badge badge-info">{{ \App\Helpers\AppHelper::hostWaitlistCount($authId) }}</span>
                    @endif
                </a>
            </li>
        </ul>
    </div>
</li>

        {{-- INQUIRIES --}}
        {{-- <li class="nav-item">
            <a class="nav-link
                {{ request()->routeIs('host.inquiry.list') ? 'active' : '' }}
                {{ !$subscribed ? 'opacity-50 pointer-events-none' : '' }}"
                href="{{ route('host.inquiry.list') }}">
                <i class="mdi mdi-email menu-icon"></i>
                <span class="menu-title">Inquiries</span>
            </a>
        </li> --}}

        {{-- SETTINGS --}}
        <li class="nav-item">
            <a class="nav-link
                {{ request()->routeIs('host.setting') ? 'active' : '' }}
                {{ !$subscribed ? 'opacity-50 pointer-events-none' : '' }}"
                href="{{ route('host.setting') }}">
                <i class="mdi mdi-cog menu-icon"></i>
                <span class="menu-title">Setting</span>
            </a>
        </li>

        @endrole

    </ul>
</nav>

<style>
    .nav { padding: 1rem 0; }
    .nav-item { width: 100%; margin: 2px 0; }
    .nav-link {
        display: flex;
        align-items: center;
        padding: 0.75rem 1.5rem;
        color: #333;
        transition: all 0.3s ease;
    }
    .nav-link:hover { color: #007bff; }
    .nav-link:hover > .menu-title {
        color: #003955 !important;
        font-family: "ubuntu-medium", sans-serif;
    }
    .menu-icon { margin-right: 0.75rem; font-size: 1.1rem; width: 20px; text-align: center; }
    .menu-title { flex: 1; font-size: 0.9rem; }
    .menu-arrow { font-size: 1rem; transition: transform 0.3s ease; }
    .nav-link[aria-expanded="true"] .menu-arrow { transform: rotate(180deg); }
    .sub-menu { padding-left: 2.5rem; }
    .sub-menu .nav-link { padding: 0.5rem 1rem; font-size: 0.85rem; }
    .badge { padding: 0.25rem 0.5rem; font-size: 0.65rem; border-radius: 10px; margin-left: 0.5rem; }
    .badge-warning { background-color: #ffc107; color: #000; }
    .badge-danger { background-color: #dc3545; color: #fff; }
    .badge-success { background-color: #28a745; color: #fff; }
    .badge-info { background-color: #17a2b8; color: #fff; }
</style>

