/**
* 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';
@import '../mixins/button.less';

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

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

  &__wrapper {
    .component-css-vars-dialog-box();

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

  &.is-fullscreen {
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;

    .@{dialog-box-prefix-cls}__footer {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100vw;
    }
  }

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

  &.is-fullscreen &__body {
    max-height: calc(100vh - 94px);
  }

  & &__header {
    padding: var(--ti-dialog-box-head-padding-top) var(--ti-dialog-box-head-padding-horizontal)
      var(--ti-dialog-box-head-padding-bottom);
    background: var(--ti-dialog-box-bg-color);
    font-weight: var(--ti-dialog-box-head-title-font-weight);
    display: flex;
    position: relative;
    justify-content: space-between;
    align-items: center;
    font-size: var(--ti-dialog-box-head-title-font-size);
    color: var(--ti-dialog-box-head-title-text-color);
    font-weight: var(--ti-dialog-box-head-title-font-weight);
    border-bottom: 1px solid var(--ti-dialog-box-head-border-bottom-color);

    .@{dialog-box-prefix-cls}__title {
      flex: 1;
    }

    .@{dialog-box-prefix-cls}__headerbtn {
      border: none;
      background: none;
      padding: 0;
      line-height: 1;
      position: absolute;
      top: calc(
        var(--ti-dialog-box-btn-position-top) - (var(--ti-dialog-box-btn-height) - var(--ti-dialog-box-close-icon-size)) /
          2
      );
      right: calc(
        var(--ti-dialog-box-btn-position-right) -
          (var(--ti-dialog-box-btn-width) - var(--ti-dialog-box-close-icon-size)) / 2
      );
      cursor: pointer;
      height: var(--ti-dialog-box-btn-height);
      width: var(--ti-dialog-box-btn-width);

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

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

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

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

        &:hover {
          fill: var(--ti-dialog-box-close-icon-color-hover);
        }
      }
    }
  }

  & &__body {
    text-align: left;
    padding: var(--ti-dialog-box-body-padding-vertical) var(--ti-dialog-box-body-padding-horizontal);
    margin-bottom: var(--ti-dialog-box-body-margin-bottom);
    color: var(--ti-dialog-box-body-text-color);
    font-size: var(--ti-dialog-box-body-font-size);

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

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

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

  & &__footer {
    padding: var(--ti-dialog-box-footer-padding-top) var(--ti-dialog-box-footer-padding-horizontal)
      var(--ti-dialog-box-footer-margin-bottom);
    text-align: center;
    box-sizing: border-box;

    .@{css-prefix}button {
      min-width: var(--ti-dialog-box-footer-btn-min-width);
    }

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

  // 抽屉
  &.is-right-slide {
    border-radius: var(--ti-dialog-box-drawer-radius);
    min-width: var(--ti-dialog-box-drawer-min-width);
    max-width: var(--ti-dialog-box-drawer-max-width);

    display: flex;
    flex-direction: column;

    .@{dialog-box-prefix-cls}__header,
    .@{dialog-box-prefix-cls}__body,
    .@{dialog-box-prefix-cls}__footer {
      width: calc(100% - var(--ti-dialog-box-drawer-padding-left) - var(--ti-dialog-box-drawer-padding-right));
      margin-left: var(--ti-dialog-box-drawer-padding-left);
      margin-right: var(--ti-dialog-box-drawer-padding-right);
    }

    .@{dialog-box-prefix-cls}__header {
      padding: var(--ti-dialog-box-drawer-header-padding-top) var(--ti-dialog-box-drawer-header-padding-right)
        var(--ti-dialog-box-drawer-header-padding-bottom) var(--ti-dialog-box-drawer-header-padding-left);
      border-bottom: 1px solid var(--ti-dialog-box-drawer-divider-border-color);

      &btn {
        right: calc(
          var(--ti-dialog-box-btn-position-right) - var(--ti-dialog-box-drawer-padding-right) -
            (var(--ti-dialog-box-btn-width) - var(--ti-dialog-box-close-icon-size)) / 2
        );
      }
    }

    .@{dialog-box-prefix-cls}__body {
      flex: 1;
      overflow: auto;
      padding: var(--ti-dialog-box-drawer-body-padding-top) var(--ti-dialog-box-drawer-body-padding-right)
        var(--ti-dialog-box-drawer-body-padding-bottom) var(--ti-dialog-box-drawer-body-padding-left);
    }

    .@{dialog-box-prefix-cls}__footer {
      padding: var(--ti-dialog-box-drawer-footer-padding-top) var(--ti-dialog-box-drawer-footer-padding-right)
        var(--ti-dialog-box-drawer-footer-padding-bottom) var(--ti-dialog-box-drawer-footer-padding-left);
      border-top: 1px solid var(--ti-dialog-box-drawer-divider-border-color);
      text-align: var(--ti-dialog-box-drawer-footer-text-align);
    }
  }
}

.popup-parent--hidden {
  overflow: hidden;
}

body:not(.popup-parent--hidden) {
  .v-modal {
    pointer-events: none;
  }

  .@{dialog-box-prefix-cls}__wrapper {
    pointer-events: none;

    .@{dialog-box-prefix-cls} {
      pointer-events: auto;
    }
  }
}

.v-modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
  background: #000;
}

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

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