/* ---------------------------------------------
   Catalog cards (liste produits)
--------------------------------------------- */
.pai-espace-commande .pai-ec-catalog{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap:18px;
}
.pai-espace-commande .pai-ec-card{
  border:1px solid rgba(0,0,0,.12);
  border-radius:14px;
  overflow:hidden;
  background:#fff;
  display:flex;
  flex-direction:column;
}
.pai-espace-commande .pai-ec-card__img img{width:100%;height:auto;display:block;}
.pai-espace-commande .pai-ec-card__body{padding:14px;display:flex;flex-direction:column;gap:10px;}
.pai-espace-commande .pai-ec-card__title{margin:0;font-size:16px;line-height:1.3;}

/* ---------------------------------------------
   Sticky configurator
--------------------------------------------- */
.pai-espace-commande #pai-ec-sticky{
  position:fixed;
  left:0; right:0; bottom:0;
  z-index:99999;
  background:#fff;
  box-shadow:0 -10px 30px rgba(0,0,0,.14);
  transform:translateY(102%);
  transition:transform .22s ease;
  max-height:80vh;
  display:flex;
  flex-direction:column;
}
.pai-espace-commande #pai-ec-sticky.is-open{ transform:translateY(0); }

.pai-espace-commande .pai-ec-sticky__bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid rgba(0,0,0,.10);
}
.pai-espace-commande .pai-ec-sticky__sub{opacity:.7;font-size:13px;margin-left:8px;}
.pai-espace-commande .pai-ec-sticky__body{
  padding:16px;
  overflow:auto;
}

/* Pour éviter que le sticky masque le contenu */
body.pai-ec-sticky-open{ padding-bottom: 220px; }

/* ---------------------------------------------
   Toast "Produit ajouté" (mini-cart refresh)
--------------------------------------------- */
#pai-atc-toast{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:999999;
  background:#111;
  color:#fff;
  padding:12px 14px;
  border-radius:10px;
  opacity:0;
  transform:translateY(10px);
  transition:.2s ease;
  max-width:340px;
  font-size:14px;
  line-height:1.35;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
}
#pai-atc-toast.is-visible{ opacity:1; transform:translateY(0); }
#pai-atc-toast a{ color:#fff; text-decoration:underline; font-weight:600; }

/* ---------------------------------------------
   Product grid inside sticky: galerie + summary
--------------------------------------------- */
.pai-espace-commande .pai-ec-product__grid{
  display:flex;
  gap:28px;
  align-items:flex-start;
}
.pai-espace-commande .pai-ec-product__gallery{ flex:0 0 65%; max-width:65%; min-width:320px; }
.pai-espace-commande .pai-ec-product__summary{ flex:1 1 auto; min-width:280px; }

@media (max-width: 900px){
  .pai-espace-commande .pai-ec-product__grid{ flex-direction:column; }
  .pai-espace-commande .pai-ec-product__gallery,
  .pai-espace-commande .pai-ec-product__summary{ max-width:100%; min-width:0; }
}

/* ---------------------------------------------
   Woo gallery: thumbs left + main contained
--------------------------------------------- */
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images{
  display:grid !important;
  grid-template-columns: 90px 1fr;
  column-gap:18px;
  align-items:start;
}
/* Mobile gallery adjustments */
@media (max-width: 600px) {
  .pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images {
    grid-template-columns: 1fr 2fr !important; /* 1/3 thumbs, 2/3 main image */
    column-gap: 10px !important;
  }
}

.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images .flex-viewport{
  grid-column:2;
  grid-row:1;
  width:100% !important;
  overflow:hidden;
  height:auto !important;
}

.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images ol.flex-control-nav.flex-control-thumbs{
  grid-column:1;
  grid-row:1;
  margin:0 !important;
  padding:0 !important;
  list-style:none !important;
  display:flex !important;
  flex-direction:column !important;
  gap:10px;
  max-height: 70vh;
  overflow:auto;
}

.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images ol.flex-control-thumbs li{margin:0 !important;}
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images ol.flex-control-thumbs img{
  width:100% !important;
  height:auto !important;
  display:block;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.12);
  opacity:.7;
}
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images ol.flex-control-thumbs img.flex-active,
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery.images ol.flex-control-thumbs img:hover{opacity:1;}

.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery__wrapper{
  width:100% !important;
  grid-column: 2;
  grid-row: 1;
  display: block !important;
}
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery__image img{
  width:100% !important;
  height:auto !important;
  display:block !important;
  object-fit:contain;
}

/* ---------------------------------------------
   Swatches (Variation Swatches for WooCommerce)
   On laisse le plugin gérer la logique, on ne fait que styler.
--------------------------------------------- */

/* Legacy : si un ancien bloc custom traîne, on le masque */
.pai-espace-commande #pai-ec-sticky .pai-color-swatches{ display:none !important; }
.pai-espace-commande #pai-ec-sticky .variations .pai-color-row:not(tr){ display:none !important; }

/* Swatches (cas le plus courant : ul.variable-items-wrapper / li.variable-item) */
.pai-espace-commande #pai-ec-sticky .variations_form .variable-items-wrapper{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin:10px 0 14px;
  padding:0;
  list-style:none;
}

.pai-espace-commande #pai-ec-sticky .variations_form .variable-items-wrapper .variable-item{
  width:44px;
  height:44px;
  border:1px solid rgba(0,0,0,.15);
  border-radius:12px;
  overflow:hidden;
  background:#fff;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.pai-espace-commande #pai-ec-sticky .variations_form .variable-items-wrapper .variable-item.selected,
.pai-espace-commande #pai-ec-sticky .variations_form .variable-items-wrapper .variable-item.is-selected{
  outline:2px solid #111;
  outline-offset:2px;
}

.pai-espace-commande #pai-ec-sticky .variations_form .variable-items-wrapper .variable-item img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

/* Alternative (autres plugins) */
.pai-espace-commande #pai-ec-sticky .variations_form .tawcvs-swatches,
.pai-espace-commande #pai-ec-sticky .variations_form .swatches{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin:10px 0 14px;
}

/* Galerie : si le thème affiche des blocs thumbs/gallerie "maison", on les masque dans le sticky */
.pai-espace-commande #pai-ec-sticky .product-gallery,
.pai-espace-commande #pai-ec-sticky .product-thumbnails,
.pai-espace-commande #pai-ec-sticky .product-thumbnails-slider,
.pai-espace-commande #pai-ec-sticky .product-gallery-slider,
.pai-espace-commande #pai-ec-sticky .product-gallery-large,
.pai-espace-commande #pai-ec-sticky .ux-product-gallery,
.pai-espace-commande #pai-ec-sticky .flickity-enabled:not(.woocommerce-product-gallery){
  display:none !important;
}

/* Masquer le select d'origine quand les swatches sont générés */
.pai-espace-commande #pai-ec-sticky select.pai-hidden-select {
  display: none !important;
}

/* Size & Gender Swatches */
.pai-espace-commande #pai-ec-sticky .pai-size-swatches,
.pai-espace-commande #pai-ec-sticky .pai-gender-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 5px 0 15px;
}
.pai-espace-commande #pai-ec-sticky .pai-size-swatch,
.pai-espace-commande #pai-ec-sticky .pai-gender-swatch {
  padding: 5px 8px; /* Reduced padding (approx 1/3 smaller) */
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px; /* Reduced font size */
  min-width: 30px;
  text-align: center;
  transition: all 0.2s;
}
.pai-espace-commande #pai-ec-sticky .pai-size-swatch:hover,
.pai-espace-commande #pai-ec-sticky .pai-gender-swatch:hover {
  border-color: #999;
  background: #f9f9f9;
}
.pai-espace-commande #pai-ec-sticky .pai-size-swatch.selected,
.pai-espace-commande #pai-ec-sticky .pai-gender-swatch.selected {
  background: #111 !important;
  color: #fff !important;
  border-color: #111 !important;
}
.pai-espace-commande #pai-ec-sticky .pai-size-swatch.disabled,
.pai-espace-commande #pai-ec-sticky .pai-gender-swatch.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f5f5f5;
  color: #aaa;
  pointer-events: none;
}

/* Size Guide Modal */
#pai-guide-modal { position: fixed; inset: 0; z-index: 100000; display: none; }
#pai-guide-modal.is-open { display: flex; align-items: center; justify-content: center; }
.pai-gm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.pai-gm-content { position: relative; background: #fff; width: 90%; max-width: 800px; max-height: 90vh; overflow: auto; border-radius: 8px; padding: 20px; z-index: 1; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.pai-gm-close { position: absolute; top: 10px; right: 10px; background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: #333; }
.pai-gm-body img { max-width: 100%; height: auto; }
.pai-gm-body table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 14px; }
.pai-gm-body th, .pai-gm-body td { border: 1px solid #eee; padding: 8px; text-align: center; }
.pai-gm-body th { background: #f9f9f9; font-weight: bold; }

/* --- Additional styles from site snippets (gallery vertical + swatches + lightbox) --- */

@media (min-width: 850px) {
  .woocommerce-product-gallery{ display:flex !important; flex-wrap:nowrap !important; align-items:flex-start !important; }
  .woocommerce-product-gallery .flex-control-thumbs{ order:-1 !important; width:15% !important; min-width:80px !important; flex-direction:column !important; display:flex !important; margin-right:20px !important; margin-top:0 !important; position:relative !important; max-height:600px !important; overflow-y:auto !important; }
  .woocommerce-product-gallery .flex-viewport{ width:85% !important; flex-grow:1 !important; }
  .woocommerce-product-gallery .flex-control-thumbs li{ width:100% !important; float:none !important; margin-bottom:10px !important; display:block !important; }
  .woocommerce-product-gallery .flex-control-thumbs li img{ width:100% !important; height:auto !important; margin:0 !important; }
}

/* PAI gallery layout for espace-commande pages */
.pai-espace-commande .woocommerce-product-gallery__wrapper{ display:grid !important; grid-template-columns: 70px minmax(0,1fr) !important; column-gap:16px !important; align-items:start !important; }
.pai-espace-commande .pai-thumbcol{ grid-column:1/2 !important; max-height:600px !important; overflow-y:auto !important; direction:rtl !important; }
.pai-espace-commande .pai-thumbs{ direction:ltr !important; display:flex !important; flex-direction:column !important; gap:10px !important; }
.pai-espace-commande .pai-thumbs .woocommerce-product-gallery__image{ margin:0 !important; opacity:.9; cursor:pointer; }
.pai-espace-commande .pai-thumbs img{ width:100% !important; height:auto !important; display:block !important; }
.pai-espace-commande .woocommerce-product-gallery__image.first{ grid-column:2/3 !important; position:sticky !important; top:0 !important; margin:0 !important; }
.pai-espace-commande .woocommerce-product-gallery__image.first img{ width:100% !important; height:auto !important; display:block !important; }
.pai-espace-commande .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:not(.first){ grid-column:1/2 !important; }

/* Lightbox fallback (small) */
#pai-lightbox{position:fixed;inset:0;z-index:999999;display:none}
#pai-lightbox.is-open{display:block}
#pai-lightbox .pai-lb-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.85)}
#pai-lightbox .pai-lb-inner{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:24px}
#pai-lightbox img{max-width:min(1200px,95vw);max-height:92vh;width:auto;height:auto;box-shadow:0 10px 30px rgba(0,0,0,.5);border-radius:6px}
#pai-lightbox .pai-lb-close{position:absolute;top:12px;right:12px;width:44px;height:44px;border:0;border-radius:999px;background:rgba(255,255,255,.12);color:#fff;font-size:28px;line-height:44px;cursor:pointer}
#pai-lightbox .pai-lb-nav{position:absolute;top:50%;transform:translateY(-50%);width:52px;height:52px;border:0;border-radius:999px;background:rgba(255,255,255,.12);color:#fff;font-size:32px;cursor:pointer}
#pai-lightbox .pai-lb-prev{left:14px}
#pai-lightbox .pai-lb-next{right:14px}
@media(max-width:849px){ #pai-lightbox .pai-lb-nav{display:none} }

/* Ensure our swatch styles for CFVS and custom swatches remain */
.pai-espace-commande .cfvsw-swatches-option.mss-has-img .cfvsw-swatch-inner{ padding:0 !important; line-height:0 !important; font-size:0 !important; }
.pai-espace-commande .cfvsw-swatches-option.mss-has-img .cfvsw-swatch-inner img{ display:block; width:32px; height:32px; object-fit:cover; border-radius:3px; }
@media (min-width:768px){ .pai-espace-commande .cfvsw-swatches-option.mss-has-img .cfvsw-swatch-inner img{ width:36px; height:36px; } }

/* === GALLERY: Minimal CSS - let WooCommerce handle the layout === */

/* Default: all images hidden */
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery__image {
  display: none !important;
}

/* Active image: show only this one */
.pai-espace-commande #pai-ec-sticky .woocommerce-product-gallery__image.flex-active-slide {
  display: block !important;
}

/* === COLOR SWATCHES: Ensure full visibility === */
.pai-espace-commande #pai-ec-sticky .pai-color-row {
  display: table-row !important;
}

.pai-espace-commande #pai-ec-sticky .pai-color-swatches {
  display: flex !important;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0 !important;
  align-items: center;
}

.pai-espace-commande #pai-ec-sticky .pai-color-swatch {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  min-height: 52px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 2px solid transparent !important;
  border-radius: 4px !important;
  background: white !important;
  cursor: pointer !important;
  visibility: visible !important;
  opacity: 0.5 !important;
  filter: grayscale(100%);
  flex-shrink: 0;
  transition: all 0.2s;
}

.pai-espace-commande #pai-ec-sticky .pai-color-swatch:hover,
.pai-espace-commande #pai-ec-sticky .pai-color-swatch.is-selected {
  opacity: 1 !important;
  filter: grayscale(0);
  border-color: #111 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.pai-espace-commande #pai-ec-sticky .pai-color-swatch img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  visibility: visible !important;
  opacity: 1 !important;
  border-radius: 2px;
  padding: 0 !important;
  margin: 0 !important;
}
