/* F33.W2 — ResourceTree styles (merged sidebar tree + search + drag-drop).
 *
 * Канон Cal.com Event Types sidebar / Linear Projects sidebar / Notion sidebar.
 * Выделен в отдельный файл (вместо append в resource-editor.css 1062 LOC)
 * чтобы соблюсти лимит code-standards.md (CSS: 250 LOC) на новых файлах и
 * семантически отделить tree-компонент от остальной части ResourceEditor.
 *
 * Palette: slate-50/100/200/400/500/600/700/900 (neutral) + indigo-600 (accent)
 *          + amber-500 (warning «без группы»). Border-radius 6-10px, shadow ≤ sm.
 * Premium UI rule: emoji запрещены, иконки только Lucide.
 */

/* Layout — 2-pane (заменил re-root-3pane 244+320+1fr) */
.re-root-2pane {
  grid-template-columns: 340px 1fr;
}
@media (max-width: 1100px) {
  .re-root-2pane { grid-template-columns: 300px 1fr; }
}
@media (max-width: 768px) {
  .re-root-2pane {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .re-tree-pane {
    max-height: 280px;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
}

.re-tree-pane {
  border-right: 1px solid #e5e7eb;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.re-tree-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* Header (sticky top) */
.re-tree-header {
  flex-shrink: 0;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #eef0f3;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.re-tree-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.re-tree-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}
.re-tree-counter {
  font-size: 11.5px;
  font-weight: 500;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 1px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.re-tree-header-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
}
.re-tree-icon-btn {
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.re-tree-icon-btn:hover { background: #f1f5f9; color: #475569; }

/* Search bar */
.re-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
  transition: border-color 120ms ease-out, background 120ms ease-out;
}
.re-search:focus-within {
  border-color: var(--brand-accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-accent) 12%, transparent);
}
.re-search > svg { color: #94a3b8; flex-shrink: 0; }
.re-search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #0f172a;
  min-width: 0;
  padding: 1px 0;
}
.re-search input::placeholder { color: #94a3b8; }
.re-search input::-webkit-search-cancel-button { display: none; }
.re-search-clear {
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: inline-flex;
  flex-shrink: 0;
}
.re-search-clear:hover { background: #f1f5f9; color: #475569; }
.re-search-match {
  background: #fef08a;
  color: inherit;
  padding: 0;
  border-radius: 2px;
}
.re-search-clear-link {
  border: 0;
  background: transparent;
  color: var(--brand-accent);
  cursor: pointer;
  padding: 0 4px;
  font-size: 12.5px;
  text-decoration: underline;
}

/* Scrollable body */
.re-tree-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  min-height: 0;
}
.re-tree-divider {
  height: 1px;
  background: #eef0f3;
  margin: 6px 4px;
}
.re-tree-state {
  padding: 16px 12px;
  font-size: 12.5px;
  color: #64748b;
  text-align: center;
}
.re-tree-state.is-error { color: #b91c1c; }
.re-tree-state.is-empty { color: #94a3b8; font-style: italic; }

/* Meta-rows: «Все ресурсы» / «Без группы» (несворачиваемые) */
.re-tree-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  text-align: left;
  transition: background 100ms ease-out;
}
.re-tree-meta-row:hover { background: #f1f5f9; }
.re-tree-meta-row.is-active { background: var(--brand-accent-soft); color: var(--brand-accent-deep); font-weight: 600; }
.re-tree-meta-row.is-drag-over {
  background: var(--brand-accent-soft);
  outline: 2px dashed var(--brand-accent);
  outline-offset: -2px;
}
.re-tree-meta-icon {
  color: #94a3b8;
  display: inline-flex;
  flex-shrink: 0;
}
.re-tree-meta-icon.is-amber { color: #d97706; }
.re-tree-meta-name { flex: 1; }
.re-tree-meta-count {
  font-size: 11.5px;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}

/* Expandable groups */
.re-tree-group {
  margin: 2px 0;
  border-radius: 7px;
  transition: background 120ms ease-out;
}
.re-tree-group.is-drag-over {
  background: var(--brand-accent-soft);
  outline: 2px dashed var(--brand-accent);
  outline-offset: -2px;
}
.re-tree-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
  transition: background 100ms ease-out;
}
.re-tree-group-header:hover { background: #f1f5f9; }
.re-tree-chevron {
  color: #94a3b8;
  display: inline-flex;
  width: 14px;
  justify-content: center;
  flex-shrink: 0;
}
.re-tree-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
  display: inline-block;
}
.re-tree-color-dot.is-empty { background: #e2e8f0; }
.re-tree-color-dot.is-amber { background: #f59e0b; }
.re-tree-group-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.re-tree-group-count {
  font-size: 11.5px;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}
.re-tree-group-actions {
  display: none;
  margin-left: 4px;
}
.re-tree-group-header:hover .re-tree-group-actions { display: inline-flex; }
.re-tree-group-body {
  padding: 2px 0 4px 22px;
}

/* Resource rows */
.re-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #475569;
  transition: background 100ms ease-out, opacity 120ms ease-out;
  user-select: none;
}
.re-tree-item:hover { background: #f1f5f9; }
.re-tree-item.is-selected {
  background: var(--brand-accent-soft);
  color: var(--brand-accent-deep);
  font-weight: 500;
}
.re-tree-item.is-dragging { opacity: 0.45; }
.re-tree-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.re-tree-item-badge {
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #64748b;
  text-transform: lowercase;
  flex-shrink: 0;
}
.re-adapter-smart_process { background: #d1fae5; color: #065f46; }
.re-adapter-online_record { background: #dbeafe; color: #1e40af; }
.re-adapter-deal { background: #fef3c7; color: #92400e; }
.re-adapter-none { background: #f1f5f9; color: #64748b; }
/* F86.W6 — голый ресурс (нет основной услуги) = не продаётся. Amber-pill,
   тон премиум (slate/amber), не эмодзи. */
.re-no-service-badge {
  background: #fef3c7;
  color: #92400e;
  text-transform: none;
}

/* Empty drop zone (внутри пустой группы) */
.re-tree-empty-drop {
  padding: 8px 10px;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  margin: 4px 6px;
  text-align: center;
  background: #fafbfc;
  transition: background 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
}
.re-tree-empty-drop.is-drag-over {
  background: var(--brand-accent-soft);
  border-color: var(--brand-accent);
  color: var(--brand-accent-deep);
}

/* F83.W6 — row reorder insert indicator (drag-drop внутри группы) */
.re-tree-item-wrap {
  position: relative;
}
.re-tree-insert-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--brand-accent);
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms ease-out;
}
.re-tree-insert-line.is-before { top: -1px; }
.re-tree-insert-line.is-after { bottom: -1px; }
.re-tree-item-wrap.drop-before .re-tree-insert-line.is-before { opacity: 1; }
.re-tree-item-wrap.drop-after .re-tree-insert-line.is-after { opacity: 1; }
