@import '../abstracts/variables';

.navmenu {
    margin: 0;
    position: relative;
    list-style: none;
    overscroll-behavior-y: contain;
}

.nav-group {
    width: 100%;
    display: block;
    justify-content: flex-start;

    & > .nav-link > .nav-link-text {
        font-weight: 500;
    }

    & * .nav-group {
        & > .nav-link > .nav-link-text {
            font-weight: 400;
        }
    }

    & * .nav-group {
        & > .nav-link.expanded > .nav-link-text {
            font-weight: 500;
        }
    }

    & * .navmenu .nav-item .nav-link {
        padding-left: 36px;
        padding-inline-start: 36px;
        padding-inline-end: unset;
    }
}

.nav-group-disabled {
    &, .nav-link-text, .nav-link-expand-icon, .nav-link-icon {
        color: var(--palette-text-disabled) !important;
        cursor: default;
        pointer-events: none;
    }
}

.nav-item {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    text-decoration: none;
}

.nav-link {
    width: 100%;
    font-weight: 400;
    padding: 8px 16px 8px 16px;
    color: inherit;
    line-height: 1.75;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    text-transform: inherit;
    background-color: transparent;
    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, padding 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    align-items: flex-start;

    &.nav-link-disabled {
        color: var(--palette-text-disabled) !important;
        cursor: default;
        pointer-events: none;
    }

    &:hover:not(.nav-link-disabled) {
        cursor: pointer;
        text-decoration: none;
        background-color: var(--palette-action-default-hover);
    }

    &:focus:not(.nav-link-disabled) {
        background-color: var(--palette-action-default-hover);
    }

  &.active:not(.nav-link-disabled) {
    font-weight: 500 !important;
  }

    &:not(.nav-link-disabled) .nav-link-icon.nav-link-icon-default {
        color: var(--palette-drawer-icon);
    }

    &.nav-link-disabled .nav-link-icon {
        color: var(--palette-text-disabled);
    }

    & .nav-link-expand-icon {
        color: var(--palette-drawer-icon);
        transition: .3s cubic-bezier(.25,.8,.5,1),visibility 0s;

        &.transform {
            transform: rotate(-180deg);
        }

        &.transform-disabled {
            transform: rotate(-180deg);
        }
    }

    & .nav-link-text {
        width: 100%;
        text-align: start;
        margin-left: 12px;
        margin-inline-start: 12px;
        margin-inline-end: unset;
        letter-spacing: 0;
    }
}

.navmenu{
  
  &.navmenu-dense{
    .nav-link{
      padding: 4px 16px 4px 16px;
    }
  }
  
  &.navmenu-margin-dense{
    .nav-link{
      margin: 2px 0;
    }
  }

  &.navmenu-margin-normal{
    .nav-link{
      margin: 4px 0;
    }
  }

  &.navmenu-rounded{
    .nav-link{
      border-radius: var(--default-borderradius);
    }
  }
  
  &.navmenu-bordered{
    .nav-link{
      &.active:not(.nav-link-disabled) {
        border-inline-end-style: solid;
        border-inline-end-width: 2px;
      }
    }
  }
  
  &.navmenu-default{
    .nav-link.active:not(.nav-link-disabled) {
      color: var(--palette-primary);
      background-color: var(--palette-action-default-hover);

      &:hover:not(.nav-link-disabled), &:focus-visible:not(.nav-link-disabled) {
        background-color: var(--palette-action-default-hover);
      }
    }
    
    .nav-link-expand-icon.transform {
      fill: var(--palette-primary);
    }
  }
  
  @each $color in $palette-colors {
    &.navmenu-#{$color} {
        .nav-link.active:not(.nav-link-disabled) {
          color: var(--palette-#{$color});
          background-color: var(--palette-#{$color}-hover);

          &:hover:not(.nav-link-disabled), &:focus-visible:not(.nav-link-disabled) {
            background-color: rgba(var(--palette-#{$color}-rgb), 0.12);
          }

          .nav-link-icon {
            color: var(--palette-#{$color});
          }
        }

      .nav-link-expand-icon.transform {
        fill: var(--palette-#{$color});
      }
    }
  }
}

.nav-group * .navmenu > .nav-group {
    & .nav-link {
        padding-left: 36px;
        padding-inline-start: 36px;
        padding-inline-end: 16px;
    }

    & * .navmenu .nav-item .nav-link {
        padding-left: 48px;
        padding-inline-start: 48px;
    }

    & * .navmenu > .nav-group {
        & .nav-link {
            padding-left: 48px;
            padding-inline-start: 48px;
            padding-inline-end: 16px;
        }

        & * .navmenu .nav-item .nav-link {
            padding-left: 60px;
            padding-inline-start: 60px;
            padding-inline-end: 0;
        }

        & * .navmenu > .nav-group {
            & .nav-link {
                padding-left: 60px;
                padding-inline-start: 60px;
                padding-inline-end: 16px;
            }

            & * .navmenu .nav-item .nav-link {
                padding-left: 72px;
                padding-inline-start: 72px;
                padding-inline-end: 0;
            }
        }
    }
}

.drawer--closed.drawer-mini {
    & > .drawer-content > .navmenu {
        & .nav-link .icon-root:first-child + .nav-link-text {
            display: none;
        }
    }

    .nav-group {
        & * .navmenu .nav-item .nav-link {
            padding: 8px 16px 8px 16px;
        }
    }

    .nav-group * .navmenu > .nav-group {
        & .nav-link {
            padding: 8px 16px 8px 16px;
        }

        & * .navmenu .nav-item .nav-link {
            padding: 8px 16px 8px 16px;
        }

        & * .navmenu > .nav-group {
            & .nav-link {
                padding: 8px 16px 8px 16px;
            }

            & * .navmenu .nav-item .nav-link {
                padding: 8px 16px 8px 16px;
            }

            & * .navmenu > .nav-group {
                & .nav-link {
                    padding: 8px 16px 8px 16px;
                }

                & * .navmenu .nav-item .nav-link {
                    padding: 8px 16px 8px 16px;
                }
            }
        }
    }
}
