/* Visual Sales Page Editor — Elementor-style */
body.iga-spe-mode { overflow: hidden; }
body.iga-spe-mode .sidebar,
body.iga-spe-mode .topbar { display: none !important; }
body.iga-spe-mode .app-shell { display: block; }
body.iga-spe-mode .main { padding: 0; max-width: none; }

.spe-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #EEF2F7;
  color: #0F172A;
  font-family: var(--font, system-ui, sans-serif);
}
.spe-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
  z-index: 20;
}
.spe-back {
  width: 36px;
  height: 36px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.spe-back:hover { background: #F8FAFC; }
.spe-title-block { min-width: 0; }
.spe-title-block strong { display: block; font-size: 15px; }
.spe-title-block span { font-size: 12px; color: #64748B; }
.spe-toolbar-mid {
  display: flex;
  align-items: center;
  gap: 6px;
}
.spe-tool-btn {
  height: 34px;
  padding: 0 12px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.spe-tool-btn:hover { background: #F8FAFC; }
.spe-tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.spe-toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.spe-device-group {
  display: inline-flex;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
  background: #F8FAFC;
}
.spe-device-btn {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #64748B;
  cursor: pointer;
}
.spe-device-btn.active {
  background: #fff;
  color: #7F1D1D;
  box-shadow: inset 0 0 0 1px #E2E8F0;
}
.spe-save-status {
  font-size: 12px;
  font-weight: 600;
  color: #64748B;
  min-width: 72px;
  text-align: right;
}
.spe-save-status.is-saving { color: #D97706; }
.spe-save-status.is-saved { color: #059669; }
.spe-save-btn {
  background: #7F1D1D;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.spe-save-btn:hover { background: #991B1B; }

.spe-body {
  display: flex;
  flex: 1;
  min-height: 0;
}
.spe-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.spe-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid #E2E8F0;
}
.spe-tab {
  border: 0;
  background: #F8FAFC;
  padding: 12px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #64748B;
  cursor: pointer;
}
.spe-tab.active {
  background: #fff;
  color: #7F1D1D;
  box-shadow: inset 0 -2px 0 #7F1D1D;
}
.spe-panel {
  flex: 1;
  overflow: auto;
  overflow-x: hidden;
  padding: 14px;
  display: none;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #720026 #F5E9DA;
}
.spe-panel::-webkit-scrollbar,
.spe-sidebar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.spe-panel::-webkit-scrollbar-track,
.spe-sidebar::-webkit-scrollbar-track {
  background: #F5E9DA;
  border-radius: 999px;
}
.spe-panel::-webkit-scrollbar-thumb,
.spe-sidebar::-webkit-scrollbar-thumb {
  background: #720026;
  border-radius: 999px;
}
.spe-panel.active { display: block; }
.spe-panel-hint {
  font-size: 12px;
  color: #64748B;
  margin: 0 0 14px;
  line-height: 1.45;
}
.spe-section-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #64748B;
  margin: 16px 0 10px;
}
.spe-block-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.spe-block-card {
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 12px 10px;
  background: #fff;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.spe-block-card:hover {
  border-color: #C4B5FD;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}
.spe-block-card.active {
  border-color: #7F1D1D;
  background: #FFF1F2;
  box-shadow: 0 0 0 2px rgba(127, 29, 29, 0.15);
}
.spe-block-card .ico { font-size: 18px; margin-bottom: 4px; }
.spe-block-card span { display: block; font-size: 12px; font-weight: 700; color: #334155; }
.spe-widget-list { display: flex; flex-direction: column; gap: 6px; }
.spe-widget-item {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.spe-widget-item:hover { background: #FFFBFC; border-color: #FECDD3; }

.spe-layers-tree { list-style: none; margin: 0; padding: 0; }
.spe-layers-tree li { margin: 0; }
.spe-layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.spe-layer-row:hover { background: #F8FAFC; }
.spe-layer-row.active { background: #FFF1F2; color: #7F1D1D; font-weight: 600; }
.spe-layer-row .depth-1 { padding-left: 16px; }
.spe-layer-row .depth-2 { padding-left: 28px; }

.spe-style-group {
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.spe-style-group summary {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  background: #F8FAFC;
  list-style: none;
}
.spe-style-group summary::-webkit-details-marker { display: none; }
.spe-style-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow-x: hidden; }
.spe-offer-box {
  padding: 10px 12px 4px;
  margin: 0 0 12px;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  background: #F8FAFC;
}
.spe-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.spe-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #64748B;
  margin-bottom: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: static;
  line-height: 1.3;
}
.spe-field input,
.spe-field select,
.spe-field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  position: relative;
  z-index: 1;
}
.spe-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}
.spe-align-btns { display: flex; gap: 4px; }
.spe-align-btns button {
  flex: 1;
  padding: 8px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.spe-align-btns button.active { background: #7F1D1D; color: #fff; border-color: #7F1D1D; }

.spe-code-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #64748B;
  margin-bottom: 8px;
}
.spe-code-textarea {
  width: 100%;
  min-height: calc(100vh - 220px);
  padding: 12px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  background: #0F172A;
  color: #E2E8F0;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
  box-sizing: border-box;
}
.spe-code-textarea:focus {
  outline: 2px solid #7F1D1D;
  outline-offset: 1px;
}

.spe-canvas-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.spe-tip-banner {
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 12px;
  font-size: 13px;
  color: #1E40AF;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.spe-tip-banner[hidden] { display: none !important; }
.spe-tip-close {
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #64748B;
  line-height: 1;
}
.spe-canvas-scroll {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background:
    linear-gradient(90deg, rgba(15,23,42,.03) 1px, transparent 1px),
    linear-gradient(rgba(15,23,42,.03) 1px, transparent 1px);
  background-size: 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: #720026 #F5E9DA;
}
.spe-canvas-scroll::-webkit-scrollbar {
  width: 6px;
  height: 0;
}
.spe-device-frame {
  width: 100%;
  max-width: 1440px;
  min-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  transition: max-width .25s ease;
}
.spe-device-frame[data-device="tablet"] { max-width: 768px; }
.spe-device-frame[data-device="phone"] { max-width: 390px; }
.spe-device-frame iframe {
  display: block;
  width: 100%;
  min-height: calc(100vh - 140px);
  border: 0;
  background: #fff;
}

.spe-float-bar {
  position: absolute;
  z-index: 30;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #0F172A;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transform: translate(-50%, -100%);
  pointer-events: auto;
}
.spe-float-bar[hidden] { display: none !important; }
.spe-float-bar button {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.spe-float-bar button:hover { background: rgba(255,255,255,.12); }

.spe-root.spe-preview-mode .spe-sidebar { display: none; }
.spe-root.spe-preview-mode .spe-toolbar-mid,
.spe-root.spe-preview-mode .spe-device-group,
.spe-root.spe-preview-mode .spe-save-status { display: none; }
.spe-preview-back {
  display: none;
  margin-left: auto;
}
.spe-root.spe-preview-mode .spe-preview-back { display: inline-flex; }

.spe-mobile-toggle {
  display: none;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 12px;
}
@media (max-width: 960px) {
  .spe-sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    z-index: 40;
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: 8px 0 30px rgba(15,23,42,.12);
  }
  .spe-sidebar.open { transform: translateX(0); }
  .spe-mobile-toggle { display: inline-flex; }
}
