// Container that the modal scrolls within
.modal {
  position: fixed;
  z-index: $zindex-modal;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
  animation: fadeIn $modal-animation-duration ease;
  outline: 0;
  background-color: $modal-bg;

  -webkit-overflow-scrolling: touch;

  &.limit-height {
    overflow: hidden;

    .modal-body {
      max-height: $modal-body-max-height;
      overflow-y: auto;
    }
  }
}

// Shell div to position the modal with bottom padding
.modal-dialog {
  position: relative;
  width: auto;
  margin: $modal-dialog-margin auto;
  animation: slideInDown $modal-animation-duration ease;
  border-radius: $modal-border-radius;
}

// Actual modal
.modal-content {
  position: relative;
  border-radius: $modal-border-radius;
  outline: 0;
  background-clip: padding-box;
}

// Modal header
// Top section of the modal w/ title and dismiss
.modal-header {
  @include clearfix;
  @include set-font-size($modal-header-font-size);

  padding: $modal-header-padding;
  font-weight: $modal-header-font-weight;
  color: $modal-header-color;
  border-radius: $modal-border-radius $modal-border-radius 0 0;
  background-color: $modal-header-bg;
  border-bottom: 1px solid $modal-header-border-color;
  // 兼容旧版本的关闭按钮
  & > .close {
    margin-right: $modal-inner-padding;
  }
}

// Modal Close Icon
.dada-modal-close {
  position: absolute;
  z-index: 1;
  top: $modal-inner-padding;
  right: $modal-inner-padding;
  width: $modal-close-size;
  height: $modal-close-size;
  line-height: $modal-close-size;
  cursor: pointer;
  text-align: center;
  margin-right: ($modal-close-size - $ico-size-md) / -2;

  &:hover {
    opacity: .7;
  }

  & ~ .modal-header {
    padding-right: $modal-header-padding-right;
  }
}

.dada-modal-header-addon {
  font-size: $font-size-base;
  line-height: $modal-close-size;
  color: $body-color;
  float: right;
  font-weight: $font-weight-normal;
  padding-right: $modal-inner-padding;
}

// Modal body
// Where all modal content resides (sibling of .modal-header and .modal-footer)
.modal-body {
  @include scroll-reset();

  position: relative;
  padding: $modal-inner-padding;
  color: $modal-body-color;
  background-color: $modal-body-bg;

  &:last-child {
    border-radius: 0 0 $modal-border-radius $modal-border-radius;
  }
}

// Footer (for actions)
.modal-footer {
  @include clearfix(); // clear it in case folks use .pull-* classes on buttons

  padding: $modal-inner-padding;
  text-align: right;
  border-radius: 0 0 $modal-border-radius $modal-border-radius;
  background-color: $modal-footer-bg;

  .btn:not(:first-child) {
    margin-left: $modal-footer-btn-margin;
  }
}

// Scale up the modal

.modal-xs {
  max-width: $modal-xs;
}

.modal-sm {
  max-width: $modal-sm;
}

.modal-full {
  width: 100%;
  height: 100%;
  margin: 0;

  .modal-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    background-color: $modal-body-bg;

    .modal-body {
      flex: 1;
      overflow: auto;
    }
  }
}

@include media-breakpoint-up(sm) {
  .modal-md {
    max-width: $modal-md;
  }
}

@include media-breakpoint-up(lg) {
  .modal-lg {
    max-width: $modal-lg;
  }
}

@include media-breakpoint-up(xl) {
  .modal-xl {
    max-width: $modal-xl;
  }
}
