/* Shared product card helpers and product option modal. */
.product-card-img-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.product-card-img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.product-card:hover .product-card-img {
  transform: scale(1.04);
}

.product-img-count {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(124,77,255,0.4);
}

.pm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  height: var(--pm-vvh, 100dvh);
  background: rgba(0,0,0,0.85);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  box-sizing: border-box;
}

.pm-overlay.open {
  display: flex;
}

.pm-dialog {
  position: relative;
  width: min(90vw, 820px);
  max-height: 92vh;
  max-height: 92dvh;
  max-height: min(92dvh, calc(var(--pm-vvh, 9999px) * 0.92));
  background: var(--bg-surface);
  border: 1px solid rgba(124,77,255,0.4);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 70px rgba(124,77,255,0.25);
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.pm-gallery {
  position: relative;
  flex: 0 0 55%;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: 480px;
}

.pm-img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: var(--bg-elevated);
}

.pm-nav {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
  pointer-events: none;
}

.pm-arrow {
  pointer-events: all;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(124,77,255,0.45);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}

.pm-arrow:hover {
  background: rgba(124,77,255,0.5);
  border-color: var(--purple-bright);
}

.pm-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.pm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(124,77,255,0.4);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.pm-dot.active {
  background: var(--purple-bright);
  transform: scale(1.25);
}

.pm-body {
  flex: 1;
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  overflow: hidden;
}

.pm-overlay.has-personalization .pm-dialog {
  width: min(94vw, 1080px);
  max-height: min(86vh, 820px);
  max-height: min(86vh, 820px, calc(var(--pm-vvh, 9999px) * 0.86));
}

.pm-overlay.has-personalization .pm-gallery {
  flex-basis: 48%;
  align-self: stretch;
  aspect-ratio: auto;
  max-height: none;
  min-height: 0;
}

.pm-overlay.has-personalization .pm-body {
  padding: 1.45rem 1.5rem 1.25rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.pm-overlay.has-personalization .pm-body::-webkit-scrollbar,
.pm-personalization::-webkit-scrollbar {
  width: 8px;
}

.pm-overlay.has-personalization .pm-body::-webkit-scrollbar-track,
.pm-personalization::-webkit-scrollbar-track {
  background: rgba(12,10,28,0.45);
  border-radius: 999px;
}

.pm-overlay.has-personalization .pm-body::-webkit-scrollbar-thumb,
.pm-personalization::-webkit-scrollbar-thumb {
  background: rgba(124,77,255,0.65);
  border-radius: 999px;
}

.pm-overlay.has-personalization .pm-name {
  font-size: 1.2rem;
}

.pm-overlay.has-personalization .pm-price {
  font-size: 1.45rem;
}

.pm-overlay.has-personalization .pm-desc {
  line-height: 1.45;
}

.pm-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0;
}

.pm-price {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--purple-bright);
}

.pm-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.pm-add {
  margin-top: auto;
  width: 100%;
}

.pm-full-link {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: var(--transition);
}

.pm-full-link:hover {
  color: var(--purple-light);
}

.pm-full-link i {
  margin-right: 5px;
}

#pm-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(124,77,255,0.4);
  color: #fff;
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

#pm-close:hover {
  background: rgba(124,77,255,0.5);
}

.pm-swatches {
  display: none;
  margin: 1rem 0 0.5rem;
}

.pm-swatches-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.pm-selected-color {
  color: var(--purple-bright);
  font-weight: 700;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
}

.pm-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pm-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  outline: none;
  padding: 0;
}

.pm-swatch:hover {
  transform: scale(1.18);
  border-color: var(--purple-bright);
}

.pm-swatch.selected {
  border-color: var(--purple-bright);
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--purple-bright);
  transform: scale(1.12);
}

.pm-swatch[data-color="White"] {
  border-color: rgba(255,255,255,0.3);
}

.pm-swatch[data-color="White"].selected {
  border-color: var(--purple-bright);
}

.pm-swatch[data-color="Glow"] {
  border-color: rgba(185,246,202,0.4);
}

.pm-swatch-custom {
  background: conic-gradient(red, orange, yellow, green, cyan, blue, violet, red) !important;
  border-radius: 50% !important;
  border: none !important;
  overflow: hidden;
}

.pm-swatch-hint {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.pm-swatch-hint i {
  color: var(--purple-bright);
  margin-right: 4px;
}

.pm-personalization {
  display: none;
  margin: 0.35rem 0 0.25rem;
  padding: 0.85rem;
  border: 1px solid rgba(124,77,255,0.26);
  border-radius: 8px;
  background: rgba(124,77,255,0.08);
  max-height: min(38vh, 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.pm-overlay.has-personalization .pm-personalization {
  max-height: none;
  overflow: visible;
  padding: 0.8rem;
}

.pm-personalization-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.pm-personalization-hd i {
  color: var(--purple-bright);
}

.pm-personalization-summary {
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0 0 0.7rem;
}

.pm-personalization-fields {
  display: grid;
  gap: 0.6rem;
}

.pm-overlay.has-personalization .pm-personalization-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pm-overlay.has-personalization .pm-field-textarea,
.pm-overlay.has-personalization .pm-file-field {
  grid-column: 1 / -1;
}

.pm-field {
  display: grid;
  gap: 0.28rem;
}

.pm-field span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pm-field input,
.pm-field select,
.pm-field textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.84rem;
  padding: 0.56rem 0.65rem;
  outline: none;
}

.pm-field textarea {
  min-height: 74px;
  resize: vertical;
}

.pm-overlay.has-personalization .pm-field textarea {
  min-height: 64px;
}

.pm-field input:focus,
.pm-field select:focus,
.pm-field textarea:focus {
  border-color: var(--purple-bright);
  box-shadow: 0 0 0 2px rgba(124,77,255,0.12);
}

.pm-field small {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.pm-field-error {
  border-color: var(--error, #ff5252) !important;
  box-shadow: 0 0 0 2px rgba(255,82,82,0.14) !important;
}

@keyframes pm-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.pm-swatches.shake,
.pm-personalization.shake {
  animation: pm-shake 0.45s ease;
}

.pm-qty {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.pm-overlay.has-personalization .pm-qty {
  margin: 0.25rem 0;
}

.pm-overlay.has-personalization .pm-add {
  margin-top: 0.2rem;
}

@media (max-width: 780px) {
  .pm-dialog {
    flex-direction: column;
    width: 96vw;
    max-height: 95vh;
    max-height: 95dvh;
    max-height: min(95dvh, calc(var(--pm-vvh, 9999px) * 0.95));
  }

  .pm-overlay.has-personalization .pm-dialog {
    width: 96vw;
    max-height: 95vh;
    max-height: 95dvh;
    max-height: min(95dvh, calc(var(--pm-vvh, 9999px) * 0.95));
  }

  .pm-gallery {
    flex: 0 0 auto;
    width: 100%;
    height: 55vw;
    max-height: 55vw;
    aspect-ratio: auto;
  }

  .pm-overlay.has-personalization .pm-gallery {
    flex: 0 0 auto;
    width: 100%;
    height: 42vh;
    max-height: 42vh;
    aspect-ratio: auto;
  }

  .pm-body {
    padding: 1.25rem;
    overflow-y: auto;
  }

  .pm-overlay.has-personalization .pm-body {
    padding: 1.1rem;
    overflow-y: auto;
  }

  .pm-personalization,
  .pm-overlay.has-personalization .pm-personalization {
    max-height: 34vh;
    overflow-y: auto;
  }

  .pm-overlay.has-personalization .pm-personalization-fields {
    grid-template-columns: 1fr;
  }
}
