//** Admin | Sidebar

@use "sass:math";

.admin__sidebar {
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  height: 100%;
  padding-top: 1.625rem;

  &:hover {
    z-index: 2;
  }

  @include media-breakpoint-up(lg) {
    padding-top: 1.625rem;
  }

  &--separator {
    padding: 0 $spacer;
    margin: $spacer*1.625 0 0;
    opacity: 0.6;
    font-weight: $font-weight-bold;
    text-transform: uppercase;
    font-size: $small-font-size;
    letter-spacing: $letter-spacing;

    @include media-breakpoint-up(wd) {
      margin: $spacer*2.25 0 0 $spacer;
    }
  }

  &--menu {
    margin: 0 0 2rem 0;
    padding: 0;
    width: 100%;
    list-style: none;
  }

  &--link {
    position: relative;
    width: 100%;
    padding: math.div($spacer, 1.75) $spacer*1.5 math.div($spacer, 1.75) $spacer;
    display: block;
    font-weight: $font-weight-semibold;
    letter-spacing: $letter-spacing;
    color: var(--admin-sidebar-text);
    font-size: 0.85rem;

    @include media-breakpoint-up(wd) {
      font-size: 0.9375rem;
      padding: math.div($spacer, 1.75) $spacer*1.5 math.div($spacer, 1.75) $spacer*2;
    }

    &:hover {
      @include darken(--admin-sidebar, 0.25);

      color: var(--admin-sidebar-icon);
      text-decoration: none;

      .link--icon {
        transform: scale(1.1);
        opacity: 1;
      }
    }

    &.has-menu {
      &:hover,
      &:focus {
        .link--caret {
          color: var(--admin-sidebar-icon);
          transform: translateX(2px);
          opacity: 1;
        }

        .link--menu {
          visibility: visible;
        }
      }
    }

    .link--icon {
      font-size: 120%;
      transition: $transition-base;
      transform-origin: center;
      color: var(--admin-sidebar-icon);
      font-weight: $font-weight-bold;
      width: 22px;
      opacity: 0.5;
    }

    .link--caret {
      transition: $transition-base;
      color: var(--admin-sidebar-text);
      opacity: 0.4;
      width: 15px;
      position: absolute;
      right: 0;
      top: 0;
      height: 100%;
      display: flex;
      align-items: center;
      margin-right: 0;
    }

    .link--menu {
      background: var(--admin-sidebar-menu);
      border-radius: 0 $border-radius $border-radius 0;
      box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.2);
      border: 1px solid rgba(0, 0, 0, 0.1);
      position: absolute;
      left: 100%;
      top: 0;
      width: $admin-sidebar-width * 1.5;
      margin: 0;
      padding: 0;
      list-style: none;
      visibility: hidden;

      // display only on larger screens
      display: none;

      @include media-breakpoint-up(lg) {
        display: block;
      }

      li {
        &.link--actions {
          display: flex;
          align-content: space-around;
          border-bottom: solid 1px rgba(0, 0, 0, 0.1);

          a {
            font-weight: $font-weight-bold;
            letter-spacing: $letter-spacing;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          a + a {
            border-left: dashed 1px rgba(0, 0, 0, 0.1);
          }
        }

        a {
          padding: math.div($spacer, 1.75) $spacer;
          color: var(--admin-sidebar-menu-text);
          display: flex;
          align-items: center;
          font-weight: $font-weight-normal;
          letter-spacing: initial;

          &:hover {
            @include darken(--admin-sidebar-menu, 0.1);

            color: var(--admin-sidebar-menu-text);
            text-decoration: none;
          }

          span {
            display: inline-block;
            white-space: nowrap;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }
      }
    }
  }

  &--slim {
    background: transparent;
    border: 0;
    text-align: center;
    color: var(--shade-light);
    font-size: $font-size-lg;
    position: relative;
    margin: 0 auto;
    display: block;

    &:hover {
      color: var(--admin-sidebar-icon);
      outline: none;
      cursor: pointer;
    }

    &:focus {
      outline: 0.15rem solid;
    }
  }

  &--footer {
    -webkit-backface-visibility: hidden;
    color: var(--admin-sidebar-text);
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1;
    min-height: 40px;
    width: $admin-sidebar-width;
    padding: 0 $spacer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--admin-sidebar);

    @include media-breakpoint-up(wd) {
      width: $admin-sidebar-width-wide;
    }

    a {
      color: var(--admin-sidebar-text);
      opacity: 0.75;
      font-size: 0.875rem;

      &:hover {
        color: inherit;
      }
    }
  }
}

.admin {
  &.is-slim {
    .admin__sidebar {
      width: math.div($admin-sidebar-width, 3);

      .admin__sidebar--separator {
        visibility: hidden;
        margin: 0;
      }

      .admin__sidebar--footer {
        display: none;
      }

      .admin__sidebar--link {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: math.div($spacer, 1.25) $spacer * 0.5;

        .link--icon {
          font-size: 140%;
          margin: 0;
          width: auto;
        }

        .link--text {
          display: none;
        }
      }

      .admin__sidebar--slim {
        width: math.div($admin-sidebar-width, 3);
        bottom: $spacer * 0.5;
      }
    }

    .admin__header,
    .admin__body {
      @include media-breakpoint-up(lg) {
        margin-left: math.div($admin-sidebar-width, 3);
      }
    }
  }
}

.sidebar--sticky {
  position: sticky;
  top: 60px;
  // reset this as sticky does not work together with display block on hover li's of the sidebar menu, above in this file
  @include media-breakpoint-up(lg) {
    position: static;
    top: 0;
  }
}
