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

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>CMS-Laravel</title>
    <link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('css/custom.css') }}">
    <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=Roboto:wght@300;400;500;700;900&display=swap" rel="stylesheet">
    <link rel="icon" type="image/png" href="{{ asset('img/favicon_unioil.ico') }}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"
        integrity="sha512-..." crossorigin="anonymous" referrerpolicy="no-referrer" />

    <!-- Inline CSS to fix sidebar spacing -->
    <style>
        #sidebar .components li {
            margin-bottom: 5px; /* Reduce gap between sidebar items */
        }
        #sidebar .components li.dropdown {
            margin-bottom: 0; /* Ensure dropdown items don't add extra space when collapsed */
        }
        #sidebar .components li.dropdown .menu {
            margin-top: 0; /* Remove extra space above dropdown menu */
        }
        #sidebar .components li a {
            padding: 10px 15px; /* Consistent padding for all sidebar links */
        }
    </style>
</head>

<body>
    <div class="wrapper">
        <div class="body-overlay"></div>

        @php
            $memberManagement = ['card-member', 'locked-accounts'];
            $homePage = ['photo-slider'];
            $aboutUs = ['card-types', 'terms-and-privacy'];
            $reports = ['registration-report', 'top-up-usage-report', 'mobile-usage-report', 'station-rating-report'];
            $stationLocator = ['branches', 'stations', 'fuels'];
            $fuelPriceUpdate = ['fuel-price-on-demand', 'fuel-price-schedule', 'fuel-price-update-logs'];
        @endphp

        <!-- Sidebar -->
        <nav id="sidebar">
            <div class="sidebar-header">
                <h3><img src="img/logo.png" class="img-fluid" /><span></span></h3>
            </div>

            <ul class="list-unstyled components">
                <!-- Static Items -->
                <li class="{{ Request::is('user-management') ? 'active' : '' }}">
                    <a href="{{ route('user.management') }}" class="dashboard" style="display:flex">
                        <i class="fa-solid fa-users" style="padding-top:3px"></i><span>User Management</span>
                    </a>
                </li>
                <li class="{{ Request::is('notification') ? 'active' : '' }}">
                    <a href="{{ route('notification') }}" class="dashboard" style="display:flex">
                        <i class="fa-solid fa-bell" style="padding-top:3px"></i><span>Notifications</span>
                    </a>
                </li>

                <!-- Member Management -->
                <li class="dropdown {{ in_array(Request::path(), $memberManagement) ? 'active' : '' }}">
                    <a href="#homeSubmenu1" data-toggle="collapse"
                        aria-expanded="{{ in_array(Request::path(), $memberManagement) ? 'true' : 'false' }}"
                        class="dropdown-toggle" style="display:flex">
                        <i class="fa-solid fa-users-gear" style="padding-top:3px"></i><span>Member Management</span>
                    </a>
                    <ul class="collapse list-unstyled menu {{ in_array(Request::path(), $memberManagement) ? 'show' : '' }}"
                        id="homeSubmenu1">
                        <li class="{{ Request::is('card-member') ? 'active' : '' }}">
                            <a href="{{ route('card-member') }}">Card Member</a>
                        </li>
                        <li class="{{ Request::is('locked-accounts') ? 'active' : '' }}">
                            <a href="{{ route('locked-accounts') }}">Locked Accounts</a>
                        </li>
                    </ul>
                </li>

                <!-- Home Page -->
                <li class="dropdown {{ in_array(Request::path(), $homePage) ? 'active' : '' }}">
                    <a href="#pageSubmenu2" data-toggle="collapse"
                        aria-expanded="{{ in_array(Request::path(), $homePage) ? 'true' : 'false' }}"
                        class="dropdown-toggle" style="display:flex">
                        <i class="fa-solid fa-mobile-screen" style="padding-top:3px"></i><span>Home Page (Mobile)</span>
                    </a>
                    <ul class="collapse list-unstyled menu {{ in_array(Request::path(), $homePage) ? 'show' : '' }}"
                        id="pageSubmenu2">
                        <li class="{{ Request::is('photo-slider') ? 'active' : '' }}">
                            <a href="{{ route('photo-slider') }}">Photo Slider</a>
                        </li>
                    </ul>
                </li>

                <!-- Static -->
                <li class="{{ Request::is('promotions') ? 'active' : '' }}">
                    <a href="{{ route('promotions') }}" class="dashboard" style="display:flex">
                        <i class="fa-solid fa-tag" style="padding-top:3px"></i><span>Promotions</span>
                    </a>
                </li>

                <li class="{{ Request::is('top-up') ? 'active' : '' }}">
                    <a href="{{ route('top-up') }}" class="dashboard" style="display:flex">
                        <i class="fa-solid fa-wallet" style="padding-top:3px"></i><span>Top-Up</span>
                    </a>
                </li>

                <li class="{{ Request::is('top-up-settings') ? 'active' : '' }}">
                    <a href="{{ route('top-up-settings') }}" class="dashboard" style="display:flex">
                        <i class="fa-solid fa-cog" style="padding-top:3px"></i><span>Top Up Settings</span>
                    </a>
                </li>

                <!-- About Us -->
                <li class="dropdown {{ in_array(Request::path(), $aboutUs) ? 'active' : '' }}">
                    <a href="#pageSubmenu3" data-toggle="collapse"
                        aria-expanded="{{ in_array(Request::path(), $aboutUs) ? 'true' : 'false' }}"
                        class="dropdown-toggle" style="display:flex">
                        <i class="fa-solid fa-circle-info" style="padding-top:3px"></i><span>About Us</span>
                    </a>
                    <ul class="collapse list-unstyled menu {{ in_array(Request::path(), $aboutUs) ? 'show' : '' }}"
                        id="pageSubmenu3">
                        <li class="{{ Request::is('card-types') ? 'active' : '' }}">
                            <a href="{{ route('card-types') }}">Card Types</a>
                        </li>
                        <li class="{{ Request::is('terms-and-privacy') ? 'active' : '' }}">
                            <a href="{{ route('terms-and-privacy') }}">Terms & Privacy</a>
                        </li>
                    </ul>
                </li>

                <!-- Reports -->
                <li class="dropdown {{ in_array(Request::path(), $reports) ? 'active' : '' }}">
                    <a href="#pageSubmenu4" data-toggle="collapse"
                        aria-expanded="{{ in_array(Request::path(), $reports) ? 'true' : 'false' }}"
                        class="dropdown-toggle" style="display:flex">
                        <i class="fa-solid fa-chart-column" style="padding-top:3px"></i><span>Reports</span>
                    </a>
                    <ul class="collapse list-unstyled menu {{ in_array(Request::path(), $reports) ? 'show' : '' }}"
                        id="pageSubmenu4">
                        <li class="{{ Request::is('registration-report') ? 'active' : '' }}">
                            <a href="{{ route('registration-report') }}">Registration Report</a>
                        </li>
                        <li class="{{ Request::is('top-up-usage-report') ? 'active' : '' }}">
                            <a href="{{ route('top-up-usage-report') }}">Top-Up Usage Report</a>
                        </li>
                        <li class="{{ Request::is('mobile-usage-report') ? 'active' : '' }}">
                            <a href="{{ route('mobile-usage-report') }}">Mobile Usage Report</a>
                        </li>
                        <li class="{{ Request::is('station-rating-report') ? 'active' : '' }}">
                            <a href="{{ route('station-rating-report') }}">Station Rating Report</a>
                        </li>
                    </ul>
                </li>

                <!-- Static -->
                <li class="{{ Request::is('system-parameters') ? 'active' : '' }}">
                    <a href="{{ route('system-parameters') }}" style="display:flex">
                        <i class="fa-solid fa-sliders" style="padding-top:3px"></i><span>System Parameters</span>
                    </a>
                </li>

                <!-- Fuel Price Update -->
                <li class="dropdown {{ in_array(Request::path(), $fuelPriceUpdate) ? 'active' : '' }}">
                    <a href="#pageSubmenu6" data-toggle="collapse"
                        aria-expanded="{{ in_array(Request::path(), $fuelPriceUpdate) ? 'true' : 'false' }}"
                        class="dropdown-toggle" style="display:flex">
                        <i class="fa-solid fa-gas-pump" style="padding-top:3px"></i><span>Fuel Price Update</span>
                    </a>
                    <ul class="collapse list-unstyled menu {{ in_array(Request::path(), $fuelPriceUpdate) ? 'show' : '' }}"
                        id="pageSubmenu6">
                        <li class="{{ Request::is('fuel-price-on-demand') ? 'active' : '' }}">
                            <a href="{{ route('fuel-price-on-demand') }}">On-Demand</a>
                        </li>
                        <li class="{{ Request::is('fuel-price-schedule') ? 'active' : '' }}">
                            <a href="{{ route('fuel-price-schedule') }}">Schedule</a>
                        </li>
                        <li class="{{ Request::is('fuel-price-update-logs') ? 'active' : '' }}">
                            <a href="{{ route('fuel-price-update-logs') }}">Update Logs</a>
                        </li>
                    </ul>
                </li>

                <!-- Station Locator -->
                <li class="dropdown {{ in_array(Request::path(), $stationLocator) ? 'active' : '' }}">
                    <a href="#pageSubmenu5" data-toggle="collapse"
                        aria-expanded="{{ in_array(Request::path(), $stationLocator) ? 'true' : 'false' }}"
                        class="dropdown-toggle" style="display:flex">
                        <i class="fa-solid fa-location-dot" style="padding-top:3px"></i><span>Station Locator</span>
                    </a>
                    <ul class="collapse list-unstyled menu {{ in_array(Request::path(), $stationLocator) ? 'show' : '' }}"
                        id="pageSubmenu5">
                        <li class="{{ Request::is('branches') ? 'active' : '' }}">
                            <a href="{{ route('branches') }}">Branches</a>
                        </li>
                        <li class="{{ Request::is('stations') ? 'active' : '' }}">
                            <a href="{{ route('stations') }}">Stations</a>
                        </li>
                        <li class="{{ Request::is('fuels') ? 'active' : '' }}">
                            <a href="{{ route('fuels') }}">Fuels</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </nav>

        <!-- Page Content -->
        <div id="content">
            <div class="top-navbar">
                <nav class="navbar navbar-expand-lg" style="background-color:rgba(231, 70, 16, 0.84)">
                    <div class="container-fluid">
                        <button type="button" id="sidebarCollapse" class="d-xl-block d-lg-block d-md-none d-none">
                            <span class="fa-solid fa-arrow-left"></span>
                        </button>
                        <button class="d-inline-block d-lg-none ml-auto more-button" type="button"
                            data-toggle="collapse" data-target="#navbarSupportedContent"
                            aria-controls="navbarSupportedContent" aria-expanded="false"
                            aria-label="Toggle navigation">
                            <i class="fas fa-ellipsis-v"></i>
                        </button>
                        <div class="collapse navbar-collapse d-lg-block d-xl-block d-sm-none d-md-none d-none"
                            id="navbarSupportedContent">
                            <ul class="nav navbar-nav ml-auto">
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle d-flex align-items-center gap-2" href="#"
                                        role="button" data-toggle="dropdown">
                                        <span style="margin-right:5px">{{ $user['admin']['username'] ?? 'Guest' }}</span>
                                        <i class="fa-solid fa-user-circle" style="padding-right:5px"></i>
                                    </a>
                                    <ul class="dropdown-menu dropdown-menu-end dropdown-menu-sm">
                                        <li style="margin-right:5px">
                                            <a class="dropdown-item d-flex align-items-center gap-2"
                                                href="{{ route('my-profile') }}">
                                                <i class="fa-solid fa-user" style="font-size:16px; color:gray;"></i>
                                                <span style="margin-left:5px">My Profile</span>
                                            </a>
                                        </li>
                                        <li>
                                            <form action="{{ route('logout') }}" method="POST">
                                                @csrf
                                                <button type="submit" class="dropdown-item d-flex align-items-center gap-2 logout-btn">
                                                    <i class="fa-solid fa-right-from-bracket" style="font-size:16px; color:gray;"></i>
                                                    <span style="margin-left:5px;color:black">Logout</span>
                                                </button>
                                            </form>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </div>
            <div class="main-content container-xxl">
                <div class="row">
                    <div class="col-12">
                        <div class="card" style="min-height: 500px;">
                            <div class="card-header">
                                @yield('content')
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Footer -->
            <footer class="bg-light py-3 mt-4">
                <div class="container text-center">
                    <p class="mb-0 text-muted" style="font-family: 'Roboto', sans-serif; font-size: 0.9rem;">
                        All Rights Reserved &copy; 2025 Unioil CMS
                    </p>
                </div>
            </footer>
        </div>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="js/jquery-3.3.1.slim.min.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#sidebarCollapse').on('click', function() {
                $('#sidebar').toggleClass('active');
                $('#content').toggleClass('active');
            });

            $('.more-button,.body-overlay').on('click', function() {
                $('#sidebar,.body-overlay').toggleClass('show-nav');
            });
        });
    </script>
</body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</html>