/* ===================================================================
   Project Tree -- MkDocs Material Theme Integration
   =================================================================== */

/* -- Card Container -- */
.project-tree-card {
  background: var(--md-code-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0;
  font-family: var(--md-code-font-family);
}

/* -- Header -- */
.tree-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  background: color-mix(in srgb, var(--md-code-bg-color) 90%, var(--md-default-fg-color) 10%);
}

.tree-header-icon {
  display: flex;
  align-items: center;
}

.tree-header-icon svg {
  width: 18px;
  height: 18px;
  color: #e3b341;
}

.tree-header-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--md-default-fg-color);
}

.tree-header-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--md-default-fg-color--light);
  background: var(--md-default-fg-color--lightest);
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
}

/* -- Tree Body -- */
.tree-body {
  padding: 0.4rem 0;
  font-size: 0.78rem;
  line-height: 1;
}

/* -- Node Row -- */
.tree-body .node {
  display: flex;
  align-items: center;
  padding: 0.32rem 1rem;
  min-height: 26px;
  transition: background 0.1s ease;
}

.tree-body .node:hover {
  background: var(--md-default-fg-color--lightest);
}

/* -- Indent Units (vertical lines) -- */
.indent-unit {
  width: 20px;
  height: 26px;
  position: relative;
  flex-shrink: 0;
}

.indent-unit.line::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--md-default-fg-color--lightest);
}

/* -- Branch Connectors -- */
.branch {
  width: 20px;
  height: 26px;
  position: relative;
  flex-shrink: 0;
}

/* Mid-node connector */
.branch.mid::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--md-default-fg-color--lightest);
}

.branch.mid::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--md-default-fg-color--lightest);
}

/* Last-node connector */
.branch.last::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  height: 50%;
  width: 1px;
  background: var(--md-default-fg-color--lightest);
}

.branch.last::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--md-default-fg-color--lightest);
}

/* -- Icons -- */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon svg {
  width: 14px;
  height: 14px;
}

.icon-folder svg {
  color: #e3b341;
}

.icon-folder-open svg {
  color: #e3b341;
}

/* -- Name & Comment -- */
.tree-body .name {
  color: var(--md-default-fg-color);
  font-weight: 500;
  white-space: nowrap;
}

.tree-body .comment {
  color: var(--md-default-fg-color--light);
  margin-left: 1rem;
  font-weight: 400;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.65;
}

/* -- Section Tags -- */
.tree-body .tag {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag-src      { background: rgba(56, 139, 253, 0.15);  color: #58a6ff; }
.tag-legacy   { background: rgba(218, 109, 48, 0.15);  color: #ffa657; }
.tag-data     { background: rgba(163, 113, 247, 0.15); color: #d2a8ff; }
.tag-docs     { background: rgba(63, 185, 80, 0.15);   color: #7ee787; }
.tag-tests    { background: rgba(56, 139, 253, 0.15);  color: #79c0ff; }
.tag-scripts  { background: rgba(227, 179, 65, 0.15);  color: #e3b341; }

/* -- Legend -- */
.tree-legend {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.65rem;
  color: var(--md-default-fg-color--light);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

/* Dot colors matching the tags */
.legend-dot.tag-src     { background: #58a6ff; }
.legend-dot.tag-legacy  { background: #ffa657; }
.legend-dot.tag-data    { background: #d2a8ff; }
.legend-dot.tag-docs    { background: #7ee787; }
.legend-dot.tag-tests   { background: #79c0ff; }
.legend-dot.tag-scripts { background: #e3b341; }

/* -- Info Note -- */
.tree-info-note {
  text-align: center;
  color: var(--md-default-fg-color--lighter);
  font-size: 0.72rem;
  margin-top: 0.5rem;
}
