/* ═══════════════════════════════════════════════════════════════
 * 问卷模块 · 悟空对标 v2 · 2026-07-06
 * 5 步向导 + 预览抽屉 + 手机模拟器
 * ═══════════════════════════════════════════════════════════════ */

/* ─────────────────── 主视图（列表页） ─────────────────── */
#surveysView { padding: 16px 24px; }
#surveysView .sv-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0 14px; border-bottom: 1px solid #e5e7eb; margin-bottom: 14px;
}
#surveysView .sv-head h2 { margin: 0; font-size: 18px; color: #1f2937; }
#surveysView .sv-head .sv-actions { display: flex; gap: 8px; }

/* 空状态 */
.sv-empty {
  padding: 60px 20px; text-align: center; color: #6b7280;
  background: #fff; border: 1px dashed #d1d5db; border-radius: 10px;
}
.sv-empty .sv-empty-icon { font-size: 44px; margin-bottom: 8px; }
.sv-empty h3 { margin: 8px 0 4px; color: #1f2937; }
.sv-empty p { margin: 4px 0 16px; font-size: 13px; }

/* 列表页表格化 */
#surveysView .sv-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 12px; flex-wrap: wrap; }
#surveysView .sv-toolbar .sv-search { flex: 0 0 260px; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
#surveysView .sv-toolbar .sv-search:focus { border-color: #0052cc; outline: none; }
#surveysView .sv-actions { display: flex; gap: 8px; }

#surveysView .sv-table-wrap { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; overflow: auto; }
#surveysView .sv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#surveysView .sv-table thead { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
#surveysView .sv-table th, #surveysView .sv-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
#surveysView .sv-table th { font-weight: 600; color: #475569; font-size: 12px; }
#surveysView .sv-table tbody tr:hover { background: #f8fafc; }
#surveysView .sv-table .sv-t-name { color: #0052cc; cursor: pointer; font-weight: 500; }
#surveysView .sv-table .sv-t-name:hover { text-decoration: underline; }
#surveysView .sv-table .sv-t-actions { display: flex; gap: 4px; }
#surveysView .sv-table .sv-t-actions .wk-btn { padding: 2px 8px; font-size: 11.5px; }
#surveysView .sv-table .sv-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
#surveysView .sv-table .sv-tag.yes { background: #dcfce7; color: #166534; }
#surveysView .sv-table .sv-tag.no  { background: #fee2e2; color: #991b1b; }
#surveysView .sv-table .sv-tag.gray { background: #f1f5f9; color: #64748b; }
#surveysView .sv-table .sv-tag.blue { background: #dbeafe; color: #1d4ed8; }
#surveysView .sv-pagi { padding: 10px 14px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; color: #64748b; font-size: 12px; }

/* ─────────────────── 编辑器整页 wizard（可调宽度的右侧抽屉） ─────────────────── */
/* 2026-07-07 · 抽屉边缘对齐客户/联系人详情抽屉：top/bottom 走 --active-topbar-height / --active-pager-height 变量，避开顶部 topbar 和底部分页背景墙（与 .detail-drawer 完全一致）。原写死 top:56px bottom:0 会盖住分页条，视觉不统一 */
.sv-editor-page,
#surveyEditor.sv-editor-page,
#campaignEditor.sv-editor-page {
  position: fixed;
  top: var(--active-topbar-height, 56px);
  right: 0;
  bottom: var(--active-pager-height, 0px);
  width: calc(100vw * 2 / 3); min-width: 480px; max-width: 100vw;
  background: #f5f7fa; z-index: 90;
  display: flex; flex-direction: column;
  box-shadow: -4px 0 18px rgba(9,30,66,.28);
  border-left: 1px solid #dfe1e6;
}
/* 左边缘拖拽条 */
.sv-editor-page .sv-editor-resizer {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
  cursor: ew-resize; background: transparent;
  z-index: 5; transition: background .15s;
}
.sv-editor-page .sv-editor-resizer:hover,
.sv-editor-page .sv-editor-resizer.dragging { background: rgba(0, 82, 204, .35); }
.sv-editor-page.resizing { user-select: none; }
.sv-editor-page.resizing * { pointer-events: none; }
.sv-editor-page.resizing .sv-editor-resizer { pointer-events: auto; }
/* 2026-07-07 · 移除半透明遮罩（.sv-editor-mask） —— 位置写死 left:200px 不跟抽屉宽度联动，视觉上是"背后一片灰带"。抽屉自身已有 box-shadow 分层，与客户/联系人详情抽屉行为对齐。保留兜底 display:none 防止历史缓存里的 mask DOM 显示。 */
.sv-editor-mask { display: none !important; }

.sv-editor-page .sv-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
/* 2026-07-07 · 关闭按钮改用全站统一的 .clue-drawer-close-float（zz_reference_parity.css:147）— 抽屉左侧外挂绿色浮标 × 按钮，与客户/联系人/线索/合同 等详情抽屉完全一致。抽屉本身 position:fixed，close 按钮 position:absolute; left:-32px 会挂到抽屉左边缘外侧。原 .sv-editor-close 已废弃 */
.sv-editor-page .sv-editor-head .wk-tabs { display: flex; gap: 2px; }
.sv-editor-page .sv-editor-head .wk-tabs__item {
  padding: 8px 16px; font-size: 13px; color: #6b7280; cursor: pointer;
  border-bottom: 2px solid transparent; user-select: none;
}
.sv-editor-page .sv-editor-head .wk-tabs__item:hover { color: #0052cc; }
.sv-editor-page .sv-editor-head .wk-tabs__item.active { color: #0052cc; border-bottom-color: #0052cc; font-weight: 600; }
.sv-editor-page .sv-editor-head .sv-editor-actions { display: flex; gap: 8px; align-items: center; }

.sv-editor-page .sv-step-body { flex: 1; overflow: auto; padding: 20px 28px; }

/* 通用表单块 */
#surveyEditor .sv-step-inner { max-width: 780px; margin: 0 auto; }
#surveyEditor .sv-form-title { font-size: 15px; font-weight: 600; color: #1f2937; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid #e5e7eb; }
#surveyEditor .sv-form-row { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 14px; }
#surveyEditor .sv-form-row > label { flex: 0 0 130px; text-align: right; color: #4b5563; font-size: 13px; padding-top: 7px; }
#surveyEditor .sv-form-row > label .req { color: #dc2626; margin-right: 3px; }
#surveyEditor .sv-form-row .sv-form-ctl { flex: 1; }
#surveyEditor .sv-form-row .sv-form-ctl input[type=text],
#surveyEditor .sv-form-row .sv-form-ctl input[type=datetime-local],
#surveyEditor .sv-form-row .sv-form-ctl input[type=number],
#surveyEditor .sv-form-row .sv-form-ctl select,
#surveyEditor .sv-form-row .sv-form-ctl textarea {
  width: 100%; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; box-sizing: border-box; font-family: inherit;
}
#surveyEditor .sv-form-row .sv-form-ctl textarea { min-height: 60px; resize: vertical; }
#surveyEditor .sv-form-row .sv-form-ctl .hint { color: #9ca3af; font-size: 11.5px; margin-top: 3px; }
#surveyEditor .sv-form-row .sv-form-ctl input:focus,
#surveyEditor .sv-form-row .sv-form-ctl select:focus,
#surveyEditor .sv-form-row .sv-form-ctl textarea:focus { border-color: #0052cc; outline: none; }

/* AI 生成面板（沿用） */
.sv-ai-panel {
  background: linear-gradient(135deg, #f0f7ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d9f7; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px;
}
.sv-ai-panel .sv-ai-head { display: flex; align-items: center; gap: 6px; font-weight: 600; color: #0052cc; margin-bottom: 8px; }
.sv-ai-panel .sv-ai-hint { font-size: 12px; color: #4b5563; margin-bottom: 8px; }
.sv-ai-panel .sv-ai-row { display: flex; gap: 8px; align-items: flex-end; }
.sv-ai-panel .sv-ai-row .sv-ai-purpose { flex: 1; }
.sv-ai-panel input, .sv-ai-panel select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.sv-ai-panel .sv-ai-count { width: 90px; }
.sv-ai-panel .sv-ai-btn {
  background: linear-gradient(135deg, #0052cc, #4c1d95); color: #fff;
  border: none; padding: 7px 14px; border-radius: 6px; font-size: 13px; cursor: pointer;
  font-weight: 500; white-space: nowrap;
}
.sv-ai-panel .sv-ai-btn:hover { opacity: .92; }
.sv-ai-panel .sv-ai-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 题目条 */
.sv-questions { display: flex; flex-direction: column; gap: 8px; }
.sv-question { border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; padding: 10px 12px; }
.sv-question-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sv-question-index { background: #eef2ff; color: #4338ca; font-weight: 600; font-size: 12px; padding: 2px 8px; border-radius: 10px; min-width: 28px; text-align: center; }
.sv-question-type { padding: 4px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 12px; }
.sv-question-title { flex: 1; padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.sv-question-required { font-size: 12px; color: #4b5563; display: flex; align-items: center; gap: 4px; }
.sv-question-del { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 16px; padding: 0 4px; }
.sv-question-options { display: flex; flex-direction: column; gap: 4px; margin-left: 36px; }
.sv-question-option-row { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #4b5563; }
.sv-question-option-row input { flex: 1; padding: 3px 8px; border: 1px solid #e5e7eb; border-radius: 4px; font-size: 12.5px; }
.sv-question-option-add { background: none; border: 1px dashed #93c5fd; color: #0052cc; padding: 3px 10px; font-size: 12px; border-radius: 4px; cursor: pointer; align-self: flex-start; }
.sv-add-question { border: 1px dashed #d1d5db; background: #fafafa; padding: 10px; border-radius: 8px; color: #6b7280; cursor: pointer; font-size: 13px; text-align: center; }
.sv-add-question:hover { border-color: #0052cc; color: #0052cc; }

/* Step 占位 */
#surveyEditor .sv-step-placeholder {
  padding: 60px 20px; text-align: center; color: #9ca3af;
  background: #fff; border: 1px dashed #d1d5db; border-radius: 10px; max-width: 720px; margin: 0 auto;
}
#surveyEditor .sv-step-placeholder h3 { color: #1f2937; margin: 8px 0 6px; }
#surveyEditor .sv-step-placeholder .icon { font-size: 40px; }

/* ─────────────────── Step 3 · 外观设置：色板 ─────────────────── */
.sv-appearance-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: flex-start;
  max-width: 900px; margin: 0 auto;
}
.sv-appearance-panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px 20px; }
.sv-appearance-panel h4 { margin: 0 0 12px; font-size: 13.5px; color: #1f2937; font-weight: 600; }
.sv-color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.sv-color-swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  transition: transform .1s;
}
.sv-color-swatch:hover { transform: scale(1.1); }
.sv-color-swatch.active { border-color: #1f2937; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #1f2937; }
.sv-color-picker-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.sv-color-picker-row input[type=color] { width: 32px; height: 32px; border: 1px solid #d1d5db; border-radius: 6px; padding: 2px; cursor: pointer; background: none; }
.sv-color-picker-row input[type=text] { flex: 1; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; font-family: monospace; }

/* ─────────────────── 预览抽屉（右侧滑出） ─────────────────── */
.sv-preview-drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sv-preview-drawer-mask.open { opacity: 1; pointer-events: auto; }

.sv-preview-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 100vw;
  background: #eef1f6; z-index: 201; box-shadow: -8px 0 24px rgba(0,0,0,.12);
  transform: translateX(100%); transition: transform .25s ease, width .25s ease;
  display: flex; flex-direction: column;
}
.sv-preview-drawer.wide { width: 900px; }
.sv-preview-drawer.open { transform: translateX(0); }

.sv-preview-drawer .sv-drawer-head {
  display: flex; align-items: center; padding: 12px 18px;
  background: #fff; border-bottom: 1px solid #e5e7eb;
}
.sv-preview-drawer .sv-drawer-head h3 { margin: 0; font-size: 14.5px; color: #1f2937; }
.sv-preview-drawer .sv-drawer-head .sv-drawer-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.sv-preview-drawer .sv-drawer-close {
  background: none; border: none; font-size: 22px; color: #6b7280; cursor: pointer;
  line-height: 1; padding: 0 4px;
}
.sv-preview-drawer .sv-drawer-close:hover { color: #1f2937; }

.sv-drawer-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  background: #f8fafc; border-bottom: 1px solid #e5e7eb; font-size: 12.5px; color: #4b5563;
}
.sv-drawer-toolbar select, .sv-drawer-toolbar button {
  padding: 4px 10px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 12px;
  background: #fff; cursor: pointer; color: #1f2937;
}
.sv-drawer-toolbar button:hover { border-color: #0052cc; color: #0052cc; }
.sv-drawer-toolbar .seg {
  display: inline-flex; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; background: #fff;
}
.sv-drawer-toolbar .seg button { border: none; border-radius: 0; padding: 4px 10px; font-size: 12px; background: #fff; color: #6b7280; }
.sv-drawer-toolbar .seg button.active { background: #0052cc; color: #fff; }

/* 手机模拟器外壳 */
.sv-drawer-stage {
  flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center;
  padding: 30px 20px; background:
    radial-gradient(circle at 30% 20%, rgba(0,82,204,.06), transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(76,29,149,.06), transparent 45%),
    #eef1f6;
}
.sv-phone {
  position: relative; width: 375px; height: 760px;
  background: #111827; border-radius: 42px; padding: 12px;
  box-shadow:
    0 24px 48px rgba(0,0,0,.28),
    0 0 0 2px #0b1220,
    inset 0 0 0 2px #1f2937;
  flex: 0 0 auto;
}
.sv-phone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 26px; background: #0b1220; border-radius: 0 0 16px 16px; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.sv-phone-notch::before { content: ''; width: 8px; height: 8px; background: #1f2937; border-radius: 50%; }
.sv-phone-notch::after  { content: ''; width: 40px; height: 5px; background: #1f2937; border-radius: 3px; }
.sv-phone-screen {
  position: relative; width: 100%; height: 100%;
  background: #fff; border-radius: 30px; overflow: hidden;
}
.sv-phone-screen iframe {
  width: 100%; height: 100%; border: 0; display: block; background: #fff;
}
.sv-phone-home {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 4px; background: #4b5563; border-radius: 3px; z-index: 3;
}

/* Android 机型 */
.sv-phone.android { width: 380px; height: 720px; border-radius: 28px; background: #0f172a; padding: 8px; }
.sv-phone.android .sv-phone-notch { width: 12px; height: 12px; border-radius: 50%; top: 14px; background: #1e293b; }
.sv-phone.android .sv-phone-notch::before, .sv-phone.android .sv-phone-notch::after { display: none; }
.sv-phone.android .sv-phone-screen { border-radius: 20px; }
.sv-phone.android .sv-phone-home { display: none; }

/* iPad 机型 */
.sv-phone.ipad { width: 560px; height: 760px; border-radius: 32px; padding: 22px; }
.sv-phone.ipad .sv-phone-notch { display: none; }
.sv-phone.ipad .sv-phone-home { display: none; }
.sv-phone.ipad .sv-phone-screen { border-radius: 12px; }

/* PC 机型 */
.sv-phone.pc {
  width: 800px; height: 500px; border-radius: 14px 14px 6px 6px;
  padding: 24px 14px 40px; background: #1f2937;
}
.sv-phone.pc .sv-phone-notch { display: none; }
.sv-phone.pc .sv-phone-home {
  bottom: 12px; width: 80px; height: 8px; background: #374151; border-radius: 4px;
}
.sv-phone.pc .sv-phone-screen { border-radius: 4px; }

/* 预览未保存提示 */
.sv-drawer-empty {
  padding: 60px 30px; text-align: center; color: #6b7280;
  background: #fff; margin: 30px auto; max-width: 380px;
  border-radius: 10px; border: 1px dashed #d1d5db;
}
.sv-drawer-empty .icon { font-size: 40px; margin-bottom: 8px; }
.sv-drawer-empty h4 { margin: 8px 0 4px; color: #1f2937; font-size: 14px; }

/* ─────────────────── AI 起草面板（跟进弹窗用） ─────────────────── */
.ai-draft-panel {
  background: linear-gradient(135deg, #f0f7ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d9f7; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
}
.ai-draft-panel .ai-draft-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-weight: 600; color: #0052cc; font-size: 12.5px; }
.ai-draft-panel .ai-draft-row { display: flex; gap: 6px; align-items: center; }
.ai-draft-panel select, .ai-draft-panel input {
  padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 12.5px;
}
.ai-draft-panel select { min-width: 130px; }
.ai-draft-panel input { flex: 1; }
.ai-draft-panel .ai-draft-btn {
  background: linear-gradient(135deg, #0052cc, #4c1d95); color: #fff;
  border: none; padding: 5px 12px; border-radius: 4px; font-size: 12.5px; cursor: pointer;
  white-space: nowrap;
}
.ai-draft-panel .ai-draft-btn:hover { opacity: .92; }
.ai-draft-panel .ai-draft-btn:disabled { opacity: .5; cursor: not-allowed; }
.ai-draft-status { font-size: 11.5px; color: #6b7280; margin-left: 4px; }

/* ═══════════════════════════════════════════════════════════════
 * 阶段2 · Step 2 落地页块编辑器
 * ═══════════════════════════════════════════════════════════════ */
.sv-blocks-wrap { padding: 4px 0 40px; }

.sv-block-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: #ffffffee; backdrop-filter: blur(6px);
  padding: 10px 4px; margin: 8px 0 12px;
  border-bottom: 1px solid #e5e7eb;
}
.sv-block-toolbar-label { font-size: 12.5px; color: #6b7280; }
.sv-block-add-btn {
  border: 1px solid #d1d5db; background: #fff; border-radius: 6px;
  padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: #374151;
  transition: all .15s;
}
.sv-block-add-btn:hover {
  background: #eef2ff; border-color: #6366f1; color: #4f46e5;
}

.sv-blocks { display: flex; flex-direction: column; gap: 10px; }
.sv-blocks-empty {
  border: 2px dashed #e5e7eb; border-radius: 10px;
  padding: 40px 20px; text-align: center; background: #fafafa;
}

.sv-block {
  border: 1px solid #e5e7eb; border-radius: 8px; background: #fff;
  overflow: hidden; transition: box-shadow .15s, border-color .15s, transform .15s;
}
.sv-block:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.sv-block.dragging { opacity: .5; transform: scale(0.99); }
.sv-block.drag-over { border-color: #6366f1; box-shadow: 0 0 0 2px #c7d2fe; }

.sv-block-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #f9fafb;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12.5px;
}
.sv-block-drag {
  cursor: grab; color: #9ca3af; padding: 2px 4px;
  font-weight: bold; user-select: none;
}
.sv-block-drag:active { cursor: grabbing; }
.sv-block-badge {
  background: #eef2ff; color: #4f46e5;
  padding: 2px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 500;
}
.sv-block-idx { color: #9ca3af; font-size: 11.5px; }
.sv-block-move, .sv-block-del {
  border: 1px solid #e5e7eb; background: #fff;
  border-radius: 4px; padding: 2px 8px; font-size: 12px; cursor: pointer;
  color: #6b7280;
}
.sv-block-move:hover:not(:disabled) { background: #f3f4f6; }
.sv-block-move:disabled { opacity: .3; cursor: not-allowed; }
.sv-block-del:hover { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }

.sv-block-body { padding: 12px 14px; }
.sv-block-field { margin-bottom: 10px; }
.sv-block-field label {
  display: block; font-size: 12px; color: #4b5563;
  margin-bottom: 4px; font-weight: 500;
}
.sv-block-field input, .sv-block-field textarea {
  width: 100%; border: 1px solid #d1d5db; border-radius: 5px;
  padding: 6px 10px; font-size: 13px; box-sizing: border-box;
  font-family: inherit;
}
.sv-block-field input:focus, .sv-block-field textarea:focus {
  outline: none; border-color: #6366f1; box-shadow: 0 0 0 2px #c7d2fe;
}
.sv-block-preview { margin-top: 8px; }

/* 题目块内嵌线索映射行 */
.sv-question-mapping {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; margin: 6px 0 8px;
  background: #fef3c7; border-left: 3px solid #f59e0b;
  border-radius: 4px;
}
.sv-question-mapping select {
  border: 1px solid #d1d5db; border-radius: 4px;
  background: #fff; color: #374151;
}
