@import '../../scss/variables/colors';
@import '../../scss/variables/inAppMessage';

.inapp-base {
  position: relative;
  display: flex;
  flex-flow: column wrap;
  justify-content: center;
  margin: 10px 0;
  border-radius: 4px;
  box-shadow: 0 20px 60px 0 rgba(0, 0, 0, 0.3);
  overflow: auto;
  background-color: #fff;
  color: $font-primary-color;
  min-height: $inapp-min-height;
  max-height: $inapp-max-height;
  min-width: $inapp-min-width;
  max-width: $inapp-max-width;

  &__overlay {
    position: fixed;
    top: 0;
    left: 0;
    display: none;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background-color: $overlay-background-color;
    z-index: 13000;

    &--visible {
      display: flex;
    }

    & div { box-sizing: border-box }
  }

  &__container {
    display: flex;
    flex-flow: column wrap;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    min-width: $inapp-min-width;
    max-width: $inapp-max-width;
    min-height: $inapp-min-height;
    max-height: $inapp-max-height;
    padding: 0 10px;
    box-sizing: border-box;
  }

  &__wrapper {
    display: flex;
    flex-flow: column nowrap;
  }

  &__with_footer {
    padding-bottom: 96px;

    .inapp__body {
      padding: 32px 32px 0;
    }
  }

  &__content-container {
    display: flex;
    flex-flow: column nowrap;
    overflow-y: auto;
    align-items: center;
  }

  &__close {
    display: flex;
    justify-content: flex-end;
    flex-grow: 2;
    align-items: center;

    button {
      width: 24px;
      height: 24px;
      padding: 0;
      border: none;
      background-color: transparent;
      box-shadow: none;
      outline: none;
      cursor: pointer;
      color: #ffffff;

      &:hover {
        opacity: 1;
      }

      svg {
        fill: currentColor;
      }
    }
  }

  @include inapp-media-text {
    justify-content: flex-start;
    max-width: calc(100vw - 10px);
    max-height: calc(100vh - #{2 * $inapp-header-max-height});
    min-width: unset;
    min-height: unset;

    &__container {
      max-width: calc(100vw - 10px);
      max-height: calc(100vh - #{2 * $inapp-header-max-height});
      min-width: unset;
      min-height: unset;
    }

    &__overlay {
      max-height: 100vh;
      min-height: unset;
    }

    &__with_footer {
      padding-bottom: 135px;
    }
  }

  @include inapp-media-mobile-horizontal {
    max-height: calc(100vh - #{2 * $inapp-header-max-height});
    min-height: unset;

    &__container {
      max-height: calc(100vh - 20px);
      min-height: unset;
    }

    &__overlay {
      max-height: 100vh;
      min-height: unset;
    }
  }
}

.inapp {
  &__header {
    width: 100%;
    color: #fff;
    box-sizing: border-box;
    margin: 0;
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    min-width: $inapp-min-width;
    max-width: $inapp-max-width;
    max-height: $inapp-header-max-height;

    &__avatar {
      width: $inapp-avatar-size;
      height: $inapp-avatar-size;
      border-radius: 100%;
      margin: 0 10px 0 0;
    }

    @include inapp-media-text {
      max-width: calc(100vw - 10px);
    }
  }

  &__heading {
    margin: 0 auto;
    padding: 0;
    font-size: 16px;
    text-align: left;
    flex-grow: 3;
  }

  &__image {
    text-align: center;

    img {
      max-width: 100%;
      max-height: $inapp-image-max-height;
    }

    @include inapp-media-text {
      display: none;
    }

    @include inapp-media-mobile-horizontal {
      display: none;
    }
  }

  &__body {
    width: 100%;
    max-width: $inapp-max-width;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    padding: 32px;
    box-sizing: border-box !important;
    color: $font-primary-color;
    text-align: center;

    & > * {
      box-sizing: border-box;
      margin: 12px 0;
      max-width: $inapp-content-max-width;

      &:first-child {
        margin: 0 0 12px 0;
      }

      &:last-child {
        margin: 12px 0 0 0;
      }
    }

    & > p {
      text-align: justify;
    }

    & > h1, & > h2, & > h3, & > h4, & > h5, & > h6 {
      max-width: $inapp-max-width;
    }
  }

  &__footer {
    width: 100%;
    max-width: $inapp-max-width;
    display: flex;
    justify-content: space-between;
    align-self: center;
    padding: 24px 32px 27px;
    box-sizing: border-box !important;
    position: absolute;
    bottom: 0;
    background: #fff;

    &__single_button {
      justify-content: center;
    }

    & button {
      &:first-of-type {
        margin: 0 5px 0 0;
      }

      &:last-of-type {
        margin: 0 0 0 5px
      }
    }

    @include inapp-media-text {
      flex-flow: column-reverse nowrap;

      & button {
        &:first-of-type{
          margin: 6px auto 0;
        }

        &:last-of-type {
          margin: 0 auto 6px;
        }
      }
    }
  }

  @include inapp-media-text {
    &__body, &__footer {
      max-width: calc(100vw - 10px);
    }
  }

  @include inapp-media-mobile-horizontal {
    &__body, &__footer {
      max-height: calc(100vh - 20px);
      min-height: unset;
    }
  }
}
