/* ═══════════════════════════════════════════════════
   BLOCK EDITOR STYLES — Tri-zone layout
   Left palette | Center canvas | Right settings
   ═══════════════════════════════════════════════════ */

.be-container {
  display: flex;
  gap: 0;
  min-height: 300px;
  height: 100%;
}

/* ── Left palette (vertical sidebar) ────────────── */
.be-left-palette {
  width: 160px;
  border-right: 1px solid var(--rule);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
  background: var(--surface);
}

.be-palette-undoredo {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

.be-palette-undoredo .be-palette-item {
  flex: 1;
  justify-content: center;
  font-size: .7rem;
  padding: 4px 6px;
}

.be-palette-section {
  margin-bottom: 16px;
}

.be-palette-section .be-palette-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-4);
  margin-bottom: 6px;
  padding: 0 4px;
}

.be-palette-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: .78rem;
  cursor: grab;
  transition: all .12s;
  text-align: left;
  color: var(--ink-2);
  font-family: var(--font-ui);
}

.be-palette-item:hover {
  background: var(--white);
  border-color: var(--rule);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.be-palette-item:active {
  cursor: grabbing;
  transform: scale(0.95);
}

.be-palette-item[disabled] {
  cursor: default;
  pointer-events: none;
}

/* ── Old horizontal palette (hidden) ────────────── */
.be-palette {
  display: none;
}

/* ── Canvas (center area) ───────────────────────── */
.be-canvas {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.be-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 2px dashed var(--rule);
  border-radius: var(--r-sm);
  color: var(--ink-4);
  font-size: .85rem;
  flex: 1;
}

/* ── Old wrapper (no longer needed) ─────────────── */
.be-wrapper {
  display: flex;
  gap: 12px;
  min-height: 260px;
}

/* ── Block wrapper ───────────────────────────────── */
.be-block {
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}

.be-block:hover {
  border-color: #ccc;
}

.be-block.selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px var(--orange-light);
}

.be-block.dragging {
  opacity: 0.4;
}

.be-block-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 7px 7px 0 0;
  font-size: .72rem;
}

.be-drag-handle {
  cursor: grab;
  color: var(--ink-4);
  font-size: .7rem;
  letter-spacing: -.05em;
  user-select: none;
  padding: 2px 4px;
}

.be-drag-handle:active { cursor: grabbing; }

.be-block-type-label {
  font-weight: 600;
  color: var(--ink-3);
  flex: 1;
}

.be-block-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}

.be-block:hover .be-block-actions,
.be-block.selected .be-block-actions {
  opacity: 1;
}

.be-act {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: .72rem;
  border-radius: 4px;
  color: var(--ink-3);
  transition: all .12s;
  font-family: var(--font-ui);
}

.be-act:hover { background: var(--rule); color: var(--ink); }
.be-act-danger:hover { background: var(--red-bg); color: var(--red); }

.be-block-preview {
  padding: 12px;
  cursor: pointer;
  min-height: 24px;
}

.be-block-preview img {
  pointer-events: none;
}

/* ── Drop indicator ──────────────────────────────── */
.be-drop-indicator {
  height: 3px;
  background: var(--orange);
  border-radius: 2px;
  margin: 2px 0;
}

/* ── Settings panel ──────────────────────────────── */
.be-settings {
  width: 100%;
  border: none;
  background: transparent;
  align-self: flex-start;
  overflow: hidden;
}

.be-settings, .be-settings * {
  max-width: 100%;
  box-sizing: border-box;
}

/* When rendered inline (no sidebar), keep old dimensions */
.be-container > .be-settings {
  width: 240px;
  flex-shrink: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--white);
  position: sticky;
  top: 0;
  max-height: 400px;
}

.be-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 7px 7px 0 0;
}

.be-settings-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink);
}

.be-settings-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Settings sections (collapsible) ─────────────── */
.be-settings-section {
  margin-bottom: 4px;
}

.be-section-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-4);
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
}

.be-section-title::before {
  content: '\25BC ';
  font-size: .6rem;
}

.be-section-title:hover {
  color: var(--ink-2);
}

.be-settings-section.collapsed .be-section-content {
  display: none;
}

.be-settings-section.collapsed .be-section-title::before {
  content: '\25B6 ';
}

.be-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.be-field-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-3);
}

.be-field-hint {
  font-size: .68rem;
  color: var(--ink-4);
  margin: 0;
}

.be-input {
  font-family: var(--font-ui);
  font-size: .8rem;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
  background: var(--white);
  color: var(--ink);
  transition: border-color .15s;
  width: 100%;
}

.be-input:focus { border-color: var(--orange); }

.be-input-sm { width: 80px; flex-shrink: 0; }

.be-color-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.be-color {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  background: none;
}

.be-align-row {
  display: flex;
  gap: 4px;
}

.be-align-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: var(--white);
  cursor: pointer;
  font-size: .85rem;
  transition: all .12s;
}

.be-align-btn.active,
.be-align-btn:hover {
  border-color: var(--orange);
  background: var(--orange-light);
  color: var(--orange);
}

/* ── Richtext ────────────────────────────────────── */
.be-richtext {
  font-size: .88rem;
  line-height: 1.7;
  color: var(--ink);
  outline: none;
  min-height: 40px;
}

.be-richtext p { margin: 0 0 8px; }
.be-richtext a { color: var(--orange); }
.be-richtext ul, .be-richtext ol { margin: 0 0 8px 20px; }

.be-richtext-toolbar {
  display: flex;
  gap: 3px;
  padding: 4px 0;
  flex-wrap: wrap;
}

/* Variable grid (replaces popup dropdown) */
.be-var-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.be-var-grid-btn {
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  font-size: .7rem;
  font-family: var(--font-mono, monospace);
  cursor: pointer;
  transition: all .12s;
  text-align: center;
  color: var(--ink-3);
}

.be-var-grid-btn:hover {
  background: var(--orange-light, #fef3ee);
  border-color: var(--orange);
  color: var(--orange);
}

/* Floating toolbar (removed — replaced by sidebar toolbar) */
.be-float-toolbar {
  display: none;
}

.be-rt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  font-size: .75rem;
  transition: all .12s;
  font-family: var(--font-ui);
}

.be-rt-btn:hover {
  border-color: var(--orange);
  background: var(--orange-light);
}

/* ── Variable dropdown ────────────────────────────── */
.be-var-dropdown { position: relative; }

.be-var-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  z-index: 100;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  width: 220px;
  max-width: calc(100vw - 40px);
  padding: 4px;
  margin-top: 4px;
}

.be-var-menu.open { display: block; }

.be-var-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .75rem;
  font-family: var(--font-ui);
  color: var(--ink);
  border-radius: 4px;
  text-align: left;
  transition: background .1s;
}

.be-var-item:hover { background: var(--orange-light); color: var(--orange); }
.be-var-item span { color: var(--ink-4); font-size: .68rem; margin-left: auto; }

.be-var-trigger-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--rule);
  border-radius: 6px;
  background: var(--white);
  cursor: pointer;
  font-size: .75rem;
  transition: all .12s;
  flex-shrink: 0;
}

.be-var-trigger-sm:hover {
  border-color: var(--orange);
  background: var(--orange-light);
}

.be-input-with-var {
  display: flex;
  gap: 4px;
  align-items: center;
}

.be-input-with-var .be-input { flex: 1; }

/* ── Upload button ────────────────────────────────── */
.be-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1.5px dashed var(--rule);
  background: var(--surface);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 500;
  color: var(--ink-3);
  transition: all .15s;
  font-family: var(--font-ui);
}

.be-upload-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-light);
}

/* ── Image placeholder ───────────────────────────── */
.be-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  border: 2px dashed var(--rule);
  border-radius: 8px;
  color: var(--ink-4);
  font-size: .82rem;
}

/* ── Sidebar empty state ─────────────────────────── */
.be-sidebar-empty {
  padding: 8px 0;
}

/* ── Mobile floating add button ─────────────────── */
.be-mobile-add-btn {
  display: none;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .be-left-palette {
    display: none;
  }
  .be-container > .be-settings {
    width: 100%;
    position: static;
    max-height: none;
  }
  .be-mobile-add-btn {
    display: flex;
    position: fixed;
    bottom: 140px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--orange);
    color: #fff;
    font-size: 1.5rem;
    border: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(232,82,10,.4);
    z-index: 100;
    cursor: pointer;
    touch-action: manipulation;
  }
}

@media (max-width: 700px) {
  .be-wrapper {
    flex-direction: column;
  }
  .be-container > .be-settings {
    width: 100%;
    position: static;
    max-height: none;
  }
}
