/* ============================================================
   ProductImageViewer – Zoom/pan fullscreen viewer
   ============================================================ */

/* Overlay */
.piv-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #111;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.piv-overlay.piv-open {
  display: flex;
}

/* ── Top bar ──────────────────────────────────────────────── */
.piv-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.75);
  z-index: 2;
}

.piv-counter,
.piv-zoom-pct {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  min-width: 3ch;
  white-space: nowrap;
  text-align: center;
}

.piv-counter { margin-right: 4px; }
.piv-zoom-pct {
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  margin-right: auto; /* push buttons to right */
}

/* ── Buttons ──────────────────────────────────────────────── */
.piv-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 4px;
  padding: 0 10px;
  height: 32px;
  min-width: 32px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.12s;
  flex-shrink: 0;
}
.piv-btn:hover,
.piv-btn:focus-visible {
  background: rgba(255, 255, 255, 0.3);
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 1px;
}
.piv-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.piv-close { margin-left: 4px; }

/* ── Image wrap ───────────────────────────────────────────── */
.piv-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
}

/* ── Image ────────────────────────────────────────────────── */
.piv-img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  max-width: none;
  max-height: none;
  display: block;
  pointer-events: none;
  image-rendering: auto;
}

/* ── Prev / Next arrows (floating) ───────────────────────── */
.piv-prev,
.piv-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  font-size: 22px;
  padding: 0 12px;
  height: 52px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.piv-prev { left: 12px; }
.piv-next { right: 12px; }
.piv-prev:hover,
.piv-prev:focus-visible,
.piv-next:hover,
.piv-next:focus-visible {
  background: rgba(0, 0, 0, 0.7);
}

/* ── Spinner ──────────────────────────────────────────────── */
.piv-spinner-wrap {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 4;
  pointer-events: none;
}
.piv-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: piv-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes piv-spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────────── */
.piv-err {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(190, 30, 30, 0.88);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .piv-bar { padding: 4px 6px; gap: 3px; }
  .piv-btn { height: 28px; min-width: 28px; padding: 0 7px; font-size: 13px; }
  .piv-prev,
  .piv-next { height: 44px; padding: 0 10px; font-size: 18px; }
  .piv-prev { left: 6px; }
  .piv-next { right: 6px; }
}
