
$navbar-top-level-icon-size: 1.4rem;

$nav-link-margin-x: 7px;

$nav-link-padding-x: 12px;

$dropdown-menu-navbar-width: 280px;


// Apply theme variable to background of navbar
.claro-nav-container-wrapper {
    background: var(--theme-navbar-bg);
    position: relative;
    z-index: 1000;
}

.claro-navbar {
    // Navbar brand styling
    .navbar-header {
        display: flex;
        align-items: center;

        .navbar-brand {
            background-image: var(--theme-logo, url('/images/default/menu/logo.png'));
            background-repeat: no-repeat;
            background-size: contain;
            background-position: left center;
            height: 65px;
            width: var(--theme-logo-width, 186px);
            max-width: 300px;
            margin: 0.125rem 0 .125rem $nav-link-padding-x;
            outline: none;

            @media only screen and (max-width: 767px) {
                height: 62px;
                max-width: 186px;
                margin-left: 0.75rem;
                margin-right: 0.75rem;
            }


            // Navbar brand styling when an extranet logo is present
            &.has-extranet-logo {
                max-width: 120px;

                @media only screen and (max-width: 1015px) {
                    max-width: 100px;
                }
            }
        }
        // Styling of extranet logo which sits to the right of main logo when applied
        .extranet-logo {
            float: left;
            height: 64px;
            width: 90px;
            margin-left: 10px;
            position: relative;

            @media only screen and (max-width: 1015px) {
                width: 75px;
                margin-left: 5px;
            }

            @media only screen and (max-width: 360px) {
                width: 70px;
            }

            img {
                width: auto;
                max-height: 62px;
                max-width: 100%;
                position: absolute;
                top: 50%;
                transform: translate(0, -50%);
            }
        }
    }

    .navbar-header {
        @media only screen and (max-width: 767px) {
            position: relative;
            width: 100%;
        }
    }


    // Search

    // Search box styling
    .claro-navbar-search-form {
        .search-field-wrapper {
            border-radius: 10rem;
        }

        .search-field {
            height: 40px;
            width: 100%;
            padding-left: 45px;
            padding-right: 20px;
            background: rgba(36,89,148,0.08);
            border: none;
            border-radius: 10rem;
            color: var(--theme-navbar-icon-color);

            @media only screen and (min-width: 768px) and (max-width: 1080px) {
                width: auto;
            }

            &::placeholder {
                opacity: 0.7;
                transition: opacity 0.2s ease-in-out;
                color: var(--theme-navbar-icon-color);
            }

            &:focus {
                &::placeholder {
                    opacity: 1;
                    color: var(--theme-navbar-icon-color);
                }
            }

            &::-webkit-search-cancel-button {
                cursor: pointer;
                padding-left: 3px;

                @media only screen and (min-width: 768px) and (max-width: 1080px) {
                    display: none;
                }
            }
        }

        .navbar-search-results-button {
            border-radius: 8px;
        }
    }

    // Search icon sizing
    .navbar-search-icon {
        display: block;
        position: absolute;
        padding: 8px 14px;
        cursor: pointer;
        margin: 0;
        line-height: 0;
        text-align: center;

        .search-icon {
            font-size: $navbar-top-level-icon-size;
            color: var(--theme-navbar-icon-color);
        }

        // Adds hidden cross button to button which displays when the search field is opened
        .close-icon {
            font-size: ($navbar-top-level-icon-size * 1.35);
            color: var(--theme-navbar-icon-color);
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            padding: 8px 3px;
            transition: 0.3s;
            visibility: hidden;
            opacity: 0;
        }

    }

    // search suggestion dropdown sizing
    .search-suggestions {

        hr {
            display: none;
        }

        &:has(.search-suggestions-inner > ul) {
            hr {
              display: block;
            }
        }
    }

    // Search form on tablet
    @media only screen and (max-width: 1080px) and (min-width: 768px) {
        // Makes search form into button
        .claro-navbar-search-form {
            width: 40px;
            position: relative;
            z-index: 1031;
            margin: 0;

            // hides search bar on tablet until search button clicked
            .search-autocomplete {
                opacity: 0;
                visibility: hidden;
                transition: 0.3s;
            }

        }
        // Fades in icons to right of search bar when search form is active
        .claro-navbar-nav {
            visibility: visible;
            opacity: 1;
            transition: visibility 0.5s linear, opacity 0.3s linear;
        }


        .claro-navbar-search-form.search-open {

            // Shows search form on tablet when search for is active
            .search-autocomplete {
                opacity: 1;
                visibility: visible;
                transition: 0.3s;
            }

            // Hides search icon and shows cross icon when search form is active
            .navbar-search-icon {
                .search-icon {
                    visibility: hidden;
                    opacity: 0;
                    transform: scale(0.1);
                    transition: 0.3s;
                }

                .close-icon {
                    visibility: visible;
                    opacity: 1;
                    transform: scale(1);
                    transition: 0.3s;
                }
            }

            // Hides icons to right of search bar when search form is active
            & + .claro-navbar-nav {
                visibility: hidden;
                opacity: 0;
                transition: visibility 0.5s linear, opacity 0.3s linear;
            }
        }
    }



    .claro-navbar-nav {
        // nav item styling on desktop
        .nav-item {
            .nav-link-profile-img, .nav-link-icon {
                border-radius: 4px;
                margin: $nav-link-margin-x 0;
            }


            .nav-link-profile-img {
                padding: 8px $nav-link-padding-x;

                .navbar-profile-img {
                    width: 35px;
                }
            }

            .nav-link-icon {
                padding: 15px $nav-link-padding-x;
                color: var(--theme-navbar-icon-color);

                @include media-breakpoint-only(md) {
                    padding-left: calc(#{$nav-link-padding-x} - 1px);
                    padding-right: calc(#{$nav-link-padding-x} - 1px);
                }
            }
        }

        // adds margin left to nav links
        .nav-item + .nav-item {
            .nav-link {
                margin-left: 2px;
            }
        }


        // Hover/Show mode for navbar items, adds a translucent grey-200 color to background
        .nav-item .nav-link-icon:hover,
        .nav-item.show .nav-link-icon,
        .nav-item .nav-link-profile-img:hover,
        .nav-item.show .nav-link-profile-img {
            background: rgba(36,89,148,0.08);
        }
    }


    // Set's the width of dropdowns to a fixed width so they don't overflow the viewport
    .dropdown-menu-navbar {
        width: $dropdown-menu-navbar-width;
    }


}
