<div class="d-flex align-items-center justify-content-between">
    <i class="bi bi-list toggle-sidebar-btn"></i>
    <span style="margin-right: 10px;"></span>
    <a href="{{ route('admindash') }}" class="logo d-flex align-items-center">
        <img src="{{ asset('logo/baru/HC.png') }}" alt="">
        <span class="d-none d-lg-block">HeartChoice</span>
    </a>
</div><!-- End Logo -->

<nav class="header-nav ms-auto">
    <ul class="d-flex align-items-center">
        <li class="nav-item d-block d-lg-none">
            <a class="nav-link nav-icon search-bar-toggle" href="#">
                <i class="bi bi-search"></i>
            </a>
        </li><!-- End Search Icon -->

        <li class="nav-item dropdown pe-3">
            <a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown">
                {{-- <img src="{{ asset('assetss/img/profile-default.png') }}" alt="Profile" class="rounded-circle" width="32" height="32"> --}}
                <span class="d-none d-md-block dropdown-toggle ps-2 fw-semibold text-dark">{{ Auth::user()->name }}</span>
            </a>
        
            <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile shadow-sm">
                <li class="dropdown-header text-center">
                    {{-- <img src="{{ asset('assetss/img/profile-default.png') }}" alt="Profile" class="rounded-circle mb-2" width="60" height="60"> --}}
                    <h6 class="mb-0">{{ Auth::user()->name }}</h6>
                    <span class="text-muted">{{ Auth::user()->role->name ?? 'User' }}</span><br>
                    <small class="text-muted">{{ Auth::user()->email }}</small>
                </li>
                <li>  
                    <hr class="dropdown-divider">
                </li>
                <li>
                    <form id="logoutForm" method="POST" action="{{ route('logout') }}">
                        @csrf
                        <button type="button" class="dropdown-item d-flex align-items-center gap-2 text-danger" onclick="confirmLogout()">
                            <i class="bi bi-box-arrow-right" style="font-size: 1.2rem;"></i>
                            <span>Sign Out</span>
                        </button>
                    </form>
                </li>
            </ul>
        </li>
    </ul>
</nav><!-- End Icons Navigation -->

<!-- SweetAlert2 -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<!-- Confirmation Dialog Script -->
<script>
    function confirmLogout() {
        Swal.fire({
            title: 'Apakah Anda yakin?',
            text: "Anda akan keluar dari akun ini!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Ya, keluar',
            cancelButtonText: 'Batal'
        }).then((result) => {
            if (result.isConfirmed) {
                document.getElementById('logoutForm').submit();
            }
        });
    }
</script>
