/* ---------- BUILDER PAGE ---------- */
/* the canvas utility toolbar (undo/redo, selection, delete/view
   code/clear) and the "add element" palette are shared components,
   see .canvas-toolbar and .palette-panel in the shared dashboard.css.
   Logic uses the exact same pieces for its own toolbar/node palette. */

/* ---------- CANVAS ---------- */

.builder-workspace{
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.builder-canvas-wrap{
  flex: 1;
  min-width: 0;
  height: calc(100vh - 280px);
  min-height: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  position: relative; /* anchors .builder-live-preview below */
}

/* live preview (.builder-live-preview and friends) now lives in the
   shared dashboard.css, since Logic uses the exact same overlay for
   its own live preview. */

/* property panel styles now live in the shared dashboard.css, since
   both Builder and Logic use this same right-side panel component */

.builder-canvas{
  width: 100%;
  max-width: 720px;
  min-height: 480px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-md);
  padding: 20px;
  cursor: default;
  position: relative;
}

.builder-empty{
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: #9099a8;
  font-family: var(--sans);
  font-size: 13px;
  padding: 40px 20px;
}

/* ---------- CANVAS ELEMENTS ---------- */
/* these render against the white canvas, so they use their own
   light-mode-ish tones rather than the app's dark theme variables */

.b-element{
  position: absolute;
  border: 1.5px dashed transparent;
  border-radius: 4px;
  padding: 4px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  cursor: grab;
  user-select: none;
}

.b-element:hover{
  border-color: #d0d5dd;
  box-shadow: 0 2px 10px -4px rgba(20,23,31,0.25);
}

.b-element.dragging{
  cursor: grabbing;
  opacity: 0.85;
  z-index: 10;
  transition: none;
  box-shadow: 0 14px 30px -10px rgba(20,23,31,0.4);
}

.b-element.selected{
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12), 0 4px 16px -6px rgba(108,99,255,0.4);
}

.b-element:focus-visible{
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.25);
}

.b-element-tag{
  position: absolute;
  top: -9px;
  left: 6px;
  background: linear-gradient(155deg, var(--accent-2) 0%, var(--accent) 55%);
  color: #14171F;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 4px;
  opacity: 0;
  box-shadow: 0 2px 6px -2px rgba(108,99,255,0.5);
  transition: opacity 0.15s var(--ease);
}

.b-element.selected .b-element-tag{ opacity: 1; }

.b-text{
  color: #1a1d24;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

.b-image-placeholder{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 140px;
  background: #f2f4f7;
  border: 1.5px dashed #c7cdd6;
  border-radius: var(--radius-sm);
  color: #8b93a6;
  font-family: var(--sans);
  font-size: 12px;
}

.b-image-placeholder svg{ width: 28px; height: 28px; }

.b-button{
  display: inline-block;
  background: linear-gradient(155deg, var(--accent-2) 0%, var(--accent) 55%);
  color: #14171F;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px -4px rgba(108,99,255,0.4);
}

.b-container{
  min-height: 70px;
  border: 1.5px dashed #c7cdd6;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9099a8;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- RESIZE HANDLES ---------- */
/* only visible on the currently selected element */

.b-resize-handle{
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--accent);
  border: 1.5px solid #ffffff;
  border-radius: 2px;
  display: none;
  z-index: 5;
  box-shadow: 0 1px 4px rgba(20,23,31,0.35);
  transition: transform 0.15s var(--ease);
}

.b-element.selected .b-resize-handle{ display: block; }

.b-resize-handle:hover{ transform: scale(1.25); }

.b-resize-handle.tl{ top: -5px; left: -5px; cursor: nwse-resize; }
.b-resize-handle.tr{ top: -5px; right: -5px; cursor: nesw-resize; }
.b-resize-handle.bl{ bottom: -5px; left: -5px; cursor: nesw-resize; }
.b-resize-handle.br{ bottom: -5px; right: -5px; cursor: nwse-resize; }

/* touch fingertips are much wider than a mouse cursor, and a 9px handle
   is nearly unhittable, so grow the hit target (via padding-created
   transparent border, not the visible size) on coarse-pointer input. */
@media (pointer: coarse){
  .b-resize-handle{
    width: 20px;
    height: 20px;
    background-clip: content-box;
    border-width: 7px;
    border-color: transparent;
  }
  .b-resize-handle.tl{ top: -12px; left: -12px; }
  .b-resize-handle.tr{ top: -12px; right: -12px; }
  .b-resize-handle.bl{ bottom: -12px; left: -12px; }
  .b-resize-handle.br{ bottom: -12px; right: -12px; }
}

/* ---------- NEW ELEMENT TYPES (7.4) ---------- */

.b-heading{
  color: #1a1d24;
  font-family: var(--sans);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
}

.b-link{
  display: inline-block;
  color: #2563eb;
  font-family: var(--sans);
  font-size: 14px;
  text-decoration: underline;
}

.b-divider{
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.b-divider-line{
  width: 100%;
  height: 2px;
  background: #d0d5dd;
}

.b-input{
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f9fafb;
  border: 1.5px solid #d0d5dd;
  border-radius: var(--radius-sm);
  color: #9099a8;
  font-family: var(--sans);
  font-size: 13px;
}

/* ---------- CODE VIEW MODAL ---------- */

/* .code-view now lives in the shared dashboard.css, since Logic's
   "View flow code" modal uses it too */

/* ---------- SAVE ROW ---------- */

/* .save-filename-input now lives in the shared dashboard.css, since
   Logic's save row uses it too */

.save-filename-input:focus{ border-color: var(--accent); }

/* ---------- RESPONSIVE ---------- */

@media (max-width: 1024px){
  .builder-workspace{ flex-direction: column; }
  .builder-canvas-wrap{ height: 60vh; }
}