/**
 * Frontend promotion display styles.
 *
 * Covers: tier pricing table (product page), free sample notice (product page),
 * shop badge (category/loop), cart motivator (cart page).
 */

/* ══════════════════════════════════════════════════════════════
   A. Tiered Pricing Table (Product Page) — Collapsible
   ══════════════════════════════════════════════════════════════ */

.beagro-promotion-tiers {
  background-color: #f7f9f0;
  border: 1px solid #e5e9dc;
  border-radius: 8px;
  padding: 0;
  margin: 10px 0 6px;
}

/* Summary bar (collapsed header) */
.beagro-promotion-tiers__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 14px;
  font-family: "Poppins", Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  list-style: none;
  user-select: none;
}

.beagro-promotion-tiers__summary::-webkit-details-marker {
  display: none;
}

.beagro-promotion-tiers__summary-icon {
  font-size: 10px;
  color: #999;
  transition: transform 0.2s ease;
}

details[open].beagro-promotion-tiers .beagro-promotion-tiers__summary-icon {
  transform: rotate(180deg);
}

details[open].beagro-promotion-tiers .beagro-promotion-tiers__summary {
  border-bottom: 1px solid #e5e9dc;
}

/* Table */
.beagro-promotion-tiers__table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Poppins", Helvetica, Arial, sans-serif;
  font-size: 13px;
}

.beagro-promotion-tiers__table thead th {
  text-align: left;
  font-weight: 600;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 14px;
  border-bottom: 1px solid #e5e9dc;
}

.beagro-promotion-tiers__table tbody td {
  padding: 6px 14px;
  color: #333;
  border-bottom: 1px solid #eef1e8;
}

.beagro-promotion-tiers__table tbody tr:last-child td {
  border-bottom: none;
}

/* Active tier row — highlighted */
.beagro-promotion-tiers__row--active {
  background-color: #f0f5e3;
  border-left: 3px solid #95c11f;
}

.beagro-promotion-tiers__row--active td:first-child {
  padding-left: 11px;
}

/* Savings cell */
.beagro-promotion-tiers__savings {
  color: #95c11f;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   B0. Dynamic Price Calculator (Product Page)
   ══════════════════════════════════════════════════════════════ */

#beagro-dynamic-price:empty {
  display: none;
}

#beagro-dynamic-price {
  width: 100%;
  margin: 4px 0 2px;
  font-family: "Poppins", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}

.beagro-dynamic-price__row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.beagro-dynamic-price__total-value {
  font-weight: 700;
  font-size: 15px;
  color: #333;
}

.beagro-dynamic-price__savings-badge {
  display: inline-block;
  background-color: #f0f5e3;
  color: #6a8a10;
  font-weight: 600;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.beagro-dynamic-price__free-sample-line {
  color: #c48600;
  font-weight: 600;
  font-size: 12px;
  margin-top: 2px;
}

/* WPC total: tier-adjusted del/ins price override */
.wooco-total del,
.woosb-total del {
  color: #999;
  text-decoration: line-through;
  font-weight: 400;
  margin-right: 4px;
}

.wooco-total ins,
.woosb-total ins {
  color: #6a8a10;
  font-weight: 700;
  text-decoration: none;
}

/* ══════════════════════════════════════════════════════════════
   B. Free Sample Notice (Product Page) — Pill badge
   ══════════════════════════════════════════════════════════════ */

/* Flex layout for price module inner when promotion elements present */
.et_pb_wc_price .et_pb_module_inner:has(.beagro-promotion-free-sample) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.et_pb_wc_price .et_pb_module_inner > p.price {
  margin-bottom: 0;
}

.beagro-promotion-free-sample {
  display: inline-block;
  background-color: #f7f9f0;
  border: 1px dashed #95c11f;
  border-radius: 6px;
  padding: 8px 16px;
  margin: 0;
  margin-left: auto;
  font-family: "Poppins", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #333;
}

.beagro-promotion-free-sample strong {
  color: #95c11f;
}

/* ══════════════════════════════════════════════════════════════
   C. Shop Badge (Category/Loop)
   ══════════════════════════════════════════════════════════════ */

.beagro-shop-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  background-color: #95c11f;
  color: white;
  font-family: "Poppins", Helvetica, Arial, sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 3px;
  line-height: 1.3;
  letter-spacing: 0.3px;
  pointer-events: none;
}

/* Ensure product card thumbnail wrapper has relative positioning */
.woocommerce ul.products li.product .woocommerce-LoopProduct-link {
  position: relative;
}

/* ══════════════════════════════════════════════════════════════
   D. Cart Motivator
   ══════════════════════════════════════════════════════════════ */

#beagro-cart-motivator {
  margin-bottom: 20px;
}

#beagro-cart-motivator:empty {
  display: none;
}

.beagro-motivator-card {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 8px;
  font-family: "Poppins", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.beagro-motivator-card:last-child {
  margin-bottom: 0;
}

/* Tier pricing card: green accent */
.beagro-motivator-tier {
  background-color: #f7f9f0;
  border: 1px solid #e5e9dc;
  border-left: 3px solid #95c11f;
  color: #2d3b0f;
}

/* Free sample card: golden accent */
.beagro-motivator-free_sample {
  background-color: #fffbf0;
  border: 1px solid #f0e6c8;
  border-left: 3px solid #f0a500;
  color: #5a4200;
}

.beagro-motivator-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-right: 12px;
  font-size: 14px;
}

.beagro-motivator-tier .beagro-motivator-icon {
  background-color: rgba(149, 193, 31, 0.15);
  color: #6a8a10;
}

.beagro-motivator-free_sample .beagro-motivator-icon {
  background-color: rgba(240, 165, 0, 0.15);
  color: #c48600;
}

.beagro-motivator-text {
  font-weight: 500;
}

.beagro-motivator-text strong {
  font-weight: 700;
}

.beagro-motivator-tier .beagro-motivator-text strong {
  color: #6a8a10;
}

.beagro-motivator-free_sample .beagro-motivator-text strong {
  color: #c48600;
}

/* ══════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .beagro-promotion-tiers {
    margin: 8px 0 4px;
  }

  .beagro-promotion-tiers__summary {
    padding: 8px 12px;
    font-size: 12px;
  }

  .beagro-promotion-tiers__table {
    font-size: 12px;
  }

  .beagro-promotion-tiers__table thead th {
    font-size: 10px;
    padding: 4px 10px;
  }

  .beagro-promotion-tiers__table tbody td {
    padding: 5px 10px;
  }

  #beagro-dynamic-price {
    font-size: 12px;
  }

  .beagro-dynamic-price__total-value {
    font-size: 14px;
  }

  .beagro-promotion-free-sample {
    font-size: 11px;
  }

  .beagro-motivator-card {
    padding: 10px 12px;
    font-size: 13px;
  }

  .beagro-motivator-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
    margin-right: 10px;
  }

  /* ══════════════════════════════════════════════════════════════
     E. Mobile Cart — Grid Cards
     ══════════════════════════════════════════════════════════════ */

  /* E1. Cart item → CSS Grid card */
  .woocommerce table.cart tr.cart_item {
    display: grid !important;
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "name    name     name"
      "price   qty      subtotal";
    align-items: baseline;
    gap: 0 0.75em;
    padding: 0.75em 1em;
    margin-bottom: 0.5em;
    background: #fafafa;
    border-radius: 0.5em;
    border: 1px solid #f0f0f0;
    position: relative;
  }

  /* E2. Hidden cells */
  .woocommerce table.cart td.product-thumbnail {
    display: none !important;
  }

  /* E2b. Remove button — top-right corner */
  .woocommerce table.cart tr.cart_item td.product-remove {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    width: auto;
    z-index: 1;
  }

  .woocommerce table.cart tr.cart_item td.product-remove::before {
    display: none !important;
  }

  .woocommerce table.cart tr.cart_item td.product-remove a.remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    font-size: 1em;
    color: #bbb !important;
    background: transparent !important;
    border-radius: 0 0.5em 0 0.25em;
    line-height: 1;
  }

  .woocommerce table.cart tr.cart_item td.product-remove a.remove:hover {
    color: #dc3545 !important;
    background: rgba(220, 53, 69, 0.06) !important;
  }

  /* E3. Product name — full width, no label */
  .woocommerce table.cart tr.cart_item td.product-name {
    grid-area: name;
    padding: 0 2em 0 0 !important;
    font-weight: 600;
    font-size: 0.9em;
    text-align: left !important;
    border: none !important;
    background: none !important;
    word-break: break-word;
  }

  .woocommerce table.cart tr.cart_item td.product-name::before {
    display: none !important;
  }

  /* E4. Price — left-aligned, no label */
  .woocommerce table.cart tr.cart_item td.product-price {
    grid-area: price;
    padding: 0.25em 0 0 !important;
    text-align: left !important;
    font-size: 0.85em;
    color: #555;
    border: none !important;
    background: none !important;
  }

  .woocommerce table.cart tr.cart_item td.product-price::before {
    display: none !important;
  }

  /* E4b. Tiered price del/ins in mobile cards */
  .woocommerce table.cart tr.cart_item td.product-price del {
    color: #999;
    font-size: 0.85em;
    margin-right: 0.25em;
  }

  .woocommerce table.cart tr.cart_item td.product-price ins {
    text-decoration: none;
    font-weight: 600;
  }

  /* E5. Quantity — center */
  .woocommerce table.cart tr.cart_item td.product-quantity {
    grid-area: qty;
    padding: 0.25em 0 0 !important;
    text-align: center !important;
    font-size: 0.85em;
    color: #888;
    border: none !important;
    background: none !important;
  }

  .woocommerce table.cart tr.cart_item td.product-quantity::before {
    display: none !important;
  }

  /* E6. Subtotal — right-aligned, bold, no label */
  .woocommerce table.cart tr.cart_item td.product-subtotal {
    grid-area: subtotal;
    padding: 0.25em 0 0 !important;
    text-align: right !important;
    font-weight: 700;
    font-size: 0.9em;
    color: #333;
    border: none !important;
    background: none !important;
  }

  .woocommerce table.cart tr.cart_item td.product-subtotal::before {
    display: none !important;
  }

  /* E7. Even/odd background normalization */
  .woocommerce table.cart tr.cart_item:nth-child(2n) td {
    background: transparent !important;
  }

  /* E8. Bundle children — hidden on mobile */
  .woocommerce table.cart tr.cart_item.woosb-item-child {
    display: none !important;
  }

  /* E9. Bundle parent — green left accent */
  .woocommerce table.cart tr.woosb-item-parent {
    border-left: 3px solid #95c11f;
  }
}
