/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

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

@dialog-box-prefix-cls: ~'@{css-prefix}dialog-box';

.@{dialog-box-prefix-cls} {
  position: absolute;
  background: var(--tv-DialogBox-bg-color);
  border: 1px solid transparent;
  border-radius: var(--tv-DialogBox-border-radius);
  box-shadow: var(--tv-DialogBox-shadow);
  overflow: hidden;

  &__wrapper {
    .inject-DialogBox-vars();

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: auto;
    margin: 0;
    display: block;
    align-items: normal;
  }

  &.is-fullscreen {
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  &.is-center {
    .@{dialog-box-prefix-cls}__header,
    .@{dialog-box-prefix-cls}__footer {
      text-align: center;
    }
  }

  &.is-fullscreen &__body {
    flex: 1;
    overflow: scroll;
    max-height: 100vh;
  }

  & &__header {
    padding: var(--tv-DialogBox-padding) var(--tv-DialogBox-padding) 24px;
    background: var(--tv-DialogBox-bg-color);
    font-weight: var(--tv-DialogBox-head-title-font-weight);
    display: flex;
    position: relative;
    justify-content: space-between;
    align-items: center;
    font-size: var(--tv-DialogBox-head-title-font-size);
    color: var(--tv-DialogBox-head-title-text-color);

    .@{dialog-box-prefix-cls}__title {
      flex: 1;
    }
    .@{dialog-box-prefix-cls}__btn-tools {
      display: flex;
      justify-content: space-between;
    }
    .@{dialog-box-prefix-cls}__headerbtn {
      position: relative;
      border: none;
      background: none;
      padding: 0;
      line-height: 1;
      top: -12px;
      right: -12px;
      cursor: pointer;

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

      &:focus {
        outline: none; //解决chrome下,focus状态下蓝边问题
      }

      .@{dialog-box-prefix-cls}__close {
        fill: var(--tv-DialogBox-close-icon-color);
        font-size: var(--tv-DialogBox-close-icon-size);

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

      .@{dialog-box-prefix-cls}__resize {
        fill: var(--tv-DialogBox-resize-icon-color);
        font-size: var(--tv-DialogBox-resize-icon-size);

        &:hover {
          fill: var(--tv-DialogBox-resize-icon-color-hover);
        }
      }
    }
  }

  & &__body {
    text-align: left;
    padding: var(--tv-DialogBox-vertical-padding) var(--tv-DialogBox-padding);
    color: var(--tv-DialogBox-body-text-color);
    font-size: var(--tv-DialogBox-body-font-size);
    overflow: auto;
    max-height: 65vh;

    .@{css-prefix}upload {
      overflow: hidden;
    }

    > span {
      max-height: 120px;
      overflow-y: auto;
    }

    .@{css-prefix}dept__search {
      line-height: 30px;
    }
  }

  & &__footer {
    padding: 24px var(--tv-DialogBox-padding) var(--tv-DialogBox-padding);
    text-align: right;
    box-sizing: border-box;

    .@{css-prefix}button {
      min-width: var(--tv-DialogBox-footer-btn-min-width);
    }

    .@{css-prefix}toolbar {
      .@{css-prefix}button {
        margin: 0 4px;
      }
    }
  }

  // 抽屉
  &.is-right-slide {
    border-radius: 0;
    min-width: var(--tv-DialogBox-drawer-min-width);
    max-width: var(--tv-DialogBox-drawer-max-width);

    display: flex;
    flex-direction: column;

    .@{dialog-box-prefix-cls}__header,
    .@{dialog-box-prefix-cls}__footer {
      width: calc(100% - 64px);
      margin-left: var(--tv-DialogBox-padding);
      margin-right: var(--tv-DialogBox-padding);
    }

    .@{dialog-box-prefix-cls}__header {
      padding: var(--tv-DialogBox-padding) 0 24px;
      border-bottom: 1px solid var(--tv-DialogBox-head-divider-border-color);

      &btn {
        right: -16px;
      }
    }

    .@{dialog-box-prefix-cls}__body {
      flex: 1;
      overflow: auto;
      color: var(--tv-DialogBox-drawer-body-color);
      border-bottom: 1px solid var(--tv-DialogBox-drawer-divider-border-color);
      padding: var(--tv-DialogBox-vertical-padding) var(--tv-DialogBox-padding);
      max-height: 100vh;
    }

    .@{dialog-box-prefix-cls}__footer {
      padding: 24px 0 var(--tv-DialogBox-padding);
      text-align: right;
    }
  }
}

.dialog-box__scroll-lock {
  overflow: hidden;
}

.v-modal {
  .inject-DialogBox-vars();
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--tv-DialogBox-mask-bg-color);
}

.v-modal-enter {
  animation: v-modal-in 0.2s ease;
}

.v-modal-leave {
  animation: v-modal-out 0.2s ease forwards;
}

@keyframes v-modal-in {
  0% {
    opacity: 0;
  }
}

@keyframes v-modal-out {
  100% {
    opacity: 0;
  }
}

.dialog-slideRight-enter-active {
  animation: slideRight 0.5s ease-in forwards;
}

.dialog-slideRight-leave-active {
  animation: slideRightout 0.5s ease-in forwards;
}

@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%);
  }
}

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

.dialog-fade-leave-active {
  .@{dialog-box-prefix-cls} {
    animation: dialog-fade-out 3s;
  }
  animation: dialog-fade-out 0.3s;
}

@keyframes dialog-fade-in {
  0% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }

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

@keyframes dialog-fade-out {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }

  100% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
}

.enlarge-enter-active {
  animation: enlarge-in 350ms linear;
}

@keyframes enlarge-in {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(0.5);
  }

  100% {
    transform: scale(1);
  }
}

@media (max-width: 480px) {
  .@{dialog-box-prefix-cls} {
    width: 100% !important;
    top: 0 !important;
    left: 0 !important;
  }
}
