/* Territory drag and drop: Roles designer. Drag roles to create territories and overlays */

/* ---------- Available roles ---------- */

.bbi-td-roles .bbi-card__head { padding-bottom: 4px; }

.bbi-td-hint {
  padding: 0 18px;
  font-size: 11px;
  white-space: nowrap;
  font-weight: 600;
  color: var(--bbi-muted);
}

.bbi-td-rolelist { padding: 4px 16px 0; }

.bbi-td-group {
  margin: 12px 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bbi-muted);
}

.bbi-td-role {
  --td-role: var(--bbi-indigo);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 10px 0 12px;
  border-radius: 12px;
  border: 1px solid var(--bbi-line);
  border-left: 4px solid var(--td-role);
  background: #fff;
  box-shadow: var(--bbi-shadow-sm);
  transition: opacity 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.bbi-td-role + .bbi-td-role { margin-top: 8px; }

.bbi-td-role__text { min-width: 0; flex: 1; }

.bbi-td-role__text b {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--bbi-ink);
  white-space: nowrap;
}

.bbi-td-role__text b::before {
  content: '';
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--td-role);
}

.bbi-td-role__text small {
  display: block;
  padding-left: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bbi-muted);
}

.bbi-td-grip {
  display: grid;
  grid-template-columns: repeat(2, 3px);
  gap: 3px;
  flex: none;
}

.bbi-td-grip i { width: 3px; height: 3px; border-radius: 50%; background: var(--bbi-faint); }

.bbi-td-role.is-dragging {
  opacity: 0.45;
  border-style: dashed;
  border-left-style: solid;
  box-shadow: none;
}

.bbi-td-clone {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 45;
  margin: 0;
  border-color: rgba(94, 114, 228, 0.35);
  border-left-color: var(--td-role);
  box-shadow: 0 22px 40px -14px rgba(50, 50, 93, 0.45), 0 0 0 4px rgba(94, 114, 228, 0.12);
  pointer-events: none;
  will-change: transform;
}

/* ---------- Tree ---------- */

.bbi-td-tree .bbi-card__head { padding-bottom: 8px; }

.bbi-td-tnode {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  margin: 0 14px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 800;
  color: var(--bbi-ink);
}

.bbi-td-tnode.is-active { background: rgba(94, 114, 228, 0.1); color: var(--bbi-indigo); }

.bbi-td-tcaret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.bbi-td-tempty.bbi-hide { display: none; }

.bbi-td-tempty {
  margin: 10px 0 0 44px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bbi-faint);
}

.bbi-td-kids {
  position: relative;
  margin: 4px 14px 0 30px;
  padding-left: 12px;
}

.bbi-td-kids::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 14px;
  left: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--bbi-line);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bbi-td-kids.is-on::before { opacity: 1; }

.bbi-td-kid {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bbi-muted);
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.bbi-td-kid .bbi-avatar { width: 20px; height: 20px; box-shadow: 0 0 0 2px #fff; }
.bbi-td-kid .bbi-td-ghost { width: 20px; height: 20px; }
.bbi-td-kid .bbi-td-ghost svg { width: 11px; height: 11px; }
.bbi-td-kid.is-owned { color: var(--bbi-ink); }
.bbi-td-kid__text em { font-style: normal; font-weight: 600; color: var(--bbi-muted); }

/* ---------- Workspace ---------- */

.bbi-td-work .bbi-card__head { padding-bottom: 10px; }

.bbi-td-nodelvl {
  position: absolute;
  top: 58px;
  left: 18px;
  right: 18px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 9px 0 12px;
  border-radius: 14px;
  border: 2px dashed transparent;
  background: var(--bbi-surface-2);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.bbi-td-nodelvl.is-hot { border-color: rgba(130, 94, 228, 0.7); background: rgba(130, 94, 228, 0.08); }

.bbi-td-nodelvl__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: #fff;
  color: var(--bbi-muted);
  box-shadow: var(--bbi-shadow-sm);
}

.bbi-td-nodelvl__icon svg { width: 16px; height: 16px; }

.bbi-td-nodelvl__text { min-width: 0; flex: 1; }
.bbi-td-nodelvl__text b { display: block; font-size: 13px; font-weight: 800; color: var(--bbi-ink); line-height: 1.3; }
.bbi-td-nodelvl__text small { display: block; font-size: 11px; font-weight: 600; color: var(--bbi-muted); line-height: 1.35; }

.bbi-td-nlchip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  width: 152px;
  height: 48px;
  flex: none;
  padding: 0 6px 0 10px;
  border-radius: 11px;
  border: 1px solid var(--bbi-line);
  border-left: 4px solid #825ee4;
  background: #fff;
  box-shadow: var(--bbi-shadow-sm);
}

.bbi-td-nlchip em {
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  color: #6b46d6;
  white-space: nowrap;
}

.bbi-td-nlchip .bbi-td-pick { height: 24px; padding: 0 4px 0 0; border: 0; background: none; box-shadow: none; }
.bbi-td-nlchip .bbi-td-pick .bbi-avatar,
.bbi-td-nlchip .bbi-td-pick .bbi-td-ghost { width: 20px; height: 20px; }

.bbi-td-zone {
  position: absolute;
  top: 132px;
  left: 18px;
  right: 18px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  border: 2px dashed rgba(94, 114, 228, 0.35);
  background: rgba(94, 114, 228, 0.03);
  color: var(--bbi-indigo);
  font-size: 13px;
  font-weight: 700;
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s var(--bbi-spring);
}

.bbi-td-zone svg { width: 16px; height: 16px; }

.bbi-td-zone.is-hot {
  border-color: rgba(94, 114, 228, 0.85);
  background: rgba(94, 114, 228, 0.1);
  transform: scale(1.015);
}

.bbi-td-empty {
  position: absolute;
  top: 252px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--bbi-faint);
}

.bbi-td-empty svg { width: 40px; height: 40px; }

.bbi-td-grid {
  position: absolute;
  top: 198px;
  left: 18px;
  right: 18px;
}

.bbi-td-ghead {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding-left: 10px;
  border-left: 4px solid var(--bbi-indigo);
  font-size: 14px;
  font-weight: 800;
  color: var(--bbi-ink);
}

.bbi-td-count {
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  background: rgba(94, 114, 228, 0.12);
  color: var(--bbi-indigo);
  font-size: 12px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}

.bbi-td-cols,
.bbi-td-row {
  display: grid;
  grid-template-columns: 114px 152px 152px;
  column-gap: 8px;
  align-items: center;
}

.bbi-td-cols {
  height: 34px;
  margin-top: 6px;
  padding: 0 4px;
  border-bottom: 1px solid var(--bbi-line);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bbi-muted);
  white-space: nowrap;
}

.bbi-td-secol { display: flex; align-items: center; gap: 6px; padding-left: 8px; border-left: 3px solid #825ee4; }

.bbi-td-secol i {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(94, 114, 228, 0.12);
  color: var(--bbi-indigo);
}

.bbi-td-secol svg { width: 11px; height: 11px; }

.bbi-td-rows { padding: 6px 4px 0; }

.bbi-td-row { height: 50px; }
.bbi-td-row + .bbi-td-row { border-top: 1px solid var(--bbi-line); }

.bbi-td-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bbi-td-name i { width: 10px; height: 10px; flex: none; border-radius: 3px; background: var(--bbi-indigo); }
.bbi-td-name b { font-size: 13px; font-weight: 800; color: var(--bbi-ink); white-space: nowrap; }

/* Rep picker cell (dropdown look) */
.bbi-td-pick {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px 0 6px;
  border-radius: 10px;
  border: 1px solid var(--bbi-line);
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.bbi-td-pick .bbi-avatar { width: 24px; height: 24px; box-shadow: none; }
.bbi-td-pick b { font-size: 13px; font-weight: 700; color: var(--bbi-ink); }
.bbi-td-pick > i { font-style: normal; font-weight: 600; color: var(--bbi-muted); }
.bbi-td-pick.is-open { border-color: rgba(94, 114, 228, 0.7); box-shadow: 0 0 0 3px rgba(94, 114, 228, 0.12); }

.bbi-td-caret {
  margin-left: auto;
  width: 0;
  height: 0;
  flex: none;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--bbi-faint);
}

.bbi-td-ghost {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 1.5px dashed var(--bbi-faint);
  color: var(--bbi-muted);
}

.bbi-td-ghost svg { width: 12px; height: 12px; }

/* Read-only node-level column (inherited from Enterprise) */
.bbi-td-se {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 8px 0 6px;
  border-radius: 10px;
  background: #f4f0ff;
  font-size: 13px;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.bbi-td-se .bbi-avatar { width: 24px; height: 24px; box-shadow: none; }
.bbi-td-se b { font-size: 13px; font-weight: 700; color: var(--bbi-ink); }

/* Ghost rows while territories are created */
.bbi-td-row.is-loading .bbi-td-name b,
.bbi-td-row.is-loading .bbi-td-pick > * {
  visibility: hidden;
}

.bbi-td-row.is-loading .bbi-td-name i,
.bbi-td-row.is-loading .bbi-td-pick {
  border-color: transparent;
  background: linear-gradient(90deg, #eef1f8 0%, #f8f9fd 50%, #eef1f8 100%);
  background-size: 200% 100%;
  animation: bbi-td-shimmer 1s linear infinite;
}

@keyframes bbi-td-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.bbi-td-toast {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px 0 8px;
  border-radius: 12px;
  background: var(--bbi-good-bg);
  color: #12855a;
  font-size: 13px;
  font-weight: 800;
}

.bbi-td-toast__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--bbi-grad-good);
  color: #fff;
}

.bbi-td-toast__icon svg { width: 14px; height: 14px; }

/* ---------- Create Multiple Territories modal ---------- */

.bbi-td-veil {
  position: absolute;
  z-index: 30;
  border-radius: 18px;
  background: rgba(30, 42, 74, 0.16);
  transition: opacity 0.25s ease;
}

.bbi-td-modal {
  position: absolute;
  z-index: 31;
  padding: 18px 20px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--bbi-shadow-lg);
  transition: opacity 0.2s ease;
}

.bbi-td-modal__title {
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--bbi-ink);
}

.bbi-td-modal__title span { margin-left: auto; color: var(--bbi-faint); }
.bbi-td-modal__title svg { width: 16px; height: 16px; display: block; }

.bbi-td-modal p {
  margin: 6px 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--bbi-muted);
}

.bbi-td-modal label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--bbi-ink);
}

.bbi-td-input {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #dfe4ef;
  font-size: 15px;
  font-weight: 700;
  color: var(--bbi-ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bbi-td-input i {
  width: 2px;
  height: 18px;
  margin-left: 2px;
  background: var(--bbi-indigo);
  opacity: 0;
}

.bbi-td-input.is-focus { border-color: rgba(94, 114, 228, 0.7); box-shadow: 0 0 0 3px rgba(94, 114, 228, 0.12); }
.bbi-td-input.is-focus i { animation: bbi-td-blink 0.9s steps(1) infinite; }

@keyframes bbi-td-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.bbi-td-modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.bbi-td-cancel {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #dfe4ef;
  font-size: 13px;
  font-weight: 700;
  color: var(--bbi-muted);
}

.bbi-td-create { height: 36px; padding: 0 16px; font-size: 13px; }

/* ---------- Rep dropdown ---------- */

.bbi-td-dd {
  position: absolute;
  z-index: 40;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--bbi-line);
  background: #fff;
  box-shadow: var(--bbi-shadow-lg);
}

.bbi-td-dd__item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

.bbi-td-dd__item .bbi-avatar { width: 22px; height: 22px; box-shadow: none; }
.bbi-td-dd__item b { font-weight: 700; color: var(--bbi-ink); }
.bbi-td-dd__item.is-hover { background: rgba(94, 114, 228, 0.1); }
