/**
 * Chamevo Bulk Variations — frontend styles.
 * Scoped under .wcbv-wrapper so it stays out of the theme's way.
 */

.wcbv-wrapper {
	--wcbv-accent: #3498db;
	--wcbv-accent-dark: #1d8ad3;
	--wcbv-accent-soft: #e8f4fd;
	--wcbv-heading: #01192a;
	--wcbv-text: #50545e;
	--wcbv-muted: #8a8f9a;
	--wcbv-border: #e2e5ec;
	--wcbv-surface: #fff;
	--wcbv-surface-soft: #f5f7fb;
	--wcbv-error: #e02b2b;
	--wcbv-error-soft: #fff1f1;
	--wcbv-radius: 8px;
	--wcbv-shadow: 0 8px 28px rgba(1, 25, 42, 0.12);

	margin: 24px 0;
	clear: both;
	color: var(--wcbv-text);
}

.wcbv-wrapper *,
.wcbv-wrapper *::before,
.wcbv-wrapper *::after {
	box-sizing: border-box;
}

/* --- Column headers (fit-in-row layout only) --- */
.wcbv-attributes-head {
	display: none;
	align-items: flex-end;
	gap: 10px;
	margin: 0 0 6px;
}

.wcbv-wrapper.wcbv-fit_in_row .wcbv-attributes-head {
	display: flex;
}

.wcbv-attributes-head > div {
	flex: 1;
	padding-bottom: 4px;
	font-size: 11px;
	line-height: 1.2;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-align: center;
	color: var(--wcbv-muted);
	border-bottom: 1px solid var(--wcbv-border);
	word-break: break-word;
}

.wcbv-attributes-head > .wcbv-quantity {
	flex: 0 0 84px;
}

.wcbv-attributes-head > .wcbv-remove {
	flex: 0 0 28px;
	border-bottom: none;
}

/* --- Rows --- */
.wcbv-variations {
	margin-bottom: 8px;
}

.wcbv-variations > .wcbv-row {
	display: flex;
	flex-direction: column;
	position: relative;
	margin-bottom: 14px;
}

.wcbv-row .wcbv-fields {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.wcbv-fields > .wcbv-selects {
	flex: 1;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	min-width: 0;
}

.wcbv-select-col {
	flex: 1;
	min-width: 0;
}

/* --- Quantity --- */
.wcbv-quantity {
	flex: 0 0 84px;
}

/*
 * The quantity field is a real <input>, so it is prefixed with .wcbv-wrapper
 * to out-specify theme rules such as `input[type=number]` that would otherwise
 * override the plugin's border and make it clash with the custom select.
 */
.wcbv-wrapper .wcbv-quantity input[type="number"] {
	width: 100%;
	height: 46px;
	margin: 0;
	padding: 0 10px;
	text-align: center;
	font-size: 15px;
	color: var(--wcbv-heading);
	background: var(--wcbv-surface);
	border: 1px solid var(--wcbv-border);
	border-radius: var(--wcbv-radius);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	-moz-appearance: textfield;
}

.wcbv-wrapper .wcbv-quantity input[type="number"]:focus {
	outline: none;
	border-color: var(--wcbv-accent);
	box-shadow: 0 0 0 3px var(--wcbv-accent-soft);
}

/* --- Remove button --- */
.wcbv-remove {
	flex: 0 0 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 46px;
}

.wcbv-row:first-child .wcbv-remove-row {
	display: none;
}

.wcbv-remove-row {
	display: block;
	position: relative;
	width: 26px;
	height: 26px;
	padding: 0;
	color: var(--wcbv-text);
	background: transparent;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.15s ease, background 0.15s ease;
}

.wcbv-remove-row::before,
.wcbv-remove-row::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 13px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

.wcbv-remove-row::before {
	transform: translate(-50%, -50%) rotate(45deg);
}

.wcbv-remove-row::after {
	transform: translate(-50%, -50%) rotate(-45deg);
}

.wcbv-remove-row:hover {
	opacity: 1;
	background: var(--wcbv-surface-soft);
	color: var(--wcbv-error);
}

/* --- Searchable select --- */
.wcbv-select__native {
	display: none !important;
}

.wcbv-select {
	position: relative;
	width: 100%;
}

.wcbv-select__control {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 46px;
	margin: 0;
	padding: 0 14px;
	font-size: 15px;
	line-height: 1.3;
	text-align: left;
	color: var(--wcbv-heading);
	background: var(--wcbv-surface);
	border: 1px solid var(--wcbv-border);
	border-radius: var(--wcbv-radius);
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wcbv-select__control:hover {
	border-color: #cdd2dd;
}

.wcbv-select.is-open .wcbv-select__control,
.wcbv-select__control:focus-visible {
	outline: none;
	border-color: var(--wcbv-accent);
	box-shadow: 0 0 0 3px var(--wcbv-accent-soft);
}

.wcbv-select__value {
	flex: 1;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.wcbv-select--placeholder .wcbv-select__value {
	color: var(--wcbv-muted);
}

.wcbv-select__arrow {
	flex: 0 0 auto;
	width: 10px;
	height: 10px;
	border-right: 2px solid var(--wcbv-muted);
	border-bottom: 2px solid var(--wcbv-muted);
	transform: rotate(45deg) translate(-2px, -2px);
	transition: transform 0.2s ease;
}

.wcbv-select.is-open .wcbv-select__arrow {
	transform: rotate(-135deg) translate(-3px, -3px);
}

.wcbv-select__panel {
	position: absolute;
	z-index: 50;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	background: var(--wcbv-surface);
	border: 1px solid var(--wcbv-border);
	border-radius: var(--wcbv-radius);
	box-shadow: var(--wcbv-shadow);
	overflow: hidden;
}

.wcbv-select__search-wrap {
	padding: 8px;
	border-bottom: 1px solid var(--wcbv-border);
}

/* Prefixed with .wcbv-wrapper so theme `input` rules do not override it. */
.wcbv-wrapper .wcbv-select__search {
	width: 100%;
	height: 38px;
	margin: 0;
	padding: 0 12px;
	font-size: 14px;
	color: var(--wcbv-heading);
	background: var(--wcbv-surface-soft);
	border: 1px solid var(--wcbv-border);
	border-radius: 6px;
}

.wcbv-wrapper .wcbv-select__search:focus {
	outline: none;
	border-color: var(--wcbv-accent);
	background: var(--wcbv-surface);
}

.wcbv-select__options {
	max-height: 240px;
	margin: 0;
	padding: 6px;
	overflow-y: auto;
}

.wcbv-select__option {
	margin: 0;
	padding: 9px 12px;
	font-size: 14px;
	line-height: 1.3;
	color: var(--wcbv-text);
	border-radius: 6px;
	cursor: pointer;
}

.wcbv-select__option.is-hidden {
	display: none;
}

.wcbv-select__option:hover,
.wcbv-select__option.is-active {
	background: var(--wcbv-surface-soft);
	color: var(--wcbv-heading);
}

.wcbv-select__option.is-selected {
	font-weight: 600;
	color: var(--wcbv-accent-dark);
	background: var(--wcbv-accent-soft);
}

/* --- Validation --- */
.wcbv-select-col.wcbv-error .wcbv-select__control {
	border-color: var(--wcbv-error);
	background: var(--wcbv-error-soft);
}

/* --- Per-row & total price --- */
.wcbv-row .wcbv-price {
	display: none;
	align-self: flex-end;
	margin: 8px 4px 0 0;
	font-size: 14px;
	color: var(--wcbv-muted);
}

.wcbv-row.wcbv-show-price .wcbv-price {
	display: block;
}

.wcbv-wrapper .wcbv-total-price {
	display: none;
	margin: 4px 0 12px;
	text-align: right;
	font-size: 20px;
	font-weight: 700;
	color: var(--wcbv-heading);
}

/* --- Actions --- */
.wcbv-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 16px 0 0;
}

/*
 * Deliberately understated so it blends into any theme and is easy to
 * override. Merchants can also point the button at their own theme's button
 * class via Settings ▸ Bulk Variations ▸ "Button CSS Class".
 */
.wcbv-actions .wcbv-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	font-size: 14px;
	line-height: 1.4;
	color: var(--wcbv-text);
	background: transparent;
	border: 1px solid var(--wcbv-border);
	border-radius: var(--wcbv-radius);
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.wcbv-actions .wcbv-btn::before {
	content: "+";
	font-size: 15px;
	line-height: 1;
}

.wcbv-actions .wcbv-btn:hover {
	border-color: var(--wcbv-muted);
	color: var(--wcbv-heading);
}

.wcbv-actions .wcbv-reset-variations {
	margin-left: auto;
	font-size: 13px;
	color: var(--wcbv-muted);
}

.wcbv-actions .wcbv-reset-variations:hover {
	color: var(--wcbv-accent);
}

/* --- Column layouts (admin "selects per row" option) --- */
.wcbv-wrapper.wcbv-columnize .wcbv-selects > .wcbv-select-col {
	flex-grow: 0;
}

.wcbv-wrapper.wcbv-one .wcbv-selects > .wcbv-select-col {
	flex-basis: 100%;
}
.wcbv-wrapper.wcbv-two .wcbv-selects > .wcbv-select-col {
	flex-basis: calc(50% - 5px);
}
.wcbv-wrapper.wcbv-three .wcbv-selects > .wcbv-select-col {
	flex-basis: calc(33.33% - 7px);
}
.wcbv-wrapper.wcbv-four .wcbv-selects > .wcbv-select-col {
	flex-basis: calc(25% - 8px);
}
.wcbv-wrapper.wcbv-five .wcbv-selects > .wcbv-select-col {
	flex-basis: calc(20% - 8px);
}
.wcbv-wrapper.wcbv-six .wcbv-selects > .wcbv-select-col {
	flex-basis: calc(16.66% - 9px);
}

/* --- Discounts table --- */
/* The table can render outside .wcbv-wrapper, so it declares its own tokens. */
.wcbv-discounts-table {
	--wcbv-accent: #3498db;
	--wcbv-accent-soft: #e8f4fd;
	--wcbv-heading: #01192a;
	--wcbv-text: #50545e;
	--wcbv-muted: #8a8f9a;
	--wcbv-border: #e2e5ec;
	--wcbv-surface: #fff;
	--wcbv-surface-soft: #f5f7fb;
	--wcbv-radius: 8px;

	margin-bottom: 22px;
	color: var(--wcbv-text);
}

.wcbv-discounts-table *,
.wcbv-discounts-table *::before,
.wcbv-discounts-table *::after {
	box-sizing: border-box;
}

.wcbv-discounts-table .wcbv-variation-desc {
	display: block;
	margin: 20px 0 8px;
	font-size: 14px;
	font-weight: 600;
	color: var(--wcbv-heading);
}

.wcbv-discounts-table .wcbv-variation-desc:first-child {
	margin-top: 0;
}

.wcbv-discounts-table .wcbv-discount-rules {
	border: 1px solid var(--wcbv-border);
	border-radius: var(--wcbv-radius);
	overflow: hidden;
	background: var(--wcbv-surface);
}

.wcbv-discounts-table .wcbv-head,
.wcbv-discounts-table .wcbv-discount-rule {
	display: flex;
	border-bottom: 1px solid var(--wcbv-border);
}

.wcbv-discounts-table .wcbv-discount-rule:last-child {
	border-bottom: none;
}

.wcbv-discounts-table .wcbv-discount-rule:nth-child(even) {
	background: var(--wcbv-surface-soft);
}

.wcbv-discounts-table .wcbv-head > div,
.wcbv-discounts-table .wcbv-discount-rule > div {
	flex: 1;
	padding: 10px 14px;
	font-size: 13px;
	line-height: 1.4;
}

.wcbv-discounts-table .wcbv-head > div {
	padding: 8px 14px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wcbv-muted);
	background: var(--wcbv-surface);
	border-bottom: 1px solid var(--wcbv-border);
}

.wcbv-discounts-table .wcbv-discount-rule > div:last-child {
	font-weight: 600;
	color: var(--wcbv-accent);
}

/* --- Hide the native WooCommerce variation UI on bulk products --- */
.wcbv-product .variations_form .variations,
.wcbv-product .single_variation_wrap .quantity,
.wcbv-product .single_variation_wrap .woocommerce-variation-price {
	display: none !important;
}

/* --- Responsive --- */
@media (max-width: 568px) {
	.wcbv-wrapper.wcbv-fit_in_row .wcbv-attributes-head {
		display: none;
	}

	.wcbv-row .wcbv-fields {
		flex-wrap: wrap;
	}

	.wcbv-fields > .wcbv-selects {
		flex: 1 1 100%;
	}

	.wcbv-wrapper .wcbv-selects > .wcbv-select-col {
		flex-basis: 100% !important;
	}

	.wcbv-quantity {
		flex: 1 1 auto;
	}
}
