/* Collapsible collection tree (see collection_tree.js). */

/* Persistent folder sidebar on the images listing. */
.ekg-ctree-imglayout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.ekg-ctree-sidebar {
  flex: 0 0 16rem;
  position: sticky;
  top: 1rem;
  padding-left: 1.5rem; /* match the listing's nice-padding gutter */
}

.ekg-ctree-sidebar__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.4rem 0.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--w-color-text-meta, #5c5c5c);
}

.ekg-ctree-sidebar__add {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--w-color-text-link-default, #007d7e);
  text-decoration: none;
}

.ekg-ctree-sidebar__add:hover {
  text-decoration: underline;
}

.ekg-ctree-sidebar .ekg-ctree {
  max-width: none;
}

.ekg-ctree-imglayout > #listing-results {
  flex: 1 1 auto;
  min-width: 0; /* let the grid shrink instead of overflowing the flex row */
}

@media (max-width: 800px) {
  .ekg-ctree-imglayout {
    display: block;
  }
  .ekg-ctree-sidebar {
    position: static;
    padding-left: 0;
    margin-bottom: 1rem;
  }
}

.ekg-ctree__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;
}

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

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

.ekg-ctree__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;
}

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

.ekg-ctree__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;
}

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

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

.ekg-ctree__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

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

.ekg-ctree__list.is-collapsed {
  display: none;
}

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

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

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

.ekg-ctree__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;
}

.ekg-ctree__toggle--leaf {
  visibility: hidden;
  cursor: default;
}

.ekg-ctree__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;
}

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

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

.ekg-ctree__label--container:hover {
  background: transparent;
}
