/* ====== BASE ====== */
.poyco-pack-stack { 
  max-width: 600px; 
  margin: 0 auto; 
  /* Variables con valores por defecto (se sobrescriben desde PHP) */
  --poyco-title-font: inherit;
  --poyco-title-color: #333;
  --poyco-title-size: 15px;

  --poyco-subtitle-font: inherit;
  --poyco-subtitle-color: #555;
  --poyco-subtitle-size: 13px;

  --poyco-badge-font: inherit;
  --poyco-badge-color: #fff;
  --poyco-badge-size: 12px;
  --poyco-badge-bg: #000;

  --poyco-price-font: inherit;
  --poyco-price-color: #000;
  --poyco-price-size: 18px;

  --poyco-price-old-font: inherit;
  --poyco-price-old-color: #777;
  --poyco-price-old-size: 13px;

  --poyco-label-font: inherit;
  --poyco-label-color: #333;
  --poyco-label-size: 13px;

  /* === Botón Añadir al carrito (nuevas variables) === */
  --poyco-btn-font: inherit;
  --poyco-btn-color: #fff;
  --poyco-btn-bg: #000;
  --poyco-btn-color-hover: #fff;   /* color de texto en hover */
  --poyco-btn-bg-hover: #333;
  --poyco-btn-radius: 6px;
  --poyco-btn-fs: 16px;
  --poyco-btn-py: 16px;
  --poyco-btn-px: 16px;
  --poyco-btn-border-color: transparent;
  --poyco-btn-text-align: center;
}

.poyco-pack-boxes { 
  display: flex; 
  flex-direction: column; 
  gap: 25px; 
  margin-bottom: 20px; 
}

.poyco-pack-box { 
  border: 2px solid #e0e0e0; 
  border-radius: 8px; 
  padding: 16px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: visible !important; /* importante para badges */
}

.poyco-pack-box:hover { border-color: #bbb; }
.poyco-pack-box.active { border-color: #000; background: #fffef7; }
/* Borde por defecto y cuando está activo */
.poyco-pack-box { border-color: #e0e0e0 !important; }
.poyco-pack-box:not(.active) { border-color: #e0e0e0 !important; }
.poyco-pack-box.active { border-color: #fb4e00 !important; background: #fffef7; }

.poyco-box-header { 
  display: flex; 
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
  position: relative; 
  z-index: 1; 
}

/* ====== TÍTULO & SUBTÍTULO ====== */
.poyco-box-label { 
  font-weight: 600; 
  font-size: var(--poyco-title-size);
  color: var(--poyco-title-color);
  font-family: var(--poyco-title-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.poyco-pack-subheader{
  order: 3;
  flex: 1 0 100%;
  margin-left: 28px;      
  font-size: var(--poyco-subtitle-size);
  color: var(--poyco-subtitle-color);
  line-height: 1.3;
  font-family: var(--poyco-subtitle-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ====== BADGE ====== */
.poyco-box-badge{ 
    position: relative;
    width:200px;
    text-align: center;
  order: 2;
  margin-left: auto;
  background: var(--poyco-badge-bg);
  color: var(--poyco-badge-color);
  padding: 6px 12px; 
  border-radius: 999px; 
  font-size: var(--poyco-badge-size);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000 !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  font-family: var(--poyco-badge-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ====== PRECIO ====== */
.poyco-box-header .poyco-box-price{
  order: 4;
  margin-left: auto;      
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 96px;        
}

.poyco-box-header .poyco-price{
  font-weight: 700;
  font-size: var(--poyco-price-size);
  line-height: 1;
  color: var(--poyco-price-color);
  font-family: var(--poyco-price-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  transition: all .2s ease;
}

.poyco-box-header .poyco-price-old{
  font-size: var(--poyco-price-old-size);
  color: var(--poyco-price-old-color);
  line-height: 1;
  font-family: var(--poyco-price-old-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.poyco-price-old>.woocommerce-Price-amount.amount{
  text-decoration-line: line-through;
}

/* ====== RADIO + CABECERA ORDEN ====== */
.poyco-box-radio { 
  order: 1;
  display: inline-flex; 
  align-items: center; 
  gap: 8px;
  cursor: pointer;
  margin: 0;
}

.poyco-box-header .poyco-box-badge{ order: 2; }

/* ====== CUERPO PACK ====== */
.poyco-box-content { display: flex; flex-direction: column; gap: 16px; }
.poyco-slot-inline { 
  display: flex; flex-direction: column; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid #f0f0f0;
}
.poyco-slot-inline:last-child { border-bottom: none; padding-bottom: 0; }

.poyco-field-buttons { display: flex; flex-direction: column; gap: 8px; }

.poyco-label-buttons { 
  font-size: var(--poyco-label-size); 
  font-weight: 600;
  color: var(--poyco-label-color);
  margin: 0;
  font-family: var(--poyco-label-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ====== BOTONES ====== */
.poyco-buttons-group { display: flex; flex-wrap: wrap; gap: 8px; }
.poyco-btn-option { display: inline-block; cursor: pointer; margin: 0; position: relative; }
.poyco-btn-option input[type="radio"] {
  position: absolute !important; opacity: 0 !important; pointer-events: none !important; width: 0 !important; height: 0 !important; left: -9999px !important;
}

/* Talla */
.poyco-pack-form .poyco-btn-option .poyco-btn-text {
  display: inline-flex !important; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 12px; border: 2px solid #ddd; border-radius: 6px;
  font-size: 14px; font-weight: 600; color: #333; background: #fff; transition: all 0.2s; cursor: pointer; box-sizing: border-box;
}
.poyco-pack-form .poyco-btn-option:hover .poyco-btn-text { border-color: #5b4e2c !important; color: #5b4e2c !important; }
.poyco-pack-form .poyco-btn-option input[type="radio"]:checked + .poyco-btn-text { border-color: #5b4e2c !important; background-color: #5b4e2c !important; color: #fff !important; }

/* Color/Imagen */
.poyco-pack-form .poyco-btn-option.is-color-btn .poyco-btn-color,
.poyco-pack-form .poyco-btn-option.is-color-btn .poyco-btn-image {
  display: block !important; width: 50px; height: 50px; border: 3px solid #ddd; border-radius: 50%;
  transition: all 0.2s; background-size: cover; background-position: center; background-repeat: no-repeat; cursor: pointer; box-sizing: border-box;
}
.poyco-pack-form .poyco-btn-option.is-color-btn:hover .poyco-btn-color,
.poyco-pack-form .poyco-btn-option.is-color-btn:hover .poyco-btn-image { border-color: #5b4e2c !important; transform: scale(1.05); }
.poyco-pack-form .poyco-btn-option.is-color-btn input[type="radio"]:checked + .poyco-btn-color,
.poyco-pack-form .poyco-btn-option.is-color-btn input[type="radio"]:checked + .poyco-btn-image { border-color: #5b4e2c !important; border-width: 4px !important; transform: scale(1.1) !important; box-shadow: 0 2px 8px rgba(91, 78, 44, 0.3) !important; }

/* Feedback slot */
.poyco-slot-status-inline { font-size: 13px; text-align: center; min-height: 20px; font-weight: 600; }

/* ====== BOTÓN AÑADIR ====== */
.poyco-add-cart-btn {
  width: 100%;
  padding: var(--poyco-btn-py) var(--poyco-btn-px);
  background: var(--poyco-btn-bg);
  color: var(--poyco-btn-color);
  border: 1px solid var(--poyco-btn-border-color);
  border-radius: var(--poyco-btn-radius);
  font-size: var(--poyco-btn-fs);
  font-family: var(--poyco-btn-font), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 600;
  text-align: var(--poyco-btn-text-align);
  cursor: pointer;
  transition: all 0.2s;
}

.poyco-add-cart-btn:hover:not(:disabled) {
  background: var(--poyco-btn-bg-hover);
  color: var(--poyco-btn-color-hover);
}

.poyco-add-cart-btn:disabled { 
  opacity: 0.6; 
  cursor: not-allowed; 
}

/* Mantener visible el texto del botón en todos los estados */
.poyco-add-cart-btn.loading,
.poyco-add-cart-btn.added,
.poyco-add-cart-btn:disabled {
  color: var(--poyco-btn-color) !important;      /* texto visible */
  background: var(--poyco-btn-bg) !important;    /* mismo fondo que en reposo */
  text-indent: 0 !important;                     /* evita “ocultar texto” de algunos temas */
  opacity: 1 !important;                         /* que no se vuelva casi transparente */
}

/* Si tu tema añade un spinner con ::after que tapa el texto, lo desactivamos */
.poyco-add-cart-btn.loading::after,
.poyco-add-cart-btn.added::after {
  display: none !important;
}

/* Opcional: mientras está cargando puedes usar el color hover si lo prefieres */
.poyco-add-cart-btn.loading {
  background: var(--poyco-btn-bg-hover) !important;
  color: var(--poyco-btn-color-hover) !important;
}
/* ==== Mantener visible el texto del botón tras añadir al carrito (Bricks) ==== */

/* Estado después de añadir */
.poyco-add-cart-btn.bricks-cart-added {
  color: var(--poyco-btn-color) !important;          /* vuelve a mostrar el texto */
  background: var(--poyco-btn-bg) !important;
  text-indent: 0 !important;
  opacity: 1 !important;
  pointer-events: auto !important;                   /* por si Bricks lo bloquea */
}

/* Desactivar el pseudo-elemento que suele tapar el texto */
.poyco-add-cart-btn.bricks-cart-added::after {
  content: none !important;
  display: none !important;
}

/* También para el estado de carga (si Bricks lo usa antes del “added”) */
.poyco-add-cart-btn.bricks-loading,
.poyco-add-cart-btn.bricks-cart-adding {
  color: var(--poyco-btn-color-hover) !important;
  background: var(--poyco-btn-bg-hover) !important;
  text-indent: 0 !important;
  opacity: 1 !important;
}

/* Evita que el texto se colapse cuando cambia el contenido del botón */
.poyco-add-cart-btn {
  min-height: 44px;  /* asegúrate de que no cambia de tamaño */
  display: inline-flex;
  justify-content: center;
  align-items: center;
}


/* ====== ACORDEÓN ====== */
.poyco-pack-box.is-collapsed > .poyco-acc-body { display: none; }
.poyco-pack-box > :first-child { cursor: pointer; }
.poyco-pack-box.is-open { box-shadow: 0 0 0 2px rgba(91,78,44,.15) inset; background: #fffaf0; }

/* ====== RESPONSIVE ====== */
@media (max-width: 600px){
  .poyco-pack-box { padding: 12px; }
  .poyco-btn-text { min-width: 40px; height: 40px; font-size: 13px; }
  .poyco-btn-option.is-color-btn .poyco-btn-color,
  .poyco-btn-option.is-color-btn .poyco-btn-image { width: 44px; height: 44px; }
  .poyco-box-header .poyco-price{ font-size: calc(var(--poyco-price-size) - 2px); }
  .poyco-box-header .poyco-price-old{ font-size: calc(var(--poyco-price-old-size) - 1px); }
  .poyco-box-badge {
      position:relative;
      top:-40px;
      font-size: 8px;
  }
  
   .poyco-pack-box[data-pack-size="2"] .poyco-box-radio{padding-top:15px;margin-bottom:-40px;}
   .poyco-pack-box[data-pack-size="3"] .poyco-box-radio{padding-top:15px;margin-bottom:-40px;}
}


/* Mantener visible el texto del botón en estados Bricks/Woo */
.poyco-add-cart-btn,
.poyco-add-cart-btn.bricks-cart-adding,
.poyco-add-cart-btn.bricks-cart-added,
.poyco-add-cart-btn.loading,
.poyco-add-cart-btn.added {
  text-indent: 0 !important;
  color: var(--poyco-btn-color) !important;
  opacity: 1 !important;
  display: inline-flex !important;
  justify-content: center !important;
  align-items: center !important;
  min-height: 44px; /* evita que cambie de altura al mutar el contenido */
}

/* Oculta pseudo-elementos que puedan tapar el texto */
.poyco-add-cart-btn.bricks-cart-adding::after,
.poyco-add-cart-btn.bricks-cart-added::after,
.poyco-add-cart-btn.loading::after,
.poyco-add-cart-btn.added::after {
  content: none !important;
  display: none !important;
}


/* Garantizar que la X de FunnelKit sea clicable */
.fkcart-icon-close {
  pointer-events: auto !important;
  cursor: pointer !important;
  z-index: 9999 !important;
}



/* ===== CRÍTICO: Evitar que el texto desaparezca ===== */
.poyco-add-cart-btn,
.poyco-add-cart-btn.loading,
.poyco-add-cart-btn.added,
.poyco-add-cart-btn.bricks-cart-adding,
.poyco-add-cart-btn.bricks-cart-added {
  text-indent: 0 !important;
  font-size: 16px !important;
  line-height: 1.4 !important;
  opacity: 1 !important;
  visibility: visible !important;
  color: inherit !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
}

/* Eliminar pseudo-elementos que ocultan texto */
.poyco-add-cart-btn::before,
.poyco-add-cart-btn::after,
.poyco-add-cart-btn.loading::before,
.poyco-add-cart-btn.loading::after,
.poyco-add-cart-btn.added::before,
.poyco-add-cart-btn.added::after,
.poyco-add-cart-btn.bricks-cart-adding::before,
.poyco-add-cart-btn.bricks-cart-adding::after,
.poyco-add-cart-btn.bricks-cart-added::before,
.poyco-add-cart-btn.bricks-cart-added::after {
  content: none !important;
  display: none !important;
}

/* Forzar que todo el contenido sea visible */
.poyco-add-cart-btn * {
  opacity: 1 !important;
  visibility: visible !important;
  display: inline !important;
}


/* ===== ESTILOS PARA PACKS AUTOMÁTICOS ===== */

/* Mensaje de pack detectado */
.woocommerce-message.poyco-auto-pack-msg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-left: 4px solid #fff;
  padding: 16px 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.woocommerce-message.poyco-auto-pack-msg::before {
  content: "🎉";
  font-size: 24px;
  margin-right: 12px;
}

/* Badge de descuento en el carrito */
.woocommerce-cart-form__cart-item .poyco-pack-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #0f9d58 0%, #0d7d46 100%);
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 10px;
  box-shadow: 0 2px 6px rgba(15, 157, 88, 0.3);
  animation: packPulse 2s ease-in-out infinite;
}

@keyframes packPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 6px rgba(15, 157, 88, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(15, 157, 88, 0.5);
  }
}

/* Badge específico para "GRATIS" */
.woocommerce-cart-form__cart-item .poyco-pack-badge.is-free {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
  animation: freeItemPulse 1.5s ease-in-out infinite;
}

@keyframes freeItemPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

/* Aviso de "casi pack" */
.poyco-almost-pack-notice {
  background: linear-gradient(135deg, #ffd93d 0%, #ffb800 100%);
  color: #333;
  border: none;
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(255, 184, 0, 0.3);
}

.poyco-almost-pack-notice::before {
  content: "💡";
  font-size: 20px;
  margin-right: 10px;
}

/* Resumen visual del pack en el carrito */
.poyco-pack-summary {
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  padding: 16px;
  margin: 20px 0;
}

.poyco-pack-summary-title {
  font-weight: 700;
  font-size: 14px;
  color: #333;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.poyco-pack-summary-title::before {
  content: "📦";
  font-size: 18px;
}

.poyco-pack-savings {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #fff;
  border-radius: 6px;
  margin-top: 8px;
}

.poyco-pack-savings-amount {
  font-size: 18px;
  font-weight: 700;
  color: #0f9d58;
}

/* Responsive */
@media (max-width: 768px) {
  .woocommerce-cart-form__cart-item .poyco-pack-badge {
    display: block;
    margin-left: 0;
    margin-top: 8px;
    width: fit-content;
  }
}