/* ============================================================
   tree.css — Systems tree view
   ============================================================ */

.systems-view {
    animation: fadeIn var(--transition-normal) ease-out;
}

/* ── Add System Form ─────────────────────────────────────── */
.add-system-row {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.add-system-row input {
    max-width: 400px;
}

/* ── Tree Container ──────────────────────────────────────── */
.system-tree {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* ── System Card ─────────────────────────────────────────── */
.tree-system {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.tree-system:hover {
    border-color: var(--border-hover);
}

.tree-system.drop-target {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tree-system.dragging {
    opacity: 0.3;
    transform: scale(0.98);
}

.tree-system.drop-above {
    border-top: 3px solid var(--accent-primary);
    margin-top: -3px;
}

.tree-system.drop-below {
    border-bottom: 3px solid var(--accent-primary);
    margin-bottom: -3px;
}

.tree-system-header {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    gap: var(--space-3);
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

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

.tree-expand-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
    font-size: 12px;
    flex-shrink: 0;
}

.tree-system.expanded .tree-expand-icon {
    transform: rotate(90deg);
}

.tree-system-name {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    flex: 1;
    cursor: text;
}

.tree-system-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.tree-system-count {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    white-space: nowrap;
}

.tree-system-actions {
    display: flex;
    gap: var(--space-1);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

/* ── Components List ─────────────────────────────────────── */
.tree-components {
    border-top: 1px solid var(--border-color);
    display: none;
}

.tree-system.expanded .tree-components {
    display: block;
}

.tree-component {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-5);
    padding-left: var(--space-10);
    gap: var(--space-3);
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.tree-component:last-child {
    border-bottom: none;
}

.tree-component:hover {
    background: var(--bg-hover);
}

.tree-component.dragging {
    opacity: 0.5;
}

.tree-component.drop-above {
    box-shadow: inset 0 2px 0 var(--accent-primary);
}

.tree-component.drop-below {
    box-shadow: inset 0 -2px 0 var(--accent-primary);
}

.tree-components.drop-target {
    background: rgba(59, 130, 246, 0.06);
}

.tree-component-name {
    font-size: var(--text-sm);
    color: var(--text-primary);
    flex: 1;
    font-weight: var(--font-medium);
}

.tree-component-meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.tree-component-tasks {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    white-space: nowrap;
}

.tree-component-actions {
    display: flex;
    gap: var(--space-1);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.tree-component:hover .tree-component-actions {
    opacity: 1;
}

.tree-component-priority {
    font-size: var(--text-xs);
}

/* ── Add Component Inline ────────────────────────────────── */
.add-component-row {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-5);
    padding-left: var(--space-10);
    gap: var(--space-3);
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.add-component-row input {
    flex: 1;
    max-width: 300px;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
}

.add-component-btn {
    padding: var(--space-2) var(--space-10);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: none;
    background: none;
}

.add-component-btn:hover {
    color: var(--accent-primary);
}

/* ── Legend ───────────────────────────────────────────────── */
.tree-legend {
    margin-top: var(--space-8);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
}

.tree-legend-title {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-3);
}

.tree-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.tree-legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
