@using System.Security.Claims

<nav class="navbar navbar-expand-lg navbar-light bg-light border-bottom border-2 fixed-top">
    <div class="container">
        <a class="navbar-brand d-flex align-items-center" href="/">
            <img src="/img/logo.png" alt="" width="40" height="40" class="d-inline-block align-top">
            <div class="ms-2 unturned-font">Unturned Store</div>
        </a>

        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-collapse-main">
            <i class="fas fa-bars fs-3"></i>
        </button>

        <div id="navbar-collapse-main" class="collapse navbar-collapse">
            <div class="desktop-only">
                <ul class="navbar-nav fs-6">
                    <li class="nav-item">
                        <a href="/" class="nav-link">
                            <i class="fas fa-home"></i> Home
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="/products" class="nav-link">
                            <i class="fas fa-store"></i> Products
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="/discord" target="_blank" class="nav-link">
                            <i class="fab fa-discord"></i> Discord
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="/loader" class="nav-link">
                            <i class="fas fa-cloud-download-alt"></i> Loader
                        </a>
                    </li>
			    	<li class="nav-item">
                        <a href="https://pinehosting.com/clientarea/aff.php?aff=130&page=unturned" target="_blank" class="nav-link">
                            <i class="fas fa-server"></i> Hosting
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="/about" class="nav-link">
                            <i class="fas fa-info-circle"></i> About
                        </a>
                    </li>
                </ul>
            </div>

            <ul class="navbar-nav ms-auto fs-4 align-items-center navbar--right">
                <AuthorizeView>
                    <Authorized>
                        <li class="nav-item ms-2">
                            <a href="/messages" class="nav-link position-relative">
                                <i class="far fa-envelope">
                                @if (MessageReadService.HasNewMessages)
                                {
                                    <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" class="NewMessagesDot">
                                        <g color="#f8f9fa">
                                            <circle r="22.5" cx="50" cy="50" fill="currentcolor"></circle>
                                            <g color="#dc3545">
                                                <circle cx="50" cy="50" r="12.5" fill="currentcolor"></circle>
                                            </g>
                                        </g>
                                    </svg>
                                }
                                </i>
                            </a>                
                        </li>
                        <li class="nav-item ms-2">
                            <a href="javascript:void(0)" class="nav-link position-relative">
                                <i class="far fa-bell"></i>
                            </a>
                        </li>
                    </Authorized>
                </AuthorizeView>
                
                <li class="nav-item ms-2">
                    <a href="/cart" class="nav-link position-relative">
                        <i class="fas fa-shopping-cart"></i>
                        @if (CartService.Carts != null && CartService.Carts.Sum(x => x.Items.Count) > 0)
                        {
                            <span class="button-badge-count">@CartService.Carts.Sum(x => x.Items.Count)</span>
                        }
                    </a>
                </li>
                
                <AuthorizeView>
                    <Authorized>
                        <li class="nav-item dropdown ms-3">
                            <a href="#" class="navbar-btn-avatar nav-link" data-bs-toggle="dropdown">
                                <Avatar User="UserService.UserInfo" Width="40" Height="40" Class="border border-2 m-auto" />
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end dropdown-menu-sm-start dropdown-menu-md-end position-absolute">
				                <div class="navbar-arrow-up"></div>
                                <AuthorizeView Context="context2" Roles="@RoleConstants.AdminRoleId">
                                    <Authorized>
                                        <li><a class="dropdown-item" href="/admin/users">Manage Users</a></li>
                                        <li><a class="dropdown-item" href="/admin/products">Manage Products</a></li>
                                        <li><hr class="dropdown-divider"></li>
                                    </Authorized>
                                </AuthorizeView>
                                <AuthorizeView Context="context2" Roles="@RoleConstants.AdminAndSeller">
                                    <Authorized>
                                        <li><a class="dropdown-item" href="/seller/statistics">Your Statistics</a></li>
                                        <li><a class="dropdown-item" href="/seller/products">Your Products</a></li>
                                        <li><a class="dropdown-item" href="/seller/offers">Your Offers</a></li>
                                        <li><a class="dropdown-item" href="/seller/customers">Your Customers</a></li>
                                        <li><hr class="dropdown-divider"></li>
                                    </Authorized>
                                </AuthorizeView>
                                <li><a class="dropdown-item" href="/users/@context.User.FindFirst(ClaimTypes.NameIdentifier).Value">Profile</a></li>
                                <li><a class="dropdown-item" href="/settings">Settings</a></li>
                                <li><a class="dropdown-item" href="/messages">Messages</a></li>
                                <li><a class="dropdown-item" href="/licenses">Licenses</a></li>                             
                                <li><a class="dropdown-item" href="/orders">Orders</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="/signout">Sign Out</a></li>
                            </ul>
                        </li>
                    </Authorized>
                    <NotAuthorized>
                        <li class="nav-item ms-3">
                            <a href="/signin">
                                <img src="/img/steam/buttons/sits_small.png" />
                            </a>
                        </li>                            
                    </NotAuthorized>
                </AuthorizeView>
            </ul>
        </div>

        @*<div class="d-flex align-items-center">

            <div>
                <a href="/messages" class="position-relative">
                  <i class="far fa-envelope fs-4"></i>
                  <span class="position-absolute top-100 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">
                    10
                  </span>
                </a>
            </div>

            <div class="d-flex align-items-center" style="height: 40px;">
                <div style="margin-bottom: 6px;">
                    <a href="/cart" class="d-flex align-items-center text-black-50 ps-2 pe-2 align-middle">
                        <div class="position-relative">
                            <i class="bi bi-cart-fill fs-4"></i>
                            @if (CartService.Carts != null && CartService.Carts.Sum(x => x.Items.Count) > 0)
                            {
                                <span class="position-absolute translate-middle badge rounded-pill bg-danger" style="font-size: 9px; top: 100%; left: 100%;">
                                    @CartService.Carts.Sum(x => x.Items.Count)
                                </span>
                            }
                        </div>
                    </a>
                </div>                    
            </div>
            <div class="ms-3 d-flex align-items-center"  style="height: 40px;">
                
            </div>
        </div>*@

    </div>

    <div class="navbar navbar-expand-lg bg-light border-2 border-top fixed-bottom mobile-only">
        <div class="container d-block">
            <ul class="navbar-nav flex-row flex-wrap fs-6 justify-content-around">
                <li class="nav-item">
                    <a href="/" class="nav-link d-flex flex-column align-items-center">
                        <i class="fas fa-home fs-4"></i>
                        <span class="small">Home</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/products" class="nav-link d-flex flex-column align-items-center">
                        <i class="fas fa-store fs-4"></i>
                        <span class="small">Products</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/discord" target="_blank" class="nav-link  d-flex flex-column align-items-center">
                        <i class="fab fa-discord fs-4"></i>
                        <span class="small">Discord</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/loader" class="nav-link d-flex flex-column align-items-center">
                        <i class="fas fa-cloud-download-alt fs-4"></i>
                        <span class="small">Loader</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="https://pinehosting.com/clientarea/aff.php?aff=130&page=unturned" target="_blank" class="nav-link d-flex flex-column align-items-center">
                        <i class="fas fa-server fs-4"></i>
                        <span class="small">Hosting</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/about" class="nav-link d-flex flex-column align-items-center">
                        <i class="fas fa-info-circle fs-4"></i>
                        <span class="small">About</span>
                    </a>
                </li>
            </ul>
        </div>
    </div>

</nav>
