/* ============================================================
 * CustomizerPro - frontend styles (consolidated)
 * Fusion de front.css + front-v3.css + front-v125.css
 * Version: 1.0.0
 * ============================================================ */

/* ===== Bouton 'Personnaliser cet article' + summary ===== */
/* ============================================================
 * CustomizerPro - styles front
 * Sobre, neutre, conçu pour s'intégrer dans la plupart des thèmes.
 * ============================================================ */
#cp-wrapper { margin: 1rem 0; }

.cp-open-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: 6px;
  background: #1c2330; color: #fff; border: 0; cursor: pointer;
  font-weight: 600;
}
.cp-open-btn:hover { background: #2a3344; }
.cp-open-btn .material-icons { font-size: 1.1rem; }

.cp-summary {
  margin-top: .75rem; padding: .75rem 1rem;
  background: #f4f6f9; border-radius: 6px;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.cp-summary-label { font-weight: 600; }
.cp-summary-text  { color: #1c2330; }
.cp-summary-price { margin-left: auto; font-weight: 700; }
.cp-edit-btn      { background: transparent; border: 0; color: #007bff; cursor: pointer; text-decoration: underline; }

/* ============== MODAL ============== */
.cp-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
body.cp-modal-open { overflow: hidden; }
.cp-modal[hidden]  { display: none; }

.cp-modal-dialog {
  background: #fff; border-radius: 10px;
  width: 100%; max-width: 1100px; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.cp-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid #eee;
}
.cp-modal-header h3 { margin: 0; font-size: 1.15rem; }
.cp-close {
  background: transparent; border: 0; font-size: 1.5rem;
  cursor: pointer; color: #666;
}
.cp-modal-body {
  display: flex; flex: 1; overflow: hidden; min-height: 480px;
}
.cp-sidebar {
  width: 320px; padding: 1rem; border-right: 1px solid #eee;
  overflow-y: auto; background: #fafbfc;
  display: flex; flex-direction: column; gap: .75rem;
}
.cp-canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #f0f1f3; padding: 1rem; position: relative;
}
.cp-canvas-inner {
  position: relative;
  max-width: 100%; max-height: 100%;
}
.cp-canvas-inner img { display: block; max-width: 100%; max-height: 70vh; }
.cp-canvas-inner canvas { position: absolute; left: 0; top: 0; }
.cp-modal-footer {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding: 1rem 1.5rem; border-top: 1px solid #eee; background: #fafbfc;
}

/* ============== sidebar widgets ============== */
.cp-zone-tabs { display: flex; gap: .35rem; flex-wrap: wrap; }
.cp-zone-tab {
  padding: .35rem .75rem; border-radius: 16px;
  background: #e9ecf1; border: 0; cursor: pointer;
  font-size: .85rem;
}
.cp-zone-tab.active { background: #1c2330; color: #fff; }

.cp-label { display: block; margin: .25rem 0; font-weight: 600; font-size: .85rem; }
.cp-input, .cp-select {
  width: 100%; padding: .45rem .6rem; border: 1px solid #d0d5dd;
  border-radius: 5px; font-size: .9rem; background: #fff;
}
.cp-tool-group {
  padding: .75rem; background: #fff; border: 1px solid #e6e8ed; border-radius: 6px;
}
.cp-tool-group h4 { margin: 0 0 .5rem 0; font-size: .95rem; }
.cp-tool-group label { display: block; margin: .5rem 0 .25rem; font-size: .8rem; font-weight: 600; }
.cp-hint { font-size: .75rem; color: #777; margin-top: .25rem; }

.cp-swatches { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .5rem; }
.cp-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #ccc; cursor: pointer; padding: 0;
}
.cp-swatch.active { border-color: #1c2330; box-shadow: 0 0 0 2px #fff inset; }

.cp-add-text {
  margin-top: .5rem; width: 100%;
  padding: .45rem; border: 0; border-radius: 5px;
  background: #007bff; color: #fff; cursor: pointer; font-weight: 600;
}

.cp-price-box {
  margin-top: auto; padding: .75rem 1rem; background: #1c2330; color: #fff;
  border-radius: 6px; text-align: center;
}
.cp-price-label  { font-size: .8rem; opacity: .8; }
.cp-price-amount { font-size: 1.3rem; font-weight: 700; }

/* ============== responsive ============== */
@media (max-width: 768px) {
  .cp-modal-body { flex-direction: column; min-height: 0; }
  .cp-sidebar { width: 100%; max-height: 40vh; border-right: 0; border-bottom: 1px solid #eee; }
  .cp-canvas-wrap { padding: .5rem; }
}

/* PATCH v1.2 : Fabric.js cree un .canvas-container qui wrap le canvas.
   Le selecteur .cp-canvas-inner canvas ne le cible pas car c'est un div. */
.cp-canvas-inner .canvas-container {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
}

/* PATCH v1.3 : sélecteur de couleur produit en haut du sidebar */
.cp-product-colors { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #eee; }
.cp-product-colors label { display: block; font-weight: 600; margin-bottom: 0.5rem; font-size: 0.9rem; color: #333; }
.cp-product-swatches { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cp-product-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); transition: transform 0.15s; background-size: cover; background-position: center; background-repeat: no-repeat; }
.cp-product-swatch:hover { transform: scale(1.15); }
.cp-product-swatch.active { border-color: #007bff; box-shadow: 0 0 0 2px white, 0 0 0 4px #007bff; }
/* [v1.2.9] Swatch en mode image (hex manquant) : leger contour pour distinguer du fond */
.cp-product-swatch.cp-swatch-img { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25); }

/* Boutons actions row */
.cp-actions-row { display:flex; gap:.5rem; margin-top:.5rem; }
.cp-actions-row .btn { flex:1; font-size:.85rem; padding:.5rem .7rem; }
.cp-actions-row .btn-danger { background:#dc3545; color:#fff; border:none; cursor:pointer; border-radius:4px; }
.cp-actions-row .btn-danger:hover { background:#bb2d3b; }

/* Effets texte */
.cp-text-effects { display:flex; flex-wrap:wrap; gap:.25rem; align-items:center; margin-top:.25rem; margin-bottom:.5rem; }
.cp-fx-btn { width:32px; height:32px; padding:0; border:1px solid #ccc; background:#fff; cursor:pointer; border-radius:4px; font-size:14px; }
.cp-fx-btn:hover { background:#f0f0f0; }
.cp-fx-btn.active { background:#007bff; color:#fff; border-color:#0056b3; }
.cp-fx-sep { width:1px; height:24px; background:#ddd; margin:0 .25rem; }

/* Cout personnalisation dans le header du modal */
.cp-modal-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; }
.cp-price-display { display:flex; align-items:center; gap:.5rem; margin-left:auto; margin-right:1rem; }
.cp-price-label-inline { font-size:.9rem; color:#555; font-weight:500; }
.cp-price-amount { font-size:1.25rem; font-weight:700; color:#fff; background:#28a745; padding:.35rem .75rem; border-radius:6px; box-shadow:0 1px 3px rgba(0,0,0,0.1); }


/* Boutons actions plus aerees pour eviter texte tronque */
.cp-actions-row .btn { font-size:.8rem; padding:.4rem .5rem; white-space:nowrap; min-width:0; }

/* Reorder : Image AVANT Texte (via column-reverse) */
.cp-tools { display:flex; flex-direction:column-reverse; }

/* ===== SVG fallback colorable (v1.2.5) ===== */
/* ============================================================
 * CustomizerPro v1.2.5 - styles fallback SVG colorable
 * ============================================================
 * À charger APRÈS front-v3.css (override / additions)
 * NOTE : on NE TOUCHE PAS au positioning du canvas Fabric
 *        (déjà géré par front-v3.css). On ajoute seulement le
 *        conteneur SVG avec pointer-events:none pour ne pas
 *        bloquer les interactions Fabric.
 * ============================================================ */

/* Conteneur SVG inline : positionné comme l'<img id="cp-product-img"> */
.cp-svg-container {
  /* On hérite des styles de positionnement de #cp-product-img */
  display: block;
  /* Variable CSS : couleur du produit, modifiée par JS */
  --product-color: #e8e8e8;
}

.cp-svg-container[hidden] {
  display: none !important;
}

#cp-product-img[hidden] {
  display: none !important;
}

/* CRUCIAL : empêche le SVG et tous ses enfants de capturer les clics
   sinon le canvas Fabric au-dessus ne reçoit plus les events */
.cp-svg-container,
.cp-svg-container * {
  pointer-events: none !important;
}

.cp-svg-container svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Les paths "corps produit" utilisent var(--product-color) déclarée plus haut */
.cp-svg-container svg .cp-product-body,
.cp-svg-container svg [class*="cp-product-body"] {
  fill: var(--product-color) !important;
  transition: fill 0.2s ease;
}

/* [v1.2.5] Bouton "Supprimer" dans le summary personnalisation */
.cp-delete-btn {
  margin-left: 8px;
  background: transparent;
  color: #c62828;
  border: 1px solid #c62828;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.cp-delete-btn:hover {
  background: #c62828;
  color: #fff;
}
.cp-delete-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ============================================================
 * v1.1.0 - Améliorations modal : courbure, drag&drop, undo, snap
 * ============================================================ */

/* Valeurs live à côté des sliders */
.cp-tool-group label .cp-val {
  float: right;
  font-size: 12px;
  color: #666;
  background: #f0f0f0;
  padding: 1px 8px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.cp-tool-group label .cp-hint-inline {
  margin-left: 6px;
  color: #888;
  cursor: help;
  font-size: 12px;
}

/* Courbure : slider entre 2 presets visuels */
.cp-curve-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.cp-curve-row input[type="range"] {
  flex: 1;
}
.cp-curve-preset {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  width: 34px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: #555;
  transition: all 0.15s ease;
}
.cp-curve-preset:hover {
  background: #4caf50;
  color: #fff;
  border-color: #4caf50;
}

/* Drag & drop image */
.cp-drop-zone {
  position: relative;
  border: 2px dashed #c8c8c8;
  border-radius: 10px;
  background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 8px;
}
.cp-drop-zone:hover {
  border-color: #4caf50;
  background: linear-gradient(180deg, #f6fff6 0%, #ebfaeb 100%);
}
.cp-drop-zone.cp-drop-active {
  border-color: #2e7d32;
  border-style: solid;
  background: #e8f5e9;
  transform: scale(1.02);
}
.cp-drop-icon {
  font-size: 32px;
  color: #999;
  line-height: 1;
  margin-bottom: 6px;
  transition: color 0.2s ease;
}
.cp-drop-zone.cp-drop-active .cp-drop-icon {
  color: #2e7d32;
}
.cp-drop-label {
  margin: 0;
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}
.cp-drop-label small {
  font-size: 12px;
  color: #888;
}
.cp-drop-btn {
  background: none;
  border: none;
  color: #2e7d32;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
}
.cp-drop-btn:hover { color: #1b5e20; }

/* Warning DPI */
.cp-dpi-warning {
  background: #fff3cd;
  border: 1px solid #ffe0a3;
  color: #7a5d00;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
}
.cp-dpi-warning.cp-dpi-ok {
  background: #e8f5e9;
  border-color: #b6dfb9;
  color: #1b5e20;
}

/* Undo/Redo row */
.cp-undo-row {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.cp-undo-btn, .cp-redo-btn {
  flex: 1;
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 5px 8px;
  color: #444;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cp-undo-btn:hover:not(:disabled),
.cp-redo-btn:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #c8c8c8;
  color: #000;
}
.cp-undo-btn:disabled,
.cp-redo-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Boutons d'action plus visuels (sans fond) */
.cp-actions-row .btn {
  flex: 1;
  font-size: 13px;
}
.cp-dup-selected, .cp-delete-selected {
  max-width: 44px;
  flex: 0 0 44px !important;
  padding: 6px 8px;
}

/* Snap guides : lignes au centre du canvas */
.cp-snap-guide {
  position: absolute;
  background: #4caf50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}
.cp-snap-guide-v {
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.3);
}
.cp-snap-guide-h {
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.3);
}

/* Le canvas-inner doit pouvoir contenir les guides absolus */
.cp-canvas-inner { position: relative; }

/* Polices : agrandit l'affichage des options du dropdown pour preview */
#cp-font-select option {
  padding: 8px 10px;
  font-size: 17px !important;
  line-height: 1.4;
}
#cp-font-select {
  font-size: 16px;
  height: auto;
  padding: 8px 10px;
}

/* Boutons fooder du modal — laisse de la place pour les raccourcis */
.cp-modal-footer {
  display: flex;
  align-items: center;
}
.cp-modal-footer::before {
  content: 'Astuce : Ctrl+Z annuler · Suppr supprimer · Échap fermer';
  flex: 1;
  font-size: 11px;
  color: #999;
  text-align: left;
}
@media (max-width: 600px) {
  .cp-modal-footer::before { display: none; }
}
