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

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

.@{drawer-prefix-cls} {
  .component-css-vars-drawer();

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

    &.show-bg-color {
      background-color: rgba(0, 0, 0, 0.3);
    }
  }

  .@{drawer-prefix-cls}__main {
    position: fixed;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-color: #e8ebef;
    border-style: solid;
    box-shadow: var(--ti-drawer-shadow);

    &.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;

      .@{drawer-prefix-cls}__drag-bar {
        left: -4px;
      }
    }

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

      .@{drawer-prefix-cls}__drag-bar {
        right: -4px;
      }
    }

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

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

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

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

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

      .@{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: calc(
            var(--ti-drawer-btn-position-top) - (var(--ti-drawer-btn-height) - var(--ti-drawer-close-icon-size)) / 2
          );
          right: calc(
            var(--ti-drawer-btn-position-right) - (var(--ti-drawer-btn-width) - var(--ti-drawer-close-icon-size)) / 2
          );
          cursor: pointer;
          height: var(--ti-drawer-btn-height);
          width: var(--ti-drawer-btn-width);

          &:hover {
            background-color: var(--ti-drawer-btn-background-color-hover);
            border-radius: var(--ti-drawer-btn-border-radius);
          }

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

          .@{drawer-prefix-cls}__close {
            font-size: var(--ti-drawer-close-icon-size);
          }
        }

        .@{drawer-prefix-cls}__header {
          padding: var(--ti-drawer-header-padding-top) var(--ti-drawer-header-padding-right)
            var(--ti-drawer-header-padding-bottom) var(--ti-drawer-header-padding-left);
          background: var(--ti-drawer-bg-color);
          display: flex;
          justify-content: space-between;
          align-items: center;
          border-bottom: 1px solid var(--ti-drawer-divider-border-color);

          .@{drawer-prefix-cls}__title {
            max-width: 80%;
            text-align: left;
            padding-right: 16px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: var(--ti-drawer-head-title-font-size);
            color: var(--ti-drawer-head-title-text-color);
            font-weight: var(--ti-drawer-head-title-font-weight);
          }

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

      .@{drawer-prefix-cls}__body {
        flex: auto;
        overflow: auto;
      }

      .@{drawer-prefix-cls}__footer {
        flex: none;
        display: flex;
        justify-content: var(--ti-drawer-footer-justify-content);
        padding: var(--ti-drawer-footer-padding-top) var(--ti-drawer-footer-padding-right)
          var(--ti-drawer-footer-padding-bottom) var(--ti-drawer-footer-padding-left);
        border-top: 1px solid var(--ti-drawer-divider-border-color);
        
      }
    }
  }
}

.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;
  }
}
