/* ==========================================================================
   OmniRSS Subscriptions Tree Styling (Left Pane)
   ========================================================================== */

.tree-header {
  height: 34px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.tree-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.tree-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tree-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tree-action-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.tree-action-btn.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
}

.tree-scroll-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100% - 34px);
  overflow: hidden;
  padding: 0;
}

/* Smart Folders Section (All, Unread, Starred, Trash) */
.smart-folders-group {
  border-bottom: 1px solid var(--border-color-subtle);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.tree-item {
  height: max(24px, calc(var(--tree-font-size, 12px) + 12px));
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  cursor: pointer;
  font-size: var(--tree-font-size, 12px);
  color: var(--text-secondary);
  position: relative;
  transition: background-color 0.1s;
  min-width: 0;
  width: 100%;
}

.tree-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.tree-item.active {
  background-color: var(--bg-selected-row);
  color: var(--text-unread);
  font-weight: 500;
}

.tree-item .tree-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.tree-item.active .tree-icon {
  color: var(--accent-primary);
}

.tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  font-size: max(10px, calc(var(--tree-font-size, 12px) - 1px));
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 4px;
}

.tree-count.has-unread {
  color: var(--accent-primary);
}

/* Row Hover Actions (Mark Read / Delete) */
.tree-row-actions {
  display: none;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
  flex-shrink: 0;
}

.tree-item:hover .tree-row-actions,
.category-item:hover .tree-row-actions,
.feed-item:hover .tree-row-actions {
  display: flex;
}

.tree-row-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-row-btn:hover {
  background: var(--bg-surface-active);
  color: var(--text-primary);
}

.tree-row-btn.btn-refresh:hover {
  color: var(--accent-primary);
}

.tree-row-btn.spinning svg {
  animation: tree-spin 0.8s linear infinite;
}

@keyframes tree-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.tree-row-btn.btn-delete:hover {
  color: var(--accent-danger, #ef4444);
}

/* Categories & Feeds Section */
.category-item {
  height: max(24px, calc(var(--tree-font-size, 12px) + 12px));
  display: flex;
  align-items: center;
  padding: 0 6px 0 4px;
  gap: 4px;
  cursor: pointer;
  font-size: var(--tree-font-size, 12px);
  font-weight: 600;
  color: var(--text-secondary);
  transition: background-color 0.1s;
  min-width: 0;
  width: 100%;
}

.category-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.category-item.active {
  background-color: var(--bg-selected-row);
  color: var(--text-unread);
}

.category-toggle {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.category-toggle.collapsed svg {
  transform: rotate(-90deg);
}

.category-feeds-container {
  padding-left: var(--tree-indent);
}

.feed-item {
  height: max(24px, calc(var(--tree-font-size, 12px) + 12px));
  display: flex;
  align-items: center;
  padding: 0 8px 0 4px;
  gap: 6px;
  cursor: pointer;
  font-size: var(--tree-font-size, 12px);
  color: var(--text-secondary);
  transition: background-color 0.1s;
  min-width: 0;
  width: 100%;
}

.feed-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.feed-item.active {
  background-color: var(--bg-selected-row);
  color: var(--text-unread);
  font-weight: 500;
}

.feed-favicon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  object-fit: contain;
}

.feed-favicon-fallback {
  width: 14px;
  height: 14px;
  background: var(--accent-orange-dim);
  color: var(--accent-orange);
  border-radius: 2px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Category Aggregated Error Badges */
.category-error-badge {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}

.category-error-badge.dead {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.category-error-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Vertical Splitter between Categories and Tags */
.tree-pane-splitter {
  height: 8px;
  background: var(--bg-surface-hover, #22272e);
  cursor: row-resize;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
  z-index: 20;
  border-top: 1px solid var(--border-color-subtle);
  border-bottom: 1px solid var(--border-color-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}

.tree-pane-splitter::before {
  content: "";
  width: 24px;
  height: 2px;
  background: var(--text-muted);
  opacity: 0.5;
  border-radius: 1px;
  transition: all 0.15s ease;
}

.tree-pane-splitter::after {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 0;
  right: 0;
  z-index: 21;
}

.tree-pane-splitter:hover,
.tree-pane-splitter.dragging {
  background: var(--accent-primary, #3b82f6) !important;
}

.tree-pane-splitter:hover::before,
.tree-pane-splitter.dragging::before {
  background: #ffffff;
  opacity: 1;
  width: 32px;
}

/* 全域拖曳時透明遮罩 (防止 iframe 或其他元件截斷 mousemove) */
.drag-resizing-active {
  user-select: none !important;
  cursor: row-resize !important;
}
.drag-resizing-active iframe,
.drag-resizing-active webview {
  pointer-events: none !important;
}


