/* ===== 1. ESTRUCTURA BÀSICA I MODAL ===== */
.ewc-qv-overlay {
  --ewc-qv-overlay-opacity: 1;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999998;
  cursor: pointer;
}
.ewc-qv-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 999999;
  pointer-events: none;
}
.ewc-qv-inner {
  --qv-width: 1000px;
  --qv-height: 600px;
  max-width: min(95vw, var(--qv-width));
  max-height: min(90vh, var(--qv-height));
  width: 100%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  padding: 30px;
  position: relative;
  overflow-y: auto;
  pointer-events: auto; /* Reactiva el click dins */
}

/* ===== 2. BOTÓ TANCAR ===== */
.ewc-qv-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
  padding: 0;
  color: #111;
  transition: color 0.2s;
  z-index: 50;
  line-height: 0;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.ewc-qv-close:hover {
  color: #000;
  transform: scale(1.05);
}

/* ===== 3. LAYOUT (GRID 2 COLUMNES) ===== */
.ewc-qv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 50% - 50% */
  gap: 30px;
}
.ewc-qv-grid.ewc-qv-grid--no-gallery {
  grid-template-columns: 1fr;
}
@media (max-width: 768px) {
  .ewc-qv-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 4. SLIDER / GALERIA ===== */
.ewc-qv-slider {
  position: relative;
  width: 100%;
}
.ewc-qv-slide {
  display: none;
}
.ewc-qv-slide.is-active {
  display: block;
}
.ewc-qv-media img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 4px;
}

/* Fletxes slider (rodones, variables per Estilo) */
.ewc-qv-arrow {
  --ewc-qv-arrow-bg: rgba(255, 255, 255, 0.8);
  --ewc-qv-arrow-size: 20px;
  --ewc-qv-arrow-color: #333;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ewc-qv-arrow-bg);
  border: none;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: var(--ewc-qv-arrow-size);
  color: var(--ewc-qv-arrow-color);
  line-height: 1;
  flex-shrink: 0;
  box-sizing: border-box;
}
.ewc-qv-arrow svg,
.ewc-qv-arrow i {
  width: var(--ewc-qv-arrow-size);
  height: var(--ewc-qv-arrow-size);
  display: block;
}
.ewc-qv-prev {
  left: 10px;
}
.ewc-qv-next {
  right: 10px;
}

/* Thumbs */
.ewc-qv-thumbs {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  overflow-x: auto;
}
.ewc-qv-thumb {
  width: 60px;
  height: 60px;
  border: 1px solid #ddd;
  cursor: pointer;
  opacity: 0.6;
  flex-shrink: 0;
}
.ewc-qv-thumb.is-active {
  opacity: 1;
  border-color: #000;
}
.ewc-qv-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== 5. DETALLS PRODUCTE (DRETA) ===== */
.ewc-qv-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Alineació esquerra per defecte */
}

.ewc-qv-block {
  margin-bottom: 15px;
  width: 100%;
}
.ewc-qv-title {
  margin-top: 0;
  font-size: 24px;
  line-height: 1.2;
}
.ewc-qv-price {
  font-size: 20px;
  font-weight: bold;
  color: #333;
}
.ewc-qv-stock-wrap span {
  font-size: 13px;
  padding: 4px 8px;
  background: #e6f7ec;
  color: #2e7d32;
  border-radius: 4px;
}

/* ===== 6. QUANTITAT + BOTÓ (FIX DEFINITIU) ===== */

/* 1. Contenidor general per a productes SIMPLES */
.ewc-qv-atc form.cart:not(.variations_form) {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ewc-qv-atc .woocommerce-variation-availability {
  display: none;
}


/* 2. Contenidor específic per a productes VARIABLES */
/* WooCommerce posa el botó dins de .single_variation_wrap -> .woocommerce-variation-add-to-cart */
.ewc-qv-atc .woocommerce-variation-add-to-cart {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* 3. Input de quantitat (forçar que es vegi i tingui mida correcta) */
.ewc-qv-atc .quantity {
  display: block !important;
  margin: 0 !important;
}

/* 4. Botó (alçada igual que l'input) */
.ewc-qv-atc button.single_add_to_cart_button,
.ewc-qv-atc button.button.alt {
  margin: 0 !important;
  align-self: stretch; /* Estirar alçada */
  height: auto;
}

.ewc-qv-atc .ewc-qv-view-cart-wrap {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.ewc-qv-atc .ewc-qv-view-cart-wrap .added_to_cart.wc-forward {
  display: inline-block;
  text-decoration: none;
}

.ewc-qv-atc form.cart > .added_to_cart.wc-forward {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-decoration: none;
}

/* 5. Taula de variacions (desplegables a sobre) */
.ewc-qv-atc .variations {
  width: 100%;
  margin-bottom: 15px;
  border-spacing: 0;
  border-collapse: collapse;
}
.ewc-qv-atc .variations td {
  display: block; /* Posa l'etiqueta sobre el select */
  padding: 0 0 5px;
}
.ewc-qv-atc .variations label {
  font-weight: 600;
  margin-bottom: 2px;
  display: inline-block;
}
.ewc-qv-atc .reset_variations {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.85em;
}

/* ===== 7. EDITOR D'ELEMENTOR (FIX PREVIEW) ===== */

/* Contenidor base: Assegurar grid */
.ewc-qv-editor-embed .ewc-qv-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
  align-items: start !important;
}

/* Forçar que les imatges no s'apilin */
.ewc-qv-editor-embed .ewc-qv-slide {
  display: none !important; /* Amaga-les totes per defecte */
}

/* Mostra NOMÉS la primera imatge (simulació d'estat inicial) */
.ewc-qv-editor-embed .ewc-qv-slide:first-child {
  display: block !important;
}

/* Assegurar que la imatge es vegi bé */
.ewc-qv-editor-embed .ewc-qv-media img {
  width: 100%;
  height: auto;
  display: block;
}

/* Estilitzar l'input fake de quantitat perquè es vegi al costat del botó */
.ewc-qv-editor-embed .ewc-qv-atc {
  display: flex !important;
  gap: 10px !important;
  align-items: center !important;
}

/* Amagar els thumbs a l'editor si molesten, o deixar-los */
.ewc-qv-editor-embed .ewc-qv-thumbs {
  margin-top: 10px;
}

/* ===== 8. FIX FINAL: OCULTAR QUANTITAT ===== */
/* Aquesta classe s'afegeix via PHP quan l'interruptor està apagat */
.ewc-qv-atc.ewc-no-qty .quantity {
  display: none !important;
}
/* Estirar botó si està sol */
.ewc-qv-atc.ewc-no-qty button.button {
  width: 100%;
}
.ewc-qv-atc.ewc-no-atc button.single_add_to_cart_button,
.ewc-qv-atc.ewc-no-atc button.button.alt,
.ewc-qv-atc.ewc-no-atc .single_add_to_cart_button,
.ewc-qv-atc.ewc-no-atc .button.alt {
  display: none !important;
}

/* ===== RESET ESTILS PER ALS CONTROLS D'ELEMENTOR ===== */

/* Treure subratllat i colors per defecte de links (Categories i Breadcrumbs) */
.ewc-qv-panel .ewc-qv-category a,
.ewc-qv-panel .ewc-qv-breadcrumbs a {
  text-decoration: none; /* Elimina subratllat per defecte */
  transition: color 0.3s;
}

/* Preu Regular (Tatxat) - Assegurar que Elementor pot controlar el color i la font */
.ewc-qv-panel .ewc-qv-price del {
  opacity: 1; /* Woo a vegades posa opacitat, la traiem per controlar color */
  display: inline-block;
  margin-right: 5px;
}

/* Variacions: Selectors */
.ewc-qv-atc .variations select {
  /* Assegurar que agafi els estils de bordes i fons */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  padding-right: 30px !important; /* Espai per la fletxeta */
}

/* Botó Close (per centrar icona si canvien mida) */
.ewc-qv-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0; /* Controlat per Elementor */
}

/* ===== NETEJA D'ESTILS PER ALS CONTROLS D'ELEMENTOR (Quick View) ===== */

/* 1. Traiem subratllat i colors forçats dels enllaços (Breadcrumbs/Categoria) */
.ewc-qv-panel .ewc-qv-category a,
.ewc-qv-panel .ewc-qv-breadcrumbs a {
  text-decoration: none !important;
  box-shadow: none !important;
  border: none !important;
  transition: color 0.3s;
}

/* 2. Preu antic (Tatxat): Permet que el control de tipografia manegi la "decoració" */
.ewc-qv-panel .ewc-qv-price del {
  opacity: 1; /* WooCommerce sol posar opacitat 0.5, la traiem per tenir control total */
  display: inline-block;
  margin-right: 5px;
  /* NO posem text-decoration aquí, perquè ho manarà Elementor */
}

/* 3. Preu Oferta: Permet personalitzar */
.ewc-qv-panel .ewc-qv-price ins {
  background: transparent;
  text-decoration: none; /* Per si el tema en posa */
}

/* 4. Selectors de Variacions (Netegem l'estil natiu) */
.ewc-qv-atc .variations select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  /* Fletxeta personalitzada */
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  padding-right: 30px !important;
}

/* 5. Botó Tancar: Centrar la icona */
.ewc-qv-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.ewc-qv-close svg,
.ewc-qv-close i {
  display: block; /* Evita espais fantasma */
  width: 16px;
  height: 16px;
  line-height: 1;
}
.ewc-qv-close-fallback {
  display: none;
  font-size: 20px;
  line-height: 1;
}
