/* PBN Preview v2 */
.pbn-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  font-family: system-ui, -apple-system, sans-serif;
}
.pbn-modal {
  background: #fff; border-radius: 16px; padding: 24px;
  max-width: 580px; width: 95vw; max-height: 90vh;
  overflow-y: auto; position: relative; box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
}
.pbn-close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; font-size: 28px; cursor: pointer;
  color: #666; line-height: 1; padding: 4px 8px; border-radius: 50%;
}
.pbn-close:hover { background: #f0f0f0; color: #000; }
.pbn-title { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.pbn-subtitle { margin: 0 0 16px; color: #6b7280; font-size: 14px; }

/* Color count tabs */
.pbn-color-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px;
}
.pbn-color-tab {
  padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 8px;
  background: #f9fafb; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all 0.15s;
}
.pbn-color-tab:hover { border-color: #d1d5db; background: #f3f4f6; }
.pbn-color-tab.active {
  background: #111; color: #fff; border-color: #111;
}

/* View mode tabs */
.pbn-view-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: #f3f4f6; border-radius: 8px; padding: 3px;
}
.pbn-view-tab {
  flex: 1; padding: 6px 12px; border: none; border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 13px; font-weight: 500;
  color: #6b7280; transition: all 0.15s;
}
.pbn-view-tab:hover { color: #374151; }
.pbn-view-tab.active {
  background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Canvas area — fixed aspect ratio container so it doesn't jump */
.pbn-canvas-wrap {
  position: relative; background: #f9fafb; border-radius: 12px;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.pbn-canvas {
  max-width: 100%; max-height: 50vh; display: block; border-radius: 8px;
}
/* Lock canvas wrapper height after first render */
.pbn-canvas-wrap.pbn-sized {
  min-height: unset;
}
.pbn-progress {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; background: rgba(249,250,251,0.9);
}
.pbn-spinner {
  width: 32px; height: 32px; border: 3px solid #e5e7eb;
  border-top-color: #111; border-radius: 50%;
  animation: pbn-spin 0.8s linear infinite;
}
@keyframes pbn-spin { to { transform: rotate(360deg); } }
.pbn-progress-text { margin: 0; font-size: 13px; color: #6b7280; }
.pbn-bar-wrap {
  width: 200px; height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden;
}
.pbn-bar {
  height: 100%; background: #111; border-radius: 2px;
  transition: width 0.3s ease; width: 0%;
}

/* Palette — collapsible */
.pbn-palette-section {
  margin-top: 16px; border-top: 1px solid #e5e7eb; padding-top: 8px;
}
.pbn-palette-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 8px 0; border: none; background: none;
  cursor: pointer; font-size: 14px; font-weight: 600; color: #374151;
  font-family: system-ui, -apple-system, sans-serif;
}
.pbn-palette-toggle:hover { color: #111; }
.pbn-chevron {
  transition: transform 0.2s ease; flex-shrink: 0;
}
.pbn-chevron-open { transform: rotate(180deg); }
.pbn-palette {
  display: flex; flex-wrap: wrap; gap: 6px;
  overflow: hidden; transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
  max-height: 300px; opacity: 1; padding-top: 8px;
}
.pbn-palette-collapsed {
  max-height: 0; opacity: 0; padding-top: 0;
}
.pbn-swatch {
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15); border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

/* ========== Product page button styles ========== */
.pbn-preview-wrap { margin: 12px 0; }
.pbn-preview-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; line-height: 1.4;
  font-family: system-ui, -apple-system, sans-serif;
}
.pbn-btn-default {
  background: #111; color: #fff; border: 1px solid #111;
}
.pbn-btn-default:hover { background: #333; border-color: #333; }
.pbn-btn-outline {
  background: transparent; color: #111; border: 1.5px solid #d1d5db;
}
.pbn-btn-outline:hover { border-color: #111; background: #f9fafb; }

/* Flatsome theme compatibility */
.product-info .pbn-preview-wrap { width: 100%; }
.product-info .pbn-preview-trigger { width: 100%; justify-content: center; }

/* ========== Color Palette Selector ========== */
.pbn-palette-selector { margin: 14px 0; }
.pbn-palette-label {
  font-size: 13px; font-weight: 600; color: #374151;
  margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.05em;
}
.pbn-palette-cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.pbn-pc {
  padding: 10px 12px; border: 2.5px solid #e5e7eb; border-radius: 10px;
  cursor: pointer; transition: all 0.15s; background: #fff;
  user-select: none;
}
.pbn-pc:hover { border-color: #9ca3af; }
.pbn-pc-active {
  border-color: #111 !important; background: #f9fafb;
  transform: scale(1.02); box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.pbn-pc-main {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.pbn-pc-label { font-size: 14px; font-weight: 600; color: #111; }
.pbn-pc-price { font-size: 12px; font-weight: 600; color: #16a34a; }
.pbn-pc-desc { font-size: 11px; color: #6b7280; margin: 2px 0 0; line-height: 1.3; }

/* ========== Extra Paint upsell card ========== */
.pbn-extra-paint-wrap { margin: 12px 0; }
.pbn-ep-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border: 2px solid #e5e7eb; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; background: #fff;
  position: relative; user-select: none;
}
.pbn-ep-card:hover { border-color: #9ca3af; }
.pbn-ep-card.pbn-ep-selected {
  border-color: #16a34a; background: #f0fdf4;
}
.pbn-ep-img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0;
}
.pbn-ep-icon {
  width: 56px; height: 56px; display: flex; align-items: center; justify-content: center;
  background: #f3f4f6; border-radius: 8px; flex-shrink: 0;
}
.pbn-ep-content { flex: 1; min-width: 0; }
.pbn-ep-title { font-size: 14px; font-weight: 600; color: #111; display: block; }
.pbn-ep-desc { font-size: 12px; color: #6b7280; margin: 2px 0 6px; line-height: 1.3; }
.pbn-ep-pricing { display: flex; align-items: center; gap: 8px; }
.pbn-ep-sale-price {
  font-size: 14px; font-weight: 700; color: #16a34a;
}
.pbn-ep-regular-price {
  font-size: 13px; color: #9ca3af; text-decoration: line-through;
}
.pbn-ep-toggle {
  width: 24px; height: 24px; border: 2px solid #d1d5db; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 4px; transition: all 0.2s;
}
.pbn-ep-check { display: none; }
.pbn-ep-selected .pbn-ep-toggle {
  background: #16a34a; border-color: #16a34a;
}
.pbn-ep-selected .pbn-ep-check {
  display: block; color: #fff;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .pbn-modal { max-width: 100vw; max-height: 100vh; border-radius: 0; padding: 16px; }
  .pbn-canvas { max-height: 40vh; }
  .pbn-preview-trigger { width: 100%; justify-content: center; }
}
