@import "mixins/mixins";
@import "common/var";

@keyframes el-drawer-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@mixin drawer-animation($direction) {

  @keyframes #{$direction}-drawer-in {
    0% {

      @if $direction == ltr {
        transform: translate(-100%, 0px);
      }

      @if $direction == rtl {
        transform: translate(100%, 0px);
      }

      @if $direction == ttb {
        transform: translate(0px, -100%);
      }

      @if $direction == btt {
        transform: translate(0px, 100%);
      }
    }

    100% {
      @if $direction == ltr {
        transform: translate(0px, 0px);
      }

      @if $direction == rtl {
        transform: translate(0px, 0px);
      }

      @if $direction == ttb {
        transform: translate(0px, 0px);
      }

      @if $direction == btt {
        transform: translate(0px, 0px);
      }
    }
  }

  @keyframes #{$direction}-drawer-out {
    0% {
      @if $direction == ltr {
        transform: translate(0px, 0px);
      }

      @if $direction == rtl {
        transform: translate(0px, 0px);;
      }

      @if $direction == ttb {
        transform: translate(0px, 0px);
      }

      @if $direction == btt {
        transform: translate(0px, 0);
      }
    }

    100% {
      @if $direction == ltr {
        transform: translate(-100%, 0px);
      }

      @if $direction == rtl {
        transform: translate(100%, 0px);
      }

      @if $direction == ttb {
        transform: translate(0px, -100%);
      }

      @if $direction == btt {
        transform: translate(0px, 100%);
      }
    }
  }
}

@mixin animation-in($direction) {
  .el-drawer__open &.#{$direction} {
    animation: #{$direction}-drawer-in .3s 1ms;
  }
}

@mixin animation-out($direction) {
  &.#{$direction} {
    animation: #{$direction}-drawer-out .3s;
  }
}

@include drawer-animation(rtl);
@include drawer-animation(ltr);
@include drawer-animation(ttb);
@include drawer-animation(btt);

$directions: rtl, ltr, ttb, btt;

@include b(drawer) {
  position: absolute;
  box-sizing: border-box;
  background-color: $--dialog-background-color;
  display: flex;
  flex-direction: column;
  // box-shadow: 0 8px 10px -5px rgba(0, 0, 0, 0.2),
  // 0 16px 24px 2px rgba(0, 0, 0, 0.14),
  // 0 6px 30px 5px rgba(0, 0, 0, 0.12);
  box-shadow: -4px 0px 16px 0px rgba(26, 111, 255, 0.08);
  overflow: hidden;
  &:focus, * {
    outline: 0 !important;
  }
  @each $direction in $directions {
    @include animation-out($direction);
    @include animation-in($direction);
  }

  &__wrapper {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    margin: 0;
  }

  &__header {
    align-items: center;
    color: $--color-text-primary;
    font-weight: $--font-weight-primary;
    display: flex;
    padding: 0 24px;
    height: 56px;
    line-height: 56px;
    border-bottom: 1px solid $--drawer-header-border;
    font-size: $--drawer-title-font-size;
    & > span:not(.el-drawer__returnBtn){
      font-weight: 700;
    }
    & > :first-child {
      flex: 1;
    }
    @include m(return) {
      & > :nth-child(2) {
        flex: 1;
      }
    }
    // 抽屉头部选项卡隐藏底边
    .el-tabs__nav-wrap::after {
      height: 0px;
    }
    .el-tabs__item {
      font-size: $--drawer-title-font-size;
      font-weight: $--font-weight-secondary;
      color: $--color-text-primary;
    }
    .el-tabs__item.is-active {
      color: $--color-primary;
      font-weight: $--font-weight-primary;
    }
  }

  &__title {
    margin: 0;
    flex: 1;
    line-height: inherit;
    font-size: 1rem;
    color: $--color-text-primary;
    font-weight: bold;
  }

  &__close-btn {
    border: none;
    cursor: pointer;
    font-size: $--font-size-extra-large;
    color: inherit;
    background-color: transparent;
    &:hover i {
      color: $--color-primary;
    }
  }

  &__body {
    flex: 1;
    padding: 16px 24px;
    overflow: auto;
    & > * {
      box-sizing: border-box;
    }
  }

  &__footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 24px;
    align-items: center;
    border-top: 1px solid $--drawer-header-border;
  }

  &__footerBtn +  &__footerBtn{
    margin-left: 16px;
  }

  &.ltr, &.rtl {
    height: 100%;
    top: 0;
    bottom: 0;
  }

  &.ttb, &.btt {
    width: 100%;
    left: 0;
    right: 0;
  }

  &.ltr {
    left: 0;
  }

  &.rtl {
    right: 0;
  }

  &.ttb {
    top: 0;
  }

  &.btt {
    bottom: 0;
  }
  @include e(returnBtn) {
    display: inline-block;
    width: 88px;
    height: 32px;
    line-height: 32px;
    border-radius: 0px 100px 100px 0px;
    background: mix($--color-white, $--color-primary, 96%);
    margin-left: - $--dialog-padding-x;
    flex: unset !important;
    text-align: center;
    &:hover {
      color: $--color-primary;
    }
  }
}

.el-drawer__container {
  position: relative;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  height: 100%;
  width: 100%;
}

.el-drawer-fade-enter-active {
  animation: el-drawer-fade-in .3s;
}

.el-drawer-fade-leave-active {
  animation: el-drawer-fade-in .3s reverse;
}
