// mixin to apply a vertical gradient in navigator
.checkVerticalGradient(@color1; @color2) when not (@color1 ='') {
  #gradient > .vertical(@start-color: @color1; @end-color: @color2);
}

.navigator {
  position: fixed;
  z-index: (@zindex-navbar-fixed + 1);
  top: 0;
  bottom: 0;
  left: calc((@navigatorWidth--sm + 10px) * -1);
  width: @navigatorWidth--sm;
  @media (min-width: @screen-sm-min) {
    left: -(@navigatorWidth + 10);
    width: @navigatorWidth;
  }
  padding-top: 0;
  padding-bottom: @navigator-padding-bottom;
  color: @navigator-text-color;
  background: @navColor;
  font-family: @navigator-font-family;
  display: flex;
  flex-flow: column nowrap;
  .transition(left @open-menu-time-type);
  .checkVerticalGradient(@grad-top; @grad-bottom);

  &.open {
    left: 0;
    box-shadow: var(--c8y-elevation-md-right);

    @media (min-width: @grid-float-breakpoint) {
      border-right: 1px solid @navigator-separator-color;
      box-shadow: none;
    }
  }

  &.minheight {
    height: @headerHeight;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.navigator .title {
  position: relative;
  z-index: 100;
  display: flex;
  flex-flow: column nowrap;
  justify-content: space-around;
  margin: 0;
  padding: @navigator-app-name-size 0 0;
  font-size: @navigator-app-name-size;
  font-weight: 500;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.6;
  white-space: nowrap;
  color: @navigator-header-color;
  background-color: @navColorHeader;
  flex: 0 0 auto;

  &:after {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    display: block;
    width: 100%;
    height: 4px;
    content: '';
    background-color: @navColorHeader;
    .shadow-scroll();
  }
  .c8y-app-icon{
    display: contents;
  }
  .c8y-icon + span,
  .app-noicon + span {
    display: block;
  }

  .c8y-icon {
    font-size: @navigator-app-logo-size;

    &::before {
      color: var(--navigator-dark-icon, currentColor);
    }

    &::after {
      color: var(--navigator-light-icon, @icon-dark-color-light);
    }
  }

  .app-noicon {
    width: calc(@margin-base * 6);
    height: calc(@margin-base * 6);
    line-height: calc(@margin-base * 6);
    background-color: white;
    color: @gray-40;
    margin-top: 8px;
    margin-bottom: 6px;
  }

  .tenant-brand when (@appLogo =deprecated) {
    display: block;

    & when not(@extending) {
      background-image: @navigator-platform-logo-css-var;
      padding-bottom: @navigator-platform-logo-height;

      .c8y-dark-theme & {
        background-image: @navigator-platform-logo-dark-css-var;
      }

      
      //@TODO: uncomment when the theme switcher is available
      // @media (prefers-color-scheme: dark) {
      //   background-image: @navigator-platform-logo-dark-css-var;
      // }
    }

    background-size: contain;
    background-position: center top;
    background-repeat: no-repeat;
    margin: 0 auto 8px;
    width: 208px;
    /* Legacy support for @appLogo */
  }

  & when not(@appBranding='') {
    // hide app logo
    text-indent: -1000px;
    overflow: hidden;
    height: 0;
    min-height: 0;
  }

  /* Legacy support for @appLogo */
  &
    when
    (not(@appLogo-height =deprecated))
    and
    (not(@appLogo-height =''))
    and
    (not(@appLogo =deprecated))
    and
    (not(@appLogo ='')) {
    & when not(@extending) {
      background-image: @navigator-platform-logo-css-var;
    }

    padding-top: @appLogo-height;
    padding-bottom: 0;
    background-size: contain;
    background-position: center 5px;
    background-repeat: no-repeat;
    line-height: 2.85;

    .c8y-icon,
    .app-noicon {
      display: none !important;
    }

    span {
      display: block;
    }

    br {
      display: none;
    }
  }
}

// Navigator content
.navigatorContent {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 4px 0 0 0;
  padding: 4px 0 0 0;
  list-style: none;
  max-height: 100%;
  background-color: @navigator-background-default;

  &:before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1001;
    height: 4px;
    background-color: @navColor;
    content: '';
  }

  .expander {
    margin-left: auto;
    transition: transform 0.25s ease;
    width: 24px;
    text-align: center;
    line-height: 30px;
    flex-shrink: 0;
    margin-right: 0;
    font-size: 16px;
  }

  .dragged {
    opacity: 1;
  }

  .link {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    border-left: @navigator-active-border-width solid transparent;
    font-size: @navigator-font-size;
    color: @navigator-text-color;

    .btn-clean {
      cursor: pointer;
      text-decoration: none;
      position: relative;
      transition: background 0.2s ease;
      display: flex;
      flex-flow: row nowrap;
      align-items: center;
      flex-grow: 1;
      min-height: 40px;
      background-color: transparent;
      padding: 8px 16px;
      min-width: 0;
      color: inherit;

      > div {
        flex-shrink: 0;
      }

      > span,
      > div {
        .text-truncate();
        background-color: transparent;
      }

      &.open {
        .expander {
          .rotate(180deg);
        }
      }
    }

    c8y-navigator-icon,
    device-status {
      padding: 0 0 0 16px;
      margin-right: 16px;
      flex-grow: 0;
      + .btn-clean {
        padding-left: 0;
      }
    }

    .btn-clean:active {
      background-color: @navigator-background-active;
    }

    &:hover,
    &:focus-within {
      outline: 2px solid @navigator-border-selected;
      outline-offset: -2px;

      .btn-clean,
      .btn-link {
        background-color: transparent;
        outline: 0 !important;
      }
    }

    &.active {
      color: @navigator-text-color-selected;
      background: @navigator-background-selected;
      border-left-color: @navigator-border-selected;
      font-weight: 500;
    }

    &.dragged-hover {
      .lighten(@navigator-background-selected, 0.2);

      * {
        pointer-events: none;
      }
    }

    &.open {
      box-shadow: inset 0 1px 0 @navigator-separator-color,
        inset 0 -1px 0 @navigator-separator-color;
    }

    &.open.active {
      .shadow-border(1px; rgba(0, 0, 0, 0.2));
      background: @navigator-background-selected;
    }

    &.parent.open:not(.active) {
      .shadow-border(1px; @navigator-separator-color);

      ~ .children {
        .shadow-border(-1px; @navigator-separator-color);
      }
    }
  }

  .icon {
    font-size: calc(var(--c8y-navigator-font-size) * 1.428571428571429);
  }

  .root-link {
    font-size: calc(var(--c8y-navigator-font-size) * 1.1428571429);
    padding: 8px 16px;
    .icon {
      font-size: calc(var(--c8y-navigator-font-size) * 1.5);
    }
  }

  .children {
    transition: all 0.35s ease;

    .link {
      padding-left: calc(@margin-16 * 1);
    }

    .children {
      .link {
        padding-left: calc(@margin-16 * 1 + @margin-base);
      }

      .children {
        .link {
          padding-left: calc(@margin-16 * 1 + @margin-base * 2);
        }

        .children {
          .link {
            padding-left: calc(@margin-16 * 1 + @margin-base * 3);
          }

          .children {
            .link {
              padding-left: calc(@margin-16 * 1 + @margin-base * 4);
            }

            .children {
              .link {
                padding-left: calc(@margin-16 * 1 + @margin-base * 5);
              }

              .children {
                .link {
                  padding-left: calc(@margin-16 * 1 + @margin-base * 6);
                }
              }
            }
          }
        }
      }
    }
  }

  .slot {
    position: relative;

    .loadingIndicator {
      position: absolute;
      top: 50%;
      left: 0;
      margin-top: -8px;
      opacity: 0.3;
    }

    c8y-device-status-display {
      height: @margin-16;
    }

    .statusContainer {
      font-size: 14px;
      overflow: hidden;
      height: 20px;
      width: 20px;
      border-radius: 50%;
      border: 0;
      background-image: none;
      background-color: @palette-high;
      padding: 1px 2px;
    }

    .disabled {
      pointer-events: none;
    }
  }

  .icon {
    display: inline-block;
    margin-right: 0;
    text-align: center;
  }

  .empty,
  .showMore {
    font-size: 0.93em;
    opacity: 0.6;
    font-style: italic;
  }

  .link.empty:hover {
    background-color: transparent;
    opacity: 0.8;
  }
}

.powered-by {
  position: absolute;
  bottom: 0;
  width: 100%;
  font-size: 11px;
  background: @navColor;

  p {
    margin: 4px;
    height: 15px;
    text-align: center;
    opacity: 0.8;
  }
}
