#cb-form-builder {
  height: 100vh;
}

s-app-nav {
  display: none;
}

.cb-admin-form-builder-preview {
  background: #f4f6f8;
  height: calc(100vh - 109px);
  overflow-y: auto;
  padding: 24px;
  position: relative;   /* stable positioning anchor for float/popup */
  box-sizing: border-box;
}

/* When the theme-template banner is shown above the preview, it consumes ~48px.
   Shrink the preview so its bottom stays inside the viewport and the float
   button / popup modal anchor to the correct (visible) bounds. */
.cb-admin-form-builder-preview.cb-has-banner {
  height: calc(100vh - 157px);
}

/* ── Header / Footer HoverEditWrapper (admin only) ── */
.hew-wrapper {
  position: relative;
  border-radius: 6px;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
  overflow: visible;
  /* No border/margin/padding — zero layout impact in edit mode */
}

.hew-wrapper:hover {
  box-shadow: inset 0 0 0 1.5px rgba(0, 93, 215, 0.45);
  background-color: rgba(0, 93, 215, 0.01);
}

.hew-wrapper.hew-selected {
  box-shadow: inset 0 0 0 1.5px #005dd7, 0 0 0 1px rgba(0, 93, 215, 0.15) !important;
  background-color: rgba(0, 93, 215, 0.03) !important;
}

/* Toolbar pill — same dark charcoal as row toolbars */
.hew-toolbar {
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  background: #222222;
  color: #ffffff;
  border-radius: 6px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  pointer-events: none;
}

.hew-wrapper.hew-selected .hew-toolbar {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.hew-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffffff;
  user-select: none;
}

/* Sortable Preview Block Admin Hover Effects */
.preview-block-wrapper {
  position: relative;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
  border-radius: 6px;
  width: 100%;
  /* No border/margin/padding — keeps spacing identical between edit and view mode.
     Visual ring uses inset box-shadow which takes zero layout space. */
  overflow: visible;
}

.preview-block-wrapper.admin-mode:hover {
  box-shadow: inset 0 0 0 1.5px rgba(0, 93, 215, 0.45);
  background-color: rgba(0, 93, 215, 0.01);
}

.preview-block-wrapper.admin-mode.selected {
  box-shadow: inset 0 0 0 1.5px #005dd7, 0 0 0 1px rgba(0, 93, 215, 0.15) !important;
  background-color: rgba(0, 93, 215, 0.03) !important;
}

/* ── Toolbar (dark pill) ── */
.preview-block-toolbar {
  position: absolute;
  background: #222222;
  color: #ffffff;
  border-radius: 6px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  pointer-events: none;
}

/* Standalone block (row-level) — toolbar floats centered ABOVE */
.preview-block-wrapper:not(.row-item) > .preview-block-toolbar {
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
}

/* Row item (element inside a row) — toolbar sits INSIDE at top-right corner */
.preview-block-wrapper.row-item > .preview-block-toolbar {
  top: 4px;
  right: 4px;
  left: auto;
  transform: none;
  border-radius: 4px;
  padding: 3px 8px;
  gap: 6px;
}

/* Show toolbar on hover and on selected */
.preview-block-wrapper.admin-mode:hover > .preview-block-toolbar,
.preview-block-wrapper.admin-mode.selected > .preview-block-toolbar {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Hidden element — dimmed in admin preview */
.preview-block-wrapper.admin-mode.el-hidden {
  opacity: 0.38;
  filter: grayscale(0.4);
}

/* ── Toolbar Buttons ── */
.preview-block-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.preview-block-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.preview-block-btn.delete-btn {
  color: #ff6b6b;
}

.preview-block-btn.delete-btn:hover {
  background: rgba(255, 77, 77, 0.22);
  color: #ff8888;
}

.preview-block-btn.drag-handle {
  cursor: move;
  color: rgba(255, 255, 255, 0.65);
}

.preview-block-btn.drag-handle:hover {
  color: #ffffff;
}

/* ── Border Plus Buttons ── */
.border-plus-btn {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #005dd7;
  color: #ffffff;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 210;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, background-color 0.15s ease, transform 0.15s ease;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 93, 215, 0.35);
  line-height: 1;
}

.border-plus-btn:hover {
  background: #0047b0;
  box-shadow: 0 0 0 4px rgba(0, 93, 215, 0.16), 0 3px 8px rgba(0, 93, 215, 0.45);
}

.border-plus-btn svg {
  display: block;
  flex-shrink: 0;
}

/* Position — Row-level blocks (top / bottom) */
.border-plus-btn.top-center {
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
}
.border-plus-btn.top-center:hover {
  transform: translate(-50%, -50%) scale(1.18);
}

.border-plus-btn.bottom-center {
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 50%);
}
.border-plus-btn.bottom-center:hover {
  transform: translate(-50%, 50%) scale(1.18);
}

/* Position — Row-item elements (left / right) */
.border-plus-btn.left-center {
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
}
.border-plus-btn.left-center:hover {
  transform: translate(-50%, -50%) scale(1.18);
}

.border-plus-btn.right-center {
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
}
.border-plus-btn.right-center:hover {
  transform: translate(50%, -50%) scale(1.18);
}

/* Show border-plus-btns on hover */
.preview-block-wrapper.admin-mode:hover > .border-plus-btn {
  opacity: 1;
  visibility: visible;
}

/* ── Insertion Line Indicators ─────────────────────────────────
   Uses :has() so the line lives on the wrapper, not the button.
   admin-mode scoped → never visible in front-end extension.
   row-item vs non-row-item are mutually exclusive so
   ::before / ::after pseudo-elements never conflict.
──────────────────────────────────────────────────────────────── */

/* Top insertion line — top-level block */
.preview-block-wrapper.admin-mode:not(.row-item):has(> .border-plus-btn.top-center:hover)::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #005dd7 20%, #005dd7 80%, transparent);
  border-radius: 1px;
  z-index: 205;
  pointer-events: none;
}

/* Bottom insertion line — top-level block */
.preview-block-wrapper.admin-mode:not(.row-item):has(> .border-plus-btn.bottom-center:hover)::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #005dd7 20%, #005dd7 80%, transparent);
  border-radius: 1px;
  z-index: 205;
  pointer-events: none;
}

/* Left insertion line — element inside a row */
.preview-block-wrapper.row-item.admin-mode:has(> .border-plus-btn.left-center:hover)::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 10%;
  bottom: 10%;
  width: 2px;
  background: linear-gradient(180deg, transparent, #005dd7 20%, #005dd7 80%, transparent);
  border-radius: 1px;
  z-index: 205;
  pointer-events: none;
}

/* Right insertion line — element inside a row */
.preview-block-wrapper.row-item.admin-mode:has(> .border-plus-btn.right-center:hover)::after {
  content: '';
  position: absolute;
  right: -2px;
  top: 10%;
  bottom: 10%;
  width: 2px;
  background: linear-gradient(180deg, transparent, #005dd7 20%, #005dd7 80%, transparent);
  border-radius: 1px;
  z-index: 205;
  pointer-events: none;
}

/* ── Row-level Visual Layout ── */
.preview-block-wrapper.row-item {
  /* Do NOT force width:100% — let the grid/flex parent control sizing */
  box-sizing: border-box;
  margin: 0;
}

/* ── Add Element Button (inside row) ── */
.row-add-btn-wrap {
  grid-column: span 12;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 6px 8px 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.df-row:hover .row-add-btn-wrap {
  opacity: 1;
  pointer-events: auto;
}

/* Inline Plus Button Insertion Line */
.inline-insert-separator {
  position: relative;
  height: 12px;
  margin: 2px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.inline-insert-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #005dd7 15%, #005dd7 85%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.inline-insert-btn-wrap {
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.inline-insert-separator:hover .inline-insert-line {
  opacity: 1;
}

.inline-insert-separator:hover .inline-insert-btn-wrap {
  opacity: 1;
  transform: scale(1);
}

/* Row-level Visual Layout Elements */
.preview-block-wrapper.row-item {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.row-add-btn-wrap {
  grid-column: span 12;
  display: flex;
  justify-content: flex-end;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.df-row:hover .row-add-btn-wrap {
  opacity: 1;
  pointer-events: auto;
}

/* Device View wrappers */

/* Desktop: block fill — height: 100% resolves correctly in a block container. */
.cb-device-frame--desktop {
  height: 100%;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}


/* In view mode (no df-admin class on df-root), give df-root the same scroll
   behavior as edit mode so the form looks identical in both modes. */
.cb-admin-form-builder-preview .cb-device-frame--desktop .df-root:not(.df-admin) {
  height: 100%;
  overflow-y: auto;
}

/* Mobile: phone shell centered with margin auto in the block container */
.cb-device-frame--mobile {
  width: 390px;
  height: 720px;
  margin: 0 auto;
  border: 14px solid #1a1a1a;
  border-radius: 48px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22), 0 0 0 2px rgba(0,0,0,0.06);
  background: #fff;
  position: relative;   /* anchor for absolute popup/float children */
  isolation: isolate;   /* contain popup z-index stack within this frame */
}

/* Form scrolls inside the phone shell */
.cb-device-frame--mobile .df-root {
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Admin preview: contain float/popup inside the preview area ─────────────
   cb-admin-form-builder-preview only exists in the admin, never on the frontend.
   cb-device-frame--desktop has position:relative + overflow:hidden, so these
   absolutely-positioned elements are clipped to the device frame bounds.
───────────────────────────────────────────────────────────────────────────── */
.cb-admin-form-builder-preview .df-float-btn {
  position: absolute !important;
  z-index: 1 !important; /* behind the float panel (99999) so the icon sits under the form */
}
.cb-admin-form-builder-preview .df-float-panel {
  position: absolute !important;
  max-height: calc(100% - 40px) !important;   /* stay inside the preview */
  /* width comes from the form's own formWidth (inline style) */
}
.cb-admin-form-builder-preview .df-popup-overlay {
  position: absolute !important;
  inset: 0 !important;
}

/* ── Admin preview scroll containment ──────────────────────────────────────
   The base layouts use viewport units (boxed: min-height:100vh, modal:
   max-height:82vh) which are TALLER than the preview frame. Inside the admin
   preview the frame is the real viewport, so constrain everything to it and let
   the inner element scroll — no content gets clipped and the top stays visible. */

/* Default & Boxed: df-root fills the frame exactly and scrolls internally,
   in both edit (df-admin) and view mode. Kills the boxed min-height:100vh. */
.cb-admin-form-builder-preview .df-root.df-layout-default,
.cb-admin-form-builder-preview .df-root.df-layout-boxed {
  height: 100% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}

/* Popup modal fits within the preview (82vh overflowed the frame and cut off
   the modal's header) and scrolls its own content. */
.cb-admin-form-builder-preview .df-popup-modal {
  max-height: 100% !important;
}

.cb-device-frame--mobile .df-root::-webkit-scrollbar {
  width: 3px;
}

.cb-device-frame--mobile .df-root::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}