/* ===========================
   SimpleDesigner - Optimized v1.1
   =========================== */

/* 
 * Google Fonts - OPTIMISÉ: 1 seul appel au lieu de 5
 * Améliore le temps de chargement initial
 */
@import url('https://fonts.googleapis.com/css2?family=Abel&family=Abril+Fatface&family=Acme&family=Alegreya&family=Alfa+Slab+One&family=Allura&family=Amatic+SC&family=Anton&family=Antic+Slab&family=Archivo+Black&family=Arimo&family=Arvo&family=Asap+Condensed&family=Audiowide&family=Bad+Script&family=Baloo&family=Baloo+Bhai&family=Bangers&family=Bebas+Neue&family=Bowlby+One+SC&family=Bree+Serif&family=Cabin+Sketch&family=Cantata+One&family=Caveat&family=Chewy&family=Cinzel&family=Comfortaa&family=Cookie&family=Cormorant+Garamond&family=Courgette&family=Covered+By+Your+Grace&family=Damion&family=Dancing+Script&family=Days+One&family=Didact+Gothic&family=EB+Garamond&family=Encode+Sans&family=Fauna+One&family=Fjalla+One&family=Fondamento&family=Forum&family=Fredericka+the+Great&family=Fredoka+One&family=Fugaz+One&family=Glegoo&family=Gloria+Hallelujah&family=Gochi+Hand&family=Great+Vibes&family=Homemade+Apple&family=IBM+Plex+Serif&family=Inconsolata&family=Indie+Flower&family=Italianno&family=Josefin+Sans&family=Julius+Sans+One&family=Kalam&family=Karma&family=Kaushan+Script&family=Lato&family=Libre+Baskerville&family=Lobster&family=Luckiest+Guy&family=Marcellus&family=Marck+Script&family=Merienda&family=Merienda+One&family=Mitr&family=Monda&family=Monoton&family=Montserrat&family=Montserrat+Subrayada&family=Mountains+of+Christmas&family=Nanum+Gothic+Coding&family=Nunito&family=Old+Standard+TT&family=Open+Sans&family=Orbitron&family=Oswald&family=Pacifico&family=Pangolin&family=Parisienne&family=Patrick+Hand&family=Patua+One&family=Permanent+Marker&family=Pinyon+Script&family=Play&family=Playfair+Display&family=Playfair+Display+SC&family=Poiret+One&family=Pontano+Sans&family=Poppins&family=Press+Start+2P&family=Pridi&family=Quantico&family=Raleway&family=Righteous&family=Roboto&family=Roboto+Slab&family=Rochester&family=Rock+Salt&family=Rubik&family=Rubik+Mono+One&family=Russo+One&family=Sacramento&family=Sanchez&family=Satisfy&family=Sawarabi+Mincho&family=Shadows+Into+Light&family=Shadows+Into+Light+Two&family=Sigmar+One&family=Slabo+27px&family=Source+Code+Pro&family=Special+Elite&family=Staatliches&family=Syncopate&family=Taviraj&family=Teko&family=Ultra&family=Unica+One&family=Varela+Round&family=Vidaloka&family=Zilla+Slab&display=swap');

/* System fonts (no import): Arial, Helvetica, Verdana, Georgia */

/* ============================
   SD Stage + Layout (Option C)
   ============================ */

/* 1) Cache la galerie native */
.has-simpledesigner .product-cover,
.has-simpledesigner .product-images .js-qv-mask,
.has-simpledesigner .product-images .product-thumbs,
.has-simpledesigner .product-images .thumb-container {
  display: none !important;
}

/* 2) Le container produit devient un flux "stage puis achat" */
.has-simpledesigner .product-container.js-product-container {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
}

/* 3) Stage 100% */
.has-simpledesigner #sd-stage.sd-stage {
  flex: 0 0 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  order: 0;
}

/* 4) Colonne images (gauche) : masquée */
.has-simpledesigner .product-container.js-product-container > .col-md-6:first-child {
  display: none !important;
}

/* 5) Colonne achat (droite) : dessous */
.has-simpledesigner .product-container.js-product-container > .col-md-6:last-child {
  flex: 0 0 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  order: 1;
  margin-top: 24px !important;
}

/* 6) Module full width */
.has-simpledesigner .simpledesigner {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}
.has-simpledesigner .simpledesigner,
.has-simpledesigner .simpledesigner * {
  box-sizing: border-box;
}

/* 7) "Un peu plus large à l'intérieur" sur desktop */
@media (min-width: 992px) {
  .has-simpledesigner #sd-stage.sd-stage {
    margin-left: -24px;
    margin-right: -24px;
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* 8) Grille interne: aperçu gauche / contrôles droite - AGRANDI */
.simpledesigner__grid {
  display: grid;
  grid-template-columns: minmax(620px, 700px) minmax(400px, 500px);
  gap: 28px;
  align-items: start;
}

@media (max-width: 1399.98px) {
  .simpledesigner__grid {
    grid-template-columns: minmax(560px, 650px) minmax(380px, 480px);
    gap: 24px;
  }
}

@media (max-width: 1199.98px) {
  .simpledesigner__grid {
    grid-template-columns: minmax(500px, 1fr) minmax(360px, 460px);
    gap: 20px;
  }
}

@media (max-width: 991.98px) {
  .simpledesigner__grid {
    grid-template-columns: 1fr;
  }
}

/* 9) Panneau scrollable */
@media (min-width: 992px) {
  .simpledesigner__controls {
    max-height: calc(100vh - 160px);
    overflow: auto;
    padding-right: 14px;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    border-left: 1px solid #eee;
    padding-left: 16px;
  }
}

@media (max-width: 991.98px) {
  .simpledesigner__controls {
    max-height: none;
    overflow: visible;
    border-left: none;
    padding-left: 0;
    padding-right: 0;
  }
}

/* 10) Mockup/canvas - AGRANDI à 700px max */
.simpledesigner__mockup {
  position: relative;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  overflow: hidden;
}

#sd-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

/* ============================
   SD Purchase UI integration
   ============================ */

/* Topbar: NOM | PRIX | LIKE */
#sd-topbar.sd-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 14px 0;
}

#sd-topbar h1 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

#sd-topbar .product-prices,
#sd-topbar .current-price {
  margin: 0;
  white-space: nowrap;
}

/* Wishlist align */
#sd-topbar .wishlist-button-add,
#sd-topbar button.wishlist-button-add {
  margin-left: auto;
}

/* Slots */
#sd-variants-slot {
  margin: 0 0 14px 0;
}

#sd-cart-slot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}

/* Cache "originaux" clonés */
.sd-hidden-original {
  display: none !important;
}

/* colonne achat conservée mais invisible et non gênante */
.sd-buy-ghost {
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ============================
   Proxy variants (radio + thumbs)
   ============================ */

#simpledesigner #sd-variants-slot .sd-variants-proxy,
#simpledesigner #sd-variants-slot .sd-variants-proxy * {
  box-sizing: border-box;
}

#simpledesigner #sd-variants-slot .sd-variants-proxy .product-variants-item {
  margin: 0 0 12px;
}

#simpledesigner #sd-variants-slot .sd-variants-proxy label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin: 4px 6px 0 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  max-width: 100%;
}

#simpledesigner #sd-variants-slot .sd-variants-proxy input[type="radio"] {
  margin: 0;
}

#simpledesigner #sd-variants-slot .sd-variants-proxy img {
  max-width: 42px !important;
  max-height: 42px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

/* ============================
   SD Custom Dropdown (fonts)
   ============================ */

.sd-dd {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.sd-dd__btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: .375rem .75rem;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  background: #fff;
  line-height: 1.2;
  cursor: pointer;
}

.sd-dd__value {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sd-dd__caret {
  flex: 0 0 auto;
  opacity: .7;
}

/* menu (default: inside component) */
.sd-dd__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 9999;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: .25rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  display: none;
  padding: 6px 0;
}

.sd-dd--open .sd-dd__menu {
  display: block;
}

.sd-dd__opt {
  width: 100%;
  text-align: left;
  padding: .4rem .75rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  line-height: 1.2;
}

.sd-dd__opt:hover {
  background: #f3f5f7;
}

/* PORTAL: menu moved to <body>, so it must be fixed and on top */
.sd-dd__menu.sd-dd__menu--portal {
  position: fixed !important;
  left: 0;
  top: 0;
  right: auto;
  z-index: 2147483647 !important;
}

/* ============================
   SD Text size slider
   ============================ */

.sd-size {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sd-size input[type="range"] {
  flex: 1 1 auto;
}

.sd-size__val {
  flex: 0 0 auto;
  min-width: 46px;
  text-align: right;
  font-size: 12px;
  color: #666;
}

/* ============================
   Safety: ensure controls are full width
   ============================ */

#sd-controls,
#sd-layer-controls,
#sd-text-controls,
#sd-textblocks {
  width: 100%;
}

/* Konva container */
#sd-konva.sd-konva {
  width: 100%;
  height: 100%;
  display: block;
}

/* Faces switch */
#sd-faces.sd-faces {
  display: flex;
  gap: 8px;
  margin: 0 0 10px 0;
}

#sd-faces .sd-face-btn {
  border: 1px solid #ddd;
  background: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

#sd-faces .sd-face-btn:hover {
  border-color: #bbb;
}

#sd-faces .sd-face-btn.is-active {
  border-color: #2fb5d2;
  background-color: #f0fafc;
}

#sd-faces .sd-face-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* Konva containers - AGRANDI à 700px */
.sd-konva {
  width: 100%;
  height: 100%;
  display: block;
}

#sd-konva-A,
#sd-konva-B {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sd-konva canvas {
  touch-action: none;
}

/* ============================
   Loading state (anti-clignotement)
   ============================ */
.simpledesigner__mockup.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.simpledesigner__mockup.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #e5e5e5;
  border-top-color: #2fb5d2;
  border-radius: 50%;
  animation: sd-spin 0.8s linear infinite;
}

@keyframes sd-spin {
  to { transform: rotate(360deg); }
}

/* ========== Cart: design thumbnails ========== */
/* JS in cart_design_thumbs.tpl moves .sd-cart-thumbs into
   .product-line-grid-body so it appears below product attributes. */
.sd-cart-thumbs {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 4px 10px;
  margin-top: 8px;
}
.sd-cart-thumb {
  text-align: center;
  flex-shrink: 0;
}
.sd-cart-thumb__img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  display: block;
}
.sd-cart-thumb__label {
  display: block;
  font-size: 9px;
  color: #888;
  margin-top: 1px;
}

/* ========== Add-to-cart confirmation toast ========== */
.sd-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: 16px 20px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity .3s, transform .3s;
  font-family: inherit;
}
.sd-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.sd-toast__thumb {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid #eee;
  flex-shrink: 0;
}
.sd-toast__body {
  flex: 1;
  min-width: 0;
}
.sd-toast__title {
  font-size: 14px;
  font-weight: 600;
  color: #4cbb6c;
  margin: 0 0 6px;
}
.sd-toast__title i {
  vertical-align: middle;
  margin-right: 4px;
  font-size: 18px;
}
.sd-toast__text {
  font-size: 13px;
  color: #555;
  margin: 0 0 10px;
}
.sd-toast__actions {
  display: flex;
  gap: 8px;
}
.sd-toast__btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  text-align: center;
}
.sd-toast__btn--primary {
  background: #2fb5d2;
  color: #fff;
}
.sd-toast__btn--primary:hover {
  background: #2698b1;
  color: #fff;
  text-decoration: none;
}
.sd-toast__btn--secondary {
  background: #f1f1f1;
  color: #333;
}
.sd-toast__btn--secondary:hover {
  background: #e0e0e0;
  text-decoration: none;
}
.sd-toast__close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  color: #aaa;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.sd-toast__close:hover {
  color: #333;
}
