/* CustomAll Renderer - Shared Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: #fff; color: #333; }
.page-wrapper { max-width: 1200px; margin: 0 auto; padding: 20px; }
.breadcrumb { font-size: 13px; color: #888; margin-bottom: 16px; }
.breadcrumb a { color: #8b1a1a; text-decoration: none; }
.product-layout { display: grid; grid-template-columns: 55fr 45fr; gap: 40px; }

/* Left column */
.gallery { position: sticky; top: 20px; align-self: start; min-width: 0; overflow: hidden; }
.main-image-wrap {
  position: relative; overflow: hidden; border-radius: 4px; aspect-ratio: 1; cursor: zoom-in;
}
.main-image-wrap img { width: 100%; height: 100%; display: block; border-radius: 4px; object-fit: cover; }

/* Canvas container -- overlays on top of product image, transparent background */
.canvas-container {
  display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;
}
.canvas-container .konvajs-content {
  width: 100% !important; height: 100% !important;
  position: absolute; top: 0; left: 0;
}
.canvas-container .konvajs-content canvas {
  width: 100% !important; height: 100% !important; border-radius: 4px;
}

.thumb-strip {
  display: flex; gap: 8px; margin-top: 12px; overflow-x: auto;
  padding-bottom: 4px;
}
.thumb-strip .thumb {
  width: 72px; height: 72px; border-radius: 8px; border: 2px solid transparent;
  cursor: pointer; overflow: hidden; flex-shrink: 0; background: #fff;
}
.thumb-strip .thumb.active { border-color: #8b1a1a; }
.thumb-strip .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-strip .thumb-canvas {
  width: 72px; height: 72px; border-radius: 8px; border: 2px solid transparent;
  cursor: pointer; flex-shrink: 0; background: #fff8f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #8b1a1a; font-weight: 600;
}
.thumb-strip .thumb-canvas.active { border-color: #8b1a1a; }

/* Right column */
.product-info h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: #222; }
.price { font-size: 22px; font-weight: 700; color: #8b1a1a; margin-bottom: 20px; }
.price .compare { text-decoration: line-through; color: #999; font-size: 16px; font-weight: 400; margin-left: 8px; }

.personalizer { display: flex; flex-direction: column; gap: 20px; }
.section-title {
  font-size: 15px; font-weight: 700; font-style: italic;
  letter-spacing: 0.3px; color: #222; padding-bottom: 4px;
  margin-bottom: 4px;
}
.option-group { display: flex; flex-direction: column; gap: 6px; }
.option-label { font-size: 15px; font-weight: 700; font-style: italic; color: #111; }
/* Option swatch grid */
.option-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px;
}
.option-grid.scrollable { max-height: 260px; overflow-y: auto; padding-right: 4px; }
.option-cell {
  position: relative; border-radius: 8px; border: 2px solid #e0e0e0;
  cursor: pointer; overflow: hidden; background: #fff;
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, transform 0.15s;
}
.option-cell:hover { transform: scale(1.04); }
.option-cell.selected { border-color: #8b1a1a; box-shadow: 0 0 0 1px #8b1a1a; }
.option-cell.selected::after {
  content: ''; position: absolute; top: 3px; right: 3px;
  background: #8b1a1a; width: 18px; height: 18px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpolyline points='3 8 7 12 13 4' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 11px 11px;
}
.option-cell img { width: 100%; height: 100%; object-fit: contain; display: block; background: #f0eeeb; border-radius: 6px; padding: 2px; }
.option-cell .cell-text {
  font-size: 13px; font-weight: 800; text-transform: uppercase; color: #222;
  padding: 4px; text-align: center; word-break: break-word; line-height: 1.2;
}
.option-cell .cell-label {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.55);
  color: #fff; font-size: 11px; font-weight: 600; text-align: center; padding: 3px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.option-cell.selected .cell-label { background: #8b1a1a; }

/* Color swatches - circular */
.color-swatch-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding-bottom: 4px;
}
.color-swatch {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid #d0d0d0;
  cursor: pointer; transition: all 0.15s; position: relative; flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.12); border-color: #999; }
.color-swatch.selected { border-color: #8b1a1a; box-shadow: 0 0 0 2px #8b1a1a; }
.color-swatch.selected::after {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpolyline points='3 8 7 12 13 4' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: contain;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.5));
}
.color-swatch-tooltip {
  position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
  font-size: 10px; white-space: nowrap; color: #666; opacity: 0; transition: opacity 0.15s;
  pointer-events: none; z-index: 10;
}
.color-swatch:hover .color-swatch-tooltip { opacity: 1; }

/* Pill buttons for text/number choices */
.pill-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.pill-btn {
  padding: 8px 18px; border-radius: 100px; border: 2px solid #e0e0e0;
  cursor: pointer; font-size: 14px; font-weight: 600; color: #333;
  background: #fff; transition: all 0.15s; white-space: nowrap;
  user-select: none;
}
.pill-btn:hover { border-color: #bbb; background: #fafafa; }
.pill-btn.selected { border-color: #8b1a1a; background: #fdf2f2; color: #8b1a1a; }
.pill-btn.selected::before {
  content: '\2713\00a0'; font-size: 12px;
}
.pill-btn.disabled { opacity: 0.35; cursor: default; }

.text-input-wrap { position: relative; }
.text-input-wrap input {
  width: 100%; padding: 10px 50px 10px 12px; border: 2px solid #e0e0e0;
  border-radius: 8px; font-size: 14px; font-family: inherit;
  transition: border-color 0.15s;
}
.text-input-wrap input:focus { outline: none; border-color: #8b1a1a; }
.char-count {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #999;
}

.btn-add-to-cart {
  width: 100%; padding: 16px; background: #8b1a1a; color: #fff;
  border: none; border-radius: 10px; font-size: 16px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.5px; transition: background 0.2s;
  margin-top: 8px;
}
.btn-add-to-cart:hover { background: #a02020; }

/* Image preview modal */
.image-preview-modal {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.85); cursor: pointer;
  align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.image-preview-modal.open { display: flex; }
.image-preview-modal img {
  max-width: 92vw; max-height: 92vh; object-fit: contain;
  border-radius: 8px; cursor: default;
}
.image-preview-modal .modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  color: #fff; font-size: 22px; line-height: 36px; text-align: center;
  transition: background 0.15s;
}
.image-preview-modal .modal-close:hover { background: rgba(255,255,255,0.3); }

/* Scrollbar */
.scrollable::-webkit-scrollbar { width: 5px; }
.scrollable::-webkit-scrollbar-track { background: #f0f0f0; border-radius: 4px; }
.scrollable::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }

/* ===== Mobile ===== */
@media (max-width: 860px) {
  .product-layout { grid-template-columns: 1fr; gap: 16px; }
  .page-wrapper { padding: 12px; }
  .gallery { position: static; }
  .product-info h1 { font-size: 20px; }
  .price { font-size: 20px; margin-bottom: 14px; }
  .personalizer { gap: 16px; }
  .thumb-strip { margin-top: 8px; }
  .thumb-strip .thumb, .thumb-strip .thumb-canvas { width: 56px; height: 56px; }
  .btn-add-to-cart { position: sticky; bottom: 0; z-index: 100; margin-top: 12px; }
}

@media (max-width: 480px) {
  .page-wrapper { padding: 8px; }
  .product-layout { gap: 16px; }
  .option-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; }
  .color-swatch { width: 34px; height: 34px; }
  .color-swatch-row { gap: 8px; }
  .pill-btn { padding: 7px 14px; font-size: 13px; }
  .pill-row { gap: 6px; }
  .option-label { font-size: 14px; }
  .text-input-wrap input { padding: 9px 45px 9px 10px; font-size: 16px; /* >=16px prevents iOS auto-zoom */ }
  .btn-add-to-cart { -webkit-tap-highlight-color: transparent; }
  .pill-btn { -webkit-tap-highlight-color: transparent; }
  .option-cell { -webkit-tap-highlight-color: transparent; }
}
