/*
 * Kaally Bundle & Save — Module B cross-sell block (v1.3.0)
 * Full stylesheet (progressive enhancement over the inline fallback in
 * kbs_b_get_critical_css() inside includes/module-b-crosssell.php).
 *
 * Brand tokens: mauve #6B5A5B, cream #F7F1E8, brown #5D4A3A.
 * Font stack: Lato body, Libre Baskerville headings.
 *
 * IMPORTANT: If you update styles here, keep kbs_b_get_critical_css() in sync.
 * The inline block is the LiteSpeed UCSS safety guarantee for logged-out visitors.
 *
 * Layout change in v1.3.0:
 *   - Replaced checkbox layout with "+ Add" button row layout.
 *   - Each add-on row: thumb | info (name + was/now price) | "+ Add" button.
 *   - Locked variable add-ons show a static "locked label" under the name.
 *   - Variation picker still appears below the row for non-locked variable add-ons.
 */

/* ── Wrapper ── */
.kbs-b-crosssell {
  margin: 1.4rem 0 .5rem;
  font-family: Lato, sans-serif;
}

/* ── Heading ── */
.kbs-b-heading {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: .95rem;
  color: #5D4A3A;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0 0 .75rem;
}

/* ── Add-on list ── */
.kbs-b-addon-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

/* ── Individual add-on card ── */
.kbs-b-addon-item {
  border: 1.5px solid #e8ddd4;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease;
}

.kbs-b-addon-item:hover {
  border-color: #c8b8b0;
  background: #faf7f4;
}

/* ── Main row (thumb + info + button) ── */
.kbs-b-addon-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .85rem;
}

/* ── Thumbnail ── */
.kbs-b-addon-thumb {
  flex-shrink: 0;
}

.kbs-b-addon-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

/* WooCommerce sometimes wraps the image in an <a>; make it invisible */
.kbs-b-addon-thumb a {
  display: contents;
}

/* ── Info: name + price ── */
.kbs-b-addon-info {
  flex: 1;
  min-width: 0; /* allow text-overflow: ellipsis to work */
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.kbs-b-addon-name {
  font-size: .88rem;
  color: #3d2d2e;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Static label for locked-variation add-ons (e.g. "6mm") */
.kbs-b-addon-lock-label {
  font-size: .75rem;
  color: #7a6060;
  font-style: italic;
  line-height: 1.3;
}

/* Price: was/now inline */
.kbs-b-addon-price {
  font-size: .82rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem;
}

/* Struck-through full price */
.kbs-b-was {
  color: #a89c9c;
  text-decoration: line-through;
  font-weight: 400;
  font-style: normal;
}

/* Discounted price */
.kbs-b-now {
  color: #6B5A5B;
  font-weight: 700;
  font-style: normal;
}

/* "with your cup" qualifier */
.kbs-b-with-cup {
  font-size: .72rem;
  color: #a89c9c;
  font-weight: 400;
}

/* ── "+ Add" button ── */
.kbs-b-addon-action {
  flex-shrink: 0;
}

.kbs-b-add-btn {
  background: #6B5A5B;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: Lato, sans-serif;
  font-size: .8rem;
  font-weight: 700;
  padding: .4rem .8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, opacity .15s ease;
  letter-spacing: .02em;
  line-height: 1.4;
}

.kbs-b-add-btn:hover {
  background: #5D4A3A;
}

/* Disabled while request is in-flight */
.kbs-b-add-btn:disabled,
.kbs-b-add-btn.kbs-b-added {
  background: #a89c9c;
  cursor: default;
}

/* Tick prefix injected by CSS on "added" state (also set in JS textContent) */
.kbs-b-add-btn.kbs-b-added::before {
  content: "✓ ";
}

/* Focus ring for keyboard nav */
.kbs-b-add-btn:focus-visible {
  outline: 2px solid #6B5A5B;
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════
   Variation picker — swatches and pills
   (Keep in sync with kbs_b_get_critical_css() in module-b-crosssell.php)
   ══════════════════════════════════════════════════════════════ */

/* Picker wrapper — sits below the row, inside the card */
.kbs-b-variation-picker {
  padding: .35rem .85rem .6rem;
  border-top: 1px dashed #f0e8e0;
}

/* One group per attribute (e.g. "Topper:" followed by its pills) */
.kbs-b-picker-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .3rem;
}

.kbs-b-picker-group:last-child {
  margin-bottom: 0;
}

/* Attribute label ("Colour:", "Size:", …) */
.kbs-b-picker-label {
  font-size: .77rem;
  color: #7a6060;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Colour swatches ── */

.kbs-b-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.kbs-b-swatch {
  display: inline-flex;
  cursor: pointer;
}

.kbs-b-swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.kbs-b-swatch-chip {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #e0d4cc;
  box-sizing: border-box;
  transition: border-color .12s ease, box-shadow .12s ease;
  font-size: .55rem;
  text-align: center;
  line-height: 20px;
  color: #5D4A3A;
  overflow: hidden;
}

.kbs-b-swatch--selected .kbs-b-swatch-chip,
.kbs-b-swatch:has(input:checked) .kbs-b-swatch-chip {
  border-color: #6B5A5B;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #6B5A5B;
}

.kbs-b-swatch:focus-within .kbs-b-swatch-chip {
  outline: 2px solid #6B5A5B;
  outline-offset: 2px;
}

/* ── Pill buttons ── */

.kbs-b-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}

.kbs-b-pill {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-size: .75rem;
  padding: .2rem .55rem;
  border: 1.5px solid #d4c8c0;
  border-radius: 20px;
  color: #5D4A3A;
  background: #fff;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
  line-height: 1.4;
  white-space: nowrap;
}

.kbs-b-pill input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.kbs-b-pill--selected,
.kbs-b-pill:has(input:checked) {
  border-color: #6B5A5B;
  background: #6B5A5B;
  color: #fff;
}

.kbs-b-pill:focus-within {
  outline: 2px solid #6B5A5B;
  outline-offset: 2px;
}

/* ── Hover states (pointer devices only) ── */
@media (hover: hover) {
  .kbs-b-swatch:hover .kbs-b-swatch-chip {
    border-color: #6B5A5B;
  }

  .kbs-b-pill:hover:not(.kbs-b-pill--selected):not(:has(input:checked)) {
    border-color: #6B5A5B;
    background: #f8f2f0;
  }
}

/* ── Mobile: narrow-width adjustments ── */
@media (max-width: 380px) {
  .kbs-b-addon-row {
    padding: .5rem .7rem;
    gap: .6rem;
  }

  .kbs-b-addon-img {
    width: 44px;
    height: 44px;
  }

  .kbs-b-addon-name {
    font-size: .82rem;
  }

  .kbs-b-addon-price {
    font-size: .78rem;
  }

  .kbs-b-add-btn {
    font-size: .75rem;
    padding: .35rem .6rem;
  }

  .kbs-b-variation-picker {
    padding: .3rem .7rem .5rem;
  }

  .kbs-b-picker-group {
    gap: .35rem;
  }

  .kbs-b-swatch-chip {
    width: 20px;
    height: 20px;
    line-height: 18px;
  }

  .kbs-b-pill {
    font-size: .72rem;
    padding: .18rem .45rem;
  }
}

/* ── Very narrow (320–340 px): hide thumbnail ── */
@media (max-width: 340px) {
  .kbs-b-addon-img {
    display: none;
  }
}

/* ── Cart: was/now per line (used by kbs_b_cart_item_price_html etc.) ── */
.kbs-b-was {
  color: #a89c9c;
  text-decoration: line-through;
  font-weight: 400;
  margin-right: .25rem;
  font-style: normal;
}

.kbs-b-now {
  font-weight: 700;
  color: #3d2d2e;
  font-style: normal;
}
