/* MEDS location hierarchy tree — Vanilla Noir */

.loc-tree {
  max-height: min(70vh, 640px);
  padding: var(--space-2) var(--space-3) var(--space-4);
  overflow-x: hidden;
  overflow-y: auto;
}

.loc-tree__node {
  position: relative;
}

.loc-tree__row {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  margin: 1px 0;
  padding: 2px 4px 2px 2px;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  transition:
    color var(--motion),
    background var(--motion),
    border-color var(--motion);
}

.loc-tree__row:hover,
.loc-tree__row:focus-within {
  color: var(--text-secondary);
  background: var(--surface-2);
}

.loc-tree__row[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.loc-tree__expand {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.loc-tree__expand:disabled {
  opacity: 0.35;
  cursor: default;
}

.loc-tree__expand .icon {
  width: 14px;
  height: 14px;
  transition: transform 160ms ease;
}

.loc-tree__expand[aria-expanded="true"] .icon {
  transform: rotate(90deg);
}

.loc-tree__label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 2px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.loc-tree__icon {
  display: grid;
  place-items: center;
  color: var(--text-very-muted);
}

.loc-tree__row[aria-selected="true"] .loc-tree__icon,
.loc-tree__expand[aria-expanded="true"] + .loc-tree__label .loc-tree__icon {
  color: var(--accent);
}

.loc-tree__icon .icon {
  width: 15px;
  height: 15px;
}

.loc-tree__name {
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-tree__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
}

.loc-tree__count {
  color: var(--text-very-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.loc-tree__actions {
  display: none;
  gap: 2px;
}

.loc-tree__row:hover .loc-tree__actions,
.loc-tree__row:focus-within .loc-tree__actions,
.loc-tree__row[aria-selected="true"] .loc-tree__actions {
  display: flex;
}

.loc-tree__action {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.loc-tree__action:hover,
.loc-tree__action:focus-visible {
  color: var(--text);
  background: var(--surface-3, var(--surface-2));
  outline: 0;
}

.loc-tree__action--danger:hover,
.loc-tree__action--danger:focus-visible {
  color: var(--critical);
}

.loc-tree__action .icon {
  width: 14px;
  height: 14px;
}

.loc-tree__children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--border-subtle);
}

.loc-tree__children[hidden] {
  display: none;
}

@keyframes loc-tree-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .loc-tree__children:not([hidden]) > .loc-tree__node {
    animation: loc-tree-in 160ms ease-out;
  }
}

.loc-tree__empty {
  padding: var(--space-5) var(--space-3);
  color: var(--text-muted);
  font-size: 13px;
}

.loc-tree-float-tip {
  position: fixed;
  z-index: 120;
  max-width: min(280px, calc(100vw - 16px));
  padding: 6px 10px;
  color: var(--text);
  background: var(--surface-3, #2b2b2b);
  border: 1px solid var(--border-strong, #3c342b);
  border-radius: var(--radius-control, 8px);
  box-shadow: var(--shadow-panel, 0 10px 28px rgba(0, 0, 0, 0.35));
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.loc-tree-float-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.loc-tree-float-tip.is-above.is-visible {
  transform: translateY(0);
}

.loc-tree-float-tip[hidden] {
  display: none !important;
}

.location-tree-panel .panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.location-tree-panel .panel-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
