@use '../../shared/styles/variables' as *;

.navbar {
    position: sticky;
    top: 0;
    z-index: 350;

    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 100px;
    justify-content: space-between;
    padding: 18px 20px 0px;
    //box-shadow: 0 0 10px 15px $color-bg;

    //min-height: $layout-navbar-height;
    .back-navbar {
        position: absolute;
        background: color-mix(in srgb, var(--color-bg) 85%, transparent);
        backdrop-filter: blur(10px);
        z-index: 349;
        width: 100%;
        height: calc(100% + 18px);
        left: 0;
        top: 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    &.navbar--scrolled {
        .back-navbar {
            opacity: 1;
        }
    }

    .navbar-content {
        position: relative;
        display: flex;
        flex: 1;
        flex-direction: row;
        align-items: center;
        gap: 100px;
        justify-content: space-between;
        z-index: 350;
    }
}

.navbar__main {
    min-width: 0;

    display: flex;
    align-items: center;
    line-height: 1;
    gap: 14px;

    h1 {
        display: flex;
        align-items: flex-end;
        gap: 8px;
        font-size: var(--font-size-26);
        min-width: 0;
        overflow: visible;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.navbar__title-link,
.navbar__title-text {
    color: $color-text-heading;
    text-decoration: none;
}

.navbar__title-link {
    transition: 0.2s ease;

    &:hover {
        //color: $blue;
    }
}

.navbar-breadcrumbs {
    min-width: 0;

    display: inline-flex;
    align-items: baseline;
    gap: 8px;

    color: $color-text-muted;
    font-size: var(--font-size-18);
    font-weight: 500;
    line-height: 1.1;
}

.navbar-breadcrumbs__item {
    min-width: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;

    >span:last-child,
    a {
        min-width: 0;
        max-width: min(420px, 38vw);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    a {
        color: $color-text-muted;
        text-decoration: none;
        transition: 0.2s ease;

        &:hover {
            color: $blue;
        }
    }
}

.navbar-breadcrumbs__separator {
    color: $color-text-muted;
    font-weight: 500;
}

.navbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar__icon-btn {
    width: 34px;
    height: 34px;

    border: none;
    border-radius: 12px;
    background: $transparent;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: $color-text-muted;
    cursor: pointer;

    transition: 0.2s ease;

    &:hover {
        background: $color-surface;
        color: $blue;
    }
}

.navbar__menu-btn,
.navbar__logo {
    display: none;
}

.navbar__logo {
    align-items: center;
    flex: 0 0 auto;

    img {
        height: 28px;
        width: auto;
        display: block;
    }
}

.navbar__theme-button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: transparent;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: $gray50;
    cursor: pointer;
    transition: 0.2s ease;

    svg {
        flex: 0 0 auto;
        transition: transform 0.2s ease;
    }

    &:hover {
        background: $gray30;
    }

    &:active {
        transform: scale(0.96);
    }

    &.is-dark:hover {
        background: var(--color-surface-hover);
    }
}

.navbar-user {
    border: none;
    background: $transparent;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: $color-text-strong;
    font-size: $font-size-16;
    font-weight: 500;
    cursor: pointer;

    &:focus-visible {
        outline: none;
    }
}

.navbar-user__avatar {
    width: 34px;
    height: 34px;

    border-radius: 50%;
    background: $blue;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;

    color: $color-text-inverse;

    svg {
        height: 16px;
        width: auto;
    }

    img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.navbar-user__chevron {
    color: $color-text-muted;
}

.navbar-dropdown {
    z-index: 401;

    width: 250px;
    border-radius: 16px;
    background: $color-surface;
    padding: 8px;

    box-shadow: $shadow-popover;

    animation: navbarDropdownShow 0.16s ease;
}

.navbar-dropdown__user {
    padding: 10px 12px;

    display: flex;
    flex-direction: column;
    gap: 4px;

    span {
        color: $color-text-muted;
        font-size: $font-size-13;
    }

    b {
        color: $color-text-strong;
        font-size: $font-size-15;
        font-weight: 600;
    }
}

.navbar-dropdown__separator {
    height: 1px;
    margin: 6px 0;
    background: $color-border;
}

.navbar-dropdown__item {
    min-height: 38px;
    padding: 0 10px;
    border-radius: 10px;

    display: flex;
    align-items: center;
    gap: 8px;

    color: $color-text-heading;
    font-size: $font-size-14;
    font-weight: 500;

    outline: none;
    cursor: pointer;

    &[data-highlighted] {
        background: $color-surface-subtle;
    }
}

.navbar-dropdown__item--danger {
    color: $red;

    &[data-highlighted] {
        background: $color-danger-tint;
    }
}

@include wide-down {
    .navbar {
        gap: 40px;
    }

    .navbar__menu-btn {
        display: inline-flex;
    }

    .navbar__logo {
        display: inline-flex;
    }
}

@include laptop-down {
    .navbar {
        gap: 40px;
    }

    .navbar-user__role {
        max-width: 280px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .navbar-breadcrumbs {
        font-size: var(--font-size-18);
    }

    .navbar-breadcrumbs__item {

        >span:last-child,
        a {
            max-width: min(320px, 32vw);
        }
    }
}

@include tablet-down {
    .navbar {
        gap: 16px;
        padding-bottom: 14px;
    }

    .navbar__actions {
        gap: 8px;
    }

    .navbar__actions>.navbar__icon-btn:not(.navbar__theme-btn) {
        display: none;
    }

    .navbar-user {
        gap: 0;
    }

    .navbar-user__role,
    .navbar-user__chevron {
        display: none;
    }
}

@keyframes navbarDropdownShow {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
