/**
 * Clearis — Product Builder · estilos de front
 * Paleta y radios de la casa vía tokens --cle-*
 */

:root {
  --cle-primary: #6F9B3B;
  --cle-primary-600: #5f8732;
  --cle-primary-700: #4f7029;
  --cle-accent: #8FC15B;
  --cle-light: #C0E59C;
  --cle-tint: #f6faee;
  --cle-tint-2: #edf4dd;
  --cle-line: #e7eed9;
  --cle-line-soft: #f0f4e8;
  --cle-ink: #2c3720;
  --cle-text: #46503a;
  --cle-muted: #828c70;
  --cle-white: #ffffff;
  --cle-warn-bg: #f8f0d8;
  --cle-warn-tx: #856414;
  --cle-warn-rail: #d9a93a;
  --cle-danger-bg: #f5e6e2;
  --cle-danger-tx: #a4443c;
  --cle-danger-rail: #c46a61;
  --cle-r: 14px;
  --cle-r-sm: 10px;
  --cle-pill: 999px;
}

.cle-pb,
.cle-pb * {
  box-sizing: border-box;
}

.cle-pb {
  font-family: inherit;
  color: var(--cle-text);
  margin: 24px 0;
}

/* ---------------------------------------------------------------- Cabecera */

.cle-pb-head {
  padding-left: 14px;
  border-left: 3px solid var(--cle-primary);
  margin-bottom: 22px;
}

.cle-pb-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--cle-ink);
  margin: 0;
  line-height: 1.3;
}

.cle-pb-intro {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--cle-muted);
  line-height: 1.5;
}

/* ---------------------------------------------------------------- Secciones */

.cle-pb-section {
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--cle-line-soft);
}

.cle-pb-section:last-of-type {
  border-bottom: none;
}

.cle-pb-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.cle-pb-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--cle-ink);
  margin: 0;
}

.cle-pb-section-counter {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--cle-primary-700);
  background: var(--cle-tint-2);
  border-radius: var(--cle-pill);
  padding: 3px 11px;
}

.cle-pb-section-counter.is-invalid {
  background: var(--cle-warn-bg);
  color: var(--cle-warn-tx);
}

/* Tope alcanzado: la sección está completa, no es un error. */
.cle-pb-section-counter.is-full {
  background: var(--cle-primary);
  color: #fff;
}

/* Opción que ya no cabe: se apaga, pero sigue legible. */
.cle-pb-check.is-capped,
.cle-pb-card.is-capped,
.cle-pb-choice-opt.is-capped {
  opacity: .5;
}

.cle-pb-check.is-capped .cle-pb-check-label,
.cle-pb-choice-opt.is-capped .cle-pb-check-label {
  cursor: not-allowed;
}

.cle-pb-section-desc,
.cle-pb-section-rule {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--cle-muted);
  line-height: 1.5;
}

.cle-pb-section-rule {
  color: var(--cle-primary-700);
  font-weight: 500;
}

/* ---------------------------------------------------------------- Tarjetas */

.cle-pb-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.cle-pb-card {
  display: flex;
  flex-direction: column;
  background: var(--cle-white);
  border: 1px solid var(--cle-line);
  border-radius: var(--cle-r);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}

.cle-pb-card.is-selected {
  border-color: var(--cle-primary);
  box-shadow: 0 0 0 2px rgba(111, 155, 59, .16);
}

.cle-pb-card.is-unavailable {
  opacity: .55;
}

.cle-pb-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--cle-tint);
}

.cle-pb-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cle-pb-card-placeholder {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--cle-tint), var(--cle-tint-2));
}

.cle-pb-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--cle-pill);
  padding: 3px 9px;
}

.cle-pb-badge--out {
  background: var(--cle-danger-bg);
  color: var(--cle-danger-tx);
}

.cle-pb-badge--changed {
  left: auto;
  right: 8px;
  background: var(--cle-light);
  color: var(--cle-primary-700);
}

.cle-pb-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  flex: 1;
}

.cle-pb-item-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--cle-ink);
  line-height: 1.35;
}

.cle-pb-item-meta {
  margin: 0;
  font-size: 12px;
  color: var(--cle-muted);
}

.cle-pb-item-price {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cle-primary-700);
}

/* ---------------------------------------------------------------- Stepper */

.cle-pb-stepper {
  display: flex;
  align-items: stretch;
  margin-top: auto;
  border: 1px solid var(--cle-line);
  border-radius: var(--cle-r-sm);
  overflow: hidden;
}

.cle-pb-step {
  flex: 0 0 34px;
  border: none;
  background: var(--cle-tint);
  color: var(--cle-primary-700);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}

.cle-pb-step:hover:not(:disabled) {
  background: var(--cle-tint-2);
}

.cle-pb-step:disabled {
  opacity: .4;
  cursor: default;
}

.cle-pb-step:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(111, 155, 59, .35);
}

.cle-pb-qty {
  flex: 1;
  min-width: 0;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--cle-ink);
  background: var(--cle-white);
  -moz-appearance: textfield;
}

.cle-pb-qty::-webkit-outer-spin-button,
.cle-pb-qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cle-pb-qty:focus {
  outline: none;
  background: var(--cle-tint);
}

/* ---------------------------------------------------------------- Casillas */

.cle-pb-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--cle-line);
  border-radius: var(--cle-r);
  overflow: hidden;
}

.cle-pb-check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--cle-line-soft);
  background: var(--cle-white);
}

.cle-pb-check:last-child {
  border-bottom: none;
}

.cle-pb-check.is-selected {
  background: var(--cle-tint);
}

.cle-pb-check.is-unavailable {
  opacity: .55;
}

.cle-pb-check-label {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  flex: 1;
  margin: 0;
}

.cle-pb-check-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cle-pb-check-box {
  flex-shrink: 0;
  width: 19px;
  height: 19px;
  border: 1.5px solid var(--cle-line);
  border-radius: 5px;
  background: var(--cle-white);
  position: relative;
  transition: background .15s, border-color .15s;
}

.cle-pb-check-label input:checked + .cle-pb-check-box {
  background: var(--cle-primary);
  border-color: var(--cle-primary);
}

.cle-pb-check-label input:checked + .cle-pb-check-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.cle-pb-check-label input:focus-visible + .cle-pb-check-box {
  box-shadow: 0 0 0 3px rgba(111, 155, 59, .25);
}

.cle-pb-check-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Miniatura del producto en el modo casillas */
.cle-pb-check-thumb,
.cle-pb-choice-thumb {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: var(--cle-r-sm);
  overflow: hidden;
  background: var(--cle-tint);
  border: 1px solid var(--cle-line-soft);
}

.cle-pb-check-thumb img,
.cle-pb-choice-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cle-pb-check-thumb-empty {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--cle-tint), var(--cle-tint-2));
}

/* ---------------------------------------------------------------- Desplegable */

.cle-pb-select-wrap {
  max-width: 460px;
}

.cle-pb-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cle-line);
  border-radius: var(--cle-r-sm);
  background: var(--cle-white);
  color: var(--cle-text);
  font-size: 14px;
  font-family: inherit;
}

.cle-pb-select:focus {
  outline: none;
  border-color: var(--cle-primary);
  box-shadow: 0 0 0 3px rgba(111, 155, 59, .15);
}

.cle-pb-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- Resumen */

.cle-pb-summary {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  margin-top: 8px;
  padding: 18px;
  background: var(--cle-tint);
  border-radius: var(--cle-r);
}

.cle-pb-summary-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--cle-ink);
}

.cle-pb-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cle-pb-summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--cle-line);
  font-size: 13px;
}

.cle-pb-summary-list li:last-child {
  border-bottom: none;
}

.cle-pb-summary-list .cle-pb-sum-name {
  color: var(--cle-ink);
}

.cle-pb-summary-list .cle-pb-sum-qty {
  font-weight: 700;
  color: var(--cle-primary-700);
  flex-shrink: 0;
}

.cle-pb-summary-list li.is-changed .cle-pb-sum-name::after {
  content: "•";
  color: var(--cle-primary);
  margin-left: 6px;
}

.cle-pb-summary-empty {
  margin: 0;
  font-size: 13px;
  color: var(--cle-muted);
}

.cle-pb-progress {
  margin-bottom: 14px;
}

.cle-pb-progress-bar {
  height: 6px;
  border-radius: var(--cle-pill);
  background: var(--cle-line);
  overflow: hidden;
}

.cle-pb-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--cle-primary);
  border-radius: var(--cle-pill);
  transition: width .25s ease;
}

.cle-pb-progress-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--cle-muted);
}

.cle-pb-summary-side {
  background: var(--cle-white);
  border-radius: var(--cle-r-sm);
  padding: 16px;
}

.cle-pb-totals {
  margin: 0 0 14px;
}

.cle-pb-total-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}

.cle-pb-total-row dt {
  color: var(--cle-muted);
  margin: 0;
}

.cle-pb-total-row dd {
  margin: 0;
  font-weight: 600;
  color: var(--cle-ink);
}

.cle-pb-total-row--grand {
  border-top: 1px solid var(--cle-line);
  margin-top: 6px;
  padding-top: 10px;
}

.cle-pb-total-row--grand dt,
.cle-pb-total-row--grand dd {
  font-size: 16px;
  font-weight: 700;
  color: var(--cle-ink);
}

.cle-pb-messages {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.cle-pb-messages li {
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 11px;
  border-radius: var(--cle-r-sm);
  border-left: 3px solid var(--cle-warn-rail);
  background: var(--cle-warn-bg);
  color: var(--cle-warn-tx);
  margin-bottom: 6px;
}

.cle-pb-messages li.is-error {
  border-left-color: var(--cle-danger-rail);
  background: var(--cle-danger-bg);
  color: var(--cle-danger-tx);
}

.cle-pb-messages li.is-ok {
  border-left-color: var(--cle-primary);
  background: var(--cle-tint-2);
  color: var(--cle-primary-700);
}

/* ---------------------------------------------------------------- Acciones */

.cle-pb-add {
  display: block;
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: var(--cle-pill);
  background: var(--cle-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}

.cle-pb-add:hover:not(:disabled) {
  background: var(--cle-primary-700);
}

.cle-pb-add:disabled {
  background: var(--cle-line);
  color: var(--cle-muted);
  cursor: not-allowed;
}

.cle-pb-add:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(111, 155, 59, .3);
}

.cle-pb-add.is-busy {
  opacity: .7;
  pointer-events: none;
}

.cle-pb-reset {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  border: none;
  background: none;
  color: var(--cle-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.cle-pb-reset:hover {
  color: var(--cle-primary-700);
}

.cle-pb-help {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--cle-muted);
  line-height: 1.5;
}

/* ------------------------------------------- Composición en carrito/pedido */

.cle-pb-composition {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--cle-text);
}

.cle-pb-composition-item {
  padding: 1px 0;
}

.cle-pb-composition-qty {
  font-weight: 700;
  color: var(--cle-primary-700);
}

.cle-pb-composition-ref {
  color: var(--cle-muted);
}

/* Aclaración cuando la línea agrupa varios packs idénticos. */
.cle-pb-composition-note,
.cle-pb-order-note {
  margin: 0 0 6px;
  font-size: 12px;
  font-style: italic;
  color: var(--cle-muted);
}

.cle-pb-order {
  margin: 18px 0;
}

.cle-pb-order-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--cle-ink);
  margin: 0 0 8px;
}

.cle-pb-order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 14px;
}

.cle-pb-order-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--cle-muted);
  background: var(--cle-tint);
  padding: 8px 10px;
  border-bottom: 1px solid var(--cle-line);
}

.cle-pb-order-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--cle-line-soft);
}

/* ------------------------------------ Opciones fijas y grupos de elección */

.cle-pb-check.is-locked,
.cle-pb-card.is-locked{ background:var(--cle-tint, #f6faee); }
.cle-pb-check.is-locked .cle-pb-check-label,
.cle-pb-card.is-locked .cle-pb-qty{ cursor:default; }

.cle-pb-badge--fixed{
  background: var(--cle-light);
  color: var(--cle-primary-700);
}

/* En listados no hay caja donde anclar el distintivo: fluye con la fila. */
.cle-pb-check .cle-pb-badge,
.cle-pb-choice-opt .cle-pb-badge{
  position: static;
  flex-shrink: 0;
}

.cle-pb-locked-note{
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--cle-primary-700, #4f7029);
}

.cle-pb-choice-set{
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--cle-line, #e7eed9);
  border-radius: 10px;
  background: rgba(255,255,255,.6);
}

.cle-pb-choice-legend{
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--cle-ink, #2c3720);
}

.cle-pb-choice-hint{
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  color: var(--cle-muted, #828c70);
}

.cle-pb-choice-list{
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cle-pb-choice-opt{ display: flex; align-items: center; gap: 8px; }
.cle-pb-choice-opt.is-unavailable{ opacity: .55; }
.cle-pb-choice-opt--none .cle-pb-item-name{ font-style: italic; color: var(--cle-muted, #828c70); }

/* Los radios reutilizan la caja de las casillas, pero redonda. */
.cle-pb-choice-opt .cle-pb-check-box{ border-radius: 50%; }

/* ------------------------------------------------- Aviso al añadir al carrito */

.cle-pb-toasts{
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.cle-pb-toast{
  pointer-events: auto;
  background: #fff;
  border: 1px solid var(--cle-line, #e7eed9);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20,30,10,.16);
  overflow: hidden;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .25s ease, transform .25s ease;
}
.cle-pb-toast.is-visible{ opacity: 1; transform: none; }

.cle-pb-toast-head{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--cle-tint, #f6faee);
  border-bottom: 1px solid var(--cle-line, #e7eed9);
}
.cle-pb-toast-tick{
  width: 20px; height: 20px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--cle-primary, #6F9B3B);
  color: #fff; font-size: 12px; font-weight: 700;
}
.cle-pb-toast-title{ flex: 1; font-size: 13.5px; font-weight: 700; color: var(--cle-ink, #2c3720); }
.cle-pb-toast-close{
  border: none; background: none; cursor: pointer; padding: 0 2px;
  font-size: 20px; line-height: 1; color: var(--cle-muted, #828c70);
}
.cle-pb-toast-close:hover{ color: var(--cle-ink, #2c3720); }

.cle-pb-toast-body{ display: flex; gap: 10px; padding: 12px; }
.cle-pb-toast-thumb{
  width: 54px; height: 54px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden; background: #f4f4f4;
}
.cle-pb-toast-thumb img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.cle-pb-toast-info{ min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cle-pb-toast-name{ font-size: 13px; font-weight: 600; color: var(--cle-ink, #2c3720); }
.cle-pb-toast-composition{
  font-size: 11.5px; line-height: 1.45; color: var(--cle-muted, #828c70);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cle-pb-toast-meta{ font-size: 13px; font-weight: 700; color: var(--cle-primary-700, #4f7029); }

.cle-pb-toast-foot{
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px; border-top: 1px solid var(--cle-line, #e7eed9);
}
.cle-pb-toast-cart{ font-size: 11.5px; color: var(--cle-muted, #828c70); }
.cle-pb-toast-actions{ display: inline-flex; gap: 6px; margin-left: auto; }
.cle-pb-toast-btn{
  display: inline-flex; align-items: center; padding: 7px 13px;
  border: 1px solid transparent; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; line-height: 1; cursor: pointer; text-decoration: none;
}
.cle-pb-toast-btn--ghost{ background: transparent; color: var(--cle-text, #46503a); border-color: var(--cle-line, #e7eed9); }
.cle-pb-toast-btn--ghost:hover{ background: var(--cle-tint, #f6faee); }
.cle-pb-toast-btn--primary{ background: var(--cle-primary, #6F9B3B); color: #fff; }
.cle-pb-toast-btn--primary:hover{ background: var(--cle-primary-700, #4f7029); color: #fff; }

@media (max-width: 480px){
  .cle-pb-toasts{ top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce){
  .cle-pb-toast{ transition: none; }
}

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 900px) {
  .cle-pb-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .cle-pb-cards {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .cle-pb-summary {
    padding: 14px;
  }

  .cle-pb-check {
    flex-wrap: wrap;
  }
}

/* Resumen sin desglose: solo queda el total, así que se le da aire. */
.cle-pb-totals--compact .cle-pb-total-row--grand {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
  font-size: 17px;
}

/* Sección del componente en el desglose por líneas del back-office */
.cle-pb-order-section {
  font-size: 11px;
  color: var(--cle-muted);
}

/* Desglose por líneas del back-office: miniatura y filas legibles */
.cle-pb-order-table--flat td {
  vertical-align: middle;
}

.cle-pb-order-thumb {
  width: 52px;
}

.cle-pb-order-thumb img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
