/* 仅作用于 product-image*；页面只占一张缩略图的空间。 */
.product-image-host,
.product-image {
  display: inline-flex;
  flex: 0 0 auto;
  vertical-align: middle;
  line-height: 1.3;
}

.product-image-thumbnail {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: var(--product-image-size, 48px);
  height: var(--product-image-size, 48px);
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f3f4f6;
  color: #4b5563;
  text-decoration: none;
  touch-action: manipulation;
}

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

.product-image-placeholder {
  padding: 2px;
  color: #4b5563;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.product-image-thumbnail:focus-visible,
.product-image-search:focus-visible,
.product-image-close:focus-visible,
.product-image-original:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* 单例视觉预览不接收指针，不覆盖链接交互，也不进入键盘焦点顺序。 */
.product-image-hover {
  position: fixed;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  padding: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 28px #0003;
  pointer-events: none;
  user-select: none;
}

.product-image-hover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.product-image-hover-message {
  padding: 12px;
  color: #475569;
  font: 13px/1.6 sans-serif;
  overflow-wrap: anywhere;
  pointer-events: none;
}

/* 以下仅供显式 open/close dialog API 兼容，缩略图旁不生成按钮。 */
.product-image-search,
.product-image-close,
.product-image-original {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  color: #334155;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.product-image-search {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fdba74;
}

.product-image-search:hover { background: #ffedd5; }
.product-image-close:hover,
.product-image-original:hover { background: #f1f5f9; }

.product-image-dialog {
  width: min(920px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  box-sizing: border-box;
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  color: #1f2937;
  background: #fff;
  box-shadow: 0 12px 48px #0005;
}

.product-image-dialog::backdrop { background: #0f172ab3; }

.product-image-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.product-image-header,
.product-image-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.product-image-heading { margin: 0; font-size: 17px; font-weight: 600; }

.product-image-media {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  background: #f8fafc;
}

.product-image-large {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: min(62vh, 640px);
  max-height: min(62dvh, 640px);
  object-fit: contain;
}

.product-image-dialog-actions { justify-content: flex-start; }
.product-image-notice,
.product-image-message {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.product-image-message { padding: 20px; }
.product-image-img[hidden],
.product-image-placeholder[hidden],
.product-image-hover[hidden],
.product-image-hover-img[hidden],
.product-image-hover-message[hidden],
.product-image-large[hidden],
.product-image-message[hidden] { display: none; }

@media (max-width: 480px) {
  .product-image-panel { padding: 12px; gap: 10px; }
  .product-image-heading { font-size: 15px; }
}
