.composer-ai-helper-modal {
  .text-preview,
  .inline-diff {
    ins {
      background-color: var(--success-low);
      text-decoration: underline;
    }
    del {
      background-color: var(--danger-low);
      text-decoration: line-through;
    }

    .preview-area {
      height: 200px;
    }
  }

  &__old-value {
    background-color: var(--danger-low);
    color: var(--danger);
    margin-bottom: 1rem;
  }

  &__new-value {
    background-color: var(--success-low);
    color: var(--success);
  }
}

.topic-above-suggested-outlet.related-topics {
  margin: 4.5em 0 1em;
}

.ai-helper-context-menu {
  background: var(--secondary);
  box-shadow: var(--shadow-card);
  padding: 0.25rem;
  max-width: 25rem;
  border: 1px solid var(--primary-low);
  list-style: none;
  z-index: 999;

  &.out-of-bounds {
    visibility: hidden;
    pointer-events: none;
  }

  ul {
    margin: 0;
    list-style: none;
  }

  li {
    .btn-flat {
      justify-content: left;
      text-align: left;
      background: none;
      width: 100%;
      border-radius: 0;
      margin: 0;
      padding-block: 0.6rem;

      &:focus,
      &:hover {
        color: var(--primary);
        background: var(--d-hover);

        .d-icon {
          color: var(--primary-medium);
        }
      }

      .d-button-label {
        color: var(--primary-very-high);
      }
    }
  }

  &__options {
    padding: 0.25rem;

    li:not(:last-child) {
      border-bottom: 1px solid var(--primary-low);
    }
  }

  &__loading {
    display: flex;
    padding: 0.5rem;
    gap: 1rem;
    justify-content: flex-start;
    align-items: center;

    .dot-falling {
      margin-inline: 1rem;
      margin-left: 1.5rem;
    }
  }

  &__resets {
    display: flex;
    align-items: center;
    flex-flow: row wrap;
  }

  &__review {
    display: flex;
    align-items: center;
    flex-flow: row wrap;
  }
}

.ai-custom-prompt {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;

  &__input[type="text"] {
    border-color: var(--primary-400);
    margin-bottom: 0;

    &::placeholder {
      color: var(--primary-medium);
    }
  }
}

.d-editor-input.loading {
  animation: loading-text 1.5s infinite linear;
}

@keyframes loading-text {
  0% {
    color: var(--primary);
  }
  50% {
    color: var(--tertiary);
  }
  100% {
    color: var(--primary);
  }
}

// AI Typing indicator (taken from: https://github.com/nzbin/three-dots)
.dot-falling {
  position: relative;
  left: -9999px;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: var(--tertiary);
  color: var(--tertiary);
  box-shadow: 9999px 0 0 0 var(--tertiary);
  animation: dot-falling 1s infinite linear;
  animation-delay: 0.1s;
}
.dot-falling::before,
.dot-falling::after {
  content: "";
  display: inline-block;
  position: absolute;
  top: 0;
}
.dot-falling::before {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: var(--tertiary);
  color: var(--tertiary);
  animation: dot-falling-before 1s infinite linear;
  animation-delay: 0s;
}
.dot-falling::after {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background-color: var(--tertiary);
  color: var(--tertiary);
  animation: dot-falling-after 1s infinite linear;
  animation-delay: 0.2s;
}

@keyframes dot-falling {
  0% {
    box-shadow: 9999px -15px 0 0 rgba(152, 128, 255, 0);
  }
  25%,
  50%,
  75% {
    box-shadow: 9999px 0 0 0 var(--tertiary);
  }
  100% {
    box-shadow: 9999px 15px 0 0 rgba(152, 128, 255, 0);
  }
}
@keyframes dot-falling-before {
  0% {
    box-shadow: 9984px -15px 0 0 rgba(152, 128, 255, 0);
  }
  25%,
  50%,
  75% {
    box-shadow: 9984px 0 0 0 var(--tertiary);
  }
  100% {
    box-shadow: 9984px 15px 0 0 rgba(152, 128, 255, 0);
  }
}
@keyframes dot-falling-after {
  0% {
    box-shadow: 10014px -15px 0 0 rgba(152, 128, 255, 0);
  }
  25%,
  50%,
  75% {
    box-shadow: 10014px 0 0 0 var(--tertiary);
  }
  100% {
    box-shadow: 10014px 15px 0 0 rgba(152, 128, 255, 0);
  }
}

// Suggest Titles Related
.suggest-titles-button {
  display: block;
  align-self: baseline;
  background: var(--secondary);
  border: 1px solid var(--primary-400);
  border-left: none;
}

.showing-ai-suggestions .title-input {
  // border on focus should be on top of suggestion button
  input:focus {
    z-index: 1;
  }
}

.suggestion-button {
  .d-icon-spinner {
    animation: spin 1s linear infinite;
  }
}

.suggest-tags-button,
.suggest-category-button {
  display: block;
  align-self: baseline;
  border: 1px solid var(--primary-400);
  border-left: none;
  background: none;
}

.ai-suggestions-menu {
  list-style: none;
  margin-left: 0;
  position: absolute;
  right: 0;
  top: 1.5rem;
  max-width: 25rem;
  width: unset;
  z-index: 999;

  &__errors {
    background: var(--danger);
    padding: 0.25rem 1em;
    color: var(--secondary);
  }
}

.category-input.showing-ai-suggestion-menu {
  position: relative;
}

// Prevent suggestion button from wrapping
#reply-control {
  .with-category .showing-ai-suggestions .category-input {
    flex-wrap: nowrap;
    .select-kit {
      max-width: calc(100% - 2.25em);
    }
  }

  .with-tags .showing-ai-suggestions .mini-tag-chooser.select-kit {
    max-width: calc(100% - 2.25em);
  }
}

.suggest-tags-button + .ai-suggestions-menu {
  top: 4.25rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(359deg);
  }
}

.ai-post-helper {
  &__options {
    display: flex;
    flex-flow: column nowrap;
    align-items: flex-start;
    gap: 0.25rem;
    justify-content: flex-start;

    > button:last-child {
      margin-bottom: 0.5rem;
    }

    .ai-custom-prompt {
      padding: 0.5rem;
      margin-bottom: 0;
    }
  }

  &__options-button {
    padding: 0.65rem 1rem;
    display: block;
    width: 100%;
    text-align: left;
  }

  &__suggestion {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;

    &__copy {
      .d-icon-check {
        color: var(--success);
      }
    }

    &__text {
      padding: 0.5rem;
    }

    &__buttons {
      display: flex;
      align-items: center;
      justify-content: stretch;
      margin-top: 0.5rem;
      gap: 0.5rem;
      .btn {
        width: 100%;
      }
    }
  }

  &__fast-edit {
    .fast-edit-container {
      padding-top: 0.5em;
    }
  }
}

.choose-topic-modal .split-new-topic-form {
  .control-group {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 0.25em;
    margin-bottom: 1rem;

    label {
      flex: 100%;
    }

    input,
    .combo-box,
    .multi-select {
      flex: 1;
      margin-bottom: 0;
    }
  }

  .ai-split-topic-suggestion-button {
    .d-icon-spinner {
      animation: spin 1s linear infinite;
    }
  }
}

.ai-split-topic-suggestion__results {
  list-style: none;
  margin-left: 0;
  margin: 0;

  .btn {
    display: block;
    width: 100%;
    text-align: left;
    background: none;

    &:hover,
    &:focus {
      background: var(--d-hover);
      color: var(--primary);
    }
  }

  li:not(:last-child) {
    border-bottom: 1px solid var(--primary-low);
  }

  .ai-split-topic-suggestion__category-result {
    font-size: var(--font-0);
    padding: 0.5em 1rem;

    &:hover,
    &:focus {
      background: var(--d-hover);
      cursor: pointer;
    }
  }
}

.fk-d-menu[data-identifier="ai-split-topic-suggestion-menu"] {
  z-index: z("modal", "dropdown");
}

.ai-split-topic-loading-placeholder {
  .d-icon-spinner {
    animation: spin 1s linear infinite;
  }

  + .ai-split-topic-suggestion-button {
    display: none;
  }
}

.thumbnail-suggestions-modal {
  .ai-thumbnail-suggestions {
    display: flex;
    flex-flow: row wrap;
    position: relative;
    gap: 0.5em;

    &__item {
      flex: 35%;
      position: relative;
    }

    img {
      width: 100%;
      height: auto;
    }

    .btn {
      position: absolute;
      top: 0.5rem;
      left: 0.5rem;
    }
  }
}
