@import '~styles/items/modal';
@import '~styles/mixins';

$top-success-error: 50px;

.Modal {
  @include absolute-fill;
  position: fixed;
  white-space: nowrap;

  //display: flex;
  //justify-content: center;
  //align-items: center;
  z-index: 11;
  text-align: center;
  // Avoid the modal to be next to the top
  padding: 40px 0;
  overflow: auto;
  // Prevent propagation of scroll with no javascript!
  overscroll-behavior: contain;
  display: none;

  &.above-all {
    z-index: 12;
  }

  &.common-padding {
    padding: 40px;
  }

  &:before {
    height: 100%;
    content: '';
    @include middle;
  }

  //ANIMATION PART
  @include customAppearTransition('modal') {
    @include modalTransition;
  }

  //Rest
  .background {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: $background_opacity;
    opacity: 0;
    transition: 800ms all;
    pointer-events: none;

    &.green {
      background-color: rgba(2, 68, 66, 0.96);
      overflow: auto;
      max-height: 100%;
    }
  }

  .wrapper,
  .preview {
    transition: 400ms transform, 400ms opacity;
    transform: translateY(100px);
    position: relative;
    @include middle;
    opacity: 0;
  }

  .wrapper {
    width: 90%;
    color: $color-modal-font;
    white-space: initial;
    &:not(.no-style) {
      border-radius: $border_radius;
      background-color: $color-modal-background;
      box-shadow: 0 3px 8px 0 rgba(0, 0, 48, 0.18);
      max-width: 450px;
    }

    &.border {
      border: 1px solid $color_border;
    }

    &.large {
      max-width: 1100px;

      .close {
        font-size: 30px;
      }
    }

    &.medium {
      max-width: 700px;

      .close {
        font-size: 25px;
      }
    }

    .close {
      position: absolute;
      top: 12px;
      left: 12px;
      padding: 5px;
      font-size: 20px;
      line-height: 1;

      z-index: 9;
      cursor: pointer;

      &.light {
        color: #fff;

        &:hover {
          color: #ff9a9a;
        }
      }

      &.dark {
        color: $color-black;
      }

      &.right {
        right: 12px;
        left: auto;
      }
    }
  }

  .preview {
    @include middle;
    transition: 400ms transform, 400ms opacity;
    transform: translateY(100px);
    max-width: 80%;
    max-height: 75vh;
  }

  .title {
    font-size: 24px;
    font-weight: 900;
    color: #343944;
    margin-bottom: 5px;
  }

  .messages,
  .message {
    font-size: 14px;
    color: #8c96a3;
  }

  .messages > * {
    padding-top: 5px;
  }

  .actions {
    margin-top: 20px;
    text-align: center;

    > * {
      min-width: 40%;

      &:first-child {
        margin-right: 4%;
      }

      display: inline-block;

      &.alone {
        margin: 0;
      }
    }

    button {
      margin-top: 0;
    }
  }

  &.success,
  &.error {
    z-index: 13;
    padding: 0;

    .background {
      opacity: 0 !important;
    }

    .wrapper {
      padding: 25px;
      vertical-align: top;
      margin: 0;
      margin-top: $top-success-error - 30px;
      text-align: left;
      transform: translateY(0);
      transition: 400ms margin-top, 400ms opacity;
      box-shadow: 0 3px 8px 0 rgba(0, 0, 48, 0.18) !important;

      &.center {
        top: 50%;
        transform: translateY(-50%);
        margin-top: 0;
      }

      &.big {
        max-width: 60%;
        padding: 50px;
      }
    }
  }

  &.success {
    .wrapper {
      border-top: 5px solid $color-green;
    }
  }

  &.error {
    .wrapper {
      border-top: 5px solid $color-red;
    }
  }

  &.confirm,
  &.ok,
  &.prompt {
    .wrapper {
      padding: 20px;
    }

    .messages,
    .message {
      margin-top: 10px;
    }
  }

  @include modalProject;
}

.fit-content {
  max-width: fit-content !important;
  width: fit-content !important;
}
