/*
  Componentes — botones, chips, tarjetas de producto, tabla de catálogo,
  controles de la calculadora, FAQ y tarjetas de resultado.
  Reconstruidos a partir de los componentes React del design system original
  (Button, ChoiceChip, RangeField, EstimateCard, CatalogTable, FaqItem).
*/

/* — Botón (equivalente a components/core/Button.jsx) — */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--control-height);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: var(--transition-control);
}

.btn:hover {
  transform: var(--lift-hover);
}

.btn--sm {
  min-height: var(--control-height-sm);
  padding: 0 16px;
  font-size: var(--text-caption);
}

.btn--wide {
  display: flex;
  width: 100%;
}

.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none !important;
}

.btn--primary {
  color: var(--white);
  background: var(--brand-primary);
  box-shadow: var(--shadow-accent);
}

.btn--dark {
  color: var(--white);
  background: var(--brand-deep);
}

.btn--dark:hover {
  box-shadow: var(--shadow-soft);
}

.btn--light {
  color: var(--brand-deep);
  background: var(--white);
}

.btn--light:hover {
  box-shadow: var(--shadow-soft);
}

.btn--outline-light {
  color: var(--brand-deep);
  border-color: rgba(48, 46, 93, 0.24);
  background: transparent;
}

.btn--outline-light:hover {
  box-shadow: var(--shadow-soft);
}

.btn--whatsapp {
  color: var(--white);
  background: var(--whatsapp);
  box-shadow: var(--shadow-whatsapp);
}

/* Variante especial usada por el CTA principal de WhatsApp de la calculadora
   (waButtonProps en el original): mismo verde, pero con borde de marca. */
.btn--whatsapp-outline {
  color: var(--white);
  background: var(--whatsapp);
  border: 2px solid var(--brand-primary);
  font-weight: var(--weight-black);
  box-shadow: var(--shadow-whatsapp);
}

/* — Chip de selección (equivalente a ChoiceChip.jsx) — */
.chip {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--brand-ink);
  background: var(--surface-raised);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  transition: var(--transition-control);
}

.chip:hover {
  transform: var(--lift-hover-sm);
  border-color: var(--brand-primary);
}

.chip[aria-pressed="true"] {
  border-color: var(--brand-primary);
  color: var(--white);
  background: var(--brand-primary);
  box-shadow: var(--shadow-chip);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* — Grupos de campo del formulario de la calculadora — */
.field-group {
  min-width: 0;
  margin: 0 0 28px;
  padding: 0;
  border: 0;
}

.field-group legend,
.field-label {
  margin-bottom: 12px;
  padding: 0;
  color: var(--brand-deep);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
}

.field-row {
  margin: 0 0 26px;
}

.field-row--tight {
  margin-bottom: 28px;
}

.field-row__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: 2px;
}

.field-row__header label {
  color: var(--brand-deep);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
}

.field-row__value {
  color: var(--brand-primary);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
}

/* — Control deslizante (equivalente a RangeField.jsx) —
   El relleno se controla con la variable --fill, actualizada por js/app.js. */
.range-field {
  width: 100%;
  height: 6px;
  margin: 4px 0 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: var(--radius-pill);
  background: linear-gradient(to right, var(--brand-primary) 0 var(--fill, 0%), #dfe3f0 var(--fill, 0%) 100%);
  cursor: pointer;
}

.range-field::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 3px solid var(--white);
  box-shadow: var(--shadow-chip);
  cursor: pointer;
}

.range-field::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--brand-primary);
  box-shadow: var(--shadow-chip);
  cursor: pointer;
}

.field-hint {
  margin: 0;
  color: var(--muted-soft);
  font-size: var(--text-caption);
  line-height: 1.45;
}

/* — Tarjeta de producto 3D (equivalente a product-card-3d.js) —
   El giro se resuelve con :hover / :focus-within en CSS puro,
   sin JavaScript. */
.product-card {
  position: relative;
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  z-index: 1;
}

.product-card__figure {
  position: relative;
  height: clamp(410px, 42vw, 560px);
  margin: 0;
  overflow: hidden;
  perspective: 760px;
  perspective-origin: 50% 50%;
  background: transparent;
}

.product-card__flipper {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 760ms cubic-bezier(0.34, 0.52, 0.24, 1);
}

.product-card:hover .product-card__flipper,
.product-card:focus-within .product-card__flipper,
.product-card.is-flipped .product-card__flipper {
  /* .is-flipped la activa js/app.js al tocar la tarjeta en pantallas sin hover */
  transform: rotateY(180deg);
}

.product-card__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* compensa la magnificación de perspectiva que introduce translateZ(26px) con perspective:760px */
  transform: translateZ(26px) scale(0.9658);
}

.product-card__face--center {
  place-items: center center;
}

.product-card__face--back {
  transform: rotateY(180deg) translateZ(26px) scale(0.9658);
}

.product-card__face img {
  display: block;
  width: var(--w, 100%);
  height: calc(100% - 22px);
  max-height: 100%;
  margin-bottom: var(--offset-y, 0px);
  object-fit: contain;
  object-position: center bottom;
}

.product-card__face--center img {
  object-position: center center;
}

.product-card__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 25px 20px 0 17px;
  border-top: 1px solid var(--brand-primary);
  background: var(--surface);
}

.product-card__label {
  margin: 0 0 11px;
  color: var(--brand-primary);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-black);
  letter-spacing: 0.15em;
  line-height: 1.4;
  text-transform: uppercase;
}

.product-card__title {
  max-width: 17ch;
  margin: 0 0 13px;
  color: var(--brand-deep);
  font-size: var(--text-h3);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-h3);
  line-height: 1.04;
}

.product-card__description {
  max-width: 34ch;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: var(--text-body-sm);
  line-height: 1.55;
}

.product-card__ideal-for {
  max-width: 36ch;
  margin: 0 0 17px;
  color: var(--brand-deep);
  font-size: var(--text-caption);
  line-height: var(--leading-body);
}

.product-card__price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  max-width: 36ch;
  margin: auto 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--tint-accent-18);
}

.product-card__price-label {
  color: var(--muted-soft);
  font-size: var(--text-micro);
}

.product-card__price-value {
  color: var(--brand-primary);
  font-family: var(--font-mono);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* — Tabla de catálogo (equivalente a CatalogTable.jsx) — */
.catalog-table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.catalog-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  text-align: left;
}

.catalog-table th,
.catalog-table td {
  padding: 17px 14px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-small);
  line-height: 1.4;
}

.catalog-table th:first-child,
.catalog-table td:first-child {
  padding-left: 0;
}

.catalog-table th:last-child,
.catalog-table td:last-child {
  padding-right: 0;
  text-align: right;
}

.catalog-table thead th {
  color: var(--muted-soft);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-black);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.catalog-table tbody th {
  color: var(--brand-deep);
  font-weight: var(--weight-black);
  text-align: left;
}

.catalog-table tbody td {
  color: var(--muted);
}

.catalog-table tbody td:last-child {
  color: var(--brand-primary);
  font-family: var(--font-mono);
  font-weight: var(--weight-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* — Tarjeta de estimado (equivalente a EstimateCard.jsx) — */
.estimate-card {
  padding: 31px;
  border-radius: var(--radius);
  color: var(--white);
  background: var(--brand-primary);
  box-shadow: var(--shadow);
}

.estimate-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: 18px;
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-micro);
  font-weight: var(--weight-strong);
  letter-spacing: 0.18em;
  line-height: 1.4;
  text-transform: uppercase;
}

.estimate-card__mark {
  color: rgba(255, 255, 255, 0.62);
  font-size: var(--text-eyebrow);
  letter-spacing: 0.14em;
}

.estimate-card__figure {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: 15px;
}

.estimate-card__kg {
  font-family: var(--font-mono);
  font-size: clamp(66px, 8vw, 88px);
  font-weight: var(--weight-regular);
  letter-spacing: -0.09em;
  line-height: 0.86;
}

.estimate-card__unit {
  padding-bottom: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-lead);
  font-weight: var(--weight-bold);
}

.estimate-card__summary {
  max-width: 44ch;
  margin: 0 0 25px;
  color: rgba(255, 255, 255, 0.88);
  font-size: var(--text-body-sm);
  line-height: 1.5;
}

.estimate-card__breakdown {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.estimate-card__breakdown li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-block: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.76);
  font-size: var(--text-caption);
  line-height: 1.3;
}

.estimate-card__breakdown output {
  color: var(--white);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* — Tarjeta "paquete más económico" — */
.package-card {
  position: relative;
  margin-top: 14px;
  padding: 28px 24px 24px;
  border: 2px solid var(--brand-primary);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: 0 12px 24px rgba(102, 103, 171, 0.16);
}

.package-card__ribbon {
  position: absolute;
  top: -16px;
  left: 24px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--brand-primary);
  color: var(--white);
  font-size: var(--text-micro);
  font-weight: var(--weight-black);
  letter-spacing: 0.04em;
}

.package-card__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: 18px;
}

.package-card__tabs .chip {
  min-height: 40px;
  padding: 0 12px;
}

.package-card__lines {
  display: grid;
  gap: 2px;
}

/* Cada línea muestra el precio unitario y su subtotal, para que las cuentas
   de la tarjeta se puedan seguir a simple vista. */
.package-card__line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label    controls"
    "unit     subtotal";
  gap: 4px var(--space-3);
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--brand-soft);
}

.package-card__line--empty {
  opacity: 0.5;
}

.package-card__line-label {
  grid-area: label;
  color: var(--brand-deep);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
}

.package-card__line-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 10px;
}

.package-card__line-unit {
  grid-area: unit;
  color: var(--muted-soft);
  font-size: var(--text-caption);
}

.package-card__line-subtotal {
  grid-area: subtotal;
  color: var(--brand-ink);
  font-family: var(--font-mono);
  font-size: var(--text-body-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.package-card__line-qty {
  min-width: 16px;
  text-align: center;
  color: var(--brand-deep);
  font-family: var(--font-mono);
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
}

.stepper-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--white);
  color: var(--brand-deep);
  font-size: var(--text-lead);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: var(--transition-control);
}

.stepper-btn:hover:not(:disabled) {
  border-color: var(--brand-primary);
  transform: var(--lift-hover-sm);
}

.stepper-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.package-card__coverage {
  margin: 14px 0 0;
  color: #9496a8;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  line-height: 1.5;
}

/* Cuando el paquete editado no alcanza la cantidad recomendada */
.package-card__coverage--warn {
  color: var(--error);
  font-weight: var(--weight-medium);
}

.package-card__notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--control-radius);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: var(--text-caption);
  line-height: 1.45;
}

.package-card__reset {
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-primary);
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  cursor: pointer;
  text-decoration: underline;
}

.package-card__unit {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  line-height: 1.5;
}

/* Estado inicial, mientras la calculadora está en cero */
.package-card__empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-small);
  line-height: 1.5;
}

.package-card__total {
  margin: 18px 0 0;
  color: var(--brand-primary);
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: var(--weight-black);
  letter-spacing: -0.02em;
}

.package-card__savings {
  margin: 8px 0 0;
  color: #187548;
  font-size: var(--text-body-sm);
  font-weight: var(--weight-bold);
}

.package-card__delivery-note {
  margin: 8px 0 22px;
  color: #9496a8;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  line-height: 1.5;
}

.package-card__copy-link {
  display: block;
  margin: 14px auto 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted-soft);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-decoration: underline;
}

/* — Tarjeta contenedora del formulario de la calculadora — */
.calculator__form {
  padding: clamp(26px, 4vw, 46px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

.calculator__form-note {
  margin: 0;
  color: var(--muted-soft);
  font-size: var(--text-caption);
  line-height: 1.45;
}

/* — Preguntas frecuentes (equivalente a FaqItem.jsx, con <details> nativo) — */
.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 17px 0;
  color: var(--brand-deep);
  cursor: pointer;
  font-size: var(--text-lead);
  font-weight: var(--weight-strong);
  line-height: 1.3;
  list-style: none;
}

.faq-item__question {
  max-width: 40ch;
}

.faq-item__icon {
  flex: none;
  color: var(--brand-primary);
  font-size: 22px;
  font-weight: var(--weight-regular);
  transition: transform var(--duration-fast) var(--ease);
}

.faq-item[open] .faq-item__icon {
  transform: rotate(45deg);
}

.faq-item p {
  max-width: 60ch;
  margin: -2px 0 24px;
  color: var(--muted);
  font-size: var(--text-body-sm);
  line-height: 1.6;
}

/* ==========================================================================
   Responsive de componentes
   Acompaña a los cortes de layout.css (860px y 560px).
   ========================================================================== */

@media (max-width: 860px) {
  /* En una sola columna la figura de 410px de alto es desproporcionada */
  .product-card__figure {
    height: clamp(300px, 62vw, 430px);
  }

  .estimate-card {
    padding: 26px 22px;
  }
}

@media (max-width: 560px) {
  .calculator__form {
    padding: 22px 18px;
  }

  .field-group,
  .field-row--tight {
    margin-bottom: 24px;
  }

  .estimate-card {
    padding: 24px 20px;
  }

  .estimate-card__kg {
    font-size: clamp(54px, 15vw, 70px);
  }

  .package-card {
    padding: 26px 18px 20px;
  }

  .package-card__ribbon {
    left: 18px;
    font-size: var(--text-eyebrow);
  }

  /* En pantalla angosta la etiqueta ocupa su propia fila completa y debajo
     quedan el precio unitario, el +/- y el subtotal. */
  .package-card__line {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label    label"
      "controls subtotal"
      "unit     unit";
    gap: 6px var(--space-3);
  }

  .package-card__line-unit {
    order: 3;
  }

  .package-card__total {
    font-size: 32px;
  }

  /* La tabla de catálogo se reorganiza en fichas: en un teléfono la columna
     del precio quedaba fuera de pantalla. Cada fila pasa a una grilla de dos
     líneas —"Formato · Peso" con el valor a la derecha, y la presentación
     debajo— sin desplazamiento horizontal. */
  .catalog-table-wrap {
    overflow-x: visible;
    border-top: 0;
  }

  .catalog-table,
  .catalog-table tbody,
  .catalog-table tr,
  .catalog-table th,
  .catalog-table td {
    display: block;
  }

  .catalog-table {
    min-width: 0;
  }

  .catalog-table thead {
    display: none;
  }

  .catalog-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "formato valor"
      "detalle peso";
    gap: 3px var(--space-4);
    align-items: baseline;
    padding: 13px 0;
    border-top: 1px solid var(--border);
  }

  .catalog-table tbody tr:last-child {
    border-bottom: 1px solid var(--border);
  }

  .catalog-table tbody th,
  .catalog-table tbody td {
    padding: 0;
    border: 0;
  }

  .catalog-table tbody th {
    grid-area: formato;
    font-size: var(--text-body-sm);
  }

  .catalog-table tbody td:nth-of-type(1) {
    grid-area: detalle;
    color: var(--muted-soft);
    font-size: var(--text-caption);
  }

  .catalog-table tbody td:nth-of-type(2) {
    grid-area: peso;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    text-align: right;
    white-space: nowrap;
  }

  .catalog-table tbody td:nth-of-type(3) {
    grid-area: valor;
    text-align: right;
    font-size: var(--text-lead);
  }

  .faq-item summary {
    gap: var(--space-3);
    min-height: 60px;
    font-size: var(--text-body);
  }

  .btn {
    white-space: normal;
  }
}
