/* ========================================================================
   HIERARCHICAL TREE STYLES (Figures -> Axes -> Plots/Guides/Annotations)
   ======================================================================== */

/* Tree structure with proper indentation */
.tree-item[data-level="0"] {
    padding-left: 8px;
}

.tree-item[data-level="1"] {
    padding-left: 24px;
}

.tree-group[data-level="2"] {
    padding-left: 40px;
}

.tree-item[data-level="3"] {
    padding-left: 56px;
}

/* Tree item header (for expandable items) */
.tree-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 0;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    border-radius: 4px;
}

.tree-item-header:hover {
    background: var(--vis-bg-hover);
}

.tree-item-header:hover .tree-item-actions {
    opacity: 1;
}

/* Tree toggle (chevron) */
.tree-toggle {
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: transform 0.15s ease;
    width: 12px;
    text-align: center;
}

.tree-toggle.fa-chevron-down {
    transform: rotate(0deg);
}

.tree-toggle.fa-chevron-right {
    transform: rotate(0deg);
}

/* Tree icon */
.tree-icon {
    font-size: 13px;
    width: 16px;
    text-align: center;
}

.tree-figure .tree-icon {
    color: var(--workspace-icon-primary);
}

.tree-axis .tree-icon {
    color: var(--workspace-icon-secondary);
}

.tree-plot .tree-icon {
    color: var(--workspace-icon-primary);
}

.tree-guide .tree-icon {
    color: var(--workspace-icon-muted);
}

.tree-annotation .tree-icon {
    color: var(--text-secondary);
}

/* Tree label */
.tree-label {
    flex: 1;
    font-size: 12px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--workspace-border-default);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 4px;
    flex-shrink: 0;
}

.tree-badge:empty,
.tree-badge[data-count="0"] {
    background: transparent;
    color: var(--text-muted);
    opacity: 0.5;
}

.tree-empty-state {
    padding: 4px 8px 4px 24px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
}

/* Tree item actions (edit, delete) */
.tree-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tree-action-btn {
    padding: 2px 6px;
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    transition: all 0.15s ease;
}

.tree-action-btn:hover {
    background: var(--workspace-bg-tertiary);
    color: var(--text-primary);
}

.tree-action-btn:active {
    transform: scale(0.95);
}

/* Tree add button */
.tree-add-btn {
    padding: 2px 6px;
    background: transparent;
    border: 1px solid var(--workspace-border-default);
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    transition: all 0.15s ease;
    opacity: 0.7;
}

.tree-add-btn:hover {
    background: var(--status-success-bg);
    border-color: var(--status-success);
    color: var(--status-success);
    opacity: 1;
}

.tree-section-header .tree-add-btn {
    margin-left: auto;
}

/* Tree children container */
.tree-item-children {
    overflow: hidden;
    transition: max-height 0.2s ease-out;
}

/* Tree group (Plots, Guides, Annotations) */
.tree-group {
    margin: 4px 0;
}

.tree-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 0;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tree-group-header:hover {
    background: var(--vis-bg-hover);
}

.tree-group-children {
    margin: 2px 0;
}

/* Selected state - highlight both header and give card a subtle background */
.tree-item-header.selected {
    background: var(--status-info-bg);
    border-radius: 4px;
}

/* When an item is selected, give the whole card a subtle tint */
.tree-item:has(.tree-item-header.selected) {
    background: var(--bg-hover, rgba(0, 0, 0, 0.02));
    border-radius: 6px;
    padding: 4px 0;
}

/* Active/focused state */
.tree-item:focus-within {
    outline: 2px solid var(--status-info);
    outline-offset: -2px;
    border-radius: 4px;
}

/* Drag and drop states */
.tree-item.dragging {
    opacity: 0.4;
}

.tree-item.drop-target {
    background: var(--status-success-bg);
    border: 2px dashed var(--status-success);
}

/* Empty state for tree groups */
.tree-group-children:empty::after {
    content: "No items";
    display: block;
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}
