/* ====== 图标对齐 ====== */
.tpl-icon {
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* ====== 拖拽上传区 ====== */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-normal) var(--ease-default),
              background-color var(--duration-normal) var(--ease-default);
}

.drop-zone:hover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-bg);
}

.drop-zone.drag-over {
  border-color: var(--color-primary);
  background-color: var(--color-primary-bg);
  border-style: solid;
}

.drop-zone.has-files {
  padding: var(--space-4) var(--space-6);
}

.drop-zone.has-files .drop-icon {
  display: none;
}

.drop-zone.has-files .drop-title {
  font-size: var(--text-sm);
  margin-bottom: 0;
}

.drop-zone.has-files .drop-hint {
  display: none;
}

.drop-icon {
  opacity: 0.4;
  margin-bottom: var(--space-3);
  transition: opacity var(--duration-normal) var(--ease-default);
}

.drop-zone:hover .drop-icon {
  opacity: 0.6;
}

.drop-title {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.drop-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ====== 文件列表 ====== */
.file-list-section {
  margin-top: var(--space-5);
}

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.file-count {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.file-sort-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-left: var(--space-3);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-normal) var(--ease-default),
              opacity var(--duration-fast) var(--ease-default);
}

.file-item:hover {
  border-color: var(--color-border);
}

.file-item.drag-active {
  opacity: 0.4;
}

.file-item.drag-target-above {
  border-top: 2px solid var(--color-primary);
}

.file-drag-handle {
  flex-shrink: 0;
  cursor: grab;
  opacity: 0.3;
  transition: opacity var(--duration-fast) var(--ease-default);
  user-select: none;
  display: flex;
  align-items: center;
}

.file-drag-handle:active {
  cursor: grabbing;
}

.file-item:hover .file-drag-handle {
  opacity: 0.6;
}

.file-item-icon {
  flex-shrink: 0;
  opacity: 0.45;
}

.file-item-name {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.file-item-size {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.file-item-remove {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.3;
  transition: opacity var(--duration-fast) var(--ease-default),
              background-color var(--duration-fast) var(--ease-default);
  padding: 0;
}

.file-item:hover .file-item-remove {
  opacity: 0.7;
}

.file-item-remove:hover {
  background: var(--color-error-bg);
  opacity: 1;
}

/* ====== 排版选项 ====== */
.layout-options {
  margin-top: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.layout-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.layout-btns {
  display: flex;
  gap: 0;
}

.layout-btns .btn {
  border-radius: 0;
}

.layout-btns .btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.layout-btns .btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.layout-btns .btn + .btn {
  margin-left: -1px;
}

.layout-checkboxes {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-left: var(--space-2);
}

/* ====== 预览区 ====== */
.preview-section {
  margin-top: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.preview-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.preview-summary {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.preview-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

/* 预览页 */
.preview-page {
  background: #FFFFFF;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: relative;
  /* A4 比例：1 : sqrt(2) ≈ 1 : 1.414 */
  width: 210px;
  height: 297px;
  overflow: hidden;
}

.preview-page-label {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-text-muted);
}

/* 预览槽位 */
.preview-slot {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-slot-inner {
  background: var(--color-primary-bg);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 2px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  padding: 2px;
}

.preview-slot-name {
  font-size: 10px;
  color: var(--color-text);
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.preview-slot-num {
  font-size: 9px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.preview-slot-inner-border {
  border: 1px dashed rgba(13, 148, 136, 0.3);
}

/* 裁剪标记 — 四角 L 形短线 */
.preview-slot-cropmark::after {
  content: '';
  position: absolute;
  inset: -1px;
  pointer-events: none;
  --c: var(--color-primary);
  --L: 10px;
  --w: 2px;
  background:
    /* 左上 */ linear-gradient(to right,  var(--c) var(--w), transparent var(--w)) 0 0 / var(--L) var(--w) no-repeat,
               linear-gradient(to bottom, var(--c) var(--w), transparent var(--w)) 0 0 / var(--w) var(--L) no-repeat,
    /* 右上 */ linear-gradient(to left,   var(--c) var(--w), transparent var(--w)) 100% 0 / var(--L) var(--w) no-repeat,
               linear-gradient(to bottom, var(--c) var(--w), transparent var(--w)) 100% 0 / var(--w) var(--L) no-repeat,
    /* 左下 */ linear-gradient(to right,  var(--c) var(--w), transparent var(--w)) 0 100% / var(--L) var(--w) no-repeat,
               linear-gradient(to top,    var(--c) var(--w), transparent var(--w)) 0 100% / var(--w) var(--L) no-repeat,
    /* 右下 */ linear-gradient(to left,   var(--c) var(--w), transparent var(--w)) 100% 100% / var(--L) var(--w) no-repeat,
               linear-gradient(to top,    var(--c) var(--w), transparent var(--w)) 100% 100% / var(--w) var(--L) no-repeat;
}

.preview-more {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ====== 生成按钮区 ====== */
.merge-actions {
  margin-top: var(--space-5);
  display: flex;
  justify-content: center;
}

/* ====== 状态提示 ====== */
.merge-status {
  margin-top: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.merge-status.info {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border: 1px solid rgba(13, 148, 136, 0.2);
}

.merge-status.success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.merge-status.error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.merge-status .status-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.merge-status .status-text {
  line-height: 1.5;
}

/* ====== 工具描述 + FAQ 同容器宽度 ====== */
.tool-header .tool-desc {
  max-width: none;
}

.faq-section {
  max-width: none;
}

/* ====== 移动端 700px 断点 ====== */
@media (max-width: 700px) {
  .drop-zone {
    padding: var(--space-8) var(--space-4);
  }

  .drop-zone.has-files {
    padding: var(--space-3) var(--space-4);
  }

  .file-item {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .file-item-size {
    order: 10;
    width: 100%;
    margin-left: 28px;
  }

  .layout-options {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .layout-checkboxes {
    margin-left: 0;
  }

  .preview-page {
    width: 150px;
    height: 212px;
  }

  .merge-actions {
    flex-direction: column;
  }

  .merge-actions .btn {
    width: 100%;
  }
}
