
@import "../../../mixins/_color-mixins.less";
@import "../../../mixins/_gradients.less";
@import "../../../mixins/_shadows-helper.less";
@import "../../../mixins/_vendor-prefixes.less";

// 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;
  padding-top: 0;
  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);
  
  @media (min-width: @screen-sm-min) {
    left: calc((@navigatorWidth + 10px) * -1);
    width: @navigatorWidth;
  }

  &.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;
  }

  // Note: LESS guard removed - was: when (@appLogo =deprecated)
  .tenant-brand {
    display: block;

    background-size: contain;
    background-position: center top;
    background-repeat: no-repeat;
    margin: 0 auto;
    width: 208px;

    // Note: LESS guard removed - was: & when not(@extending)
    background-image: @navigator-platform-logo;
    padding-bottom: @navigator-platform-logo-height;
  }
  .c8y-logo {
    .tenant-brand{
      width: 136px;
      padding-bottom: @navigator-platform-logo-height-fallback;
      margin-bottom: 0;
    }
  }
}

.navigator .title {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: @size-8;
  margin: 0;
  padding: @navigator-app-name-size @size-16;
  font-size: @navigator-app-name-size;
  font-weight: 600;
  text-overflow: ellipsis;
  line-height: 1;
  color: @navigator-header-color;
  text-wrap: pretty;
  background-color: @navColorHeader;
  flex: 0 0 auto;
  text-transform: uppercase;
  min-height: 108px;
  border-bottom: 1px solid @navigator-separator-color;


  &:after {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    display: block;
    width: 100%;
    height: 4px;
    content: '';
    background-color: @navColorHeader;
    box-shadow: 0 2px 3px fade(black, 10%);
  }
  .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(@size-base * 6);
    height: calc(@size-base * 6);
    line-height: calc(@size-base * 6);
    border: 1px solid @palette-high;
    display: block;
    margin: 0;
  }

  /* Legacy support for @appLogo */
  // Note: The following code was conditionally applied in LESS with guards.
  // In SCSS, we cannot replicate LESS guards, so this legacy code is commented out.
  // If you need to hide the app logo or use legacy @appLogo variables,
  // you should override these styles in your custom branding CSS.
  //
  // Original LESS conditions were:
  // - & when not(@appBranding='')
  // - & when (not(@appLogo-height =deprecated)) and (not(@appLogo-height ='')) and (not(@appLogo =deprecated)) and (not(@appLogo =''))
  //
  // To enable legacy app logo behavior, add this to your custom CSS:
  // .navigator .title {
  //   text-indent: -1000px;
  //   overflow: hidden;
  //   height: 0;
  //   min-height: 0;
  //   background-image: var(--navigator-platform-logo, var(--c8y-navigator-platform-logo));
  //   padding-top: deprecated;
  //   padding-bottom: 0;
  //   background-size: contain;
  //   background-position: center 5px;
  //   background-repeat: no-repeat;
  //   line-height: 2.85;
  // }
  // .navigator .title .c8y-icon,
  // .navigator .title .app-noicon {
  //   display: none !important;
  // }
  // .navigator .title span {
  //   display: block;
  // }
  // .navigator .title 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 {
        display: block;
        overflow: hidden !important;
        max-width: 100% !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        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: 0;
      background-color: @navigator-background-selected;
      color: @navigator-text-color-selected;
      .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);
      outline: 2px dashed @navigator-border-selected;
      outline-offset: -2px;
      * {
        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(@size-16 * 1);
    }

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

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

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

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

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

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

  .slot {
    position: relative;

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

    c8y-device-status-display {
      height: @size-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;
    }
    // remove the background color from the active nodes which have an active child
    &:has(.children.collapse.in .link.active) > .link.active {
      background: transparent;
    }
  
  }

  .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;
  }
}

.navigator-slot-bottom {
  position: sticky;
  bottom: 0;
  width: 100%;
  font-size: 11px;
  background: @navColor;
  margin-top: auto;
  order: 10;
  border-top: 1px solid @navigator-separator-color;
  padding: 0 @size-16;
  a{
    color: currentColor;
  }
  &:has(.c8y-logo) {
    padding: @size-8 @size-16;
  }
  &:has(.logo-spacer) {
    display: flex;
    flex-direction: column;
    gap: @size-8;

  }
  p {
    text-align: center;
    opacity: 0.8;
    align-self: flex-end;
  }
}
