// Backdrop
.modal-backdrop {
  background-color: $black;
  z-index: 10000;

  &.show {
    @extend .animated-faster;
    animation-name: fadeIn60;
  }
}

// Wrappers
.modal {
  z-index: 10000 !important;
  align-items: center;

  &.show {
    display: flex !important;
  }
}

.modal-dialog {
  @extend .animated-faster;
  animation-name: fallInSoft;
  background-color: $white;
  box-shadow: 0 .3rem 0.15rem 0 $shadow-darker;
  left: 0;
  max-width: 100vw;
  position: fixed;
  width: 100vw;
  margin: 0;
  z-index: 10001;
}

.modal-aside .modal-dialog, .modal-fixed .modal-aside .modal-dialog {
  animation-name: slideInAside;
  top: 0;
  bottom: 0;
  right: 0;
  left: unset;
  max-width: 430px;
  box-shadow: 0 1px 12px 0 rgba(0, 0, 0, 0.25);

  modal-body {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    height: calc(100vh - 195px);
    padding: 1rem 0;

    .modal-body {
      padding-bottom: 3rem;
    }

    // no modal-footer
    &:last-child {
      height: calc(100vh - 150px);
      .modal-body {
        padding-bottom: 1rem;
      }
    }

    &:before, &:after {
      display: block;
      content: ' ';
      width: 100%;
      height: 30px;
      position: absolute;
      left: 0;
    }

    &:before {
      background: linear-gradient(to bottom, #FFF 0, rgba(255, 255, 255, 0) 100%);
      top: 108px;
      z-index: 2;
    }

    &:after {
      background: linear-gradient(to top, #FFF 0, rgba(255, 255, 255, 0) 100%);
      bottom: 32px;
    }
  }


  .modal-content {
    max-width: 100%;
    padding: 2rem;
  }

  .modal-title {
    color: $gray-850;
    font-family: $font-family-brand;
    font-weight: normal;
    text-transform: none;
    margin-bottom: 0.5rem;
  }

  .ico-close {
    display: block;
  }

  modal-footer {
    position: absolute;
    bottom: -40px;
    left: 0;
    width: 100%;
    background-color: #fff;

    .modal-footer {
      padding: 10px 2rem;
    }
  }
}

.modal-aside .modal-dialog.modal-lg,
.modal-fixed .modal-aside .modal-dialog.modal-lg {
  max-width: 860px;
}

.modal-aside.modal-backdrop {
  &.show {
    animation-name: fadeIn30;
  }
}

.modal-fixed .modal-dialog {
  top: 25%;
}

.modal-danger {

  .modal-footer {
    .btn-link {
      color: $gunmetal;
    }

    .btn-primary {
      @include button($red-700);
    }

    .btn-primary:active {
      background-color: $red-700;
    }
  }
}

.modal-content {
  border: none;
  max-width: 50vw;
  margin: auto;
  position: relative;
  padding: 2rem 0 1rem;
  background-color: transparent;
}


@include media-breakpoint-down(xs) {
  .modal-content {
    max-width: 85%;
  }
}

// Sections : Header
.modal-header {
  border: none;
  padding-bottom: .5rem;
  padding-top: 1.5rem;
  align-items: baseline;

  .modal-title {
    @include brand-font-h2();
    margin: 0;
  }

  .ico-close {
    // we currently only want to show this for the aside
    display: none;
    color: $gray-700;
  }
}

// Sections : Body
.modal-body {
  padding-top: .5rem;
}

// Sections : Footer
.modal-footer {
  border-top: none;
  justify-content: flex-end;
  padding-bottom: 2.5rem;

  // .btn-link {
  //   color: $blue-700;
  // }
}

@mixin flush-with-header() {
  $offset: -66px;
  @each $breakpoint in $breakpoint-keys {
    @if $breakpoint {
      .modal-body .flush-with-header-#{$breakpoint} {
        @include media-min($breakpoint) {
          margin-top: $offset;
        }
      }
    } @else {
      .modal-body .flush-with-header {
        margin-top: $offset;
      }
    }
  }
}

// large aside
.modal-aside .modal-dialog.modal-lg {
  $padding-x: 2.5rem;

  .modal-content {
    @extend .px-0;
    @extend .mx-0;
  }

  .table-container {
    margin-top: 0;
    margin-left: -1 * $padding-x;
    margin-right: -1 * $padding-x;
    box-shadow: none;

    header {
      @extend .pt-0;
      background-color: transparent;
    }
  }

  .modal-header, modal modal-body {
    padding-left: $padding-x;
    padding-right: $padding-x;
  }


  modal modal-body {
    &:before {
      display: none;
    }

    .modal-body {
      @extend .px-0;
    }
  }
}

@include flush-with-header();

.modal-backdrop.modal-stacked, .modal.modal-stacked {
  z-index: 10010 !important;
  .modal-dialog { z-index: 10011 !important;}
}
