<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title', 'Admin Panel') - LECL</title>

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    <!-- FontAwesome Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <style>
        .sidebar {
            min-height: 100vh;
            background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
        }

        .sidebar .nav-link {
            color: rgba(255, 255, 255, 0.8);
            padding: 0.75rem 1rem;
            margin: 0.25rem 0;
            border-radius: 0.5rem;
            transition: all 0.3s ease;
        }

        .sidebar .nav-link:hover,
        .sidebar .nav-link.active {
            color: white;
            background-color: rgba(255, 255, 255, 0.1);
        }

        .main-content {
            background-color: #f8f9fa;
            min-height: 100vh;
        }

        .card {
            border: none;
            box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
        }

        .btn-primary {
            background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
            border: none;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
        }
    </style>
</head>

<body>
    <div class="container-fluid">
        <div class="row">
            <!-- Sidebar -->
            <nav class="col-md-3 col-lg-2 d-md-block sidebar collapse p-0">
                <div class="position-sticky">
                    <div class="text-center p-3" style="background: rgb(169, 161, 161)">
                        <img src="{{ asset('img/lecl.png') }}" alt="LECL Logo"
                            style="height: 50px; width: auto; animation: pulse 2s infinite;">
                        {{-- <h4 class="text-white">LECL Admin</h4> --}}
                        {{-- <small class="text-white-50">Content Management</small> --}}
                    </div>

                    <ul class="nav flex-column">
                        {{-- @php
                            $menus = \App\Models\Menu::active()
                                ->parents()
                                ->with([
                                    'children' => function ($query) {
                                        $query->active()->orderBy('sort_order');
                                    },
                                ])
                                ->orderBy('sort_order')
                                ->get();
                        @endphp

                        @foreach ($menus as $menu)
                            @if ($menu->children->count() > 0)
                                <!-- Parent menu with children -->
                                <li class="nav-item">
                                    <a class="nav-link d-flex justify-content-between align-items-center"
                                        data-bs-toggle="collapse" href="#submenu-{{ $menu->id }}" role="button"
                                        aria-expanded="false">
                                        <span>
                                            @if ($menu->icon)
                                                <i class="{{ $menu->icon }} me-2"></i>
                                            @endif
                                            {{ $menu->title }}
                                        </span>
                                        <i class="bi bi-chevron-down"></i>
                                    </a>
                                    <div class="collapse" id="submenu-{{ $menu->id }}">
                                        <ul class="nav flex-column ms-3">
                                            @foreach ($menu->children as $child)
                                                <li class="nav-item">
                                                    <a class="nav-link {{ $child->route_name && request()->routeIs($child->route_name . '*') ? 'active' : '' }}"
                                                        href="{{ $child->url }}" target="{{ $child->target }}">
                                                        @if ($child->icon)
                                                            <i class="{{ $child->icon }} me-2"></i>
                                                        @endif
                                                        {{ $child->title }}
                                                    </a>
                                                </li>
                                            @endforeach
                                        </ul>
                                    </div>
                                </li>
                            @else
                                <!-- Single menu item -->
                                <li class="nav-item">
                                    <a class="nav-link {{ $menu->route_name && request()->routeIs($menu->route_name . '*') ? 'active' : '' }}"
                                        href="{{ $menu->url }}" target="{{ $menu->target }}">
                                        @if ($menu->icon)
                                            <i class="{{ $menu->icon }} me-2"></i>
                                        @endif
                                        {{ $menu->title }}
                                    </a>
                                </li>
                            @endif
                        @endforeach --}}

                        <!-- Menu Management Link -->
                        {{-- <li class="nav-item mt-3">
                            <a class="nav-link {{ request()->routeIs('admin.menus.*') ? 'active' : '' }}"
                                href="{{ route('admin.menus.index') }}">
                                <i class="bi bi-list me-2"></i>
                                Menu Management
                            </a>
                        </li> --}}
                        <li class="nav-item">
                            <a class="nav-link d-flex justify-content-between align-items-center {{ request()->routeIs('admin.content-sections.*') ||
                            request()->routeIs('admin.statistics.*') ||
                            request()->routeIs('admin.why-lecl.*') ||
                            request()->routeIs('admin.testimonials.*') ||
                            request()->routeIs('admin.university-partners.*') ||
                            request()->routeIs('admin.impact-numbers.*')
                                ? 'active'
                                : '' }}"
                                data-bs-toggle="collapse" href="#submenu-home" role="button"
                                aria-expanded="{{ request()->routeIs('admin.content-sections.*') ||
                                request()->routeIs('admin.statistics.*') ||
                                request()->routeIs('admin.why-lecl.*') ||
                                request()->routeIs('admin.testimonials.*') ||
                                request()->routeIs('admin.university-partners.*') ||
                                request()->routeIs('admin.impact-numbers.*')
                                    ? 'true'
                                    : 'false' }}">
                                <span>
                                    <i class="fa fa-home me-2"></i> Landing Page
                                </span>
                                <i class="bi bi-chevron-down"></i>
                            </a>
                            <div class="collapse {{ request()->routeIs('admin.content-sections.*') ||
                            request()->routeIs('admin.statistics.*') ||
                            request()->routeIs('admin.why-lecl.*') ||
                            request()->routeIs('admin.testimonials.*') ||
                            request()->routeIs('admin.university-partners.*') ||
                            request()->routeIs('admin.impact-numbers.*')
                                ? 'show'
                                : '' }}"
                                id="submenu-home">
                                <ul class="nav flex-column ms-3">
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.content-sections.show') && request()->route('content_section')->id == 1 ? 'active' : '' }}"
                                            href="{{ route('admin.content-sections.show', 1) }}">
                                            <i class="bi bi-house me-2"></i>
                                            Hero Section
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.statistics.*') ? 'active' : '' }}"
                                            href="{{ route('admin.statistics.index') }}">
                                            <i class="bi bi-house me-2"></i>
                                            Statistics
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.content-sections.show') && request()->route('content_section')->id == 2 ? 'active' : '' }}"
                                            href="{{ route('admin.content-sections.show', 2) }}">
                                            <i class="bi bi-house me-2"></i>
                                            About LECL
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.content-sections.show') && request()->route('content_section')->id == 4 ? 'active' : '' }}"
                                            href="{{ route('admin.content-sections.show', 4) }}">
                                            <i class="bi bi-house me-2"></i>
                                            Guidance
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.content-sections.show') && request()->route('content_section')->id == 5 ? 'active' : '' }}"
                                            href="{{ route('admin.content-sections.show', 5) }}">
                                            <i class="bi bi-house me-2"></i>
                                            Destinations
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.why-lecl.*') ? 'active' : '' }}"
                                            href="{{ route('admin.why-lecl.index') }}">
                                            <i class="bi bi-house me-2"></i>
                                            Why LECL
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.testimonials.*') ? 'active' : '' }}"
                                            href="{{ route('admin.testimonials.index') }}">
                                            <i class="bi bi-house me-2"></i>
                                            Testimonials
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.university-partners.*') ? 'active' : '' }}"
                                            href="{{ route('admin.university-partners.index') }}">
                                            <i class="bi bi-house me-2"></i>
                                            University Partners
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link {{ request()->routeIs('admin.impact-numbers.*') ? 'active' : '' }}"
                                            href="{{ route('admin.impact-numbers.index') }}">
                                            <i class="bi bi-house me-2"></i>
                                            Impact Numbers
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </li>

                        <!-- EU/UK Financial Aids Management Link -->
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.eu-uk.*') ? 'active' : '' }}"
                                href="{{ route('admin.eu-uk.index') }}">
                                <i class="bi bi-globe-europe-africa me-2"></i>
                                EU/UK Financial Aids
                            </a>
                        </li>

                        <!-- International Management Link -->
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.destinations.*') ? 'active' : '' }}"
                                href="{{ route('admin.destinations.index') }}">
                                <i class="bi bi-globe-europe-africa me-2"></i>
                                International
                            </a>
                        </li>
                        <!-- Find A University Management Link -->
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.universities.*') ? 'active' : '' }}"
                                href="{{ route('admin.universities.index') }}">
                                <i class="bi bi-globe-europe-africa me-2"></i>
                                Find A University
                            </a>
                        </li>
                        <!-- Blog Management -->
                        {{-- <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.blog.*') ? 'active' : '' }}"
                                href="{{ route('admin.blog.index') }}">
                                <i class="bi bi-journal-text me-2"></i>
                                Blog Management
                            </a>
                        </li> --}}

                        <!-- About Page Management Link -->
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.about.*') ? 'active' : '' }}"
                                href="{{ route('admin.about.index') }}">
                                <i class="bi bi-info-circle me-2"></i>
                                About Us
                            </a>
                        </li>

                        <!-- Pathways Management Link -->
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.pathways.*') ? 'active' : '' }}"
                                href="{{ route('admin.pathways.index') }}">
                                <i class="bi bi-signpost-2 me-2"></i>
                                Pathways
                            </a>
                        </li>

                        <!-- Contact Management Link -->
                        <li class="nav-item">
                            <a class="nav-link {{ request()->routeIs('admin.contact.*') ? 'active' : '' }}"
                                href="{{ route('admin.contact.index') }}">
                                <i class="bi bi-envelope me-2"></i>
                                Contact us
                            </a>
                        </li>
                        <!-- View Website Link -->
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('home') }}" target="_blank">
                                <i class="bi bi-eye me-2"></i>
                                View Website
                            </a>
                        </li>
                    </ul>

                    <div class="mt-auto pt-4">
                        <div class="dropdown">
                            <a class="nav-link dropdown-toggle text-white" href="#" role="button"
                                data-bs-toggle="dropdown">
                                <i class="bi bi-person-circle me-2"></i>
                                {{ Auth::guard('admin')->user()->name }}
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <form method="POST" action="{{ route('admin.logout') }}">
                                        @csrf
                                        <button type="submit" class="dropdown-item">
                                            <i class="bi bi-box-arrow-right me-2"></i>
                                            Logout
                                        </button>
                                    </form>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </nav>

            <!-- Main content -->
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 main-content">
                <div class="pt-3 pb-2 mb-3">
                    @if (session('success'))
                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                            {{ session('success') }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    @endif

                    @if (session('error'))
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            {{ session('error') }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    @endif

                    @yield('content')
                </div>
            </main>
        </div>
    </div>

    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    @stack('scripts')
</body>

</html>
