/* Best Before theme · modern commerce interactions (global).
   Loaded sitewide alongside assets/js/commerce.js (inc/woocommerce/ajax-cart.php).
   Base dialog chrome (.bb-dialog, ::backdrop, head/body/foot, the <767px
   bottom-sheet rule) comes from assets/css/main.css - this file only adds
   what's specific to: button busy/success states, the hidden "View cart"
   link, quick view, share basket and the small toast. */

/* ---------- Add-to-cart button busy/success state ----------
   Works for every add-to-cart control on the site: grid/rail/search cards
   (.ajax_add_to_cart, decorated by Woo core's own AJAX script), the single
   product/quick-view submit (.single_add_to_cart_button) and the Pack Size
   Selector snippet's own button (.bb-pack-add-btn, toggles its own
   .bb-loading class) - main.css already fades these via `.bb-btn.loading,
   .button.loading { opacity:.7 }`; this only adds the spinner on top, so the
   button's own width never changes (no layout jump) and the label stays in
   the DOM (screen readers still have something coherent via aria-busy). */
.ajax_add_to_cart, .single_add_to_cart_button, .bb-pack-add-btn, .bb-qv-add {
	position: relative;
}
.ajax_add_to_cart.loading::before,
.single_add_to_cart_button.loading::before,
.bb-pack-add-btn.bb-loading::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border-radius: 50%;
	border: 2.5px solid rgba(17, 17, 17, .22);
	border-top-color: var(--bb-ink);
	animation: bbSpin .7s linear infinite;
}
@keyframes bbSpin {
	to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
	.ajax_add_to_cart.loading::before,
	.single_add_to_cart_button.loading::before,
	.bb-pack-add-btn.bb-loading::before {
		animation: none;
		opacity: .8;
	}
}

/* ---------- Hide Woo's injected "View cart" link everywhere ---------- */
a.added_to_cart.wc-forward,
a.added_to_cart {
	display: none !important;
}

/* ---------- Inline form notices (single product / quick view AJAX errors).
   Reuses Woo's own .woocommerce-error markup (wc_print_notices() output) so
   it looks identical to every other Woo notice on the site - only the
   spacing/placement above the form is this theme's own. ---------- */
[data-bbt-form-notice] {
	margin: 0 0 14px;
}
[data-bbt-form-notice] .woocommerce-error,
[data-bbt-form-notice] .woocommerce-message,
[data-bbt-form-notice] .woocommerce-info {
	margin: 0;
	list-style: none;
	padding: 12px 14px;
	border-radius: var(--bb-r-small);
	background: #fdeceb;
	color: var(--bb-error);
	font-size: .875rem;
	font-weight: 600;
}

/* ---------- Basket page "Share basket" / "Clear basket" (printed via the
   bbt_cart_actions hook woocommerce/cart/cart.php leaves open, next to
   "Continue shopping" - no edit to that template needed). ---------- */
.bb-cart__head-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bb-cart__share { display: inline-flex; align-items: center; gap: 6px; }
.bb-cart__clear { border: 0; background: none; color: var(--bb-error); font: 700 .875rem/1 var(--bb-font-body); text-decoration: underline; cursor: pointer; min-height: var(--bb-touch); padding: 0 4px; }
.bb-cart__clear[aria-busy="true"] { opacity: .5; pointer-events: none; }

/* ---------- Real discount-rule "Sale" badge (card.php), styled like the
   existing -x% badge so the two never look like two different systems. ---------- */
.bb-badge--sale { background: var(--bb-ink); color: var(--bb-yellow); }

/* bb-bb-pill's one layout rule (assets/css/pages/product.css) doesn't load
   outside the product page - quick view needs it everywhere else too. */
.bb-bb-pill { align-self: flex-start; }

/* ============================================================
 * Quick view
 * ============================================================ */
.bb-quickview { width: min(880px, calc(100vw - 32px)); max-height: min(90vh, 760px); }
.bb-quickview__body { padding: 0; overflow: hidden; display: flex; min-height: 0; }
.bb-quickview__loading, .bb-quickview__error { margin: 48px auto; color: var(--bb-muted); }
.bb-quickview__error { color: var(--bb-error); }
.bb-quickview__content { width: 100%; overflow-y: auto; overscroll-behavior: contain; }
.bb-quickview__layout { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 28px; padding: 22px 26px 26px; }

.bb-quickview__gallery { display: flex; flex-direction: column; gap: 10px; }
.bb-quickview__main { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; padding: 16px; border: 1px solid var(--bb-border); border-radius: var(--bb-r-small); background: var(--bb-surface); }
.bb-quickview__main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bb-quickview__thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.bb-quickview__thumb { width: 56px; height: 56px; padding: 4px; border: 1.5px solid var(--bb-border); border-radius: var(--bb-r-small); background: var(--bb-surface); cursor: pointer; }
.bb-quickview__thumb.is-active { border-color: var(--bb-ink); }
.bb-quickview__thumb img { width: 100%; height: 100%; object-fit: contain; }
.bb-quickview__thumb:focus-visible { outline: 3px solid var(--bb-ink); outline-offset: 1px; }

.bb-quickview__details { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bb-quickview__metaline { margin: 0; color: var(--bb-muted); font-size: .875rem; }
.bb-quickview__price { display: flex; align-items: baseline; gap: 10px; margin-top: 2px; }
.bb-quickview__meta { display: flex; flex-wrap: wrap; gap: 8px; }
.bb-quickview__excerpt { margin-top: 2px; color: var(--bb-body); font-size: .9375rem; line-height: 1.5; }
.bb-quickview__excerpt p:first-child { margin-top: 0; }
.bb-quickview__buy { margin-top: 10px; }
.bb-quickview__buy form.cart { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bb-quickview__full { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 10px; font-weight: 700; color: var(--bb-ink); text-decoration: none; }
.bb-quickview__full:hover { text-decoration: underline; }

/* ---------- Dialog header title: brand + name, truncated to 2 lines, so the
   close button has a real sibling and lands on the right (space-between) -
   see template-parts/product/quick-view.php for why a bare screen-reader-text
   title broke that. Filled in by assets/js/commerce.js once the fetch
   resolves; the body never repeats the full name (brand only, see
   quick-view-content.php). ---------- */
.bb-quickview__headtitle {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	font-size: 1.0625rem;
	line-height: 1.3;
	min-width: 0;
}

@media (max-width: 767px) {
	.bb-quickview__layout { grid-template-columns: 1fr; padding: 18px 18px 20px; }
}

/* ============================================================
 * Share basket
 * ============================================================ */
.bb-shareconfirm__row { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; padding-block: 10px; border-bottom: 1px solid var(--bb-border); }
.bb-shareconfirm__row:last-child { border-bottom: 0; }
.bb-shareconfirm__row img { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--bb-border); border-radius: var(--bb-r-small); background: var(--bb-surface); padding: 4px; }
.bb-shareconfirm__info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bb-shareconfirm__name { font-weight: 700; font-size: .9375rem; }
.bb-shareconfirm__meta { font-size: .8125rem; color: var(--bb-muted); }
.bb-shareconfirm__row.is-unavailable { opacity: .55; }
.bb-shareconfirm__row.is-unavailable .bb-shareconfirm__meta { color: var(--bb-error); }
.bb-shareconfirm__error { color: var(--bb-error); font-weight: 600; }
.bb-shareconfirm__foot { display: flex; flex-direction: column; gap: 10px; }
.bb-shareconfirm__actions { display: flex; gap: 10px; }
.bb-shareconfirm__actions .bb-btn { flex: 1 1 0; min-height: var(--bb-touch); }
.bb-shareconfirm__cancel { align-self: center; border: 0; background: none; color: var(--bb-muted); font: inherit; text-decoration: underline; cursor: pointer; min-height: var(--bb-touch); }

/* ============================================================
 * Toast ("Removed · Undo", "Link copied", clear-basket result).
 * ============================================================ */
.bb-toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; display: flex; align-items: center; gap: 12px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 10px 12px 16px; border-radius: var(--bb-r-pill); background: var(--bb-ink); color: #fff; font-size: .875rem; font-weight: 600; box-shadow: var(--bb-shadow); transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: transform .25s var(--bb-ease), opacity .25s var(--bb-ease); }
.bb-toast.is-visible { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.bb-toast__text { flex: 1 1 auto; }
.bb-toast__action { flex: none; border: 0; background: none; color: var(--bb-yellow); font: inherit; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; cursor: pointer; min-height: 32px; }
.bb-toast__close { flex: none; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
	.bb-toast { transition: opacity .2s linear; transform: translate(-50%, 0); }
}
@media (max-width: 480px) {
	.bb-toast { left: 16px; right: 16px; bottom: 16px; transform: translateY(16px); max-width: none; }
	.bb-toast.is-visible { transform: translateY(0); }
}

/* Toast as a manual popover (top layer): undo the UA popover box so our own
   positioning/styling applies, and keep it above open dialogs. */
.bb-toast[popover] { inset: auto auto 24px 50%; margin: 0; border: 0; overflow: visible; color: #fff; }
@media (max-width: 480px) { .bb-toast[popover] { inset: auto 16px 16px 16px; } }

/* ---------- Woo Discount Rules promotion inside the QUICK VIEW modal ----------
   Same card as the product page (assets/css/pages/product.css), scoped to .bb-quickview
   because product.css only loads on product pages.
   The plugin prints the same rule twice: its bulk table ("Promotion / ANY 4 FOR R99")
   and its discount bar ("ANY 4 FOR R99"). Show ONE theme-styled promo card: the table
   (it also carries the per-item price), and hide the bar whenever a table is present.
   Applies to every rule going forward because it targets the plugin's own markup. */
.bb-quickview:has(.awdr-bulk-customizable-table) .awdr_discount_bar { display: none !important; }

.bb-quickview .awdr-bulk-customizable-table { margin: 0 0 14px; }
.bb-quickview .awdr-bulk-customizable-table table,
.bb-quickview .awdr-bulk-customizable-table thead,
.bb-quickview .awdr-bulk-customizable-table tbody { display: block; width: auto; margin: 0; border: 0; background: none; }
.bb-quickview .awdr-bulk-customizable-table tr { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; border: 0; background: none; }
.bb-quickview .awdr-bulk-customizable-table thead tr { display: none; }
.bb-quickview .awdr-bulk-customizable-table tbody tr {
	padding: 12px 16px;
	border: 1.5px solid #e9c200;
	border-radius: var(--bb-r-tile);
	background: var(--bb-pale-yellow, #fff8d6);
}
.bb-quickview .awdr-bulk-customizable-table tbody tr + tr { margin-top: 8px; }
.bb-quickview .awdr-bulk-customizable-table tbody tr::before {
	content: "";
	grid-row: 1 / span 2;
	width: 40px; height: 40px;
	border-radius: 50%;
	background: var(--bb-yellow) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8Z'/%3E%3Ccircle cx='7.5' cy='7.5' r='1.5'/%3E%3C/svg%3E") center / 20px no-repeat;
}
.bb-quickview .awdr-bulk-customizable-table td { display: block; padding: 0; border: 0; background: none; text-align: left; }
.bb-quickview .awdr-bulk-customizable-table .wdr_bulk_title { grid-column: 2; color: var(--bb-ink); font-weight: 800; font-size: 1rem; letter-spacing: .02em; }
.bb-quickview .awdr-bulk-customizable-table .wdr_bulk_title::before { content: "Promotion"; display: block; margin-bottom: 2px; color: #7a6400; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.bb-quickview .awdr-bulk-customizable-table .wdr_bulk_range { display: none !important; }
/* Per-item price from the plugin's own data (e.g. R99 for 4 = R24,75 each). */
.bb-quickview .awdr-bulk-customizable-table .wdr_bulk_table_discount { display: block !important; grid-column: 3; grid-row: 1 / span 2; text-align: right; }
.bb-quickview .awdr-bulk-customizable-table .wdr_table_discounted_value { display: none !important; }
.bb-quickview .awdr-bulk-customizable-table .wdr_table_discounted_price { display: block !important; color: var(--bb-ink); font-weight: 800; font-size: 1.0625rem; white-space: nowrap; }
.bb-quickview .awdr-bulk-customizable-table .wdr_table_discounted_price::after { content: " each"; color: var(--bb-muted); font-size: .8125rem; font-weight: 600; }

/* A rule with only the discount bar (no table): same card look. */
.bb-quickview .awdr_discount_bar {
	display: flex; align-items: center; gap: 10px;
	margin: 0 0 14px; padding: 12px 16px;
	border: 1.5px solid #e9c200 !important; border-radius: var(--bb-r-tile);
	background: var(--bb-pale-yellow, #fff8d6) !important; color: var(--bb-ink) !important;
	font-weight: 800; letter-spacing: .02em;
}
/* The plugin paints its table/wrapper yellow; the card above carries the colour. */
.bb-quickview .awdr-bulk-customizable-table,
.bb-quickview .awdr-bulk-customizable-table table,
.bb-quickview .awdr-bulk-customizable-table th,
.bb-quickview .awdr-bulk-customizable-table td { background: transparent !important; box-shadow: none !important; outline: 0 !important; }
/* Quick view qty: no browser spinner arrows (cleaner, matches the theme fields). */
.bb-quickview input.qty { -moz-appearance: textfield; text-align: center; }
.bb-quickview input.qty::-webkit-outer-spin-button, .bb-quickview input.qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
