/* ============================================
   PULSE — Section-Based Email Editor v2
   ============================================ */

/* ── Floating Rich Text Toolbar ── */
.pe-ftbar {
  display: none;
  position: absolute;
  z-index: 9999;
  align-items: center;
  gap: 1px;
  background: #1e1e2e;
  border-radius: 10px;
  padding: 4px 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.06);
  animation: pe-ftbar-in 0.12s ease-out;
}
@keyframes pe-ftbar-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.pe-ftbar button {
  width: 32px; height: 32px; padding: 6px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px;
  background: transparent; cursor: pointer;
  color: #ccc; font-size: 13px; font-weight: 600;
  transition: all 0.1s ease;
  font-family: inherit;
}
.pe-ftbar button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.pe-ftbar button.pe-ftbar-active { background: rgba(10,143,143,0.3); color: #5ef0f0; }
.pe-ftbar button svg { display: block; }
.pe-ftbar-sep {
  width: 1px; height: 18px;
  background: rgba(255,255,255,0.12);
  margin: 0 3px;
  flex-shrink: 0;
}
.pe-ftbar-sm { font-size: 10px !important; }
.pe-ftbar-lg { font-size: 17px !important; }
.pe-ftbar-sel {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #ccc;
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
.pe-ftbar-sel:hover { background: rgba(255,255,255,0.14); color: #fff; }
.pe-ftbar-sel option { background: #1e1e2e; color: #ccc; }

.pe-editor {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  gap: 0;
  min-height: 600px;
  border: 2px solid var(--border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fa;
}

.pe-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.pe-tbtn {
  padding: 6px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.pe-tbtn:hover { background: #f0f0f0; }
.pe-tbtn-primary { background: var(--teal, #0A8F8F); color: #fff; border-color: var(--teal, #0A8F8F); }
.pe-tbtn-primary:hover { opacity: 0.9; }
.pe-sep { width: 1px; height: 24px; background: var(--border, #e5e7eb); margin: 0 6px; }

/* Canvas */
.pe-canvas {
  padding: 20px;
  overflow-y: auto;
  max-height: 75vh;
}

/* Sections */
.pe-section {
  background: #fff;
  border: 2px solid transparent;
  border-radius: 8px;
  margin-bottom: 16px;
  position: relative;
  transition: border-color 0.15s;
}
.pe-section:hover { border-color: #c8d0d8; }

.pe-section-handle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  border-radius: 6px 6px 0 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.pe-section:hover .pe-section-handle { opacity: 1; }

.pe-section-controls { display: flex; gap: 1px; align-items: center; background: #f1f3f5; border-radius: 8px; padding: 2px; }
.pe-section-label { font-size: 11px; color: #888; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; margin-right: 10px; }
.pe-section-layout-label { font-size: 11px; color: #bbb; }

.pe-sbtn {
  width: 32px; height: 32px; padding: 6px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px;
  background: transparent; cursor: pointer;
  font-size: 13px; color: #555;
  transition: all 0.15s ease;
}
.pe-sbtn svg { display: block; }
.pe-sbtn:hover { background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.pe-sbtn:active { transform: scale(0.92); }
.pe-sbtn-danger:hover { background: #fff0f0; color: #dc2626; box-shadow: 0 1px 3px rgba(220,38,38,0.15); }
.pe-sbtn:disabled { opacity: 0.25; cursor: default; pointer-events: none; }

/* Columns */
.pe-columns { padding: 12px; }

.pe-column {
  min-height: 60px;
  border: 2px dashed transparent;
  border-radius: 6px;
  padding: 4px;
  transition: all 0.15s;
}
.pe-column:hover { border-color: #e5e7eb; }
.pe-drag-over { border-color: var(--teal, #0A8F8F) !important; background: rgba(10, 143, 143, 0.04); }

/* Blocks */
.pe-block {
  position: relative;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.pe-block:hover { border-color: #d1d5db; }
.pe-block-selected { border-color: var(--teal, #0A8F8F) !important; box-shadow: 0 0 0 3px rgba(10, 143, 143, 0.1); }
.pe-dragging { opacity: 0.4; }

.pe-block-toolbar {
  position: absolute;
  top: -16px; right: 4px;
  display: none;
  gap: 1px;
  z-index: 5;
  background: #f1f3f5;
  border-radius: 8px;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.pe-block:hover .pe-block-toolbar,
.pe-block-selected .pe-block-toolbar { display: flex; }

.pe-bbtn {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px;
  background: transparent; cursor: pointer;
  font-size: 11px; color: #555;
  transition: all 0.15s ease;
}
.pe-bbtn svg { display: block; }
.pe-bbtn:hover { background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.pe-bbtn:active { transform: scale(0.92); }
.pe-bbtn-danger:hover { background: #fff0f0; color: #dc2626; box-shadow: 0 1px 3px rgba(220,38,38,0.15); }
.pe-bbtn:disabled { opacity: 0.25; cursor: default; pointer-events: none; }

.pe-block-content { min-height: 20px; }
.pe-block-content [contenteditable]:focus { outline: 1px solid var(--teal, #0A8F8F); outline-offset: 1px; border-radius: 2px; }
.pe-block-content [contenteditable]:focus:not(:focus-visible) { outline: none; }
.pe-block-content [contenteditable] { cursor: text; }

/* Add buttons */
.pe-add-block, .pe-add-section {
  padding: 12px;
  border: 2px dashed #ddd;
  border-radius: 8px;
  text-align: center;
  color: #bbb;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.25s ease;
}
.pe-add-block { padding: 8px; margin-top: 4px; opacity: 0.4; }
.pe-add-block:hover { opacity: 0.8; border-color: var(--teal, #0A8F8F); color: var(--teal, #0A8F8F); background: rgba(10, 143, 143, 0.03); }
.pe-add-section:hover {
  border-color: var(--teal, #0A8F8F);
  color: var(--teal, #0A8F8F);
  background: rgba(10, 143, 143, 0.03);
}

/* Image placeholder */
.pe-image-placeholder {
  padding: 32px;
  background: #f8f9fa;
  border: 2px dashed #ddd;
  border-radius: 8px;
  text-align: center;
  color: #999;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.pe-image-placeholder:hover { border-color: var(--teal, #0A8F8F); }
.pe-img-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #333;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pe-img-btn:hover { border-color: var(--teal, #0A8F8F); color: var(--teal, #0A8F8F); background: rgba(10,143,143,0.04); }

/* Properties Panel */
.pe-props {
  background: #fff;
  border-left: 1px solid var(--border, #e5e7eb);
  overflow-y: auto;
  max-height: 75vh;
}
.pe-props-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: #bbb;
  font-size: 14px;
}
.pe-props-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: #f8f9fa;
}
.pe-props-type { font-weight: 700; font-size: 14px; }
.pe-props-body { padding: 12px 16px; }

.pe-prop { margin-bottom: 14px; }
.pe-prop label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pe-prop input[type="text"],
.pe-prop input[type="url"],
.pe-prop input[type="number"],
.pe-prop select,
.pe-prop textarea {
  width: 100%;
  padding: 8px 11px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #e5e5e5;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.pe-prop input:focus, .pe-prop select:focus, .pe-prop textarea:focus {
  border-color: #0A8F8F;
  box-shadow: 0 0 0 2px rgba(10,143,143,0.15);
}
.pe-prop input[type="color"] { background: transparent; border: none; padding: 0; }
.pe-prop input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.pe-prop input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #0A8F8F;
  border-radius: 50%;
  cursor: pointer;
}
.pe-prop input[type="checkbox"] { width: auto; margin-right: 6px; }
.pe-prop select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; appearance: none; }

/* Tag / option button selector */
.pe-tag-select {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pe-tag-btn {
  flex: 1;
  min-width: fit-content;
  padding: 6px 10px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 7px;
  color: #aaa;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.pe-tag-btn:hover { border-color: #0A8F8F; color: #0A8F8F; }
.pe-tag-btn.active { background: rgba(10,143,143,0.15); border-color: #0A8F8F; color: #0A8F8F; }

/* Alignment buttons */
.pe-align-btns { display: flex; gap: 4px; }
.pe-align-btn {
  flex: 1;
  padding: 7px 8px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 7px;
  color: #aaa;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.pe-align-btn:hover { border-color: #0A8F8F; color: #0A8F8F; }
.pe-align-btn.active { background: rgba(10,143,143,0.15); border-color: #0A8F8F; color: #0A8F8F; }

/* Toggle switch */
.pe-prop-toggle { display: flex; align-items: center; justify-content: space-between; }
.pe-prop-toggle label:first-child { margin-bottom: 0; }
.pe-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.pe-switch input { opacity: 0; width: 0; height: 0; }
.pe-switch-slider {
  position: absolute; inset: 0;
  background: #333; border-radius: 20px; cursor: pointer;
  transition: background 0.2s;
}
.pe-switch-slider:before {
  content: ''; position: absolute;
  width: 14px; height: 14px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.pe-switch input:checked + .pe-switch-slider { background: #0A8F8F; }
.pe-switch input:checked + .pe-switch-slider:before { transform: translateX(16px); }

/* Section divider in props */
.pe-section-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 12px;
}
.pe-section-divider span {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: #555; white-space: nowrap;
}
.pe-section-divider::before, .pe-section-divider::after {
  content: ''; flex: 1; height: 1px; background: #2a2a2a;
}

/* Color prop inline layout */
.pe-prop-color { }
.pe-prop-color > div { display: flex; align-items: center; gap: 8px; }

/* Block Picker Overlay */
.pe-picker-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.pe-picker {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}
.pe-picker h3 { margin: 0 0 16px; font-size: 18px; }
.pe-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.pe-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 2px solid #eee;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.pe-picker-item:hover {
  border-color: var(--teal, #0A8F8F);
  background: rgba(10, 143, 143, 0.04);
}
.pe-picker-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: #f0f7f7;
  border-radius: 10px;
  color: #0A8F8F;
}
.pe-picker-icon svg { width: 24px; height: 24px; }
.pe-picker-item:hover .pe-picker-icon {
  background: #0A8F8F;
  color: #fff;
}
.pe-picker-label { font-size: 12px; font-weight: 600; color: #444; }

/* Idle panel stats + quick add */
.pe-stat-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: #f0f7f7;
  color: #0A8F8F;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}
.pe-quick-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  transition: all 0.15s;
}
.pe-quick-add-btn:hover {
  border-color: #0A8F8F;
  color: #0A8F8F;
  background: rgba(10,143,143,0.04);
}
.pe-quick-add-btn svg { width: 16px; height: 16px; }

/* Responsive */
@media (max-width: 768px) {
  .pe-editor { grid-template-columns: 1fr; }
  .pe-props { max-height: 300px; border-left: none; border-top: 1px solid var(--border, #e5e7eb); }
}

/* ── Campaign Editor — Clean Layout ── */

/* Email canvas: white email centered on dark bg */
#campEmailWrap .pe-editor {
  display: block; /* single column — no grid */
  border: none;
  border-radius: 0;
  min-height: 500px;
  background: #f0f0f0;
  overflow: visible;
}

/* Toolbar: light themed */
#campEmailWrap .pe-toolbar {
  background: #ebebeb;
  border-bottom: 1px solid #ddd;
}
#campEmailWrap .pe-tbtn { background: #e4e4e4; border-color: #d5d5d5; color: #444; }
#campEmailWrap .pe-tbtn:hover { background: #d8d8d8; color: #111; }
#campEmailWrap .pe-sep { background: #d5d5d5; }

/* Canvas area: soft off-white */
#campEmailWrap .pe-canvas {
  background: #f0f0f0;
  max-height: none;
  overflow-y: visible;
  padding: 20px;
}

/* Sections stay white for contrast */
#campEmailWrap .pe-section {
  background: #fff;
  border: 1px solid #e8e8e8;
}

/* Add Block placeholder — visible on off-white */
#campEmailWrap .pe-add-block {
  border: 2px dashed #bbb !important;
  color: #999 !important;
  background: rgba(0,0,0,0.03) !important;
}
#campEmailWrap .pe-add-block:hover {
  border-color: #0A8F8F !important;
  color: #0A8F8F !important;
  background: rgba(10,143,143,0.06) !important;
}

/* Add Section — same treatment */
#campEmailWrap .pe-add-section {
  border-color: #bbb;
  color: #999;
}

/* Hide internal props panel — we use campPropsPanel instead */
#campEmailWrap .pe-props,
#campEmailWrap .pe-props-empty { display: none !important; }

/* Props panel in right tab — dark themed */
#campPropsPanel .pe-props,
#campPropsPanel .pe-props-empty {
  background: transparent;
  border: none;
  max-height: none;
  overflow: visible;
  color: #ccc;
}
#campPropsPanel .pe-props-header { background: #1e1e1e; border-bottom: 1px solid #2a2a2a; }
#campPropsPanel .pe-props-type { color: #fff; }
#campPropsPanel .pe-props-body { padding: 12px 16px; }
#campPropsPanel .pe-prop label { color: #888; display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
#campPropsPanel .pe-prop { margin-bottom: 12px; }
#campPropsPanel .pe-prop input,
#campPropsPanel .pe-prop select,
#campPropsPanel .pe-prop textarea {
  width: 100%; background: #222; border: 1px solid #333; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; color: #fff; font-family: inherit;
  outline: none; box-sizing: border-box;
}
#campPropsPanel .pe-prop input:focus,
#campPropsPanel .pe-prop select:focus,
#campPropsPanel .pe-prop textarea:focus { border-color: #0A8F8F; }
#campPropsPanel .pe-prop input[type="color"] { height: 36px; padding: 2px 4px; }
#campPropsPanel .pe-prop input[type="checkbox"] { width: auto; margin-right: 6px; }
#campPropsPanel .pe-props-empty { display: flex !important; flex-direction: column; align-items: center; justify-content: flex-start; padding: 20px 16px; color: #444; }
#campPropsPanel .pe-sbtn { background: none; border: none; color: #888; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 4px; }
#campPropsPanel .pe-sbtn:hover { color: #fff; background: #333; }

/* Stat chips */
.pe-stat-chip { background: #2a2a2a; color: #aaa; font-size: 11px; padding: 4px 8px; border-radius: 20px; font-weight: 600; }

/* Quick-add block buttons in props panel */
.pe-quick-add-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: #222; border: 1px solid #2a2a2a; border-radius: 8px;
  color: #ccc; font-size: 12px; font-family: inherit; cursor: pointer;
  transition: all 0.15s; text-align: left; width: 100%; box-sizing: border-box;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.pe-quick-add-btn:hover { background: #2a2a2a; color: #fff; border-color: #0A8F8F; }
