<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>@yield('title')</title>
    
    <link rel="icon" type="image/png" sizes="32x32" href="{{ asset('img/logo-pegas.png') }}">
    <link rel="apple-touch-icon" href="{{ asset('img/logo-pegas.png') }}">

    <link href="{{ asset('css/user-min.css')}}" rel="stylesheet">
    <link href="{{ asset('konten-asset/vendor/fontawesome-free/css/all.min.css') }}" rel="stylesheet">
    <link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap4.min.css" rel="stylesheet">
</head>

<body id="page-top">

<div id="wrapper">
    @include('user.layout.sidebar')

    <div id="content-wrapper" class="d-flex flex-column">
        <div id="content">
            @include('user.layout.navbar')

            <div class="container-fluid">
                @yield('content')
            </div>
        </div>
    </div>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<script src="{{ asset('template/js/sb-admin-2.min.js') }}"></script>
<script src="{{ asset('js/user.js') }}"></script>

@stack('scripts')

@if(session('success_register'))
<script>
Swal.fire({
    icon: 'success',
    title: 'Akun berhasil didaftarkan!',
    text: 'Silakan lihat panduan penggunaan sistem.',
    confirmButtonText: 'Ke Panduan',
    confirmButtonColor: '#7ebc12'
}).then(() => {
    window.location.href = "{{ route('user.bantuan') }}";
});
</script>
@endif

@if(session('success_login'))
<script>
Swal.fire({
    icon: 'success',
    title: 'Berhasil Login',
    timer: 2000,
    showConfirmButton: false
});
</script>
@endif

@if(session('success'))
<script>
Swal.fire({
    icon: 'success',
    title: 'Berhasil',
    text: '{{ session('success') }}',
    confirmButtonColor: '#7ebc12'
});
</script>
@endif

<script>
    $(document).ready(function() {
        $(document).on('click touchstart', function(event) {
            if ($(window).width() < 768) {
                var $sidebar = $('.sidebar');
                var $toggleButtonTop = $('#sidebarToggleTop');
                var $toggleButton = $('#sidebarToggle');

                if ($('body').hasClass('sidebar-toggled')) {
                    if (!$sidebar.is(event.target) && 
                        $sidebar.has(event.target).length === 0 && 
                        !$toggleButtonTop.is(event.target) && 
                        $toggleButtonTop.has(event.target).length === 0 &&
                        !$toggleButton.is(event.target) && 
                        $toggleButton.has(event.target).length === 0) {
                        
                        $toggleButtonTop.click();
                    }
                }
            }
        });
    });
</script>

</body>
</html>