@import './../../theme/vars.scss';

$prefixCls: amos-modal;
$modal-overlayer-background: rgba(#42515a, 0.5);
$modal-zindex: 1000;

.modal-draggable {
  display: none;
}

.#{$prefixCls} {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: $modal-zindex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: 0;

  &-overlayer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: $modal-zindex;
    height: 100%;
    background-color: $modal-overlayer-background;

    &-closed {
      display: none;
    }
  }

  &.#{$prefixCls}-open {
    display: block;
    opacity: 1;
    visibility: visible;

    .modal-draggable {
      display: block;
    }
  }

  &.#{$prefixCls}-closed {
    display: none;
    opacity: 0;
    visibility: hidden;
  }

  &.#{$prefixCls}-fullscreen {
    .#{$prefixCls}-container {
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }

    .#{$prefixCls}-footer {
      position: absolute;
      bottom: 0;
      width: 100%;
    }
  }

  &-locked {
    animation: amosModalShake 0.6s;
  }

  &-container {
    position: absolute;
    top: 15%;
    // left: 50%;
    // transform: translate(-50%, -50%);
    width: 560px;
    overflow: hidden;
    background: white;
    border: 0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-clip: padding-box;
  }

  &-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
    padding: 0;
    font-weight: bold;
    line-height: 1;
    color: rgba(0, 0, 0, 0.45);
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    border: 0;
    outline: 0;
    transition: color 0.3s;

    &-x {
      display: block;
      width: 46px;
      height: 46px;
      font-size: 18px;
      font-style: normal;
      line-height: 40px;
      text-align: center;
      text-rendering: auto;
      text-transform: none;

      &::after {
        content: 'x';
      }
    }

    &:hover {
      color: #444;
      text-decoration: none;
    }
  }

  &-header {
    padding: $modal-title-padding;
    color: rgba(0, 0, 0, 0.65);
    background: white;
    border-bottom: 1px solid $modal-header-border-color;
    border-radius: 4px 4px 0 0;

    .#{$prefixCls}-title {
      margin: 0;
      font-size: 16px;
      font-weight: 500;
      line-height: 22px;
      color: rgba(0, 0, 0, 0.85);
    }
  }

  &-content {
    max-height: $modal-maxheight;
    padding: $modal-padding;
    overflow: auto;
    font-size: 14px;
    line-height: 1.5;
  }

  &-footer {
    padding: $modal-inner-padding;
    text-align: right;
    border-top: 1px solid $modal-footer-border-color;
    border-radius: 0 0 4px 4px;

    .amos-btn {
      & + & {
        margin-bottom: 0;
        margin-left: 5px;
      }
    }

    .amos-button-group {
      .amos-btn {
        & + & {
          margin-left: -1px;
        }
      }
    }

    .amos-btn-block {
      & + & {
        margin-left: 0;
      }
    }
  }

  // animation
  &-slide-fade-enter,
  &-slide-fade-appear {
    transform: translate(0, -25%);
  }

  &-slide-fade-enter,
  &-slide-fade-appear,
  &-slide-fade-leave {
    animation-duration: $animation-duration-slow;
    animation-play-state: paused;
    animation-timing-function: ease-out;
    animation-fill-mode: both;
  }

  &-slide-fade-enter.#{$prefixCls}-slide-fade-enter-active,
  &-slide-fade-appear.#{$prefixCls}-slide-fade-appear-active {
    animation-name: amosDialogFadeIn;
    animation-play-state: running;
  }

  &-slide-fade-leave.#{$prefixCls}-slide-fade-leave-active {
    animation-name: amosDialogFadeOut;
    animation-play-state: running;
  }

  &.zoom-enter,
  &.zoom-appear {
    opacity: 0;
    transform: none; // reset scale avoid mousePosition bug
    animation-duration: $animation-duration-slow;
  }

  &.zoom-leave {
    animation-duration: $animation-duration-slow;
    animation-play-state: paused;
    animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);
    animation-fill-mode: both;

    &.zoom-leave-active {
      animation-name: amosDialogZoomOut;
      animation-play-state: running;
    }
  }
}

.#{$prefixCls}-global-opened {
  overflow-y: hidden;
}

@keyframes amosDialogFadeIn {
  0% {
    transform: translate(0, -25%);
  }

  100% {
    transform: translate(0, 0);
  }
}

@keyframes amosDialogFadeOut {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(0, -25%);
  }
}
// Scale up the amos-dialog
@media (min-width: $screen-md) {
  .#{$prefixCls} {
    width: auto;
    // margin: 10px;

    &-container {
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }
  }
}

@keyframes amosDialogZoomIn {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes amosDialogZoomOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(0.5);
  }
}

@keyframes amosModalShake {
  10%,
  90% {
    transform: translate(-1px, 0);
  }

  20%,
  80% {
    transform: translate(2px, 0);
  }

  30%,
  50%,
  70% {
    transform: translate(-3px, 0);
  }

  40%,
  60% {
    transform: translate(3px, 0);
  }
}
