@use "@/assets/css/constants" as constants;
@use "@/assets/css/mixins" as mixins;

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
  transition: all .3s;
  white-space: nowrap;

  .title {
    display: flex;
    align-items: center;
    font-weight: bold;
    padding: 10px 14px;
    color: constants.$main-color;
    overflow: hidden;

    .icon-box {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 10px;
      width: 40px;
      height: 40px;
      font-size: constants.$SIZE_ICON_SM;
      border-radius: 8px;
      cursor: pointer;

      span {
        transform: rotateZ(180deg);
        transition: all .3s;
      }

      &:hover {
        background-color: constants.$background-color;
      }
    }

    .text {
      flex: 1;
      font-size: 2em;
      text-align: center;
      letter-spacing: 0.2em;
      transform: translateX(0.1em);
    }
  }

  .content, .bottom-fixed {
    display: flex;
    min-height: 0;
    flex-direction: column;
    flex: 1;

    .scroll {
      min-height: 0;
      flex: 1;
      width: 100%;
    }

    ul {
      > li, > div > li {
        padding: 2px 14px;

        &.item {
          position: relative;
          font-size: 1rem;

          > .menu-bt {
            border-radius: 8px;
            overflow: hidden;
            height: 40px;

            .icon-box {
              display: flex;
              justify-content: center;
              align-items: center;
              padding: 0 10px;
              width: 40px;
              height: 40px;
              font-size: constants.$SIZE_ICON_SM;
              cursor: pointer;

              img {
                width: 100%;
              }
            }

            a {
              display: flex;
              align-items: center;
              height: 100%;
              width: 100%;
              transition: all 0.2s;
              background-color: constants.$origin-color;

              .text {
                flex: 1;
                padding-left: 8px;
                width: 0;
                overflow: hidden;
                text-overflow: ellipsis;
              }

              &.active {
                color: constants.$origin-color;
                background-color: constants.$main-color;

                img {
                  filter: drop-shadow(1000px 0 0 constants.$origin-color);
                  transform: translate(-1000px);
                }
              }
            }
          }

          .submenu {
            visibility: hidden;
            position: fixed;
            padding-left: 10px;
            z-index: 10000;
            animation: 0.1s ease forwards;
            @include mixins.unique-keyframes {
              0% {
                transform: translateX(0);
                opacity: 1;
              }
              100% {
                transform: translateX(-10px);
                opacity: 0;
              }
            }

            .content {
              display: flex;
              flex-direction: column;
              gap: 2px;
              padding: 10px 10px;
              background-color: constants.$origin-color;
              border-radius: 8px;
              box-shadow: 2px 2px 10px 0 rgba(0,0,0,0.1);

              .item {
                border-radius: 8px;
                white-space: nowrap;
                overflow: hidden;
                padding: 0;

                a {
                  display: block;
                  padding: 8px 16px;
                  transition: all 0.2s;

                  .text {
                    width: unset;
                  }

                  &.active {
                    color: constants.$origin-color;
                    background-color: constants.$main-color;
                  }
                }

                &:hover a:not(.active) {
                  background-color: constants.$background-color;
                }
              }
            }
          }

          &:hover {
            > .menu-bt {
              a:not(.active) {
                background-color: constants.$background-color;
              }
            }

            .submenu {
              visibility: visible;
              animation: 0.3s ease;
              @include mixins.unique-keyframes {
                0% {
                  transform: translateX(-10px);
                  opacity: 0;
                }
                100% {
                  transform: translateX(0);
                  opacity: 1;
                }
              }
            }
          }
        }
      }

      .delete {
        .menu-bt {
          border: {
            width: 1px;
            color: constants.$error-secondary-color;
            style: dashed;
          };
          filter: drop-shadow(1000px 0 0 constants.$error-secondary-color);
          transform: translate(-1000px);

          > a {
            background-color: transparent !important;
          }
        }
      }
    }
  }

  .separate {
    height: 0;
    margin: 10px 5px;
    border: {
      width: 1px;
      color: constants.$font-secondary-color;
      style: solid;
    };
    opacity: 0.4;
  }

  .footer {
    display: flex;
    align-items: center;
    font-weight: bold;
    padding: 8px 14px;
    color: constants.$main-color;

    .icon-user {
      display: flex;
      justify-content: center;
      align-items: center;
      flex: 0 0 auto;
      margin-left: 4px;
      width: 36px;
      height: 36px;
      font-size: constants.$SIZE_ICON_XS;
      border: 2px constants.$font-secondary-color solid;
      color: constants.$font-secondary-color;
      border-radius: 50%;
      overflow: hidden;
      cursor: pointer;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .text {
      flex: 1;
      padding-left: 10px;
      font-size: 1.4em;
      color: constants.$font-main-color;
      user-select: text;
      overflow: hidden;
      text-overflow: ellipsis;

      a {
        color: constants.$main-color;
        text-decoration: underline;
      }
    }

    .icon-exit {
      font-size: constants.$SIZE_ICON_XS;
      color: constants.$error-color;
      padding: 6px 10px;
      cursor: pointer;

      &:hover {
        border-radius: 8px;
        background-color: constants.$background-color;
      }
    }
  }

  &.hide {
    width: 68px !important;

    .title {
      .icon-box {
        span {
          transform: rotateZ(360deg);
          transition: all .3s;
        }
      }

      .text {
        display: none;
      }
    }

    .menu-bt {
      .text, .extend {
        display: none;
      }
    }

    .submenu {
      .menu-bt {
        .text {
          display: block;
        }
      }
    }

    .footer {
      position: relative;

      .text {
        display: none;
      }

      .submenu-exit {
        display: none;
        position: absolute;
        padding-left: 6px;
        left: 100%;
        z-index: 1000;
        box-shadow: 5px 5px 15px 0 rgba(0, 0, 0, 0.1);

        .content {
          padding: 8px;
          border-radius: 8px;
          background-color: constants.$origin-color;

          .icon-exit {
            padding: 4px 8px;

            &:hover {
              border-radius: 8px;
              background-color: constants.$background-color;
            }
          }
        }

        &.hide {
          display: none !important;
        }
      }

      &:hover .submenu-exit {
        display: block;
        animation: 0.3s ease;
        @include mixins.unique-keyframes {
          0% {
            transform: translateX(-10px);
            opacity: 0;
          }
          100% {
            transform: translateX(0);
            opacity: 1;
          }
        }
      }
    }
  }
}
