/* The collapsible, searchable tree that stands in for a long <select>.
   Shared by the image folders (collection_tree.js) and the shop's category and
   collection pickers (shop_tree.js); see tree_select.js for the markup. */

.cms-tree__native {
  /* Visually hidden but kept in the DOM for form submission. */
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cms-tree {
  border: 1px solid var(--w-color-border-field-default, #c8c8c8);
  border-radius: 6px;
  background: var(--w-color-surface-field, #fff);
  max-width: 32rem;
}

.cms-tree__search {
  padding: 0.4rem;
  border-bottom: 1px solid var(--w-color-border-furniture, #e6e6e6);
}

.cms-tree__search-input {
  /* Wagtail's admin form reset forces width:100% + content-box + 20px side
     padding on inputs, so the border box overflows the tree. Pin box-sizing and
     padding (with !important to beat the per-input-type reset) to fit. */
  width: 100%;
  min-width: 0;
  box-sizing: border-box !important;
  padding: 0.35rem 0.5rem !important;
  font-size: 0.85rem;
  border: 1px solid var(--w-color-border-field-default, #c8c8c8);
  border-radius: 4px;
}

.cms-tree__scroll {
  max-height: 18rem;
  overflow-y: auto;
  padding: 0.25rem 0.4rem;
}

.cms-tree__clear {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.25rem 0.4rem;
  margin-bottom: 0.15rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--w-color-text-meta, #5c5c5c);
  border-radius: 4px;
}

.cms-tree__clear:hover {
  background: var(--w-color-surface-field-inactive, #f0f0f2);
}

.cms-tree__clear.is-selected {
  background: var(--w-color-surface-field-inactive, #f0f0f2);
  font-weight: 600;
  color: var(--w-color-text-link-default, #007d7e);
}

.cms-tree__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cms-tree__list--nested {
  margin-left: 1.1rem;
  border-left: 1px solid var(--w-color-border-furniture, #ededed);
  padding-left: 0.2rem;
}

.cms-tree__list.is-collapsed {
  display: none;
}

.cms-tree__row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  border-radius: 4px;
}

.cms-tree__row.is-selected {
  background: var(--w-color-surface-field-inactive, #f0f0f2);
}

.cms-tree__row.is-selected > .cms-tree__label {
  font-weight: 600;
  color: var(--w-color-text-link-default, #007d7e);
}

.cms-tree__toggle {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  line-height: 1.7rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--w-color-text-meta, #5c5c5c);
  font-size: 1.05rem;
}

.cms-tree__toggle--leaf {
  visibility: hidden;
  cursor: default;
}

.cms-tree__label {
  flex: 1 1 auto;
  text-align: left;
  padding: 0.25rem 0.4rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--w-color-text-context, #262626);
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cms-tree__label:hover {
  background: var(--w-color-surface-field-inactive, #f0f0f2);
}

.cms-tree__label--container {
  color: var(--w-color-text-meta, #767676);
  cursor: default;
}

.cms-tree__label--container:hover {
  background: transparent;
}
