/* ============================================================
   Smart Variant Bundle Selector — Frontend Styles
   Matches the reference image: teal accent, card layout,
   clean typography, smooth transitions.
   ============================================================ */

/* ── Custom Properties (overridden from PHP via :root in <head>) ── */
:root {
	--svbs-accent:         #00a99d;
	--svbs-accent-light:   #e6f7f6;
	--svbs-accent-border:  2px solid var(--svbs-accent);
	--svbs-radius:         12px;
	--svbs-radius-sm:      8px;
	--svbs-gray:           #f4f5f5;
	--svbs-gray-dark:      #666;
	--svbs-gray-border:    #e0e0e0;
	--svbs-text:           #222;
	--svbs-label-color:    #888;
	--svbs-shadow:         0 2px 10px rgba(0,0,0,.07);
	--svbs-card-size:      90px;   /* flavour card width on desktop */
	--svbs-transition:     .18s ease;
}

/* ── Wrapper ─────────────────────────────────────────────── */
.svbs-wrapper {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: var(--svbs-text);
	font-size: 14px;
	line-height: 1.5;
	margin-top: 16px;
}

.svbs-wrapper * {
	box-sizing: border-box;
}

/* ── Section ─────────────────────────────────────────────── */
.svbs-section {
	margin-bottom: 20px;
}

.svbs-section-label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--svbs-label-color);
	margin: 0 0 10px;
}

/* ── Bundle Grid ─────────────────────────────────────────── */
.svbs-bundle-grid {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.svbs-bundle-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	flex: 1 1 calc(25% - 8px);
	min-width: 100px;
	padding: 14px 10px 12px;
	background: #fff;
	border: 1.5px solid var(--svbs-gray-border);
	border-radius: var(--svbs-radius);
	cursor: pointer;
	text-align: center;
	transition: border-color var(--svbs-transition), background var(--svbs-transition), box-shadow var(--svbs-transition);
	outline: none;
}

.svbs-bundle-card:hover:not(.svbs-bundle-active) {
	border-color: #bbb;
	box-shadow: var(--svbs-shadow);
}

.svbs-bundle-card:focus-visible {
	outline: 2px solid var(--svbs-accent);
	outline-offset: 2px;
}

.svbs-bundle-card.svbs-bundle-active {
	border: var(--svbs-accent-border);
	background: #fff;
	box-shadow: 0 0 0 1px var(--svbs-accent);
}

/* "Best value" badge — sits on top edge of card */
.svbs-badge {
	position: absolute;
	top: -13px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--svbs-accent);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 10px;
	border-radius: 20px;
	white-space: nowrap;
	letter-spacing: .03em;
}

.svbs-bundle-label {
	font-size: 15px;
	font-weight: 700;
	color: var(--svbs-text);
}

.svbs-bundle-price {
	font-size: 14px;
	color: var(--svbs-text);
}

.svbs-bundle-savings {
	font-size: 12px;
	color: var(--svbs-accent);
	font-weight: 600;
}

/* ── Selected Options Section ────────────────────────────── */
.svbs-selected-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.svbs-selected-header .svbs-section-label {
	margin-bottom: 0;
}

.svbs-reset-btn {
	background: none;
	border: none;
	color: var(--svbs-accent);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	padding: 0;
	text-decoration: none;
	transition: opacity var(--svbs-transition);
}

.svbs-reset-btn:hover {
	opacity: .75;
}

/* Grid of selection slots */
.svbs-selections-grid {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

/* A filled selection card — transparent column, same pattern as flavour card */
.svbs-selection-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 7px;
	width: var(--svbs-card-size);
	padding: 0;
	background: transparent;
	border: none;
	animation: svbs-pop .18s ease;
}

@keyframes svbs-pop {
	from { transform: scale(.85); opacity: 0; }
	to   { transform: scale(1);   opacity: 1; }
}

/* Bordered image box — full-bleed square */
.svbs-selection-img-wrap {
	width: 100%;
	aspect-ratio: 1 / 1;
	flex-shrink: 0;
	border: 1.5px solid var(--svbs-gray-border);
	border-radius: var(--svbs-radius-sm);
	overflow: hidden;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}

.svbs-selection-card img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

/* Name sits below the image box */
.svbs-selection-name {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .04em;
	color: var(--svbs-text);
	text-align: center;
	line-height: 1.3;
	word-break: break-word;
	text-transform: uppercase;
}

.svbs-remove-btn {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 20px;
	height: 20px;
	background: #fff;
	border: 1.5px solid var(--svbs-gray-border);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	font-size: 11px;
	color: #555;
	line-height: 1;
	padding: 0;
	transition: background var(--svbs-transition), color var(--svbs-transition);
}

.svbs-remove-btn:hover {
	background: #f44;
	color: #fff;
	border-color: #f44;
}

/* An empty slot */
.svbs-empty-slot {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: var(--svbs-card-size);
	height: 90px;
	background: #fff;
	border: var(--svbs-accent-border);
	border-radius: var(--svbs-radius-sm);
	color: var(--svbs-gray-dark);
}

.svbs-empty-slot-num {
	font-size: 24px;
	font-weight: 700;
	color: #ccc;
	line-height: 1;
}

.svbs-empty-slot-label {
	font-size: 11px;
	color: #bbb;
	margin-top: 2px;
}

/* ── Flavour Grid ─────────────────────────────────────────── */
.svbs-flavour-grid {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

/* Card = transparent flex column; the bordered box is the img-wrap below */
.svbs-flavour-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 7px;
	flex: 0 0 var(--svbs-card-size);
	width: var(--svbs-card-size);
	padding: 0;
	background: transparent;
	border: none;
	cursor: pointer;
	text-align: center;
	transition: transform var(--svbs-transition), opacity var(--svbs-transition);
	outline: none;
}

.svbs-flavour-card:hover:not(.svbs-oos):not(.svbs-maxed) {
	transform: translateY(-2px);
}

/* Hover glow moves to the image box */
.svbs-flavour-card:hover:not(.svbs-oos):not(.svbs-maxed) .svbs-flavour-img-wrap {
	box-shadow: 0 4px 12px rgba(0,169,157,.28);
	border-color: var(--svbs-accent);
}

.svbs-flavour-card:focus-visible .svbs-flavour-img-wrap {
	outline: 2px solid var(--svbs-accent);
	outline-offset: 2px;
}

.svbs-flavour-card.svbs-oos {
	opacity: .45;
	cursor: not-allowed;
}

.svbs-flavour-card.svbs-oos .svbs-flavour-img-wrap {
	border-color: #ccc;
}

/* When bundle is full, grey out remaining flavour cards */
.svbs-flavour-card.svbs-maxed {
	opacity: .5;
	cursor: not-allowed;
}

/* Image box — full-bleed square with the teal border */
.svbs-flavour-img-wrap {
	width: 100%;
	aspect-ratio: 1 / 1;
	flex-shrink: 0;
	border: var(--svbs-accent-border);
	border-radius: var(--svbs-radius-sm);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	transition: border-color var(--svbs-transition), box-shadow var(--svbs-transition);
}

/* Image fills the entire box */
.svbs-flavour-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

/* Name — sits below the box, outside the border */
.svbs-flavour-name {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .04em;
	color: var(--svbs-text);
	line-height: 1.3;
	word-break: break-word;
}

.svbs-oos-label {
	font-size: 9px;
	color: #f44;
	font-weight: 600;
}

/* ── Add To Cart Button ───────────────────────────────────── */
.svbs-atc-section {
	margin-top: 4px;
}

.svbs-atc-btn {
	width: 100%;
	padding: 16px;
	background: #c8c8c8;
	color: #fff;
	border: none;
	border-radius: var(--svbs-radius);
	font-size: 16px;
	font-weight: 600;
	cursor: not-allowed;
	transition: background var(--svbs-transition), transform .1s ease, box-shadow var(--svbs-transition);
	letter-spacing: .01em;
}

.svbs-atc-btn:not(:disabled) {
	background: var(--svbs-accent);
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0,169,157,.30);
}

.svbs-atc-btn:not(:disabled):hover {
	background: #008c82;
	box-shadow: 0 6px 18px rgba(0,169,157,.40);
}

.svbs-atc-btn:not(:disabled):active {
	transform: scale(.98);
}

/* ── Divider between sections ─────────────────────────────── */
.svbs-section + .svbs-section {
	padding-top: 16px;
	border-top: 1px solid var(--svbs-gray-border);
}

/* ── Order meta ───────────────────────────────────────────── */
.svbs-order-meta {
	font-size: 13px;
	color: #555;
	margin-top: 4px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
	:root {
		--svbs-card-size: 80px;
	}

	.svbs-bundle-card {
		flex: 1 1 calc(50% - 8px);
		min-width: 0;
	}

	.svbs-flavour-grid {
		gap: 8px;
	}

	/* 3 cards per row — width drives the box via width:100% */
	.svbs-flavour-card {
		flex: 0 0 calc(33.33% - 6px);
		width: calc(33.33% - 6px);
	}

	.svbs-atc-btn {
		font-size: 15px;
		padding: 14px;
	}
}

@media (max-width: 400px) {
	.svbs-flavour-grid {
		gap: 8px;
	}

	/* 2 cards per row on very small screens */
	.svbs-flavour-card {
		flex: 0 0 calc(50% - 4px);
		width: calc(50% - 4px);
	}
}

/* ── Failsafe: hide native WC form when SVBS is active ──────────────────
   Belt-and-suspenders for themes / swatches plugins that independently
   render variation controls outside the woocommerce_variable_add_to_cart
   action hook (e.g., woo-variation-swatches injecting into the summary
   area directly). The body class 'svbs-enabled' is added by PHP only
   when SVBS is active on the current product page.
   ─────────────────────────────────────────────────────────────────────── */
.svbs-enabled form.variations_form,
.svbs-enabled .woo-variation-swatches-on-product,
.svbs-enabled .woocommerce-variation-add-to-cart,
.svbs-enabled .variations_button,
.svbs-enabled table.variations,
.svbs-enabled .wvs-wrap {
	display: none !important;
}
