/* ════════════════════════════════════════════════════════════════
   Сборники (collections) — наборы моделей для отсматривания
   ════════════════════════════════════════════════════════════════ */

/* Кнопка-триггер в верхней панели — в стиле .dp-trigger */
.cl-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 11px; font-family: var(--font); font-size: 11.5px; font-weight: 500;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); cursor: pointer; white-space: nowrap;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.cl-trigger:hover { color: var(--text-1); border-color: var(--border-hover); }
.cl-trigger.active { color: var(--text-1); border-color: var(--border-focus); }
.cl-trigger-icon { flex-shrink: 0; opacity: 0.85; }
.cl-trigger-count {
  font-family: var(--mono); font-size: 9.5px; color: var(--text-3);
  background: var(--accent-dim); padding: 0 5px; border-radius: 6px; min-width: 14px; text-align: center;
}

/* Чип активного сборника — обычный элемент в строке верхней панели (не плавающий) */
.cl-active-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 6px 0 11px; background: var(--surface);
  border: 1px solid var(--border-focus); border-radius: 999px; box-shadow: var(--shadow-sm);
  font-size: 12px; color: var(--text-1); max-width: 230px;
  animation: cl-chip-in 0.2s var(--ease);
}
.cl-active-chip[hidden] { display: none; }
@keyframes cl-chip-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.cl-active-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.cl-active-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-active-x {
  width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-3); font-size: 17px; line-height: 1;
  border-radius: 50%; cursor: pointer; transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.cl-active-x:hover { background: var(--accent-dim); color: var(--text-1); }

/* Панель сборников — под верхней панелью слева, в стиле .sel-panel */
.collections-panel {
  position: absolute; top: 60px; right: 16px; z-index: 1150;   /* правая вертикальная панель */
  width: 300px; max-width: calc(100% - 32px); max-height: calc(100% - 76px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden;
  animation: cl-panel-in 0.2s var(--ease);
}
.cl-head, .cl-newform { flex: 0 0 auto; }
.collections-panel[hidden] { display: none; }
@keyframes cl-panel-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
.cl-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.cl-title { font-size: 12.5px; font-weight: 600; color: var(--text-1); flex: 1; }
.cl-new-btn {
  font-size: 11.5px; color: var(--text-1); background: var(--accent-dim);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 3px 9px; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.cl-new-btn:hover { border-color: var(--border-hover); }
.cl-panel-close {
  width: 22px; height: 22px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-3); font-size: 18px; line-height: 1;
  border-radius: 50%; cursor: pointer; transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.cl-panel-close:hover { background: var(--accent-dim); color: var(--text-1); }
.cl-newform { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.cl-newform[hidden] { display: none; }
.cl-newinput {
  flex: 1; min-width: 0; font-family: var(--font); font-size: 12px; color: var(--text-1);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 6px 9px; outline: none; transition: border-color 0.15s var(--ease);
}
.cl-newinput:focus { border-color: var(--border-focus); }
.cl-newok {
  font-size: 12px; font-weight: 600; color: var(--text-1); background: var(--accent-dim);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 0 12px; cursor: pointer;
}
.cl-newok:hover { border-color: var(--border-hover); }
.cl-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px; scrollbar-width: thin; scrollbar-color: var(--text-4) transparent; }
.cl-list::-webkit-scrollbar { width: 6px; }
.cl-list::-webkit-scrollbar-thumb { background: var(--text-4); border-radius: 3px; }
.cl-empty { padding: 18px 14px; text-align: center; font-size: 12px; line-height: 1.5; color: var(--text-3); }
.cl-empty[hidden] { display: none; }

.cl-item { border-radius: var(--radius-sm); margin-bottom: 2px; }
.cl-item.active { background: var(--surface-2); }
.cl-item-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background 0.12s var(--ease);
}
.cl-item-row:hover { background: var(--surface-2); }
.cl-item.active .cl-item-row:hover { background: rgba(0,0,0,0.05); }
.cl-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 1.5px rgba(255,255,255,0.5); }
.cl-item.active .cl-dot { box-shadow: 0 0 0 2px rgba(255,255,255,0.6), 0 0 8px currentColor; }
.cl-name { flex: 0 1 auto; min-width: 0; font-size: 12.5px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-cnt { flex: 0 0 auto; font-family: var(--mono); font-size: 10px; color: var(--text-2); background: var(--accent-dim); padding: 1px 6px; border-radius: 6px; }
.cl-spacer { flex: 1 1 auto; }
.cl-act {
  width: 22px; height: 22px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-3); font-size: 13px; line-height: 1;
  border-radius: var(--radius-xs); cursor: pointer; opacity: 0; transition: opacity 0.12s var(--ease), background 0.12s var(--ease), color 0.12s var(--ease);
}
.cl-item-row:hover .cl-act { opacity: 1; }
.cl-act:hover { background: var(--accent-dim); color: var(--text-1); }
.cl-del:hover { background: rgba(239,68,68,0.14); color: var(--red); }

/* Сводка по активному сборнику — компактная строка пар «label value» (без обрезки) */
.cl-stats { display: flex; flex-wrap: wrap; gap: 3px 14px; padding: 5px 10px 7px 22px; }
.cl-stat { display: inline-flex; align-items: baseline; gap: 5px; }
.cl-stat-l { font-size: 10.5px; color: var(--text-3); }
.cl-stat-v { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text-1); white-space: nowrap; }

.cl-members { max-height: 88px; overflow-y: auto; padding: 2px 6px 6px 22px; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; scrollbar-color: var(--text-4) transparent; }
.cl-members::-webkit-scrollbar { width: 6px; }
.cl-members::-webkit-scrollbar-thumb { background: var(--text-4); border-radius: 3px; }
.cl-members-empty { font-size: 11.5px; color: var(--text-3); padding: 4px 6px; }
.cl-member {
  display: flex; align-items: center; gap: 7px; padding: 3px 6px;
  border-radius: var(--radius-xs); cursor: pointer; transition: background 0.12s var(--ease);
}
.cl-member:hover { background: rgba(0,0,0,0.05); }
.cl-member.missing { opacity: 0.45; }
.cl-member-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cl-member-name { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-member:hover .cl-member-name { color: var(--text-1); }
.cl-member-x {
  width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-4); font-size: 14px; line-height: 1;
  border-radius: 50%; cursor: pointer; opacity: 0; transition: opacity 0.12s var(--ease), background 0.12s var(--ease), color 0.12s var(--ease);
}
.cl-member:hover .cl-member-x { opacity: 1; }
.cl-member-x:hover { background: rgba(239,68,68,0.14); color: var(--red); }

/* Кнопка «В сборник» в карточке модели */
.mcard-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.mcard-collection-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--text-1);
  background: var(--accent-dim); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px; cursor: pointer; transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.mcard-collection-btn:hover { border-color: var(--border-hover); }
.mcard-collection-chevron { opacity: 0.6; }

/* Плавающее меню «В сборник» */
.collection-menu {
  position: fixed; z-index: 4000; width: 240px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden;
  animation: cl-panel-in 0.16s var(--ease);
}
.cm-title { padding: 9px 12px; font-size: 11.5px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border); }
.cm-list { max-height: 240px; overflow-y: auto; padding: 5px; scrollbar-width: thin; scrollbar-color: var(--text-4) transparent; }
.cm-list::-webkit-scrollbar { width: 6px; }
.cm-list::-webkit-scrollbar-thumb { background: var(--text-4); border-radius: 3px; }
.cm-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--text-3); }
.cm-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 8px; border: none; background: transparent; cursor: pointer;
  border-radius: var(--radius-xs); transition: background 0.12s var(--ease);
}
.cm-row:hover { background: var(--surface-2); }
.cm-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 1.5px rgba(255,255,255,0.5); }
.cm-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-row.in .cm-name { color: var(--text-2); }
.cm-check { font-size: 13px; color: var(--green); width: 14px; text-align: center; }
.cm-new { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.cm-new-input {
  flex: 1; min-width: 0; font-family: var(--font); font-size: 12px; color: var(--text-1);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 6px 9px; outline: none; transition: border-color 0.15s var(--ease);
}
.cm-new-input:focus { border-color: var(--border-focus); }
.cm-new-ok {
  font-size: 12px; font-weight: 600; color: var(--text-1); background: var(--accent-dim);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 0 12px; cursor: pointer;
}
.cm-new-ok:hover { border-color: var(--border-hover); }

/* ── Мобильная адаптация (телефоны) ───────────────────────────── */
@media (max-width: 600px) {
  /* панель сборников — нижняя «шторка» с ограниченной высотой (не на всю карту) */
  .collections-panel {
    top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-width: none;
    max-height: 56vh;
  }
  .cl-active-chip { max-width: 150px; }
  .cl-members { max-height: 110px; }
  .collection-menu { max-width: calc(100vw - 16px); }
}

/* ── Только просмотр для не-админов: прячем всё управление сборниками ── */
body:not(.is-admin) .cl-new-btn,
body:not(.is-admin) .cl-newform,
body:not(.is-admin) .cl-act,
body:not(.is-admin) .mcard-actions,
body:not(.is-admin) #sbToCollection { display: none !important; }
