/* ============================================================
   RBC Créations - Configurateur de produit
   ============================================================ */

/* Layout principal 3 colonnes */
.customizer-page {
  padding-top: 72px;
  min-height: 100vh;
  background: var(--gray-50);
}

.customizer-layout {
  display: grid;
  grid-template-columns: 300px 1fr 360px;
  min-height: calc(100vh - 72px);
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1200px) {
  .customizer-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Panneau gauche : Outils --- */
.tools-panel {
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 72px);
}

.tools-panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--gray-100);
}

.tool-section {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  transition: var(--transition);
  cursor: pointer;
}
.tool-section:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(59,130,246,0.1);
}
.tool-section.active {
  border-color: var(--accent);
  background: rgba(59,130,246,0.03);
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--gray-500);
  flex-shrink: 0;
}
.tool-section.active .tool-icon {
  background: var(--accent);
  color: var(--white);
}
.tool-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
}
.tool-info p {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 2px;
}
.tool-edit-btn {
  margin-left: auto;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  background: none;
  border: none;
  font-weight: 500;
}

/* Outil de texte */
.text-tool-content {
  margin-top: 1rem;
  display: none;
}
.text-tool-content.open {
  display: block;
}
.text-input-area {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 60px;
  transition: var(--transition);
}
.text-input-area:focus {
  outline: none;
  border-color: var(--accent);
}

.text-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.text-option-btn {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--gray-600);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.text-option-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Font picker */
.font-select {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 0.75rem;
  cursor: pointer;
}

/* Color picker for text */
.text-color-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.text-color-input {
  width: 36px;
  height: 36px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
}
.text-color-label {
  font-size: 0.85rem;
  color: var(--gray-600);
}

/* Image upload */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 0.75rem;
}
.upload-zone:hover {
  border-color: var(--accent);
  background: rgba(59,130,246,0.03);
}
.upload-zone i {
  font-size: 2rem;
  color: var(--gray-400);
  margin-bottom: 0.5rem;
}
.upload-zone p {
  font-size: 0.85rem;
  color: var(--gray-500);
}
.upload-zone small {
  font-size: 0.75rem;
  color: var(--gray-400);
}
.upload-preview {
  margin-top: 0.75rem;
  position: relative;
  display: none;
}
.upload-preview img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}
.upload-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gray-700);
  color: var(--white);
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-tool-content {
  margin-top: 0.75rem;
}
.image-supplement-notice {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: #795548;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.image-supplement-notice i {
  color: #f9a825;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Sauvegarde du design */
.design-save-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0 0.25rem;
}
.save-design-btn, .load-design-btn {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-600);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.save-design-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59,130,246,0.04);
}
.load-design-btn:hover {
  border-color: var(--gray-500);
  color: var(--gray-700);
}
.save-design-btn i, .load-design-btn i {
  font-size: 0.85rem;
}

/* Instructions */
.print-instructions {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(59,130,246,0.05);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  max-height: 0;
  overflow: hidden;
  padding: 0 0.75rem;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.tool-section.active .print-instructions {
  max-height: 200px;
  padding: 0.75rem;
}
.print-instructions input {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* --- Panneau central : Aperçu --- */
.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  background: var(--gray-50);
}

.preview-container {
  position: relative;
  width: 100%;
  max-width: 550px;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.product-preview {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SVG Product Base */
.product-svg-container {
  position: relative;
  width: 420px;
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-svg-container svg {
  width: 100%;
  height: 100%;
}

/* Zone de personnalisation sur le produit (overlay) */
.customization-overlay {
  position: absolute;
  top: 30%;
  left: 25%;
  width: 50%;
  height: 30%;
  border: 2px dashed rgba(59,130,246,0.4);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255,255,255,0.1);
  cursor: move;
  user-select: none;
  touch-action: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.customization-overlay:hover,
.customization-overlay.dragging {
  border-color: rgba(59,130,246,0.7);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* Poignées de redimensionnement */
.resize-handle {
  position: absolute;
  background: #3b82f6;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 10;
}

.resize-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.resize-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

.resize-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }
.resize-handle.e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }

/* Info-bulle de la zone */
.overlay-hint {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--gray-400);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.customization-overlay:hover .overlay-hint {
  opacity: 1;
}

.customization-overlay .custom-text {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  word-break: break-word;
  padding: 0.25rem;
  line-height: 1.3;
}

.customization-overlay .custom-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

/* Navigation du preview */
.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.2rem;
  color: var(--gray-500);
  box-shadow: var(--shadow);
  z-index: 5;
}
.preview-nav:hover {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.preview-nav-left { left: 0.5rem; }
.preview-nav-right { right: 0.5rem; }

.preview-dots {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}
.preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-300);
  cursor: pointer;
  transition: var(--transition);
}
.preview-dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 5px;
}

.preview-view-toggle {
  display: flex;
  gap: 0;
  margin-top: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--gray-200);
}
.view-btn {
  padding: 0.5rem 1.5rem;
  background: var(--white);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-500);
  transition: var(--transition);
}
.view-btn.active {
  background: var(--primary);
  color: var(--white);
}

/* Product selector bar */
.product-selector-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem 1.5rem;
}
.product-selector-bar .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.product-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: 2px solid var(--gray-200);
  border-radius: 50px;
  background: var(--white);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
}
.product-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.product-tab.active {
  border-color: var(--accent);
  background: rgba(59,130,246,0.08);
  color: var(--accent);
  font-weight: 600;
}
.product-tab i {
  font-size: 1rem;
}

/* --- Panneau droit : Détails produit --- */
.details-panel {
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 72px);
}

.product-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.rating-stars {
  color: var(--warning);
  font-size: 0.9rem;
}
.rating-note {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.9rem;
}
.rating-count {
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
}
.rating-count:hover {
  text-decoration: underline;
}

.product-price-tag {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}
.product-price-info {
  font-size: 0.85rem;
  color: var(--gray-400);
  margin-bottom: 1.5rem;
}

/* Sections du panneau details */
.detail-section {
  margin-bottom: 1.75rem;
}
.detail-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 0.25rem;
}
.detail-section-subtitle {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-bottom: 0.75rem;
}

/* Color swatches */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  border: 3px solid transparent;
}
.color-swatch:hover {
  transform: scale(1.1);
}
.color-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--accent);
}
.color-swatch.has-border {
  border: 2px solid var(--gray-300);
}
.color-swatch.has-border.active {
  border-color: var(--accent);
}
.color-swatch[title]::after {
  content: attr(title);
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.color-swatch:hover::after {
  opacity: 1;
}

/* Size selector */
.size-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.size-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
.size-row:last-child {
  border-bottom: none;
}
.size-row:hover {
  background: var(--gray-50);
}
.size-label {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.95rem;
  min-width: 60px;
}
.qty-controls {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}
.qty-btn {
  width: 36px;
  height: 36px;
  background: var(--gray-50);
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--gray-500);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:hover {
  background: var(--accent);
  color: var(--white);
}
.qty-value {
  width: 48px;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gray-800);
  border: none;
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  padding: 0.5rem 0;
}

/* Size guide */
.size-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.5rem;
  cursor: pointer;
}
.size-guide-link:hover {
  text-decoration: underline;
}

/* Order summary */
.order-summary {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.order-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--gray-600);
}
.order-total {
  display: flex;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 2px solid var(--gray-200);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

/* Add to cart button */
.add-to-cart-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--accent), var(--primary-light));
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.add-to-cart-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.add-to-cart-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Breadcrumb */
.customizer-breadcrumb {
  padding: 0.75rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
  color: var(--gray-400);
}
.customizer-breadcrumb a {
  color: var(--gray-500);
}
.customizer-breadcrumb a:hover {
  color: var(--accent);
}
.customizer-breadcrumb span {
  margin: 0 0.5rem;
}

/* Top bar */
.customizer-topbar {
  background: var(--primary);
  color: var(--white);
  padding: 0.5rem 1.5rem;
  display: flex;
  justify-content: center;
  gap: 3rem;
  font-size: 0.85rem;
}
.topbar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-item i {
  font-size: 1rem;
}

/* Responsive */
@media (max-width: 1200px) {
  .customizer-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .tools-panel {
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    max-height: none;
  }
  .details-panel {
    border-left: none;
    border-top: 1px solid var(--gray-200);
    max-height: none;
  }
  .product-svg-container {
    width: 320px;
    height: 380px;
  }
}

@media (max-width: 768px) {
  .product-svg-container {
    width: 260px;
    height: 320px;
  }
  .customizer-topbar {
    gap: 1rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
  }
}

/* --- Outil Position / Emplacement --- */
.position-tool-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1rem;
}

.tool-section.active .position-tool-content {
  max-height: 300px;
  padding: 1rem;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 180px;
  margin: 0 auto;
}

.position-btn {
  width: 50px;
  height: 50px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--gray-500);
  transition: all 0.2s ease;
}

.position-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(59,130,246,0.05);
}

.position-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* --- Sélecteur de formule (Flocage seul / Produit + Flocage) --- */
.formula-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 1rem 0;
}

.formula-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--white);
}

.formula-option:hover {
  border-color: var(--primary);
  background: rgba(59,130,246,0.02);
}

.formula-option.active {
  border-color: var(--primary);
  background: rgba(59,130,246,0.06);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.formula-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--gray-100);
  color: var(--gray-500);
  flex-shrink: 0;
}

.formula-option.active .formula-icon {
  background: var(--primary);
  color: white;
}

.formula-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.formula-details strong {
  font-size: 0.85rem;
  color: var(--gray-800);
}

.formula-details span {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.formula-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}