/* Tree structure, rows, expander, checkboxes, icons, pagination */
.tree {
  list-style: none;
}
.tree ul {
  list-style: none;
  margin-left: var(--indent-size);
}
.tree-node {
  user-select: none;
}

.tree-row {
  display: flex;
  align-items: center;
  height: var(--row-height);
  padding: 0 8px;
  cursor: pointer;
  border-radius: 3px;
  margin: 1px 4px;
  transition: background-color 0.1s ease;
}
.tree-row:hover {
  background-color: var(--bg-hover);
}
.tree-row.selected {
  background-color: var(--bg-selected);
}

/* Disabled state for nodes and items */
.tree-node.disabled {
  opacity: 0.7;
}
.tree-node.disabled .tree-row {
  cursor: default;
}
.tree-node.disabled .tree-row:hover {
  background-color: transparent;
}
.tree-node.disabled .action-icon,
.tree-node.disabled .expander,
.tree-node.disabled .node-icon,
.tree-node.disabled .action-icons,
.tree-node.disabled .pagination {
  opacity: 0.5;
  pointer-events: none;
}
.tree-node.disabled .tree-checkbox {
  cursor: not-allowed;
  opacity: 0.6;
}
.tree-node.disabled .pagination-btn,
.tree-node.disabled .pagination-select {
  cursor: not-allowed;
  opacity: 0.5;
}

.expander {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 3px;
}
.expander:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.expander svg {
  width: 16px;
  height: 16px;
  fill: var(--icon-color);
  transition: transform 0.15s ease;
}
.expander.expanded svg {
  transform: rotate(90deg);
}
.expander-placeholder {
  width: 20px;
  flex-shrink: 0;
}

.tree-checkbox {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  flex-shrink: 0;
  appearance: none;
  border: 1px solid var(--checkbox-border);
  border-radius: 3px;
  background-color: transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.tree-checkbox:hover {
  border-color: var(--accent-color);
}
.tree-checkbox:checked {
  background-color: var(--checkbox-checked);
  border-color: var(--checkbox-checked);
}
.tree-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.action-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  flex-shrink: 0;
}
.action-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.15s ease;
}
.action-icon:hover {
  background-color: rgba(255, 255, 255, 0.1);
  opacity: 1;
}
.action-icon.active {
  opacity: 1;
}
.action-icon.active svg {
  fill: var(--accent-color);
}
.action-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--icon-color);
}

/* Leading icon for a node (folder, cloud, etc.) */
.node-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex-shrink: 0;
}
.node-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--icon-color);
}

.tree-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.tree-label .count-prefix {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}
.tree-label .item-count {
  color: var(--text-muted);
  font-size: 11px;
}
.tree-metadata {
  margin-left: 8px;
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  flex-shrink: 0;
}
.pagination-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  transition: all 0.15s ease;
}
.pagination-btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--text-primary);
}
.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pagination-info {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 30px;
  text-align: center;
}
.pagination-info .current {
  color: var(--text-primary);
}
.pagination-select {
  font-size: 11px;
  padding: 2px 4px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  margin-left: 4px;
}
.pagination-select:hover {
  border-color: var(--accent-color);
}
.pagination-select:focus {
  border-color: var(--accent-color);
  color: var(--text-primary);
}

.tree-children {
  max-height: none;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 260ms cubic-bezier(0.2, 0.9, 0.2, 1),
    opacity 180ms ease, transform 200ms ease;
  will-change: max-height, opacity, transform;
}
.tree-children:not(.expanded) {
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
}
.tree-children.expanded {
  opacity: 1;
  transform: translateY(0);
}
.tree-children.collapsing {
  pointer-events: none;
}

/* Video popup player styles */
.popup {
  position: fixed;
  background: var(--bg-secondary, #111);
  color: var(--text-primary, #fff);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.popup-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  cursor: move;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  flex: 0 0 36px;
}
.popup-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.popup-controls {
  display: flex;
  gap: 6px;
}
.popup-btn {
  width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-primary, #fff);
  cursor: pointer;
  font-size: 13px;
}
.popup-body {
  flex: 1 1 auto;
  background: black;
  display: flex;
  align-items: center;
  justify-content: center;
}
.popup-body {
  flex: 1 1 auto;
  background: black;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.popup-element {
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: black;
  object-fit: contain;
  box-sizing: border-box;
}

/* Resizers */
.resizer {
  position: absolute;
  z-index: 10;
}
.resizer-n,
.resizer-s {
  height: 8px;
  left: 0;
  right: 0;
  cursor: ns-resize;
}
.resizer-n {
  top: -4px;
}
.resizer-s {
  bottom: -4px;
}
.resizer-e,
.resizer-w {
  width: 8px;
  top: 0;
  bottom: 0;
  cursor: ew-resize;
}
.resizer-e {
  right: -4px;
}
.resizer-w {
  left: -4px;
}
.resizer-ne,
.resizer-nw,
.resizer-se,
.resizer-sw {
  width: 12px;
  height: 12px;
}
.resizer-ne {
  right: -6px;
  top: -6px;
  cursor: nesw-resize;
}
.resizer-nw {
  left: -6px;
  top: -6px;
  cursor: nwse-resize;
}
.resizer-se {
  right: -6px;
  bottom: -6px;
  cursor: nwse-resize;
}
.resizer-sw {
  left: -6px;
  bottom: -6px;
  cursor: nesw-resize;
}

/* Search input for tree */
.tree-search {
  padding: 8px 8px 0 8px;
}
.tree-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 4px;
  outline: none;
}
.tree-search-input::placeholder {
  color: var(--text-muted);
}
.tree-search-input:focus {
  border-color: var(--accent-color);
}

/* Highlighted match inside label */
.tree-match {
  background-color: rgba(255, 240, 120, 0.2);
  color: var(--text-primary);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* Clear button and hide default search cancel */
.tree-search {
  max-width: inherit;
  display: flex;
  gap: 6px;
  align-items: center;
}
.tree-search-input {
  flex: 1 1 auto;
}
.tree-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.tree-search-clear {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}
.tree-search-clear:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

/* Version badge at the bottom of the tree panel */
.tree-version {
  grid-row: 3;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  border-top: 1px solid var(--border-color);
  user-select: none;
}
