@import '../custom.less';
@import './vars.less';

@drawer-prefix-cls: ~'@{css-prefix}drawer';

.@{drawer-prefix-cls} {
  .inject-Drawer-vars();

  .@{drawer-prefix-cls}__mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;

    &.show-bg-color {
      background-color: var(--tv-Drawer-mask-bg-color);
    }
  }

  .@{drawer-prefix-cls}__main {
    position: fixed;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--tv-Drawer-bg-color);
    box-shadow: var(--tv-Drawer-shadow);
    overflow: hidden;

    &.drag-effects {
      transition-timing-function: linear;
      transition-duration: 200ms;
      transition-property: all;
    }

    &.is-left,
    &.is-right {
      height: 100%;
    }

    &.is-top,
    &.is-bottom {
      max-height: 100%;
    }

    &.is-right {
      top: 0;
      right: 0;
      border-left-width: 0.5px;
      border-radius: 0;
    }

    &.is-left {
      top: 0;
      left: 0;
      border-right-width: 0.5px;
      border-radius: 0 var(--tv-Drawer-border-radius-size) var(--tv-Drawer-border-radius-size) 0;
    }

    &.is-top {
      top: 0;
      left: 0;
      border-bottom-width: 0.5px;
      border-radius: 0 0 var(--tv-Drawer-border-radius-size) var(--tv-Drawer-border-radius-size);
    }

    &.is-bottom {
      bottom: 0;
      left: 0;
      border-top-width: 0.5px;
      border-radius: var(--tv-Drawer-border-radius-size) var(--tv-Drawer-border-radius-size) 0 0;
    }

    .@{drawer-prefix-cls}__drag-bar {
      position: absolute;
      top: 0;
      width: 0.5rem;
      height: 100%;

      &.p-top-Bottom {
        width: 100%;
        height: 8px;
        left: 0;
        cursor: n-resize;
      }

      &.p-left-Right {
        height: 100%;
        top: 0;
        width: 8px;
        cursor: e-resize;
      }

      &.p-left {
        right: -4px;
      }

      &.p-right {
        left: -4px;
      }

      &.p-top {
        bottom: -4px;
      }

      &.p-bottom {
        top: -4px;
      }
    }

    .@{drawer-prefix-cls}__box {
      flex: auto;
      flex-direction: column;
      max-height: 100%;
      overflow: hidden;
      display: flex;

      .@{drawer-prefix-cls}__header,
      .@{drawer-prefix-cls}__footer {
        margin-left: var(--tv-Drawer-padding);
        margin-right: var(--tv-Drawer-padding);
      }

      .@{drawer-prefix-cls}__header-wrapper {
        flex: none;

        .@{drawer-prefix-cls}__headerbtn {
          border: none;
          outline: none;
          background: none;
          padding: 0;
          line-height: 1;
          position: absolute;
          top: 20px;
          right: 20px;
          cursor: pointer;
          height: 24px;
          width: 24px;

          & + .@{drawer-prefix-cls}__headerbtn {
            margin-left: 8px;
          }

          .@{drawer-prefix-cls}__close {
            font-size: 24px;
            fill: var(--tv-Drawer-close-icon-color);

            &:hover {
              fill: var(--tv-Drawer-close-icon-color-hover);
            }
          }
        }

        .@{drawer-prefix-cls}__header {
          padding: var(--tv-Drawer-padding) 0 24px;
          background: var(--tv-Drawer-bg-color);
          display: flex;
          justify-content: space-between;
          align-items: center;

          .@{drawer-prefix-cls}__title {
            text-align: left;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: var(--tv-Drawer-head-title-font-size);
            color: var(--tv-Drawer-head-title-text-color);
            font-weight: var(--tv-Drawer-head-title-font-weight);
          }

          .@{drawer-prefix-cls}__header-left {
            max-width: 80%;
            display: flex;
            align-items: center;
            padding-right: 16px;

            .@{drawer-prefix-cls}__help-icon {
              width: var(--tv-Drawer-help-icon-width-height);
              height: var(--tv-Drawer-help-icon-width-height);
              margin-left: 8px;
              fill: var(--tv-Drawer-help-icon-color);
            }
          }

          .@{drawer-prefix-cls}__header-right {
            justify-content: flex-end;
            align-items: center;
            flex: 1;
            display: flex;
          }
        }
      }

      .@{drawer-prefix-cls}__body {
        flex: auto;
        overflow: auto;
        padding: 0 var(--tv-Drawer-padding);
        border-bottom: 1px solid var(--tv-Drawer-divider-body-border-color);
      }

      .@{drawer-prefix-cls}__footer {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 24px 0 var(--tv-Drawer-padding);
      }
    }
  }
}

.drawer-slide-right-enter-active {
  animation: slideRight 0.3s linear;
}

.drawer-slide-right-leave-active {
  animation: slideRightout 0.3s linear;
}

@keyframes slideRight {
  0% {
    opacity: 0;
    transform: translateX(100%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(50%);
  }

  100% {
    opacity: 1;
    transform: translateX(0%);
  }
}

@keyframes slideRightout {
  0% {
    opacity: 1;
    transform: translateX(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(50%);
  }

  100% {
    opacity: 0;
    transform: translateX(100%);
  }
}

.drawer-slide-left-enter-active {
  animation: slideLeft 0.3s linear;
}

.drawer-slide-left-leave-active {
  animation: slideLeftout 0.3s linear;
}

@keyframes slideLeft {
  0% {
    opacity: 0;
    transform: translateX(-100%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(-50%);
  }

  100% {
    opacity: 1;
    transform: translateX(0%);
  }
}

@keyframes slideLeftout {
  0% {
    opacity: 1;
    transform: translateX(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateX(-50%);
  }

  100% {
    opacity: 0;
    transform: translateX(-100%);
  }
}

.drawer-slide-bottom-enter-active {
  animation: slideBottom 0.3s linear;
}

.drawer-slide-bottom-leave-active {
  animation: slideBottomout 0.3s linear;
}

@keyframes slideBottom {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(50%);
  }

  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

@keyframes slideBottomout {
  0% {
    opacity: 0;
    transform: translateY(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(50%);
  }

  100% {
    opacity: 1;
    transform: translateY(100%);
  }
}

.drawer-slide-top-enter-active {
  animation: slideTop 0.3s linear;
}

.drawer-slide-top-leave-active {
  animation: slideTopout 0.3s linear;
}

@keyframes slideTop {
  0% {
    opacity: 0;
    transform: translateY(-100%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(-50%);
  }

  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

@keyframes slideTopout {
  0% {
    opacity: 0;
    transform: translateY(0%);
  }

  50% {
    opacity: 0.6;
    transform: translateY(-50%);
  }

  100% {
    opacity: 1;
    transform: translateY(-100%);
  }
}

.drawer-fade-enter-active {
  animation: drawer-fade-in 0.3s linear;
}

.drawer-fade-leave-active {
  animation: drawer-fade-out 0.3s linear;
}

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

  100% {
    opacity: 1;
  }
}

@keyframes drawer-fade-out {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}
