/* =========================
   ESTADOS / RESETS
   ========================= */

/* body sin scroll cuando el modal está abierto */
.cp-av-lock {
  overflow: hidden;
}

/* Ocultar UI nativa de B2BKing cuando el panel está montado (solo variables, ver JS) */
.cp-av-mounted .b2bking_tiered_price_table,
.cp-av-mounted .b2bking_tiered_range_replaced,
.cp-av-mounted .b2bking_tiered_price_range_replaced {
  display: none !important;
}

/* Solo en variables: ocultar precio/stock/variaciones nativos */
.cp-av-mounted-variable .variations_form .variations,
.cp-av-mounted-variable .single_variation_wrap,
.cp-av-mounted-variable .woocommerce-variation-add-to-cart,
.cp-av-mounted-variable .wd-single-price,
.cp-av-mounted-variable .wd-single-stock-status,
.cp-av-mounted-variable .woocommerce-variation-availability .stock {
  display: none !important;
}

/* =========================
   PANEL BASE
   ========================= */

.cp-av-root {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #111827;
}

.cp-av-panel {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.cp-av-section {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.cp-av-section:last-child {
  border-bottom: none;
}

/* Título secciones */
.cp-av-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cp-av-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

/* =========================
   ESCALAS DE PRECIOS (GENERALES)
   ========================= */

.cp-av-ladder {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.cp-av-ladder .item {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 8px 10px;
  text-align: center;
  transition: all 0.15s ease;
  min-width: 0;
}

.cp-av-ladder .item .range {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
  white-space: nowrap;
}

.cp-av-ladder .item .price {
  font-size: 16px;
  font-weight: 700;
  color: #059669;
}

/* Activa por cantidad */
.cp-av-ladder .item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

.cp-av-ladder .item.active .range {
  color: #1d4ed8;
}

.cp-av-ladder .item.active .price {
  color: #047857;
}

/* Responsivo escalas */
@media (max-width: 1200px) {
  .cp-av-ladder {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .cp-av-ladder {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .cp-av-ladder .item .range {
    font-size: 11px;
  }
  .cp-av-ladder .item .price {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .cp-av-ladder {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* =========================
   VARIACIONES (RESUMEN EN FICHA)
   ========================= */

.cp-av-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cp-av-row-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.cp-av-row-head a {
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
}

.cp-av-row-head a:hover {
  text-decoration: underline;
}

.cp-av-sku-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.cp-av-thumb {
  position: relative;
  display: inline-block;
  aspect-ratio: 1 / 1;
  width: 56px;
  cursor: pointer;
}

.double-bordered-box {
  position: relative;
  border-radius: 10px;
}

.double-bordered-box.enabled.unselected {
  outline: 1px solid #e5e7eb;
}

.double-bordered-box.enabled.selected {
  outline: 2px solid #2563eb;
}

.double-bordered-box .inner-border {
  position: absolute;
  inset: 3px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  pointer-events: none;
}

.cp-av-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  display: block;
}

/* =========================
   BOTONES ACCIÓN (FICHA)
   ========================= */

.cp-av-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #ffffff;
  padding: 14px 20px 18px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.cp-av-actions .btn {
  flex: 1 1 0;
  height: 48px;
  border-radius: 999px;
  border: 1px solid #2563eb;
  background: #ffffff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cp-av-actions .btn.primary {
  background: #2563eb;
  color: #ffffff;
}

.cp-av-actions .btn.primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.cp-av-actions .btn:hover:not(.primary) {
  background: #eff6ff;
}

/* =========================
   OVERLAY + MODAL
   ========================= */

.cp-av-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 99998;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 1024px) {
  .cp-av-overlay {
    align-items: center;
  }
}

.cp-av-modal {
  background: #ffffff;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.28);
  width: 640px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 40px);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cp-av-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.cp-av-modal-title {
  font-size: 17px;
  font-weight: 700;
}

.cp-av-close {
  border: none;
  background: #f3f4f6;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: #111827 !important;
}

.cp-av-close:hover {
  background: #e5e7eb;
}

.cp-av-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 210px);
}

/* =========================
   FILAS VARIACIONES EN MODAL
   ========================= */

.cp-av-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.cp-av-row {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.cp-av-row:last-child {
  border-bottom: none;
}

/* bloque principal de la fila (imagen + nombre + precio + qty) */
.cp-av-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

/* columna izquierda */
.cp-av-row .left {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 55%;
}

.cp-av-row .left .name {
  font-size: 15px;
  font-weight: 500;
}

.cp-av-row .left .stock {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* columna derecha */
.cp-av-row .right {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 45%;
  justify-content: flex-end;
}

.cp-av-price {
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

/* =========================
   ESCALAS POR VARIACIÓN (CUADRADOS HORIZONTALES)
   ========================= */

.cp-av-row-tiers {
  margin-top: 8px;
  margin-left: 72px; /* alineado con el texto, la miniatura queda a la izquierda */
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cp-av-row-tiers::-webkit-scrollbar {
  height: 4px;
}

.cp-av-row-tiers::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

.cp-av-row-tier-item {
  flex: 0 0 auto;
  min-width: 82px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  text-align: center;
  font-size: 12px;
}

.cp-av-row-tier-item .tier-range {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 2px;
}

.cp-av-row-tier-item .tier-price {
  display: block;
  font-weight: 600;
  color: #059669;
  font-size: 13px;
}

/* Selector numérico */
.ui-number-picker {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  height: 36px;
  background: #ffffff;
  overflow: hidden;
}

.ui-number-picker input {
  width: 52px;
  text-align: center;
  border: 0;
  outline: 0;
  height: 100%;
  font-size: 14px;
}

.ui-number-picker .number-picker-button {
  width: 34px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: #f3f4f6;
  cursor: pointer;
}

.ui-number-picker .number-picker-button.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Footer modal */
.cp-av-modal-footer {
  padding: 12px 20px 18px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  position: sticky;
  bottom: 0;
}

.cp-av-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}

.cp-av-total .summary b {
  font-weight: 700;
}

/* =========================
   IMAGE VIEWER (ZOOM VARIACIÓN)
   ========================= */

.cp-av-img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.cp-av-img-viewer-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.cp-av-img-viewer-inner img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.cp-av-img-viewer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
}

/* =========================
   SIMPLE PRODUCTS PANEL (no molesta)
   ========================= */

.cp-av-simple-panel .cp-av-section {
  padding-bottom: 12px;
}

.cp-av-simple-current {
  margin-top: 10px;
  font-size: 13px;
  color: #374151;
}

/* =========================
   MOBILE TWEAKS
   ========================= */

@media (max-width: 768px) {
  .cp-av-row-main {
    align-items: flex-start;
  }

  .cp-av-row .left .name {
    font-size: 14px;
  }

  .cp-av-row .right {
    flex-direction: column;
    align-items: flex-end;
  }

  .cp-av-price {
    font-size: 14px;
  }

  .ui-number-picker {
    height: 32px;
  }

  .ui-number-picker .number-picker-button {
    width: 30px;
    height: 32px;
  }

  .ui-number-picker input {
    width: 46px;
    font-size: 13px;
  }

  .cp-av-actions .btn {
    height: 44px;
    font-size: 13px;
  }

  .cp-av-row-tiers {
    margin-left: 64px;
  }
}

@media (max-width: 480px) {
  .cp-av-modal {
    border-radius: 18px 18px 0 0;
    max-height: calc(100vh - 72px);
    margin-top: 48px;
  }

  .cp-av-modal-header,
  .cp-av-modal-body,
  .cp-av-modal-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .cp-av-row-tiers {
    margin-left: 56px;
  }
}

/* =========================
   FORZAR "X" EN BOTÓN DE CERRAR
   ========================= */

.cp-av-modal-header .cp-av-close {
  position: relative;
  overflow: hidden;
}

.cp-av-modal-header .cp-av-close svg {
  display: none !important;
}

.cp-av-modal-header .cp-av-close::before {
  content: "×";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: #111827;
}

/* =========================
   ACCESORIOS DENTRO DE LA MODAL
   ========================= */

.cp-av-accessories-section {
  margin-top: 14px;
  padding-top: 10px;
}

.cp-av-accessories-section .cpacc-wrap {
  margin: 0;
}

.cp-av-accessories-section .cpacc-grid {
  margin-top: 4px;
}

@media (max-width: 768px) {
  .cp-av-accessories-section .cpacc-item {
    padding: 8px 6px;
  }
  .cp-av-accessories-section .cpacc-figure {
    width: 60px;
    height: 60px;
  }
  .cp-av-accessories-section .cpacc-cta {
    font-size: 11px;
  }
  .cp-av-accessories-section .cpacc-pricing ins {
    font-size: 12px;
  }
  .cp-av-accessories-section .cpacc-pricing del {
    font-size: 11px;
  }
}
