@import '../../../../styles/mixins/index';

.nut-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: $dialog-width;
  min-width: $dialog-min-width;
  /* #ifndef harmony dynamic*/
  max-height: 67%;
  /* #endif */
  min-height: $dialog-min-height;
  padding: $dialog-padding;
  box-sizing: border-box;

  &-outer {
    position: fixed;
    max-height: 100%;
    background-color: $dialog-background;
    /* #ifndef dynamic*/
    transition:
      transform 0.2s,
      -webkit-transform 0.2s;
    /* #endif */
    -webkit-overflow-scrolling: touch;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    border-radius: $dialog-border-radius;
    animation-duration: 0.3s;
  }

  &-close {
    position: absolute !important;
    z-index: 1;
    cursor: pointer;
    width: $dialog-close-width;
    height: $dialog-close-height;
    display: flex;
    justify-content: center;
    align-items: center;
    color: $dialog-close-color;
    .nut-icon {
      font-size: $dialog-close-width;
      width: $dialog-close-width;
      height: $dialog-close-height;
    }

    &-top-right {
      top: $dialog-close-top;
      right: $dialog-close-right;
    }

    &-top-left {
      top: $dialog-close-top;
      left: $dialog-close-left;
    }

    &-bottom {
      bottom: scale-px(-64px);
      width: $dialog-bottom-close-icon-size;
      height: $dialog-bottom-close-icon-size;
      left: 50%;
      transform: translateX(-50%);
      .nut-icon {
        color: $color-text-disabled;
        background-color: $color-mask-part;
        border-radius: 50%;
        width: $dialog-bottom-close-icon-size;
        height: $dialog-bottom-close-icon-size;
      }
    }

    &:active {
      opacity: 0.7;
    }
  }

  &-header {
    display: block;
    text-align: center;
    font-size: $dialog-header-font-size;
    font-weight: $dialog-header-font-weight;
    color: $color-title;
    margin-bottom: $dialog-title-margin-bottom;
    @include oneline-ellipsis();
  }

  &-content {
    width: 100%;
    margin: $dialog-content-margin;
    max-height: $dialog-content-max-height;
    line-height: $dialog-content-line-height;
    font-size: $font-size-base;
    color: $color-title;
    word-wrap: break-word;
    word-break: break-all;
    white-space: pre-wrap;
    text-align: $dialog-content-text-align;
    overflow-y: auto;
  }

  &-footer {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-around;

    &.vertical {
      flex-direction: column;

      .nut-button {
        min-width: 100%;
      }

      .nut-dialog-footer-cancel {
        margin: 0;
        color: $color-text;
        font-size: $font-size-base;
        display: flex;
        justify-content: center;
        margin-top: $dialog-vertical-footer-ok-margin-top;
        background: transparent;
      }
    }

    .nut-button {
      min-width: $dialog-footer-button-min-width;
      border-radius: $dialog-footer-button-border;
      padding: var(--nutui-button-large-padding, 0 scale-px(12px));
    }

    &-cancel.nut-dialog-footer-cancel {
      margin-right: $dialog-footer-cancel-margin-right;
      background: $dialog-footer-cancel-bg;
      color: $button-default-color;
      border-color: var(--nutui-button-default-border-color, transparent);
      .nut-button-children {
        color: $button-default-color;
      }
    }

    &-ok-container {
      position: relative;
      display: flex;
      align-items: center;
      width: 100%;
      justify-content: space-around;

      .nut-dialog-footer-ok-badge {
        position: absolute;
        right: 0;
        top: $dialog-footer-badge-top;
        display: flex;
        align-items: center;
        height: $dialog-footer-badge-height;
        padding: $dialog-footer-badge-padding;
        background: $dialog-footer-badge-bg-ok;
        border-radius: $dialog-footer-badge-border-radius;
        font-size: $dialog-footer-badge-fontsize;
        color: $dialog-footer-badge-color-ok;
      }
    }

    &-ok {
      max-width: $dialog-footer-ok-max-width;
      font-weight: $font-weight-medium;
      .nut-button-children {
        font-weight: $font-weight-medium;
      }
    }

    &-block {
      &.nut-button {
        min-width: 100%;
      }
    }

    &-cancel-container {
      position: relative;
      display: flex;
      align-items: center;
      width: 100%;
      justify-content: space-around;

      .nut-dialog-footer-cancel-badge {
        position: absolute;
        right: $dialog-footer-cancel-margin-right;
        top: $dialog-footer-badge-top;
        display: flex;
        align-items: center;
        height: $dialog-footer-badge-height;
        padding: $dialog-footer-badge-padding;
        background: $dialog-footer-badge-bg-cancel;
        border-radius: $dialog-footer-badge-border-radius;
        font-size: $dialog-footer-badge-fontsize;
        color: $dialog-footer-badge-color-cancel;
      }
    }
  }
}

[dir='rtl'] .nut-dialog,
.nut-rtl .nut-dialog {
  &-outer {
    left: auto;
    right: 50%;
    -webkit-transform: translate(50%, -50%);
    transform: translate(50%, -50%);
  }

  &-close {
    &-top-right {
      right: auto;
      left: $dialog-close-right;
    }

    &-top-left {
      left: auto;
      right: $dialog-close-left;
    }
  }

  &-footer {
    &-cancel.nut-dialog-footer-cancel {
      margin-right: 0;
      margin-left: $dialog-footer-cancel-margin-right;
    }
  }

  &-content {
    text-align: var(--nutui-dialog-content-text-align, right);
  }
}
