/* ──────────────────────────────────────────────────────────────
   Chatbot — list of flows (cards) + visual flow editor (canvas)
   Used by: /chatbot (list) and /chatbot/{id}/editor (editor)
   ────────────────────────────────────────────────────────────── */

/* ── List of flows ─────────────────────────────────────── */
.cb-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  padding: 18px 24px 24px;
}

.cb-card {
  background: var(--wt-card);
  border: 1px solid var(--wt-border);
  border-radius: 10px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.cb-card:hover {
  border-color: var(--wt-border-2);
  transform: translateY(-1px);
  box-shadow: var(--wt-shadow);
}

.cb-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.cb-card-title {
  margin: 0;
  font-family: var(--wt-font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--wt-fg);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.cb-card-desc {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--wt-fg-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cb-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.cb-card-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--wt-border);
}
.cb-card-kw {
  display: inline-flex;
  align-items: center;
  font-family: var(--wt-font-mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--wt-bg-3);
  color: var(--wt-fg-3);
}

.cb-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--wt-border);
}
.cb-card-actions > .ct-btn-ghost,
.cb-card-actions > .ct-btn-primary {
  flex: 1;
  height: 30px;
  font-size: 11.5px;
  justify-content: center;
}

/* ── Flow editor ───────────────────────────────────────── */
.cb-editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px); /* topbar height */
  background: var(--wt-bg);
  color: var(--wt-fg);
  font-family: var(--wt-font);
  margin: -1.5rem; /* undo wt-shell-content padding */
  overflow: hidden;
}

.cb-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: 52px;
  background: var(--wt-card);
  border-bottom: 1px solid var(--wt-border);
  flex-shrink: 0;
}
.cb-editor-back {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wt-border);
  background: var(--wt-bg-2);
  color: var(--wt-fg-2);
  border-radius: var(--wt-r);
  cursor: pointer;
  flex-shrink: 0;
}
.cb-editor-back:hover { background: var(--wt-bg-3); color: var(--wt-fg); }
.cb-editor-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cb-editor-title-text {
  font-family: var(--wt-font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--wt-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-editor-version {
  font-family: var(--wt-font-mono);
  font-size: 11px;
  color: var(--wt-fg-4);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--wt-bg-3);
}
.cb-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cb-editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── Palette (left) ────────────────────────────────────── */
.cb-palette {
  width: 220px;
  flex-shrink: 0;
  background: var(--wt-bg-2);
  border-right: 1px solid var(--wt-border);
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cb-palette-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wt-fg-4);
  padding: 2px 6px 6px;
}
.cb-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 8px;
  background: var(--wt-card);
  border: 1px solid var(--wt-border);
  border-left: 3px solid currentColor;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--wt-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--wt-fg);
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.cb-palette-item:hover {
  background: var(--wt-bg-3);
  border-color: var(--wt-border-2);
}
.cb-palette-item-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  margin-left: 2px;
}

/* ── Canvas (center) ───────────────────────────────────── */
.cb-canvas {
  flex: 1;
  position: relative;
  overflow: auto;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in oklch, var(--wt-fg-4) 35%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
  background-color: var(--wt-bg);
}
.cb-canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--wt-fg-4);
  font-size: 13px;
  text-align: center;
  padding: 40px;
  pointer-events: none;
}
.cb-canvas-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--wt-bg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.cb-node {
  position: absolute;
  width: 240px;
  background: var(--wt-card);
  border: 1px solid var(--wt-border);
  border-left: 4px solid currentColor;
  border-radius: 9px;
  padding: 10px 12px 11px;
  cursor: pointer;
  user-select: none;
  z-index: 1;
  box-shadow: var(--wt-shadow-sm);
  transition: border-color 0.1s, box-shadow 0.1s, transform 0.1s;
}
.cb-node:hover {
  border-color: var(--wt-border-2);
  box-shadow: var(--wt-shadow);
}
.cb-node.is-selected {
  border-color: var(--wt-primary);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--wt-primary) 30%, transparent);
}
.cb-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.cb-node-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--wt-fg);
}
.cb-node-id {
  font-family: var(--wt-font-mono);
  font-size: 9.5px;
  color: var(--wt-fg-4);
}
.cb-node-preview {
  font-size: 11px;
  color: var(--wt-fg-3);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* ── Properties panel (right) ──────────────────────────── */
.cb-props {
  width: 320px;
  flex-shrink: 0;
  background: var(--wt-card);
  border-left: 1px solid var(--wt-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.cb-props-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--wt-border);
  flex-shrink: 0;
}
.cb-props-title {
  font-family: var(--wt-font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cb-props-body {
  flex: 1;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cb-props-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cb-props-section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wt-fg-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--wt-border);
}
.cb-props-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cb-props-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--wt-fg-4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cb-props-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 24px;
  text-align: center;
  color: var(--wt-fg-4);
  font-size: 12.5px;
}
