.ai-tools-library-wrapper {
  display: flex;
  margin-block-start: 0;
  margin-inline: calc(var(--gin-spacing-xxs) * -1);
}

[dir="rtl"] .ai-tools-library-wrapper {
  margin-right: -1em;
  margin-left: -1.5em;
}

.ai-tools-library-item label {
  display: inline-block;
}

/**
 * Style the ai tools library grid items.
 */

.ai-tools-library-item {
  position: relative;
}

/**
 * Ajax throbbers inside a ai tools library item.
 */

.ai-tools-library-item .ajax-progress.ajax-progress.ajax-progress {
  position: absolute;
  z-index: calc(var(--vertical-tabs-menu--z-index) + 1);
  top: 50%;
  left: 50%;
  box-sizing: border-box;
  width: 3rem; /* 56px */
  height: 3rem;
  margin: -1.5rem;
  border: var(--input-border-size) solid var(--jui-dropdown-border-color);
  border-radius: 3.5rem;
  background: var(--color-white);
  box-shadow: 0 0.25rem 0.625rem var(--jui-dropdown-shadow-color);
}

.ai-tools-library-item .ajax-progress__throbber {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.875rem;
  border: 3px solid var(--color-absolutezero);
  border-right: 3px dotted transparent;
}

.ai-tools-library-item .ajax-progress__message {
  display: none;
}

.ai-tools-library-item--grid {
  justify-content: center;
  box-sizing: border-box;
  width: 50%;
  padding: 10px 25px;
  vertical-align: top;
  outline: none;
  background: #fff;
}

.ai-tools-library-item--grid::before {
  position: absolute;
  top: 0.4375rem;
  left: 0.4375rem;
  width: calc(100% - 1rem);
  height: calc(100% - 1rem);
  content: "";
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
  pointer-events: none;
  border: 1px solid #dbdbdb;
  border-radius: 10px;
  box-shadow: var(--details-box-shadow);
}

/**
* The ai tools library grid item focus border is moved to a child element to
* improve padding.
*/

.ai-tools-library-item--grid:focus {
  outline: none;
  box-shadow: none;
}

.ai-tools-library-item--grid:focus .ai-tools-library-item__preview-wrapper {
  outline: var(--focus-outline);
  box-shadow: var(--focus-box-shadow);
}

/* Ai Tools library widget weight field styles. */

.ai-tools-library-item--grid .form-item {
  margin: 0.75em;
}

@media screen and (min-width: 45em) {
  .ai-tools-library-item--grid {
    width: 33.3%;
  }

  /* Change the width for the modal and widget since there is less space. */
  .ai-tools-library-selection .ai-tools-library-item--grid {
    width: 50%;
  }

  /* The selected items in the add form should be shown a bit smaller. */
  .ai-tools-library-wrapper .ai-tools-library-item--small {
    width: 25%;
  }
}

@media screen and (min-width: 60em) {
  .ai-tools-library-item--grid {
    width: 25%;
  }

  /* Change the width for the modal and widget since there is less space. */
  .ai-tools-library-selection .ai-tools-library-item--grid {
    width: 33.3%;
  }
}

@media screen and (min-width: 77em) {
  .ai-tools-library-item--grid {
    width: 16.6%;
  }

  /* Change the width for the modal and widget since there is less space. */
  .ai-tools-library-selection .ai-tools-library-item--grid {
    width: 25%;
  }
}

.ai-tools-library-item--grid .field--name-thumbnail {
  overflow: hidden;
  text-align: center;
  background-color: #ebebeb;
}

.ai-tools-library-item--grid .field--name-thumbnail img {
  height: 11.25rem;
  object-fit: contain;
  object-position: center center;
}

.ai-tools-library-item--grid.is-hover::before,
.ai-tools-library-item--grid.checked::before,
.ai-tools-library-item--grid.is-focus::before {
  top: 0.3125rem;
  left: 0.3125rem;
  border-width: 3px;
  border-radius: 0.1875rem;
}

.ai-tools-library-item--grid.is-hover::before,
.ai-tools-library-item--grid.checked.is-hover::before {
  border-color: var(--color-absolutezero-hover);
}

.ai-tools-library-item--grid.is-focus::before {
  border-color: var(--color-focus);
}

.ai-tools-library-item--grid.checked::before {
  border-color: var(--button--focus-border-color);
}

.ai-tools-library-item--grid .form-boolean--type-checkbox:checked {
  border-color: var(--button--focus-border-color);
  background-color: var(--button--focus-border-color);
}

.ai-tools-library-item--grid.is-focus .ai-tools-library-item__name,
.ai-tools-library-item--grid.checked .ai-tools-library-item__name {
  white-space: normal;
}

/* Add negative margin for flex grid. */

.ai-tools-library-selection {
  margin: 1em -0.5rem;
}

.ai-tools-library-item__remove,
.ai-tools-library-item__remove:hover,
.ai-tools-library-item__remove:focus {
  position: absolute;
  z-index: 1;
  top: 0.625rem;
  overflow: hidden;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.3125rem;
  padding: 0;
  transition: 0.2s border-color;
  color: transparent;
  background-size: 0.75rem;
  text-shadow: none;
  font-size: 0;
}

.ai-tools-library-item__remove {
  right: 0.625rem; /* LTR */
}

[dir="rtl"] .ai-tools-library-item__remove {
  right: auto;
  left: 0.625rem;
}

.ai-tools-library-item__remove {
  /* !important to override button class border. */
  border: 1px solid var(--color-gray-200) !important;
  background-image: url("data:image/svg+xml,%3csvg width='16' height='16' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M2.344 2.343l11.313 11.313M2.344 13.657L13.657 2.343' stroke='%2355565B' stroke-width='3'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.75rem;
  border-radius: 50%;
}

.ai-tools-library-item__remove:active {
  /* !important to override button class border. */
  border-color: var(--color-absolutezero) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3e%3cpath fill='%23ffffff' d='M3.51 13.925c.194.194.512.195.706.001l3.432-3.431c.194-.194.514-.194.708 0l3.432 3.431c.192.194.514.193.707-.001l1.405-1.417c.191-.195.189-.514-.002-.709l-3.397-3.4c-.192-.193-.192-.514-.002-.708l3.401-3.43c.189-.195.189-.515 0-.709l-1.407-1.418c-.195-.195-.513-.195-.707-.001l-3.43 3.431c-.195.194-.516.194-.708 0l-3.432-3.431c-.195-.195-.512-.194-.706.001l-1.407 1.417c-.194.195-.194.515 0 .71l3.403 3.429c.193.195.193.514-.001.708l-3.4 3.399c-.194.195-.195.516-.001.709l1.406 1.419z'/%3e%3c/svg%3e");
}
