/* Tree View Component - Monochrome Edge Theme */

.tree-view {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    font-size: 0.875rem;
    color: var(--theme-text-primary);
    user-select: none;
    overflow: auto;
}

/* Tree Node */
.tree-node {
    position: relative;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.5rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.5rem;
}

.tree-node-content:hover {
    background: var(--theme-bg);
}

.tree-node-content.selected {
    background: var(--theme-accent-alpha);
    color: var(--theme-accent);
}

.tree-node-content.focused {
    box-shadow: inset 0 0 0 2px var(--theme-accent);
}

/* Tree Icons */
.tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-text-secondary);
}

.tree-icon-chevron {
    transition: transform 0.2s;
}

.tree-node.expanded .tree-icon-chevron {
    transform: rotate(90deg);
}

/* Default chevron icon */
.tree-icon-chevron::before {
    content: '›';
    font-size: 1.2em;
    line-height: 1;
}

/* File type icons */
.tree-icon-file::before { content: '📄'; font-size: 0.9em; }
.tree-icon-folder::before { content: '📁'; font-size: 0.9em; }
.tree-icon-folder-open::before { content: '📂'; font-size: 0.9em; }

/* Monochrome icons (no emoji) */
.tree-view.no-emoji .tree-icon-file::before { content: '□'; }
.tree-view.no-emoji .tree-icon-folder::before { content: '▶'; }
.tree-view.no-emoji .tree-icon-folder-open::before { content: '▼'; }

/* Tree Label */
.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.tree-node-content.folder .tree-label {
    font-weight: 500;
}

/* Tree Badge */
.tree-badge {
    padding: 0.125rem 0.375rem;
    background: var(--theme-bg);
    color: var(--theme-text-secondary);
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: auto;
}

/* Tree Children */
.tree-children {
    margin-left: 1.25rem;
    position: relative;
}

.tree-children::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--theme-border);
    opacity: 0.5;
}

.tree-node.collapsed .tree-children {
    display: none;
}

/* Tree Actions */
.tree-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.tree-node-content:hover .tree-actions {
    opacity: 1;
}

.tree-action {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    color: var(--theme-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Tree Drag & Drop */
.tree-node-content.dragging {
    opacity: 0.5;
}

.tree-node-content.drag-over {
    background: var(--theme-accent-alpha);
    box-shadow: inset 0 0 0 2px var(--theme-accent);
}

.tree-node-content.drag-over-top::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--theme-accent);
}

.tree-node-content.drag-over-bottom::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--theme-accent);
}

/* Tree Search */
.tree-search {
    margin-bottom: 0.5rem;
    position: relative;
}

.tree-search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--theme-bg);
    border: 1px solid var(--theme-border);
    border-radius: var(--border-radius-sm);
    color: var(--theme-text-primary);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s;
}

.tree-search-input:focus {
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 3px var(--theme-accent-alpha);
}

.tree-search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--theme-text-muted);
    pointer-events: none;
}

/* Tree Loading */
.tree-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--theme-text-muted);
}

.tree-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--theme-border);
    border-top-color: var(--theme-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Tree Empty */
.tree-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--theme-text-muted);
    text-align: center;
}

.tree-empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Context Menu */
.tree-context-menu {
    position: fixed;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.25rem;
    min-width: 160px;
    z-index: 1000;
    display: none;
}

.tree-context-menu.active {
    display: block;
}

.tree-context-item {
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--theme-text-primary);
    transition: all 0.2s;
}

.tree-context-item:hover {
    background: var(--theme-bg);
}

.tree-context-item.danger {
    color: var(--theme-error);
}

.tree-context-divider {
    height: 1px;
    background: var(--theme-border);
    margin: 0.25rem 0;
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* File type specific colors */
.tree-node[data-type="js"] .tree-icon,
.tree-node[data-type="ts"] .tree-icon { color: var(--theme-warning); }

.tree-node[data-type="css"] .tree-icon,
.tree-node[data-type="scss"] .tree-icon { color: var(--theme-info); }

.tree-node[data-type="html"] .tree-icon { color: var(--theme-error); }

.tree-node[data-type="json"] .tree-icon,
.tree-node[data-type="md"] .tree-icon { color: var(--theme-success); }

/* Compact mode */
.tree-view.compact .tree-node-content {
    padding: 0.25rem 0.5rem;
}

.tree-view.compact .tree-children {
    margin-left: 1rem;
}

/* Dark theme adjustments */
[data-theme-variant="cold"] .tree-view {
    background: var(--theme-bg);
}

[data-theme-variant="cold"] .tree-node-content:hover {
    background: var(--theme-surface);
}

/* Responsive */
@media (max-width: 640px) {
    .tree-view {
        font-size: 0.8125rem;
    }
    
    .tree-actions {
        opacity: 1;
    }
}