/* 图片批量处理模块 · 样式
   左侧规则设置 380px，右侧导入 / 列表 / 结果；移动端纵向堆叠。
   所有类名统一 img- 前缀，避免覆盖全局图片样式。 */

.img-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.img-side,
.img-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------------------------------------------------------------- 规则面板 */

.img-rules {
  padding: 18px;
}

.img-rules .card-head {
  margin-bottom: 12px;
}

.img-rules .card-head .card-sub {
  margin-left: auto;
  white-space: nowrap;
}

.img-rules.is-locked {
  opacity: 0.7;
  pointer-events: none;
}

.img-group .section-label {
  margin-bottom: 10px;
}

.img-group .section-label svg {
  width: 15px;
  height: 15px;
  color: var(--sub);
  flex: 0 0 auto;
}

.img-subgroup.is-off {
  display: none;
}

.img-subgroup > .field:first-child {
  margin-top: 10px;
}

.img-rules .field-row {
  margin-bottom: 14px;
}

.img-rules .field-row .field {
  margin-bottom: 0;
}

.img-rules .divider {
  margin: 16px 0;
}

.img-switch {
  margin-left: auto;
  min-height: 24px;
}

.img-range-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.img-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.img-color {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 2px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: #fff;
  cursor: pointer;
}

.img-rules .img-color-row .img-color {
  width: 54px;
  flex: 0 0 auto;
}

.img-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.img-color::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.img-color::-moz-color-swatch {
  border: 0;
  border-radius: 5px;
}

.img-color-val {
  font-size: 11.5px;
  color: var(--sub);
  font-family: var(--mono);
  white-space: nowrap;
}

/* Logo 上传行 */
.img-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.img-logo-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: #fafafb;
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}

.img-logo-thumb svg {
  width: 18px;
  height: 18px;
}

.img-logo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.img-logo-info {
  min-width: 0;
  flex: 1 1 auto;
}

.img-logo-info .row {
  gap: 6px;
}

.img-logo-info .field-hint {
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 效果预览 */
.img-preview .section-label {
  margin-bottom: 8px;
}

.img-preview .section-label svg {
  width: 15px;
  height: 15px;
  color: var(--sub);
}

.img-preview-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
  background-color: #fff;
  background-image: linear-gradient(45deg, #f1f1f3 25%, transparent 25%),
    linear-gradient(-45deg, #f1f1f3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f1f3 75%),
    linear-gradient(-45deg, transparent 75%, #f1f1f3 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

.img-preview-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(16, 17, 20, 0.12);
}

.img-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.img-preview-empty svg {
  width: 22px;
  height: 22px;
  color: var(--faint);
}

.img-preview-tag {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 底部操作 */
.img-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.img-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--sub);
  margin-bottom: 5px;
}

.img-progress-top span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-progress-top span:last-child {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 导入区 */

.img-drop {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-m);
  background: #fcfcfd;
  padding: 24px 20px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.img-drop:hover {
  border-color: #c2c5ca;
  background: #fbfbfc;
}

.img-drop.is-over {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.img-drop.is-locked {
  cursor: default;
  opacity: 0.72;
  pointer-events: none;
}

.img-drop-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 8px;
  border-radius: 14px;
  background: linear-gradient(140deg, #fff 0%, var(--brand-soft) 100%);
  border: 1px solid var(--brand-line);
  display: grid;
  place-items: center;
  color: var(--brand);
}

.img-drop-icon svg {
  width: 22px;
  height: 22px;
}

.img-drop-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.img-drop-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.img-drop-hint {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------------------------------------------------------------- 列表与结果 */

.img-panel {
  padding: 18px;
}

.img-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-700);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  border-radius: 99px;
  padding: 0 8px;
  line-height: 18px;
  white-space: nowrap;
}

.img-thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 9px;
  overflow: hidden;
  background: #f3f3f5;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-thumb-lg {
  width: 64px;
  height: 64px;
}

.img-thumb-fail svg {
  width: 18px;
  height: 18px;
  color: var(--bad);
}

.img-list,
#imgList,
#imgResultList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.img-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: #fff;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}

.img-row:hover {
  border-color: var(--line-2);
  background: #fcfcfd;
}

.img-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.img-name {
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
  line-height: 1.5;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.img-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}

.img-sub > span + span::before {
  content: "·";
  margin-right: 8px;
  color: var(--faint);
}

.img-sub-ok {
  color: var(--ok);
}

.img-sub-ok::before {
  color: var(--ok) !important;
}

.img-sub-err {
  color: var(--bad);
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.img-sub-mute {
  color: var(--muted);
}

.img-remove {
  flex: 0 0 auto;
  color: var(--muted);
}

.img-row-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 体积对比与目标提示 */
.img-delta {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.img-delta.up {
  color: var(--ok);
}

.img-delta.down {
  color: var(--bad);
}

.img-delta.flat {
  color: var(--muted);
}

.img-row-result .img-sub .tag {
  margin-left: 2px;
}

/* ---------------------------------------------------------------- 结果区工具条 */

.img-stale {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--warn-line);
  border-radius: var(--r-s);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
}

.img-stale svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.img-stale span {
  min-width: 0;
}

.img-export {
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: #fbfbfc;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.img-export-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.img-export-row .spacer {
  flex: 1 1 auto;
}

.img-export-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  white-space: nowrap;
}

.img-naming {
  width: auto;
  min-width: 144px;
}

.img-prefix-input {
  width: 110px;
}

/* ---------------------------------------------------------------- 失败清单 */

.img-fail {
  margin-top: 14px;
  border: 1px solid var(--bad-line);
  border-radius: var(--r-m);
  background: var(--bad-soft);
  padding: 12px;
}

.img-fail .section-label {
  color: var(--bad);
  margin-bottom: 8px;
}

.img-fail .section-label svg {
  width: 14px;
  height: 14px;
}

.img-fail-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 12px;
  border-top: 1px dashed var(--bad-line);
}

.img-fail-row:first-of-type {
  border-top: 0;
}

.img-fail-name {
  flex: 0 1 auto;
  max-width: 46%;
  color: var(--ink-2);
  font-weight: 550;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.img-fail-reason {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--bad);
  line-height: 1.5;
}

/* 结果区底部提示 */
.img-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

.img-note svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  margin-top: 2px;
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 1020px) {
  .img-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 移动端先导入与结果，再调整规则 */
  .img-main {
    order: 1;
  }

  .img-side {
    order: 2;
  }

  .img-rules {
    position: static;
  }
}

@media (max-width: 560px) {
  .img-rules,
  .img-panel {
    padding: 14px;
  }

  .img-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .img-meta {
    flex: 1 1 calc(100% - 82px);
  }

  .img-row .img-thumb {
    width: 52px;
    height: 52px;
  }

  .img-row-actions {
    margin-left: auto;
  }

  .img-remove {
    margin-left: auto;
  }

  .img-export-row .spacer {
    display: none;
  }

  .img-export-row > .btn {
    width: 100%;
  }

  .img-preview-box {
    min-height: 130px;
  }

  .img-drop {
    padding: 20px 14px 16px;
  }

  .img-fail-row {
    flex-direction: column;
    gap: 2px;
  }

  .img-fail-name {
    max-width: 100%;
  }
}
