.modal {
  background: var(--bg-primary);
  min-height: 80vh;
  border-radius: 4px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(17, 20, 50, 0.2);
  transition: 0.2s all;
  & > form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem);
  }
  @media screen and (max-width: 560px) {
    &.mobileFull {
      height: 100vh;
      display: flex;
      flex-direction: column;
      & > form {
        max-height: 100vh;
      }
    }
  }

  .modal-scrollContent {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  & > *:first-child {
    border-radius: 4px 4px 0 0;
  }
  & > *:last-child {
    border-radius: 0 0 4px 4px;
  }

  width: 100%;
  max-width: 760px;
  position: relative;

  &.sm {
    max-width: 500px;
  }
  &.lg {
    max-width: 880px;
  }

  &.xl {
    max-width: 1200px;
  }
  &.xs {
    max-width: 340px;
  }
  &.full {
    max-width: none;
  }

  &.autoWidth {
    width: auto;
    min-width: 300px;
  }

  &.desktopFull {
    width: 100vw;
    height: 100vh;
    margin: 0;
    max-width: none;
  }

  h1,
  h2,
  h3,
  h4,
  h5 {
    font-weight: 500;
  }

  h3 {
    font-size: 1.125rem;
    line-height: 1.75rem;
  }
}

.modal-body,
.modal-header,
.modal-footer {
  &:not(:last-child) {
    border-bottom: var(--border-color);
  }
}

.modal-body {
  padding: 1.5rem;
  &.modal-body-secondary {
    background: var(--bg-secondary);
  }
  &.short {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}
.modal-header {
  padding: 1.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-footer {
  padding: 1.25rem 1.5rem;
  display: flex;
}

.modal-actions {
  margin-top: -1.25rem;
  margin-bottom: -1.25rem;
}

button.modal-btn-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  opacity: 0.7;
  z-index: 100;
  border: none !important;
  background: transparent;
  font-size: 1.25rem;
  border-radius: 6px;
  &:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.07);
    &:after {
      display: none;
    }
  }
  &:focus {
    background: rgba(128, 128, 128, 0.12);
  }

  & + * .modal-actions {
    margin-right: 1.5rem;
  }
}

.modal-btn-back {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  opacity: 0.3;
  z-index: 100;
  &:hover {
    opacity: 1;
  }
}

// Overlay
.overlay {
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  & > * {
    margin: auto;
  }
  padding: 1.5rem;

  @media screen and (max-width: 768px) {
    padding: 30px;
  }
  &.desktopFull {
    padding: 0;
    max-height: 100vh;
    width: 100%;
  }
  @media screen and (max-width: 560px) {
    &.mobileFull {
      padding: 0;
      max-height: 100vh;
      width: 100%;
    }
  }
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  height: 100vh;
  width: 100vw;
  z-index: 1200;
  top: 0;
  left: 0;
  background-color: rgba(0, 0, 0, 0.3);

  transition: 0.2s all;

  & > * {
    transition: 0.2s all;
    opacity: 0;
  }

  &:global(.enter) {
    opacity: 1;

    & > * {
      opacity: 0;
    }
  }
  &:global(.enter-active) {
    opacity: 1;
    & > * {
      opacity: 0;
    }
  }

  &:global(.enter-done) {
    background-color: rgba(0, 0, 0, 0.45);
    & > * {
      opacity: 1;
    }
  }

  &:global(.exit) {
    & > * {
      opacity: 0;
    }
  }
}

.hasCloseButton {
  .modal-header {
    padding-right: 4rem;
  }
}

.hasOnBackButton {
  padding-top: 4rem;
}

.scrollSpace {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.scrollCenter {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
