@use "../variables" as theme;

//START sidebar container
.side-nav-container {
  width: var(--side-nav-width);
  background-color: var(--side-nav-bg-color);
  height: calc((var(--vh) * 100) - 7.375rem);
  position: fixed;
  margin: 0;
  left: 0.625rem;
  top: 4rem;
  border-radius: var(--side-nav-border-radius);
  transition: width var(--side-nav-openclose-transition), background-color var(--side-nav-bg-color-transition), border-color var(--side-nav-border-transition);
  border: var(--side-nav-border);
  overflow: hidden;

  &::-webkit-scrollbar {
    visibility: hidden;
  }

  &.no-donate {
    height: calc((var(--vh) * 100) - 5.125rem);
  }

  &.hidden {
    display: none;
    opacity: 0;
  }
  //START closed state of the sidebar
  &.closed {
    width: 3.125rem;
    overflow-x: hidden;
    overflow-y: hidden;
    background-color: var(--side-nav-closed-bg-color);
    border: var(--side-nav-border-closed);
    height: calc((var(--vh) * 100) - 6.5rem);
    border-radius: unset;

    // For Firefox
    @supports (-moz-appearance: none) {
      width: 2.5rem;
    }

    .side-nav {
      .side-nav-item {
        color: var(--side-nav-item-closed-color);

        &:hover {
          &.active {
            color: var(--side-nav-item-active-text-color);
          }
        }

        .phone-hidden:first-of-type {
          margin-left: unset;
        }

        .active-highlight {
          opacity: 0;
        }

        .card-actions {
          opacity: 0;
          display: none;
        }
      }
    }
  }
  //END closed state of the sidebar
  //START sidebar
  .side-nav {
    overflow: hidden;
    height: 100%;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    //START sidebar nav item
    .side-nav-item {
      position: relative;
      align-items: center;
      display: flex;
      justify-content: start;
      width: 100%;
      height: auto;
      min-height: 2.6rem;
      overflow: hidden;
      cursor: pointer;
      font-size: 0.9rem;
      text-decoration: none;
      color: var(--side-nav-text-color);

      .phone-hidden {
        display: flex;

        &:first-of-type {
          width: 2.5rem;
          min-width: 2.5rem;
          margin-left: 0.3rem;
          justify-content: center;
        }

        &:last-child {
          flex-grow: 1;
          justify-content: end;
        }

        div {
          height: 100%;
          padding: 0 0.625rem;

          i {
            font-size: var(--side-nav-icon-size);
          }
        }
      }

      .active-highlight {
        background-color: var(--side-nav-item-color);
        width: 0.25rem;
        height: 100%;
        position: absolute;
        left: 0;
      }

      .side-nav-text {
        opacity: 1;
        min-width: 6.25rem;
        word-break: break-all;
        -webkit-line-clamp: 1;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;

        div {
          min-width: 6.375rem;
          width: 100%
        }
      }

      .card-actions {
        flex-grow: 1;
        justify-content: end;
        display: flex;
      }

      &.active {
        background-color: var(--side-nav-active-bg-color);
        color: var(--side-nav-item-active-text-color);

        .active-highlight {
          background-color: var(--side-nav-item-active-color);
        }
      }

      &:hover {
        color: var(--side-nav-hover-text-color);
        background-color: var(--side-nav-hover-bg-color);
      }
    }
    //END sidebar nav item
    // For firefox
    @supports (-moz-appearance: none) {
      scrollbar-color: transparent transparent;
      scrollbar-width: thin;
    }

    &::-webkit-scrollbar {
      background-color: transparent; /*make scrollbar space invisible */
      width: inherit;
      display: none;
      visibility: hidden;
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: transparent; /*makes it invisible when not hovering*/
    }

    &:hover {
      scrollbar-width: thin;
      overflow-y: auto;
      // For firefox
      @supports (-moz-appearance: none) {
        scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0);
      }

      &::-webkit-scrollbar-thumb {
        visibility: visible;
        background-color: rgba(255, 255, 255, 0.3); /*On hover, it will turn grey*/
      }
    }
  }
  //END sidebar
  //START preference sidebar
  &.preference {
    height: calc((var(--vh)*100) - 4.6875rem);
    width: 14.875rem;

    .side-nav {
      overflow-x: hidden;
      padding-bottom: 0.625rem;
      padding-left: 1.125rem;

      .side-nav-header {
        color: var(--side-nav-header-text-color);
        font-size: 1rem;
        margin-left: unset;

        &:first-of-type {
          margin-top: 0.7rem;
        }
      }

      .side-nav-item {
        font-size: 1rem;
        min-height: 1.875rem;
        justify-content: unset;

        &.active {
          .side-nav-text {
            color: var(--side-nav-item-active-text-color);
          }
        }

        .side-nav-text {
          text-align: unset;
          margin-left: 0.75rem;
          font-size: 0.9rem;
          color: var(--side-nav-text-color);
          
          div {
            display: flex;
            
            .badge {
              align-self: center;
            }
          }
        }

        &:hover {
          .side-nav-text {
            color: var(--side-nav-hover-text-color);
          }
        }
        .card-actions {
          display: none;
        }
      }
    }
  }
  //END preference sidebar
}
//END sidebar container

//START kavita+ subscription bottom heart button
.sidenav-bottom {
  position: absolute;
  bottom: 0;
  width: var(--side-nav-width);
  font-size: 0.75rem;
  transition: width var(--side-nav-openclose-transition);
  z-index: 999;
  background-color: var(--side-nav-bg-color);

  .donate {
    .side-nav-item {
      width: 100%;
      padding: 0 5rem;
      justify-content: center;
      align-items: center;
      display: flex;
      min-height: 3.125rem;
      color: var(--side-nav-text-color);

      &:hover {
        color: var(--side-nav-hover-text-color);
        background-color: var(--side-nav-hover-bg-color);
      }

      .active-highlight {
        display: none;
      }

      .phone-hidden {
        div {
          i {
            font-size: var(--side-nav-icon-size);
          }
        }
      }

      .side-nav-text {
        display: none !important;
      }

      .card-actions {
        display: none;
      }
    }
  }
  //START sidebar bottom closed
  &.closed {
    width: 2.5rem;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: unset;

    .side-nav-item {
      width: 100%;
      padding: 0;
      color: var(--side-nav-item-closed-color);

      &:hover {
        background-color: unset !important;
      }
    }
  }
  //END sidebar bottom closed
}
//END kavita+ subscription bottom heart button

@media (max-width: theme.$grid-breakpoints-lg) {
  .side-nav-container {
    padding: 0.625rem 0;
    padding-left: 0.3125rem;
    width: 55vw;
    background-color: var(--side-nav-mobile-bg-color);
    height: 100dvh;
    position: fixed;
    margin: 0;
    left: 0;
    top: 0;
    transition: width var(--side-nav-openclose-transition), visibility var(--side-nav-openclose-transition);
    z-index: 1050;
    overflow-x: hidden;
    overflow-y: auto;
    border: var(--side-nav-mobile-border);
    border-radius: 0rem;
    visibility: visible;

    &.preference {
        background-color: unset;
      .side-nav {
        .side-nav-header {
          font-size: 1.25rem;
        }

        .side-nav-item {
          .active-highlight {
          }

          .side-nav-text {
            div {
              font-size: 1rem;
            }
          }
        }
      }
    }

    &.no-donate {
      height: 100dvh;
    }

    &.closed {
      width: 0;
      background-color: var(--side-nav-mobile-bg-color);
      overflow: hidden;
      box-shadow: none;
      visibility: hidden;
    }

    .side-nav {
      overflow: auto;
      .side-nav-item {
        .active-highlight {
          border-top-left-radius: 0rem;
          border-bottom-left-radius: 0rem;
        }
      }
    }

    .side-nav-item {
      padding: 0;
    }
  }

    .sidenav-bottom {
        display: none;
        &.closed {
            left: 0.625rem;
        }
    }

    .side-nav-overlay {
        background-color: var(--side-nav-overlay-color);
        width: 100vw;
        height: 100vh;
        position: absolute;
        left: 0;
        top: 0;
        z-index: 1041;
        visibility: visible;
        opacity: 1;
        transition: visibility var(--side-nav-openclose-transition), opacity var(--side-nav-openclose-transition);

        &.closed {
          visibility: hidden;
          opacity: 0;
        }
    }
}

.btn-close {
    margin-top: -1.75rem;
    font-size: 0.8rem;
    position: absolute;
    right: 1rem;
}
