.tree {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--layout-sider-background, #fafafa);
  border-right: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
}

// ---- Project bar (above file tree header) --------------------------------

.projectBar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
  background: var(--layout-sider-background, #fafafa);
  flex-shrink: 0;
}

.projectName {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, rgba(0, 0, 0, 0.88));
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.projectSwitchBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-tertiary, rgba(0, 0, 0, 0.3));
  padding: 0;
  transition:
    background 0.12s,
    color 0.12s;
  flex-shrink: 0;

  &:hover {
    background: var(--item-hover-bg, rgba(0, 0, 0, 0.06));
    color: var(--text-secondary, rgba(0, 0, 0, 0.55));
  }
}

// --------------------------------------------------------------------------

.treeHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
  flex-shrink: 0;
}

.treeTitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, rgba(0, 0, 0, 0.45));
}

.refreshBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary, rgba(0, 0, 0, 0.45));
  padding: 0;
  transition:
    background 0.15s,
    color 0.15s;

  &:hover:not(:disabled) {
    background: var(--item-hover-bg, rgba(0, 0, 0, 0.04));
    color: var(--text-primary, rgba(0, 0, 0, 0.88));
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.spinning {
  animation: spin 0.8s linear infinite;
}

.spin {
  display: block;
  margin: 16px auto;
}

.nodeList {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.node {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 3px;
  padding-bottom: 3px;
  padding-right: 8px;
  cursor: pointer;
  border-radius: 4px;
  margin: 1px 4px;
  transition: background 0.12s;
  user-select: none;

  &:hover {
    background: var(--item-hover-bg, rgba(0, 0, 0, 0.04));
  }

  &.selected {
    background: var(--primary-bg, rgba(22, 119, 255, 0.08));
    color: var(--primary-color, #1677ff);

    .fileIcon {
      color: var(--primary-color, #1677ff);
    }
  }
}

.nodeIcon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-secondary, rgba(0, 0, 0, 0.45));
}

.folderIcon {
  color: var(--warning-color, #faad14) !important;
}

.fileIcon {
  color: var(--text-tertiary, rgba(0, 0, 0, 0.25));
}

.nodeName {
  font-size: 12.5px;
  color: var(--text-primary, rgba(0, 0, 0, 0.88));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

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

// ---- Git status decorations (VS Code style) --------------------------------

// File/folder name color overrides
.node_modified > .nodeName,
.node_modified .nodeName {
  color: #e8a84f !important; // orange
}

.node_added > .nodeName,
.node_added .nodeName,
.node_untracked > .nodeName,
.node_untracked .nodeName {
  color: #73c991 !important; // green
}

.node_deleted > .nodeName,
.node_deleted .nodeName {
  color: #f47e7e !important; // red
  opacity: 0.7;
}

.deletedName {
  text-decoration: line-through;
}

// Single-letter badge (M / A / D / U) aligned to right
.gitBadge {
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
  padding-left: 6px;
  flex-shrink: 0;
  font-family: "SFMono-Regular", Consolas, monospace;
  opacity: 0.85;
}

.git_modified {
  color: #e8a84f;
}
.git_added {
  color: #73c991;
}
.git_untracked {
  color: #73c991;
}
.git_deleted {
  color: #f47e7e;
}

// ---- Dark mode -----------------------------------------------------------
:global(.dark-mode) {
  .tree {
    background: #1a1a1a;
    border-right-color: rgba(255, 255, 255, 0.08);
  }

  .projectBar {
    background: #1a1a1a;
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .projectName {
    color: rgba(255, 255, 255, 0.88);
  }

  .projectSwitchBtn {
    color: rgba(255, 255, 255, 0.45);

    &:hover {
      background: rgba(255, 255, 255, 0.08);
      color: rgba(255, 255, 255, 0.7);
    }
  }

  .treeHeader {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .treeTitle {
    color: rgba(255, 255, 255, 0.55);
  }

  .refreshBtn {
    color: rgba(255, 255, 255, 0.55);

    &:hover:not(:disabled) {
      background: rgba(255, 255, 255, 0.08);
      color: rgba(255, 255, 255, 0.88);
    }
  }

  .node {
    &:hover {
      background: rgba(255, 255, 255, 0.06);
    }

    &.selected {
      background: rgba(22, 119, 255, 0.18);
      color: #4da3ff;

      .fileIcon {
        color: #4da3ff;
      }
    }
  }

  .nodeIcon {
    color: rgba(255, 255, 255, 0.55);
  }

  .fileIcon {
    color: rgba(255, 255, 255, 0.4);
  }

  .nodeName {
    color: rgba(255, 255, 255, 0.85);
  }
}
