/**
 * FBT Styles - Frequently Bought Together
 * YayBoost plugin. Minimal e-commerce styling.
 *
 * Layout: a "current product" card, a titled add-on section of selectable
 * cards, then the bundle total and a full-width button. Every rule is scoped
 * under .yayboost-fbt for theme safety, and nothing sets a fixed or minimum
 * width — the same markup is reused inside the post-add-to-cart popup dialog
 * (see assets/css/fbt-popup.css).
 */

/* ============================================
   Variables
   ============================================ */
:root {
  --fbt-black: #111111;
  --fbt-gray-900: #1a1a1a;
  --fbt-gray-600: #666666;
  --fbt-gray-400: #999999;
  --fbt-gray-200: #e5e5e5;
  --fbt-gray-100: #f5f5f5;
  --fbt-white: #ffffff;
  --fbt-green: #16a34a;
  --fbt-radius: 8px;
  --fbt-card-radius: 12px;
  --fbt-card-border: var(--fbt-gray-200);
  --fbt-card-border-on: var(--fbt-black);
  --fbt-thumb: 56px;
  --fbt-gap: 12px;
}

/* ============================================
   Section Container (scoped for theme safety)
   ============================================ */
.yayboost-fbt.fbt-section {
  padding: 32px 0;
  border-top: 1px solid var(--fbt-gray-200);
}

.yayboost-fbt .fbt-section__title,
.yayboost-fbt .yayboost-fbt__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fbt-black);
  margin: 0 0 20px 0;
  letter-spacing: -0.01em;
}

/* ============================================
   Current product
   ============================================ */
.yayboost-fbt .fbt-current__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fbt-gray-600);
  margin: 0 0 8px 0;
}

/* ============================================
   Cards
   ============================================ */
.yayboost-fbt .fbt-card {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 12px;
  background: var(--fbt-white);
  border: 1.5px solid var(--fbt-card-border-on);
  border-radius: var(--fbt-card-radius);
  transition: border-color 0.15s ease;
}

/* Selection state. fbt.js toggles .is-unchecked on .yayboost-fbt__product,
   which is this same element — so the border and the badge follow the
   checkbox without any extra JS. Cards start checked, hence the dark
   border above being the default. */
.yayboost-fbt .fbt-card.is-unchecked {
  border-color: var(--fbt-card-border);
}

/* Unselected cards show no badge (the dark border is the only selected
   affordance), but keep it rendered so the focus ring still has a target. */
.yayboost-fbt .fbt-card.is-unchecked .fbt-card__badge {
  opacity: 0;
}

.yayboost-fbt .fbt-card.is-unchecked .fbt-card__input:focus-visible + .fbt-card__badge {
  opacity: 1;
}

.yayboost-fbt .fbt-card--current {
  background: var(--fbt-gray-100);
  border-color: var(--fbt-card-border);
  cursor: default;
}

.yayboost-fbt .fbt-card__main {
  display: flex;
  align-items: center;
  gap: var(--fbt-gap);
  width: 100%;
  margin: 0;
  cursor: pointer;
}

.yayboost-fbt .fbt-card--current .fbt-card__main,
.yayboost-fbt .fbt-card--manual .fbt-card__main {
  cursor: default;
}

.yayboost-fbt .fbt-card__input {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.yayboost-fbt .fbt-card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

.yayboost-fbt .fbt-card__thumb {
  display: block;
  flex: 0 0 var(--fbt-thumb);
  width: var(--fbt-thumb);
  height: var(--fbt-thumb);
  background: var(--fbt-gray-100);
  border-radius: var(--fbt-radius);
  overflow: hidden;
}

.yayboost-fbt .fbt-card__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.yayboost-fbt .fbt-card__body {
  display: block;
  flex: 1;
  min-width: 0;
}

.yayboost-fbt .fbt-card__name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--fbt-black);
}

.yayboost-fbt .fbt-card__name a {
  color: inherit;
  text-decoration: none;
}

.yayboost-fbt .fbt-card__name a:hover {
  text-decoration: underline;
}

.yayboost-fbt .fbt-card__note {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--fbt-gray-600);
}

.yayboost-fbt .fbt-card__price {
  margin-left: auto;
  font-size: 14px;
  font-weight: 500;
  color: var(--fbt-black);
  white-space: nowrap;
}

/* Keeps the price clear of the absolutely positioned selection badge. */
.yayboost-fbt .fbt-card--addon .fbt-card__price {
  padding-right: 24px;
}

.yayboost-fbt .fbt-card__price del {
  color: var(--fbt-gray-400);
  font-weight: 400;
  margin-right: 0.25em;
}

.yayboost-fbt .fbt-card__price ins {
  text-decoration: none;
}

/* ============================================
   Selection badge - minimal circle
   ============================================ */
.yayboost-fbt .fbt-checkbox__box {
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--fbt-gray-400);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fbt-white);
  transition: all 0.15s ease;
}

.yayboost-fbt .fbt-card__input:checked + .fbt-checkbox__box {
  background: var(--fbt-black);
  border-color: var(--fbt-black);
}

.yayboost-fbt .fbt-checkbox__icon {
  width: 10px;
  height: 10px;
  color: var(--fbt-white);
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.15s ease;
}

.yayboost-fbt .fbt-card__input:checked + .fbt-checkbox__box .fbt-checkbox__icon {
  opacity: 1;
  transform: scale(1);
}

/* Keyboard focus: the input itself is visually hidden, so show the ring on
   the badge that stands in for it. */
.yayboost-fbt .fbt-card__input:focus-visible + .fbt-checkbox__box {
  outline: 2px solid var(--fbt-black);
  outline-offset: 2px;
}

/* ============================================
   Add-on section
   ============================================ */
.yayboost-fbt .fbt-addons {
  margin-top: 24px;
}

.yayboost-fbt .fbt-addons__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fbt-black);
  margin: 0;
}

.yayboost-fbt .fbt-addons__desc {
  font-size: 13px;
  color: var(--fbt-gray-600);
  margin: 4px 0 12px 0;
}

.yayboost-fbt .fbt-list,
.yayboost-fbt .fbt-addons__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================
   Variable products
   ============================================ */

/* No swatches plugin active: not offered as a selectable card (there is no
   picker to choose a variation with), shown as a plain card with a link out
   to the product page instead — see fbt-products.php's
   $needs_manual_selection branch. Such a card has no checkbox, so it is
   excluded from the bundle total. */
.yayboost-fbt .fbt-card--manual {
  border-color: var(--fbt-card-border);
  border-style: dashed;
  cursor: default;
}

.yayboost-fbt .fbt-card__select-options {
  display: inline-block;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fbt-black);
  text-decoration: underline;
}

/* Swatches plugin active: the inline picker (a full WooCommerce
   .variations_form, see YaySwatchesProvider) renders below the card's main
   row — its internal styling comes from YaySwatches itself, this just keeps
   it from crowding the compact card. */
.yayboost-fbt .fbt-card__variations {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--fbt-gray-200);
}

.yayboost-fbt .fbt-card__variations .yay-swatches-archive-wrapper {
  margin-top: 0;
}

.yayboost-fbt .fbt-card__variations table.variations {
  margin: 0;
}

/* ============================================
   Bundle total
   ============================================ */
.yayboost-fbt .fbt-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px 0;
  padding-top: 16px;
  border-top: 1px solid var(--fbt-gray-200);
}

.yayboost-fbt .fbt-summary__total {
  font-size: 14px;
  font-weight: 600;
  color: var(--fbt-black);
  margin: 0;
}

.yayboost-fbt .fbt-summary__price,
.yayboost-fbt .yayboost-fbt__total-price {
  font-size: 22px;
  font-weight: 600;
  color: var(--fbt-black);
  margin: 0;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* ============================================
   Add Button
   ============================================ */
.yayboost-fbt .fbt-add-btn,
.yayboost-fbt .yayboost-fbt__add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fbt-white);
  background: var(--fbt-black);
  border: none;
  border-radius: var(--fbt-radius);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.yayboost-fbt .fbt-add-btn--block {
  width: 100%;
}

.yayboost-fbt .fbt-add-btn:hover,
.yayboost-fbt .yayboost-fbt__add-btn:hover {
  opacity: 0.85;
}

.yayboost-fbt .fbt-add-btn:active,
.yayboost-fbt .yayboost-fbt__add-btn:active {
  opacity: 0.7;
}

.yayboost-fbt .fbt-add-btn:disabled,
.yayboost-fbt .yayboost-fbt__add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .yayboost-fbt.fbt-section {
    --fbt-thumb: 48px;
  }

  .yayboost-fbt .fbt-card {
    padding: 10px;
  }

  .yayboost-fbt .fbt-card__main {
    flex-wrap: wrap;
  }

  /* Price drops to its own line under the name rather than squeezing it. */
  .yayboost-fbt .fbt-card__price,
  .yayboost-fbt .fbt-card--addon .fbt-card__price {
    width: 100%;
    margin-left: calc(var(--fbt-thumb) + var(--fbt-gap));
    padding-right: 0;
  }

  .yayboost-fbt .fbt-summary__price,
  .yayboost-fbt .yayboost-fbt__total-price {
    font-size: 20px;
  }
}

/* ============================================
   Loading & Success States (JS compat)
   ============================================ */
.yayboost-fbt .fbt-add-btn--loading,
.yayboost-fbt .yayboost-fbt__add-btn.is-loading {
  color: transparent;
  position: relative;
  pointer-events: none;
}

.yayboost-fbt .fbt-add-btn--loading::after,
.yayboost-fbt .yayboost-fbt__add-btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--fbt-white);
  border-top-color: transparent;
  border-radius: 50%;
  animation: fbt-spin 0.6s linear infinite;
}

@keyframes fbt-spin {
  to {
    transform: rotate(360deg);
  }
}

.yayboost-fbt .fbt-add-btn--success,
.yayboost-fbt .yayboost-fbt__add-btn.fbt-add-btn--success {
  background: var(--fbt-green);
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .yayboost-fbt * {
    transition: none !important;
    animation: none !important;
  }
}
