/* <TreeView /> — lm-treeview-* convention, themeable via custom properties */

.lm-treeview {
    color: var(--lm-treeview-color, var(--lm-font-color, #18181b));
    font-size: var(--lm-treeview-font-size, 14px);
    user-select: none;
}

.lm-treeview ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Indentation per level — nested groups simply pad left */
.lm-treeview .lm-treeview-group {
    padding-left: var(--lm-treeview-indent, 18px);
}

/* Collapse keeps the child DOM ALIVE — visibility only, never an unmount */
.lm-treeview .lm-treeview-node[aria-expanded="false"] > .lm-treeview-group {
    display: none;
}

.lm-treeview .lm-treeview-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 4px;
    border-radius: var(--lm-treeview-radius, 6px);
    cursor: pointer;
    line-height: 1.5;
    user-select: none; /* rows are handles (click, keyboard, drag), not text */
}

.lm-treeview .lm-treeview-row:hover {
    background: var(--lm-treeview-hover-bg, var(--lm-background-color-highlight, #f4f4f5));
}

/* Focus lives on the <li role="treeitem"> (it carries the aria state);
   the ring still draws on ITS OWN row, never around the whole subtree */
.lm-treeview .lm-treeview-node:focus {
    outline: none;
}

.lm-treeview .lm-treeview-node:focus-visible > .lm-treeview-row {
    outline: 2px solid var(--lm-treeview-focus, var(--lm-border-outline, #2563eb));
    outline-offset: -2px;
}

.lm-treeview .lm-treeview-row.lm-treeview-selected {
    background: var(--lm-treeview-selected-bg, #1e90ff);
    color: var(--lm-treeview-selected-color, #fff);
}

/* Drag-and-drop (draggable). ZERO LAYOUT SHIFT: every affordance is
   pure decoration — the tree never moves during a drag.
     .lm-treeview-dragging    → the origin node, dimmed in place
     .lm-treeview-drop-before → insertion line ABOVE the row (absolute)
     .lm-treeview-drop-after  → insertion line BELOW the subtree (absolute)
     .lm-treeview-drop-inside → tint + ring on the container row
     .lm-treeview-drag-chip   → the floating label riding the cursor */
.lm-treeview .lm-treeview-node {
    position: relative; /* anchors the absolute insertion lines */
}

.lm-treeview .lm-treeview-dragging > .lm-treeview-row {
    opacity: 0.4;
}

.lm-treeview .lm-treeview-drop-before::before,
.lm-treeview .lm-treeview-drop-after::after {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    height: 2px;
    border-radius: 1px;
    background: var(--lm-treeview-drop, var(--lm-main-color, #2563eb));
    pointer-events: none;
    z-index: 1;
}

.lm-treeview .lm-treeview-drop-before::before {
    top: -1px;
}

.lm-treeview .lm-treeview-drop-after::after {
    bottom: -1px;
}

.lm-treeview .lm-treeview-drop-inside > .lm-treeview-row {
    background: var(--lm-treeview-drop-inside-bg, #dbeafe);
    outline: 1px dashed var(--lm-treeview-drop, var(--lm-main-color, #2563eb));
    outline-offset: -1px;
}

/* the chip: a small floating copy of the grabbed label under the cursor */
.lm-treeview .lm-treeview-drag-chip {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--lm-treeview-radius, 6px);
    background: var(--lm-background-color, #fff);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    font-size: var(--lm-treeview-font-size, 14px);
}

/* Chevron — rendered for parents only (they carry aria-expanded) */
.lm-treeview .lm-treeview-toggle {
    flex: none;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lm-treeview-chevron, var(--lm-font-grayout, #71717a));
}

.lm-treeview .lm-treeview-node[aria-expanded] > .lm-treeview-row > .lm-treeview-toggle::before {
    /* Stroke-drawn chevron (a rotated two-border square), not a font
       glyph: text triangles render at platform-dependent sizes/weights
       and U+25B6 can even take the emoji presentation. Borders are
       crisp at any DPI and follow currentColor. */
    content: '';
    width: var(--lm-treeview-chevron-size, 5px);
    height: var(--lm-treeview-chevron-size, 5px);
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    /* -45deg points it right (›); the translate re-centers the optical
       weight, which sits off-axis on a rotated square */
    transform: translateX(-1px) rotate(-45deg);
    transition: transform 0.15s ease;
}

.lm-treeview .lm-treeview-node[aria-expanded="true"] > .lm-treeview-row > .lm-treeview-toggle::before {
    transform: translateY(-1px) rotate(45deg); /* points down (⌄) */
}

.lm-treeview .lm-treeview-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Material icon keyword (same convention as <Tabs/> data-icon) */
.lm-treeview .lm-treeview-label[data-icon]::before {
    content: attr(data-icon);
    font-family: "Material Symbols Outlined", "Material Icons", "FontAwesome";
    font-size: var(--lm-treeview-icon-size, 16px);
    color: var(--lm-icon-color, var(--lm-font-grayout, #71717a));
}

/* selected row is solid blue — grey glyphs disappear on it: the label
   icon AND the expand chevron follow the row's white text instead */
.lm-treeview .lm-treeview-selected .lm-treeview-label[data-icon]::before,
.lm-treeview .lm-treeview-selected > .lm-treeview-toggle {
    color: inherit;
}
