/* ws-ecom-v4.162053 — 电商工坊 v4：响应式 + 上传按比例 + 结果紧凑 + 识别 4 态
   问题：缺中段断点；上传容器留白大；结果区 190px 占满；识别只有 loading 文字。
   ============================================================ */

/* ── 中段断点：1280-960 ─────────────────────────────────── */
@media (max-width: 1280px) {
  .ecommerce-layout {
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  }
}

@media (max-width: 1100px) {
  .ecommerce-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "context"
      "entry"
      "results";
    grid-template-rows: auto auto auto;
    height: auto;
    overflow: visible;
  }
  .ecommerce-input-panel { height: auto; overflow: visible; }
  .ecommerce-entry-panel { max-width: 720px; }
}

/* ── 覆盖 v3 的 max-height:264px：跟父 grid row 等高、内部独立滚 ── */
/* 关键：align-self:start 让 panel 在 grid cell 内顶部对齐、不撑大；
   高度 = 内容自然高；超过 max-height 时 panel 内部滚 */
.ecommerce-input-panel {
  align-self: start;
  max-height: calc(100dvh - 220px);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-gutter: stable;
}
/* 结果区也用 start 对齐：左 input-panel 短的时候 results 不会拉 cell */
.ecommerce-result-panel {
  align-self: start;
  max-height: calc(100dvh - 220px);
  overflow-y: auto;
  min-height: 0;
}

/* ── 上传容器：去掉空态大留白 ─────────────────────────── */
.ecommerce-product-preview {
  display: block;
  padding: 0;
  min-height: 0;
  background: transparent;
  border: none;
}
.ecommerce-product-preview.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 14px 16px;
  font-size: 12.5px;
  color: var(--muted, #9a938a);
  border-radius: 12px;
  border: 1px dashed var(--line, rgba(255, 255, 255, 0.18));
  background: rgba(255, 255, 255, 0.02);
}

/* 参考图缩略图：固定比例，不撑大容器 */
.ecommerce-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
  align-content: start;
  width: 100%;
}
.ecommerce-reference-card {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
}
.ecommerce-reference-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ecommerce-reference-card span {
  display: block;
  position: absolute;
  left: 6px;
  bottom: 6px;
  right: 6px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 6px;
  font-size: 10.5px;
  color: #f3eee3;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ecommerce-reference-card button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: rgba(180, 83, 42, 0.88);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

/* ── 识别按钮 4 态 ─────────────────────────────────── */
.ecommerce-analyze-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  gap: 0;
  transition: background 180ms ease, color 180ms ease, opacity 180ms ease, border-color 180ms ease;
}
.ecommerce-analyze-btn[data-state="idle"] {
  /* 默认 */
}
/* loading: 按钮本身灰显 + 摘要条驱动状态文字；按钮文字不变 */
.ecommerce-analyze-btn[data-state="loading"] {
  opacity: 0.6;
  pointer-events: none;
  cursor: wait;
  background: rgba(180, 83, 42, 0.12);
}
/* success / error: 仅边框/文字色变化；状态文字全交给摘要条；不再用 ::before 旋转/勾叉 */
.ecommerce-analyze-btn[data-state="success"] {
  border-color: rgba(86, 196, 130, 0.55);
  color: #b8e8c8;
  background: rgba(47, 138, 102, 0.08);
}
.ecommerce-analyze-btn[data-state="error"] {
  border-color: rgba(232, 96, 96, 0.55);
  color: #f4b3b3;
  background: rgba(220, 80, 80, 0.08);
}

/* 识别摘要条：成功后短暂浮出，再淡出 */
/* idle 态默认完全隐藏，仅 loading/success/error 时显示 */
.ecommerce-analyze-summary {
  display: none;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted, #9a938a);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.ecommerce-analyze-summary[hidden] { display: none !important; }
.ecommerce-analyze-summary[data-kind] { display: block; }
.ecommerce-analyze-summary[data-kind="loading"] {
  color: #c4d8e8;
  background: rgba(120, 180, 230, 0.08);
  border-color: rgba(120, 180, 230, 0.28);
}
.ecommerce-analyze-summary[data-kind="success"] {
  color: #b8e8c8;
  background: rgba(86, 196, 130, 0.08);
  border-color: rgba(86, 196, 130, 0.28);
}
.ecommerce-analyze-summary[data-kind="error"] {
  color: #f4b3b3;
  background: rgba(232, 96, 96, 0.08);
  border-color: rgba(232, 96, 96, 0.28);
}

/* ── 套图结果区：紧凑 ─────────────────────────────────── */
.ecommerce-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  padding: 0;
  min-height: 0;
}
.ecommerce-result-image {
  height: 160px;
  border-radius: 12px;
}
.ecommerce-result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ecommerce-result-actions #ecommerceResultStatus {
  font-size: 12.5px;
  color: var(--muted, #9a938a);
}
.ecommerce-preview-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 10px;
  height: auto;
}

/* 单图模式：1 张图时占满居中 */
.ecommerce-result-grid.is-single {
  grid-template-columns: 1fr;
  max-width: 520px;
  margin: 0 auto;
}
.ecommerce-result-grid.is-single .ecommerce-result-image {
  height: 320px;
}

/* ── 响应式窄屏：720/480 ─────────────────────────────────── */
@media (max-width: 720px) {
  .ecommerce-input-panel {
    grid-template-columns: 1fr !important;
    row-gap: 12px;
    height: auto !important;
  }
  .ecommerce-field-grid { grid-template-columns: 1fr; }
  .ecommerce-reference-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .ecommerce-result-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .ecommerce-result-image { height: 130px; }
}

@media (max-width: 480px) {
  .ecommerce-result-grid { grid-template-columns: 1fr 1fr; }
  .ecommerce-result-image { height: 110px; }
}
/* ── 单图模式（放末尾，确保覆盖上方断点规则） ─────────────── */
.ecommerce-result-grid.is-single {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
}
.ecommerce-result-grid.is-single .ecommerce-result-card {
  width: 100%;
  max-width: 520px;
}
.ecommerce-result-grid.is-single .ecommerce-result-image {
  height: 320px;
}
@media (max-width: 720px) {
  .ecommerce-result-grid.is-single .ecommerce-result-image { height: 240px; }
}

/* ── 单图快捷开关 ─────────────────────────────────────── */
.ecommerce-single-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted, #9a938a);
  padding: 6px 0 2px;
  cursor: pointer;
  user-select: none;
}
.ecommerce-single-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  accent-color: #d99a2b;
  cursor: pointer;
}
.ecommerce-single-toggle:hover { color: var(--ink, #2b2723); }

/* ── 套图配置入口卡：单图开关独占一行 ───────────────── */
.ecommerce-entry-body > .ecommerce-single-toggle {
  grid-column: 1 / -1;
  width: 100%;
  justify-content: flex-start;
  padding: 4px 0 0;
  margin: 0;
}

/* ── 单图模式：隐藏套图配置入口卡 ─────────────────────── */
.ecommerce-entry-panel.is-hidden { display: none !important; }

/* ── 出图参数 3 个 select 统一高度 + 文字不截断 ─────────── */
.ecommerce-input-panel .ecommerce-template-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 12px;
  align-items: start;
}
.ecommerce-template-inline > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted, #9a938a);
}
.ecommerce-template-inline > label > select {
  min-height: 42px;
  height: 42px;
  padding: 8px 30px 8px 12px;
  text-overflow: clip;
  white-space: nowrap;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink, #e8e3d6);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23a09889' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='3,5 6,8 9,5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
.ecommerce-template-inline > label > select:focus {
  outline: none;
  border-color: var(--accent, #d99a2b);
}
.ecommerce-template-inline > label > select:hover {
  border-color: rgba(255, 255, 255, 0.22);
}
@media (max-width: 720px) {
  .ecommerce-template-inline { grid-template-columns: 1fr; }
}
