<!-- resources/views/layouts/app.blade.php -->
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ hotelName() }} - Hotel Management System</title>
    @themeStyles
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/delux-system.css') }}" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body class="theme-{{ $themeMode ?? 'light' }}">
    <div id="app">
        <nav class="navbar navbar-expand-md navbar-dark shadow-sm">
            <div class="container">
                <a class="navbar-brand" href="{{ url('/') }}">
                    <i class="fas fa-hotel me-2"></i> {{ hotelName() }}
                </a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav me-auto">
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('dashboard') }}">Dashboard</a>
                        </li>
                        @canModule('reservations')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('reservations.index') }}">Reservations</a>
                        </li>
                        @endcanModule
                        @canModule('rooms')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('rooms.index') }}">Rooms</a>
                        </li>
                        @endcanModule
                        @canModule('guests')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('guests.index') }}">Guests</a>
                        </li>
                        @endcanModule
                        @canModule('reporting')
                        @if(Route::has('reports.index'))
                            <li class="nav-item">
                                <a href="{{ route('reports.index') }}" class="nav-link">Reports</a>
                            </li>
                        @endif
                        @endcanModule
                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ms-auto">
                        <!-- Authentication Links -->
                        @guest
                            @if (Route::has('login'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
                                </li>
                            @endif

                            @if (Route::has('register'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
                                </li>
                            @endif
                        @else
                            <li class="nav-item">
                                <a class="nav-link position-relative" href="{{ route('notifications.notifications.index') }}">
                                    <i class="fas fa-bell"></i>
                                    @php($unreadCount = auth()->user()?->unreadNotifications()->count() ?? 0)
                                    @if($unreadCount > 0)
                                        <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
                                            {{ $unreadCount > 99 ? '99+' : $unreadCount }}
                                        </span>
                                    @endif
                                </a>
                            </li>
                            <li class="nav-item dropdown">
                                <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                    {{ Auth::user()->name }}
                                </a>

                                <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="{{ route('logout') }}"
                                       onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                        {{ __('Logout') }}
                                    </a>

                                    <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                                        @csrf
                                    </form>
                                </div>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        <div class="container-fluid">
            <div class="row">
                <!-- Sidebar -->
                <div class="col-md-3 col-lg-2 sidebar py-3">
                    <ul class="nav flex-column">
                        <li class="nav-item">
                            <a class="nav-link active" href="{{ route('dashboard') }}">
                                <i class="fas fa-tachometer-alt me-2"></i> Dashboard
                            </a>
                        </li>
                        @canModule('reservations')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('reservations.index') }}">
                                <i class="fas fa-calendar-check me-2"></i> Reservations
                            </a>
                        </li>
                        @endcanModule
                        @canModule('rooms')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('rooms.index') }}">
                                <i class="fas fa-bed me-2"></i> Room Management
                            </a>
                        </li>
                        @endcanModule
                        @canModule('guests')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('guests.index') }}">
                                <i class="fas fa-users me-2"></i> Guests
                            </a>
                        </li>
                        @endcanModule
                        @canModule('hotel_services')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('services.index') }}">
                                <i class="fas fa-concierge-bell me-2"></i> Services
                            </a>
                        </li>
                        @endcanModule
                        @canModule('reporting')
                        @if(Route::has('reports.index'))
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('reports.index') }}">
                                    <i class="fas fa-chart-bar me-2"></i> Reports
                                </a>
                            </li>
                        @endif
                        @endcanModule
                        @canModule('accounting')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('accounting.index') }}">
                                <i class="fas fa-calculator me-2"></i> Accounting
                            </a>
                        </li>
                        @endcanModule
                        @canModule('settings')
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('settings.index') }}">
                                <i class="fas fa-cog me-2"></i> Settings
                            </a>
                        </li>
                        @endcanModule
                    </ul>
                </div>

                <!-- Main content -->
                <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 py-4">
                    @yield('content')
                </main>
            </div>
        </div>
    </div>
    
    <script src="{{ asset('js/app.js') }}"></script>
    <script src="https://kit.fontawesome.com/your-fontawesome-kit.js" crossorigin="anonymous"></script>
    @stack('scripts')
</body>
</html>
