<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>

    <!-- Fonts -->
    <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=Mitr:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    @yield('style')
    <style>
        html,
        body {
            height: 100%;
            margin: 0;
            font-family: 'Mitr', sans-serif;
            font-size: 13pt;
        }

        .wrapper {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        footer {
            background-color: rgb(255, 195, 0);
            box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
        }

        .loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.8);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
        }

        .spinner-grow {
            width: 3rem;
            height: 3rem;
            border-width: 0.3em;
        }

        .breadcrumb-item a {
            color: grey;
            text-decoration: none;
        }

        .breadcrumb-item.active a {
            color: black;
            font-weight: bold;
            text-decoration: none;
        }

        .breadcrumb-item a:hover {
            color: darkgrey;
            text-decoration: underline;
        }
    </style>
</head>

<body>
    <div id="loading-screen" class="loading-screen">
        <div class="spinner-grow" role="status">
            <span class="sr-only"></span>
        </div>
    </div>

    <div class="wrapper" id="app">
        @auth
        <nav class="navbar navbar-expand-lg navbar-light rounded shadow-sm" aria-label="Thirteenth navbar example" style="background-color: rgb(255, 195, 0);">
            <div class="container">
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarsExample11" aria-controls="navbarsExample11" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarsExample11">
                    <a class="navbar-brand col-lg-3 me-0" href="{{ url('/') }}">
                        {{ config('app.name', 'Laravel') }}
                    </a>
                    <ul class="navbar-nav col-lg-6 justify-content-lg-center">
                        <li class="nav-item">
                            <a class="nav-link {{ Route::is('dashboard') ? 'active' : '' }}" href="{{ route('dashboard') }}">แดชบอร์ด</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ Route::is('template') ? 'active' : '' }}" href="{{ route('template') }}">เทมเพลต</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ Route::is('questions') ? 'active' : '' }}" href="{{ route('questions') }}">คำถาม</a>
                        </li>
                    </ul>
                    <div class="d-lg-flex col-lg-3 justify-content-lg-end">
                        <div 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()->first_name }} {{ Auth::user()->last_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();">
                                    {{ __('ออกจากระบบ') }}
                                </a>

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

        @yield('content')

        @auth
        <footer class="text-back text-center text-lg-start rounded">
            <div class="text-center p-3">
                © 2024 QuizGame
            </div>
        </footer>
        @endauth
    </div>

    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script>
        document.addEventListener("DOMContentLoaded", function() {
            document.getElementById("loading-screen").style.display = "none";
        });
    </script>
    <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    @yield('script')
</body>

</html>