/* ==========================================================================
   详情页预览模式：手机视图 / 平铺视图
   ========================================================================== */

.ws-preview-mode {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--ws-line, #e2e8f0);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.ws-preview-mode.is-visible {
  display: inline-flex;
}

.ws-preview-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.ws-preview-mode-btn svg {
  width: 16px;
  height: 16px;
}

.ws-preview-mode-btn:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.14);
  color: #334155;
}

.ws-preview-mode-btn.is-active {
  background: var(--ws-primary-soft, #eff6ff);
  color: var(--ws-primary, #2563eb);
}

.ws-preview-mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 手机预览激活时禁止画布滚动，避免舞台被滚走 */
.dp-phone-host-active {
  overflow: hidden !important;
}

/* 手机预览舞台（覆盖在宫格之上；内容过长时可滚动） */
.dp-phone-stage {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(37, 99, 235, 0.04), transparent 55%),
    #f1f5f9;
  padding: 24px 0;
  box-sizing: border-box;
}

.dp-phone-stage.is-active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.dp-phone-frame {
  position: relative;
  flex: none;
  width: min(320px, calc(100% - 48px));
  /* 高度 = 各占位高度之和（由内部 stack 内容撑开） */
  height: auto;
  border: 2px solid rgba(15, 23, 42, 0.28);
  border-radius: 22px;
  background: #fff;
  box-shadow:
    0 0 0 6px rgba(15, 23, 42, 0.04),
    0 18px 40px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dp-phone-notch {
  flex: none;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
}

.dp-phone-notch span {
  width: 56px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.dp-phone-stack {
  flex: none;
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0;
  touch-action: none;
  font-size: 0;
  line-height: 0;
}

.dp-phone-item {
  position: relative;
  flex: none;
  width: 100%;
  /* 与详情宫格同一比例，完整显示每一块；无边框无间隙，上下无缝衔接 */
  aspect-ratio: var(--dp-item-ar, 9 / 16);
  overflow: hidden;
  cursor: grab;
  border: none;
  margin: 0;
  padding: 0;
  background: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.15s ease;
}

/* 消除亚像素缝隙，上下叠 1px 保证无缝 */
.dp-phone-item + .dp-phone-item {
  margin-top: -1px;
}

.dp-phone-item.is-drag-source {
  display: none !important;
}

.dp-phone-stage.is-dragging-active {
  cursor: grabbing;
  user-select: none;
  touch-action: none;
  /* 保持 overflow:auto，拖到边缘时自动滚动画布 */
}

/* 落脚占位框：拖动时挤开相邻图片 */
.dp-drop-slot {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: var(--dp-item-ar, 9 / 16);
  box-sizing: border-box;
  margin: 0;
  border: 2px dashed #2563eb;
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(37, 99, 235, 0.06),
      rgba(37, 99, 235, 0.06) 6px,
      rgba(37, 99, 235, 0.12) 6px,
      rgba(37, 99, 235, 0.12) 12px
    );
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
  pointer-events: none;
  transition: order 0.15s ease;
}

.dp-drop-slot::after {
  content: "移动至此";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.dp-phone-frame.is-drop-target {
  border-color: #2563eb;
  box-shadow:
    0 0 0 6px rgba(37, 99, 235, 0.14),
    0 18px 40px rgba(15, 23, 42, 0.12);
}

.dp-phone-frame.is-drop-outside {
  border-color: rgba(148, 163, 184, 0.55);
  opacity: 0.92;
}

/* 跟随指针的拖拽浮层 */
.dp-drag-ghost {
  position: fixed;
  z-index: 10050;
  pointer-events: none;
  margin: 0;
  border: 2px solid #2563eb;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.28);
  opacity: 0.92;
  cursor: grabbing;
  aspect-ratio: auto;
  transform: scale(1.02);
  will-change: left, top;
}

.dp-drag-ghost .dp-phone-item-tag,
.dp-drag-ghost .dp-free-item-tag {
  display: none;
}

.dp-drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.dp-phone-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  vertical-align: top;
  pointer-events: none;
  user-select: none;
  background: #fff;
}

.dp-phone-item-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  pointer-events: none;
}

/* 右键菜单 */
.dp-ctx-menu {
  position: fixed;
  z-index: 10060;
  min-width: 168px;
  padding: 4px;
  margin: 0;
  list-style: none;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  display: none;
}

.dp-ctx-menu.is-open {
  display: block;
}

.dp-ctx-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.dp-ctx-menu button:hover:not(:disabled) {
  background: #eff6ff;
  color: #1d4ed8;
}

.dp-ctx-menu button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.dp-ctx-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: #e2e8f0;
}

/* 移出容器的自由定位层 */
.dp-free-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.dp-free-item {
  position: absolute;
  width: 140px;
  aspect-ratio: 9 / 16;
  border: 1.5px solid rgba(148, 163, 184, 0.65);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}

.dp-free-item.is-dragging {
  opacity: 0.85;
  cursor: grabbing;
  z-index: 12;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.22);
}

.dp-free-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

.dp-free-item-tag {
  position: absolute;
  top: 5px;
  left: 5px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  pointer-events: none;
}

.dp-phone-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
  padding: 16px;
  pointer-events: none;
}
