/* ============================================================
   PM AdvancedPack — Refineria theme override
   Paleta: azul #001F63 · amarillo #F3F900 · gris #6C6C6C
   ============================================================ */

/* ── Reset del layout original del módulo ────────────────── */
#ap5-product-list,
#ap5-buy-block-container {
  width: auto;
  float: none;
  padding: 0;
}

/* El JS del módulo añade .ap5-fixed para simular sticky propio.
   Lo neutralizamos porque el sticky ya lo gestiona .rn-pack-buy-col */
.ap5-buy-block.ap5-fixed,
.rn-pack-buy-box__form.ap5-fixed {
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  width: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
}

/* ============================================================
   HERO: imagen + nombre (hereda estilos de product.tpl)
   ============================================================ */
.rn-pack-hero {
  margin-bottom: 48px;
}

/* Ocultar la galería en el hero ya que está repetida;
   si el pack no tiene imagen propia la galería estará vacía */
.rn-pack-hero .product-column__details {
  justify-content: center;
}

/* ============================================================
   CUERPO PRINCIPAL: grid items (izq) + sticky buy (der)
   ============================================================ */
.rn-pack-body {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: 48px;
}

/* Columna izquierda: productos del pack */
.rn-pack-items-col {
  flex: 1 1 0;
  min-width: 0;
}

/* Columna derecha: precio + carrito (sticky) */
.rn-pack-buy-col {
  flex: 0 0 320px;
  width: 320px;
  position: sticky;
  top: 230px;
  align-self: flex-start;
}

/* ============================================================
   GRID DE PRODUCTOS DEL PACK
   ============================================================ */
.rn-pack-contents-title {
  margin-bottom: 24px;
  text-align: left;
}

/* Aviso pack agotado */
.rn-pack-oos-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b00020;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

/* Grid automático: 2 columnas por defecto, 3 si hay espacio */
.rn-pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 40px;
  width: 100%;
}

/* Estado agotado */
.rn-pack-grid.ap5-pack-oos .rn-pack-card {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Tarjeta de item ──────────────────────────────────────── */
.rn-pack-card {
  position: relative;
  background: #ffffff;
  border: 1.5px solid #e8e8e8;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.rn-pack-card:hover {
  border-color: #001F63;
  box-shadow: 0 4px 20px rgba(0, 31, 99, 0.1);
}

.rn-pack-card.ap5-product-pack-row-has-errors {
  border-color: #f5a623;
}

.rn-pack-card.ap5-product-pack-row-has-fatal-errors {
  border-color: #b00020;
}

.rn-pack-card.ap5-is-excluded-product {
  opacity: 0.4;
}

/* Overlay de bloqueo */
.rn-pack-card__overlay,
.ap5-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 2;
}

/* Inner */
.rn-pack-card__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Badge cantidad */
.rn-pack-card__qty-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #001F63;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  z-index: 3;
  letter-spacing: 0.04em;
}

/* Botón eliminar / restaurar */
.rn-pack-card__remove,
.rn-pack-card__restore,
.ap5-pack-product-icon-remove,
.ap5-pack-product-icon-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 3;
  background-size: 12px;
  background-repeat: no-repeat;
  background-position: center;
  transition: background-color 0.15s, transform 0.15s;
}

.rn-pack-card__remove,
.ap5-pack-product-icon-remove {
  background-color: #fafafa;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M1 1l10 10M11 1L1 11' stroke='%23b00020' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

.rn-pack-card__remove:hover,
.ap5-pack-product-icon-remove:hover {
  background-color: #ffebee;
  transform: scale(1.1);
}

.rn-pack-card__restore,
.ap5-pack-product-icon-check {
  background-color: #e8f5e9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l4 4 6-8' stroke='%232e7d32' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.rn-pack-card__restore:hover,
.ap5-pack-product-icon-check:hover {
  background-color: #c8e6c9;
  transform: scale(1.1);
}

/* <hr> del módulo — ocultar visualmente pero mantener en DOM */
.rn-pack-card hr.ap5-pack-product-icon-plus,
#ap5-product-list hr.ap5-pack-product-icon-plus {
  display: none;
}

/* Imagen */
.rn-pack-card__image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f7f7f7;
  overflow: hidden;
}

.rn-pack-card__image-link {
  display: block;
  width: 100%;
  height: 100%;
}

.rn-pack-card__image img,
.rn-pack-card .ap5-pack-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.3s ease;
}

.rn-pack-card:hover .rn-pack-card__image img {
  transform: scale(1.04);
}

/* Info del item */
.rn-pack-card__info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  flex: 1;
}

/* Nombre */
.rn-pack-card__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #09101D;
  margin: 0;
  line-height: 1.35;
}

.rn-pack-card__name a {
  color: inherit;
  text-decoration: none;
}

.rn-pack-card__name a:hover {
  color: #001F63;
  text-decoration: underline;
}

/* Precio */
.rn-pack-card__price {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rn-pack-card__price-original {
  font-size: 0.78rem;
  color: #9e9e9e;
  text-decoration: line-through;
  font-weight: 400;
}

.rn-pack-card__price-current {
  font-size: 1rem;
  font-weight: 700;
  color: #001F63;
}

.rn-pack-card__saving {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  background: #001F63;
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  margin-top: 2px;
}

/* Disponibilidad */
.rn-pack-card__avail {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #6C6C6C;
}

.rn-pack-card__avail-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rn-pack-card__avail-dot--ok {
  background: #2e7d32;
}

.rn-pack-card__avail-dot--low {
  background: #f5a623;
}

.rn-pack-card__avail-dot--no {
  background: #b00020;
}

/* Errores */
.rn-pack-card__error {
  font-size: 0.78rem;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
}

.rn-pack-card__error ol {
  margin: 0;
  padding-left: 16px;
}

/* Acciones (cantidad + atributos) */
.rn-pack-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.rn-pack-card__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6C6C6C;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.rn-pack-card__qty-field,
.ap5-attribute-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.rn-pack-card__qty-input input.ap5-quantity-wanted {
  width: 60px;
  height: 34px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: #09101D;
  padding: 0 6px;
  transition: border-color 0.2s;
}

.rn-pack-card__qty-input input.ap5-quantity-wanted:focus {
  outline: none;
  border-color: #001F63;
}

.rn-pack-card__attr-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Select dropdown */
.ap5-attribute-select {
  width: 100%;
  height: 36px;
  border: 1.5px solid #e0e0e0;
  border-radius: 32px;
  padding: 0 32px 0 12px;
  font-size: 0.82rem;
  font-family: var(--font-family, 'Montserrat', sans-serif);
  color: #09101D;
  background-color: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23001F63' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.2s;
}

.ap5-attribute-select:focus {
  outline: none;
  border-color: #001F63;
}

/* Colores */
.rn-pack-card__colors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ap5-color.color_pick {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
}

.ap5-color.color_pick:hover,
.ap5-color.color_pick.selected {
  border-color: #001F63;
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(0, 31, 99, 0.2);
}

/* Radios */
.rn-pack-card__radios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.rn-pack-card__radio-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.rn-pack-card__radio-item input[type="radio"] {
  accent-color: #001F63;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.rn-pack-card__radio-item .radio-label {
  font-size: 0.8rem;
  color: #09101D;
}

/* ============================================================
   CAJA DE COMPRA (columna derecha sticky)
   ============================================================ */
.rn-pack-buy-box {
  background: #ffffff;
  border: 1.5px solid #e8e8e8;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Título dentro de la caja */
.rn-pack-buy-box__title {
  font-size: 1rem;
  font-weight: 700;
  color: #09101D;
  margin: 0;
  line-height: 1.3;
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
  text-align: center;
}

#ap5-buy-container {
  padding: 0 15px 15px 15px;
}

/* Precios */
.rn-pack-buy-box__prices {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.rn-pack-buy-box__price-before {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
}

.rn-pack-buy-box__price-before .label-price {
  font-size: 0.75rem;
  color: #9e9e9e;
  font-weight: 500;
}

.rn-pack-buy-box__price-before .regular-price {
  font-size: 0.9rem;
  color: #9e9e9e;
  text-decoration: line-through;
}

.rn-pack-buy-box__price-now {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}

.rn-pack-buy-box__price-now .label-price {
  font-size: 0.75rem;
  color: #6C6C6C;
  font-weight: 500;
}

.rn-pack-buy-box__price-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #001F63;
  line-height: 1;
}

/* Badge de ahorro */
.rn-pack-buy-box__saving {
  margin-top: 4px;
}

.rn-pack-buy-box__saving .discount {
  display: inline-block;
  background: #F3F900;
  color: #09101D;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  display: none;
}

/* Impuestos */
.rn-pack-buy-box__tax {
  font-size: 0.75rem;
  color: #9e9e9e;
  margin: -8px 0 0 0;
}

/* Errores en la caja */
.rn-pack-buy-box__error,
.rn-pack-buy-box__warning {
  font-size: 0.875rem;
  border-radius: 8px;
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* Zona cantidad + botón */
.rn-pack-buy-box__cart .product-add-to-cart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rn-pack-buy-box__cart .product-detail__quantity {
  gap: 12px;
  width: 100%;
  flex-direction: column;
}

.rn-pack-buy-box__cart .product-detail__quantity .qty {
  flex: 0 0 auto;
}

.rn-pack-buy-box__cart .product-detail__quantity .button.add-to-cart {
  flex: 1;
  width: 100%;
  text-align: center;
  justify-content: center;
}

/* ============================================================
   SECCIONES INFERIORES
   ============================================================ */
.rn-pack-description,
.rn-pack-tabs,
.rn-pack-attachments {
  margin-top: 48px;
}

.rn-pack-description__body {
  color: #2F2F2F;
  line-height: 1.7;
}

/* ── Tabs: nav pills ───────────────────────────────────── */
.rn-pack-tabs .tabs {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rn-pack-tabs .nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
  border-bottom: none;
}

.rn-pack-tabs .nav-item {
  margin: 0;
}

.rn-pack-tabs .nav-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-family, 'Montserrat', sans-serif);
  color: #6C6C6C;
  text-decoration: none;
  background: #f4f4f4;
  border: 1.5px solid transparent;
  border-radius: 32px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  letter-spacing: 0.01em;
}

.rn-pack-tabs .nav-tabs .nav-link:hover {
  color: #001F63;
  background: #eef0f8;
  border-color: #001F63;
}

.rn-pack-tabs .nav-tabs .nav-link.active {
  color: #fff;
  background: #001F63;
  border-color: #001F63;
}

/* ── Tabs: área de contenido ───────────────────────────── */
.rn-pack-tabs .tab-content {
  margin-top: 20px;
  border: 1.5px solid #e8e8e8 !important;
  border-radius: 16px;
  overflow: hidden;
  margin-top: 16px !important;
}

.rn-pack-tabs .tab-pane {
  display: none;
  padding: 6px 32px 28px 32px;
  flex-wrap: wrap;
  gap: 32px;
}

.rn-pack-tabs .tab-pane.active {
  display: flex;
}

/* Columnas Bootstrap dentro del pane */
.rn-pack-tabs .tab-pane [class*="col-"] {
  float: none;
  padding: 0;
  flex: 1 1 280px;
  min-width: 0;
}

/* Descripción (rte) */
.rn-pack-tabs .tab-pane .rte {
  font-size: 0.875rem;
  color: #2F2F2F;
  line-height: 1.75;
}

.rn-pack-tabs .tab-pane .rte p:last-child {
  margin-bottom: 0;
}

.rn-pack-tabs .tab-pane .rte hr {
  margin: 16px 0;
  border: 0;
  border-bottom: 1px solid #e8e8e8;
}

/* ── Data sheet (características) ─────────────────────── */
.rn-pack-tabs .product-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rn-pack-tabs .product-features .h6 {
  font-size: 0.72rem;
  font-weight: 700;
  color: #6C6C6C;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px 0;
}

.rn-pack-tabs .data-sheet {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  border: 1.5px solid #e8e8e8;
  border-radius: 12px;
  overflow: hidden;
}

.rn-pack-tabs .data-sheet dt,
.rn-pack-tabs .data-sheet dd {
  padding: 10px 16px;
  margin: 0;
  border-bottom: 1px solid #efefef;
}

.rn-pack-tabs .data-sheet dt {
  font-weight: 700;
  color: #09101D;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f9f9f9;
}

.rn-pack-tabs .data-sheet dd {
  color: #6C6C6C;
  background: #fff;
}

.rn-pack-tabs .data-sheet dt:last-of-type,
.rn-pack-tabs .data-sheet dd:last-child {
  border-bottom: none;
}

/* ============================================================
   ESTADOS JS DEL MÓDULO
   ============================================================ */
.unvisible {
  display: none !important;
}

.ap5-combination-unavailable a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet: reducir columna sticky */
@media (max-width: 996px) {
  .rn-pack-body {
    gap: 24px;
  }

  .rn-pack-buy-col {
    flex: 0 0 260px;
    width: 260px;
    top: 90px;
  }

  .rn-pack-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }
}

/* Mobile: apilar columnas verticalmente */
@media (max-width: 768px) {
  .rn-pack-body {
    flex-direction: column;
    gap: 0;
  }

  /* En mobile: primero el bloque de compra, luego el grid */
  .rn-pack-buy-col {
    flex: none;
    width: 100%;
    order: -1;
    position: static;
    margin-bottom: 32px;
  }

  .rn-pack-items-col {
    width: 100%;
  }

  .rn-pack-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .rn-pack-buy-box__price-value {
    font-size: 1.4rem;
  }

  .rn-pack-description,
  .rn-pack-tabs {
    margin-top: 32px;
  }
}

/* Mobile muy pequeño: 1 columna en grid */
@media (max-width: 480px) {
  .rn-pack-grid {
    grid-template-columns: 1fr;
  }
}