/* ========================================
   PRODUCT PREVIEW — Scoped version of product-page.css
   Used in product-builder.php and demo.php
   Supports .preview-desktop / .preview-mobile toggle
   ======================================== */

/* ── Toggle Bar ─────────────────────────────────────── */
.preview-toggle-bar {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 16px;
  background: #e5e5e5;
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}
.demo-page .preview-toggle-bar {
  background: #1a1f2e;
}
.preview-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #666;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.demo-page .preview-toggle-btn {
  color: #94a3b8;
}
.preview-toggle-btn.active {
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.demo-page .preview-toggle-btn.active {
  background: #2a2f3a;
  color: #f8fafc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.preview-toggle-btn svg {
  flex-shrink: 0;
}

/* ── Preview Frame ──────────────────────────────────── */
/* Override legacy .builder-preview .product-preview from pages.css */
.builder-preview .product-preview.preview-mobile,
.builder-preview .product-preview.preview-desktop,
.product-preview.preview-mobile,
.product-preview.preview-desktop {
  font-family: 'Inter', -apple-system, sans-serif;
  color: #1a1a1a;
  line-height: 1.5;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  transition: max-width 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: none;
}

/* ── Mobile Mode ────────────────────────────────────── */
.builder-preview .product-preview.preview-mobile,
.product-preview.preview-mobile {
  max-width: 390px;
  width: 100%;
}

/* ── Desktop Mode ───────────────────────────────────── */
.builder-preview .product-preview.preview-desktop,
.product-preview.preview-desktop {
  max-width: 820px;
  width: 100%;
}

/* ── Product Page Container ─────────────────────────── */
.product-preview .pv-page {
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Store Header ───────────────────────────────────── */
.product-preview .pv-store-header {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  transition: background-color 0.2s ease-out;
}
.product-preview .pv-store-logo {
  height: 24px;
  max-width: 100px;
  object-fit: contain;
}
.product-preview .pv-store-name {
  font-size: 14px;
  font-weight: 600;
}
.product-preview .pv-store-name img {
  height: 24px;
  max-width: 100px;
  object-fit: contain;
}

/* ── Main Layout ────────────────────────────────────── */
.product-preview .pv-main {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Desktop: two-column grid */
.product-preview.preview-desktop .pv-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

/* ── Left Column ────────────────────────────────────── */
.product-preview .pv-left {
  padding: 16px;
}
.product-preview.preview-desktop .pv-left {
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid #eee;
  max-height: 600px;
}

/* ── Product Title ──────────────────────────────────── */
.product-preview .pv-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 10px;
}
.product-preview.preview-desktop .pv-title {
  font-size: 22px;
}

/* ── Image Carousel ─────────────────────────────────── */
.product-preview .pv-carousel {
  width: 100%;
  background: #f8f8f8;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 14px;
  position: relative;
}
.product-preview .pv-carousel .swiper {
  width: 100%;
  aspect-ratio: 1;
}
.product-preview.preview-desktop .pv-carousel {
  border-radius: 10px;
}
.product-preview.preview-desktop .pv-carousel .swiper {
  aspect-ratio: auto;
  height: 280px;
}
.product-preview .pv-carousel .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-preview .pv-carousel .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-preview .pv-carousel .swiper-pagination-progressbar {
  background: rgba(0,0,0,0.1) !important;
}
.product-preview .pv-carousel .swiper-pagination-progressbar-fill {
  background: #1a1a1a !important;
}
.product-preview .pv-carousel .swiper-button-next,
.product-preview .pv-carousel .swiper-button-prev {
  display: none;
}
.product-preview.preview-desktop .pv-carousel .swiper-button-next,
.product-preview.preview-desktop .pv-carousel .swiper-button-prev {
  display: flex;
  color: #1a1a1a;
}
.product-preview.preview-desktop .pv-carousel .swiper-button-next:after,
.product-preview.preview-desktop .pv-carousel .swiper-button-prev:after {
  font-size: 16px;
}
.product-preview .pv-image-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 13px;
}
.product-preview.preview-desktop .pv-image-placeholder {
  aspect-ratio: auto;
  height: 280px;
}
.product-preview .pv-image-count {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #666;
}

/* ── Price + Quantity Row ───────────────────────────── */
.product-preview .pv-price-qty-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 14px;
}
.product-preview .pv-price-stock-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.product-preview .pv-price {
  font-size: 18px;
  font-weight: 700;
}
.product-preview.preview-desktop .pv-price {
  font-size: 20px;
}
.product-preview .pv-stock-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
}
.product-preview .pv-stock-badge.low-stock {
  background: #fffbeb;
  color: #92400e;
}
.product-preview .pv-stock-badge.sold-out {
  background: #fef2f2;
  color: #991b1b;
}
.product-preview .pv-stock-badge.in-stock {
  background: #f0fdf4;
  color: #166534;
}
.product-preview .pv-quantity-control {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border-radius: 6px;
  padding: 2px;
}
.product-preview .pv-quantity-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #1a1a1a;
  border-radius: 4px;
  font-family: inherit;
}
.product-preview .pv-quantity-btn:hover {
  background: #e5e5e5;
}
.product-preview .pv-quantity-value {
  font-size: 13px;
  font-weight: 600;
  min-width: 30px;
  text-align: center;
}

/* ── Options (price-bearing) ────────────────────────── */
.product-preview .pv-option-section {
  margin-bottom: 14px;
}
.product-preview .pv-variant-label {
  font-size: 11px;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.product-preview .pv-option-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.product-preview .pv-option-btn {
  min-width: 40px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: default;
  white-space: nowrap;
  font-family: inherit;
}
.product-preview .pv-option-btn.selected {
  border-color: #1a1a1a;
  background: #1a1a1a;
  color: #fff;
}

/* ── Color Swatches ─────────────────────────────────── */
.product-preview .pv-variant-section {
  margin-bottom: 14px;
}
.product-preview .pv-color-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.product-preview .pv-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #e5e5e5;
  cursor: default;
}
.product-preview .pv-color-swatch.selected {
  border-color: #1a1a1a;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px #1a1a1a;
}

/* ── Description ────────────────────────────────────── */
.product-preview .pv-description {
  font-size: 13px;
  color: #666;
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ── Notes ──────────────────────────────────────────── */
.product-preview .pv-notes-section {
  margin-bottom: 16px;
}
.product-preview .pv-notes-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-size: 13px;
  color: #1a1a1a;
  cursor: default;
  padding: 0;
  font-family: inherit;
}
.product-preview .pv-notes-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 50%;
}

/* ── Price Breakdown ────────────────────────────────── */
.product-preview .pv-price-breakdown {
  margin-bottom: 14px;
  padding: 14px 0;
  border-top: 1px solid #eee;
}
.product-preview.preview-desktop .pv-right .pv-price-breakdown {
  padding: 0 0 14px;
  border-top: none;
  border-bottom: 1px solid #eee;
  margin-bottom: 16px;
}
.product-preview .pv-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
  color: #666;
}
.product-preview .pv-price-row.pv-total-row {
  padding-top: 6px;
  margin-top: 6px;
  border-top: 1px solid #e5e5e5;
}
.product-preview .pv-total-label {
  font-size: 13px;
  color: #666;
}
.product-preview .pv-total-value {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
}
.product-preview.preview-desktop .pv-total-value {
  font-size: 18px;
}

/* ── Right Column (checkout) ────────────────────────── */
.product-preview .pv-right {
  padding: 16px;
}
.product-preview.preview-desktop .pv-right {
  padding: 20px;
  overflow-y: auto;
  max-height: 600px;
}

/* ── Checkout UI (simulated) ────────────────────────── */
.product-preview .pv-card-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
  margin-bottom: 8px;
  font-family: inherit;
  font-size: 13px;
  color: #999;
}
.product-preview .pv-section-label {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
  display: block;
}
.product-preview .pv-address-placeholder {
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #999;
  background: #fafafa;
}
.product-preview .pv-card-placeholder {
  padding: 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
  margin-bottom: 10px;
  font-size: 12px;
  color: #999;
}
.product-preview .pv-pay-button {
  width: 100%;
  height: 42px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: default;
  font-family: inherit;
}
.product-preview .pv-pay-button:disabled {
  background: #e5e5e5;
  color: #999;
}
.product-preview .pv-security-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  font-size: 11px;
  color: #999;
}
.product-preview .pv-security-footer svg {
  color: #16a34a;
}
.product-preview .pv-express-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: #999;
  font-size: 11px;
}
.product-preview .pv-express-divider::before,
.product-preview .pv-express-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e5e5;
}
.product-preview .pv-express-placeholder {
  width: 100%;
  height: 42px;
  background: #000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

/* ── Mobile-only bottom bar ─────────────────────────── */
.product-preview .pv-mobile-bar {
  padding: 10px 16px;
  border-top: 1px solid #eee;
  background: #fff;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.product-preview .pv-mobile-express {
  width: 100%;
  height: 40px;
  background: #000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}
.product-preview .pv-mobile-card-btn {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: #1a1a1a;
  border: 1.5px solid #1a1a1a;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: default;
  margin-bottom: 6px;
  font-family: inherit;
}
.product-preview .pv-mobile-total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666;
}
.product-preview .pv-mobile-total-value {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
}

/* ── Visibility helpers ─────────────────────────────── */
.product-preview .pv-mobile-only { display: block; }
.product-preview .pv-desktop-only { display: none; }

.product-preview.preview-desktop .pv-mobile-only { display: none !important; }
.product-preview.preview-desktop .pv-desktop-only { display: block !important; }

.product-preview.preview-mobile .pv-mobile-only { display: block !important; }
.product-preview.preview-mobile .pv-desktop-only { display: none !important; }

/* Desktop: hide store header at larger preview */
.product-preview.preview-desktop .pv-store-header {
  display: none;
}

/* Desktop mode background simulation */
.product-preview.preview-desktop {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
}
