/* src/components/basic/XWUITree/XWUITree.css */
/**
 * XWUITree Component Styles
 * Structure and behavior only - colors come from CSS variables
 */

.xwui-tree { width: 100%; }

.xwui-tree-node { position: relative; }

.xwui-tree-node-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 0.5rem);
    padding: var(--spacing-sm, 0.5rem) var(--spacing-sm, 0.5rem);
    border-radius: var(--radius-tree, var(--radius-sm, 6px));
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    color: var(--text-primary, #374151);
    font-size: var(--font-size-sm, 0.875rem);
}

.xwui-tree-node-content:focus-visible {
    /* Rows are keyboard stops now (roving tabindex, see XWUITree.view.ts).
       Inset so the ring survives an embedder that clips the row's box. */
    outline: 2px solid var(--accent-primary, #6366f1);
    outline-offset: -2px;
}

.xwui-tree-node-content:hover:not(.xwui-tree-node-disabled .xwui-tree-node-content) {
    background: var(--bg-hover, var(--bg-secondary, #f3f4f6));
    color: var(--role-primary-ink, var(--accent-primary, #6366f1));
}

.xwui-tree-node-selected > .xwui-tree-node-content {
    background: rgba(var(--accent-primary-rgb, 99, 102, 241), 0.1);
    color: var(--role-primary-ink, var(--accent-primary, #6366f1));
    font-weight: 600;
}

.xwui-tree-node-disabled { opacity: 0.5; cursor: not-allowed; }

/* Expand/collapse arrow */
.xwui-tree-expand-icon {
    width: 14px; height: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 8px;
    /* This caret is drawn as a real text glyph ("\25B6"), not as an icon font or
       an SVG, so contrast checkers measure it against the 4.5:1 body-text floor
       rather than the 3:1 non-text floor - and --text-tertiary is deliberately
       tuned to the 3:1 floor (see light.css), which left this at 1.93:1 on
       --bg-app. It is also the control that says whether a branch is open, so
       secondary ink is the honest tier for it: 4.55:1 on #f5f7fa. */
    color: var(--text-secondary, #6a727a);
    flex-shrink: 0;
    transition: transform 0.15s;
}
.xwui-tree-expand-icon.xwui-tree-expanded { transform: rotate(90deg); }

/* RTL: a collapsed caret points toward the INLINE END, which is left here, so
   the right-pointing glyph is mirrored; expanded it still points down.
   Keyed on the tree's own slot - the element whose `[dir]` XWUIComponent
   stamps from the tree's resolved direction, or that a projecting host
   declares - rather than on <html>, so an LTR tree island inside an RTL page
   (or the reverse) draws the caret its own rows read by. Known limit: a tree
   nested inside another tree's renderNode row also matches the OUTER slot.
   Mirror FIRST, then
   rotate: `scaleX(-1) rotate(90deg)` lands on the same downward glyph as LTR
   and interpolates from the collapsed state as a plain quarter turn. */
[dir="rtl"] > .xwui-tree .xwui-tree-expand-icon { transform: scaleX(-1); }
[dir="rtl"] > .xwui-tree .xwui-tree-expand-icon.xwui-tree-expanded { transform: scaleX(-1) rotate(90deg); }

.xwui-tree-spacer { width: 14px; flex-shrink: 0; }

/* Node icon (inline SVG or text) */
/* Leading ordinal/index column (numbered sections). */
.xwui-tree-node-number {
    flex-shrink: 0;
    min-width: 1.5em;
    text-align: center;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    /* No opacity here: it dimmed --text-tertiary (already tuned to 4.5:1) to 4.4:1. */
    color: var(--text-tertiary, #94a3b8);
}
.xwui-tree-compact .xwui-tree-node-number { font-size: 10.5px; }

.xwui-tree-node-icon {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    /* Fixed icon column so an empty / unresolved glyph can't expand and shove
       the label across the row. */
    width: 1.4em; min-width: 1.4em; max-width: 1.4em; overflow: hidden;
    font-size: 14px; color: var(--text-secondary, #6b7280);
}
.xwui-tree-node-icon svg { width: 1em; height: 1em; }

/* Node icon (image URL) */
.xwui-tree-node-icon-img {
    width: 16px; height: 16px; flex-shrink: 0;
    object-fit: contain; opacity: 0.75;
    border-radius: 2px;
}

/* Label */
.xwui-tree-node-label {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Badge - pinned to the inline END, so it follows the row in RTL. */
.xwui-tree-node-badge {
    margin-inline-start: auto; flex-shrink: 0;
    font-size: 11px; font-weight: 500;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-hover, var(--bg-secondary, #f3f4f6));
    padding: 1px 6px; border-radius: 8px;
}

/* Children container */
.xwui-tree-children { margin-inline-start: 0; }

/* ===== COMPACT MODE ===== */
.xwui-tree-compact .xwui-tree-node-content {
    padding: 3px 8px;
    gap: 6px;
    font-size: 12.5px;
    border-radius: 4px;
}
.xwui-tree-compact .xwui-tree-node-icon-img { width: 14px; height: 14px; }
.xwui-tree-compact .xwui-tree-expand-icon { width: 12px; height: 12px; font-size: 7px; }
.xwui-tree-compact .xwui-tree-spacer { width: 12px; }
.xwui-tree-compact .xwui-tree-node-badge { font-size: 10px; padding: 0 5px; }
