/* Gray-Hub Button Builder — visual inline-keyboard editor.
 * Styles designed to mirror the Telegram inline-keyboard look so the
 * builder IS the preview.
 */

.bb-root {
  display: block;
  padding: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
}
.dark .bb-root {
  border-color: #363b45;
  background: linear-gradient(180deg, #13151a, #181b21);
}

.bb-ui {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bb-empty {
  padding: 14px 8px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

/* One row = flex line of chips + "add in row" trailing button */
.bb-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  flex-wrap: wrap;
}

/* Chip — the actual Telegram-style button card */
.bb-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: 42px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  transition:
    border-color 120ms,
    background 120ms,
    transform 80ms,
    box-shadow 120ms;
}
.dark .bb-chip {
  background: #181b21;
  border-color: #363b45;
}
.bb-chip:hover {
  border-color: #6366f1;
  background: #eef2ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.1);
}
.dark .bb-chip:hover {
  background: rgba(99, 102, 241, 0.1);
}
.bb-chip.bb-dragging {
  opacity: 0.4;
}
.bb-chip.bb-drop-hint {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.bb-chip-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.bb-chip-text {
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dark .bb-chip-text {
  color: #e2e8f0;
}
.bb-chip-action {
  font-size: 10px;
  font-weight: 400;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.dark .bb-chip-action {
  color: #94a3b8;
  background: #262a33;
}

/* "+" inline in a row to add another button beside existing ones */
.bb-add-in-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-height: 42px;
  padding: 0;
  background: transparent;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #64748b;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  flex: 0 0 32px;
  transition: border-color 120ms, background 120ms, color 120ms;
}
.bb-add-in-row:hover {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #4f46e5;
}
.dark .bb-add-in-row {
  border-color: #363b45;
  color: #64748b;
}
.dark .bb-add-in-row:hover {
  background: rgba(79, 70, 229, 0.15);
  color: #a5b4fc;
  border-color: #6366f1;
}

/* "+ новый ряд" — full-width dashed add button at bottom */
.bb-add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 4px;
  transition: border-color 120ms, background 120ms, color 120ms;
}
.bb-add-row:hover {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #4f46e5;
}
.dark .bb-add-row {
  border-color: #363b45;
}
.dark .bb-add-row:hover {
  background: rgba(79, 70, 229, 0.15);
  color: #a5b4fc;
  border-color: #6366f1;
}
.bb-add-row-icon {
  font-size: 14px;
  line-height: 1;
}

/* Inline editor popover — floats over the page */
.bb-editor {
  position: absolute;
  z-index: 100;
  width: 320px;
  max-width: calc(100vw - 20px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dark .bb-editor {
  background: #181b21;
  border-color: #262a33;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.bb-editor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bb-editor-field > span {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dark .bb-editor-field > span {
  color: #94a3b8;
}
.bb-editor input,
.bb-editor select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background: #ffffff;
  color: #0f172a;
}
.dark .bb-editor input,
.dark .bb-editor select {
  background: #13151a;
  border-color: #363b45;
  color: #e2e8f0;
}
.bb-editor input:focus,
.bb-editor select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.bb-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}
.dark .bb-editor-actions {
  border-color: #262a33;
}
.bb-editor-actions button {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  transition: background 120ms, border-color 120ms;
}
.dark .bb-editor-actions button {
  color: #cbd5e1;
}
.bb-editor-actions button:hover {
  background: #f1f5f9;
}
.dark .bb-editor-actions button:hover {
  background: #262a33;
}
.bb-editor-save {
  background: #0f172a !important;
  color: #ffffff !important;
}
.bb-editor-save:hover {
  background: #1e293b !important;
}
.dark .bb-editor-save {
  background: #4f46e5 !important;
}
.dark .bb-editor-save:hover {
  background: #4338ca !important;
}
.bb-editor-del {
  color: #b91c1c !important;
}
.bb-editor-del:hover {
  background: #fef2f2 !important;
}
.dark .bb-editor-del:hover {
  background: rgba(239, 68, 68, 0.1) !important;
}
