/* Universal tree widget. All visuals live here so themes change in one place. */

.tme-tree-root,
.tme-tree-panel {
  position: fixed;
  z-index: 6;
  font: 13px/1.4 system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* The persistent root button. */
.tme-tree-root {
  background: rgba(20, 20, 22, 0.92);
  color: #eee;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tme-tree-root:hover { background: rgba(40, 40, 44, 0.95); }
.tme-tree-root.open  { background: #2d6cdf; color: #fff; border-color: #2d6cdf; }

.tme-tree-root.draggable { cursor: grab; }
.tme-tree-root.dragging  { cursor: grabbing; opacity: 0.9; }

/* A popped-out panel of children. data-axis controls flow direction. */
.tme-tree-panel {
  background: rgba(20, 20, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  gap: 4px;
}
.tme-tree-panel[data-axis="horizontal"] { flex-direction: row; }
.tme-tree-panel[data-axis="vertical"]   { flex-direction: column; }

/* Individual node = chip. Icons-only by default; UIs opt into showing text. */
.tme-tree-node {
  background: transparent;
  color: #bbb;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tme-tree-node:hover { background: rgba(255, 255, 255, 0.06); color: #ddd; }

/* on / off / partial state — colour mirrors existing accent. */
.tme-tree-node[data-state="on"]      { color: #2d6cdf; }
.tme-tree-node[data-state="on"]:hover{ color: #4a8af0; background: rgba(45, 108, 223, 0.10); }
.tme-tree-node[data-state="off"]     { color: #555; }
.tme-tree-node[data-state="off"]:hover { color: #888; }
/* Partial: branch has some children on, some off. Muted accent + dashed
   underline so it's distinguishable from full on/off at a glance. */
.tme-tree-node[data-state="partial"] {
  color: #6f8fc8;
  position: relative;
}
.tme-tree-node[data-state="partial"]::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  height: 0;
  border-bottom: 2px dashed rgba(45, 108, 223, 0.7);
  pointer-events: none;
}
.tme-tree-node[data-state="partial"]:hover { color: #9ab4e0; background: rgba(45, 108, 223, 0.08); }

/* Currently-open branch in its parent panel — gets a subtle ring. */
.tme-tree-node.open {
  outline: 2px solid rgba(45, 108, 223, 0.6);
  outline-offset: 1px;
}

/* Icon glyph (Material Symbols Outlined). */
.tme-tree-icon {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}
.tme-tree-root .tme-tree-icon { font-size: 22px; }

/* Optional text label. Hidden by default; UIs add .show-text on the root or
 * individual nodes to opt in.
 */
.tme-tree-text {
  font-size: 12px;
  font-weight: 500;
  display: none;
}
.tme-tree-root.show-text .tme-tree-text,
.tme-tree-panel.show-text .tme-tree-text,
.tme-tree-node.show-text .tme-tree-text {
  display: inline;
}

/* Optional swatch slot — adapter can fill via decorate(). */
.tme-tree-node .tme-tree-swatch {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}
