/*
 * Force this widget onto its own full-width row no matter how the theme
 * lays out the surrounding .cart form (inline-block, float, or flex).
 *
 * On themes where form.cart is a non-wrapping flexbox row, simply giving
 * the widget width:100% isn't enough — flex-shrink squeezes it back down
 * to fit alongside the quantity input and button on the same line. So we
 * also force the flex row itself to wrap when it doesn't fit.
 *
 * flex-shrink is deliberately left at 1 (allowed to shrink), with
 * min-width:0 to override flexbox's default min-width:auto. Quick View
 * popups (and similar narrow embeds) size their content column
 * intrinsically rather than to a fixed pixel width — if we forbid this
 * widget from ever shrinking (flex-shrink:0), it can force that whole
 * column, and the modal around it, wider than the viewport instead of
 * itself just wrapping its own contents onto more lines. Letting it
 * shrink means it always fits whatever space it's actually given.
 */
form.cart,
.woocommerce div.product form.cart,
.woocommerce-page div.product form.cart {
	flex-wrap: wrap !important;
}

.vdc-widget {
	display: block !important;
	float: none !important;
	clear: both !important;
	width: 100% !important;
	max-width: 480px;
	box-sizing: border-box;
	flex: 1 1 100% !important;
	min-width: 0 !important;
	overflow-wrap: break-word;
}

/* Belt-and-braces clearfix in case the theme floats the quantity/button
   row that follows this widget in the DOM. */
.vdc-clear {
	display: block;
	clear: both;
	width: 100%;
	height: 0;
	float: none;
}

.vdc-widget * {
	box-sizing: border-box;
}

.vdc-widget {
	--vdc-accent: #7c9473;
	--vdc-accent-dark: #5f7358;
	--vdc-border: #e2e5e0;
	--vdc-bg: #f9faf8;
	--vdc-text: #33362f;
	--vdc-error: #b3452c;
	--vdc-ok: #4a7a3d;

	background: var(--vdc-bg);
	border: 1px solid var(--vdc-border);
	border-radius: 10px;
	padding: 20px 20px 18px;
	margin: 18px 0 10px;
	color: var(--vdc-text);
	font-size: 15px;
}

@media (max-width: 480px) {
	.vdc-widget {
		padding: 16px 14px 14px;
		font-size: 14px;
	}
}

.vdc-field {
	margin-bottom: 16px;
}

.vdc-field:last-child {
	margin-bottom: 0;
}

.vdc-field > label {
	display: block;
	font-weight: 600;
	margin-bottom: 8px;
	font-size: 0.92em;
	letter-spacing: 0.01em;
}

/*
 * Delivery / Collection choice.
 *
 * Deliberately stacked full-width (not side-by-side pills). A
 * side-by-side "segmented control" looks nice on a full product page,
 * but its correct width depends entirely on how much horizontal space
 * the surrounding page gives it — which varies a lot (a full product
 * page vs. Quick View's narrower two-column layout vs. different
 * themes/screen sizes), and there's no reliable way to detect that from
 * CSS alone. Every side-by-side attempt at this ends up squeezing or
 * wrapping unpredictably in one context or another. Two full-width rows
 * are immune to all of that: each option is always exactly as wide as
 * its container, everywhere, and it's a larger, easier tap target on
 * mobile too.
 */
.vdc-segmented {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
}

.vdc-radio {
	position: relative;
	display: block;
	width: 100%;
	margin: 0;
	cursor: pointer;
}

.vdc-radio input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.vdc-radio span {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--vdc-border);
	border-radius: 8px;
	background: #fff;
	font-weight: 500;
	font-size: 0.95em;
	color: var(--vdc-text);
	transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

/* Custom radio dot, drawn rather than relying on the native input
   (which we've visually hidden so the whole row is clickable/stylable). */
.vdc-radio span::before {
	content: "";
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid var(--vdc-border);
	background: #fff;
	box-sizing: border-box;
	transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.vdc-radio input:checked + span {
	border-color: var(--vdc-accent);
	background: rgba(124, 148, 115, 0.08);
	color: var(--vdc-accent-dark);
}

.vdc-radio input:checked + span::before {
	border-color: var(--vdc-accent);
	background: var(--vdc-accent);
	box-shadow: inset 0 0 0 3px #fff;
}

.vdc-radio input:focus-visible + span {
	outline: 2px solid var(--vdc-accent-dark);
	outline-offset: 2px;
}

/* Postcode row */
.vdc-postcode-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.vdc-postcode-row input[type="text"] {
	flex: 1 1 160px;
	min-width: 140px;
}

.vdc-widget input[type="text"],
.vdc-widget input[type="date"] {
	padding: 9px 11px;
	border: 1px solid var(--vdc-border);
	border-radius: 6px;
	background: #fff;
	font-size: 0.95em;
	color: var(--vdc-text);
	line-height: 1.3;
}

.vdc-widget input[type="text"]:focus,
.vdc-widget input[type="date"]:focus {
	outline: none;
	border-color: var(--vdc-accent);
	box-shadow: 0 0 0 3px rgba(124, 148, 115, 0.18);
}

.vdc-date-field input[type="date"] {
	width: 100%;
	max-width: 220px;
}

.vdc-btn {
	background: var(--vdc-accent);
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 9px 16px;
	font-weight: 600;
	font-size: 0.92em;
	cursor: pointer;
	white-space: nowrap;
	transition: background-color 0.15s ease;
}

.vdc-btn:hover:not(:disabled) {
	background: var(--vdc-accent-dark);
}

.vdc-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.vdc-postcode-result,
.vdc-date-result {
	margin: 8px 0 0;
	font-size: 0.88em;
	line-height: 1.4;
}

.vdc-postcode-result:empty,
.vdc-date-result:empty {
	margin: 0;
}

.vdc-postcode-result.vdc-ok,
.vdc-date-result.vdc-ok {
	color: var(--vdc-ok);
}

.vdc-postcode-result.vdc-error,
.vdc-date-result.vdc-error {
	color: var(--vdc-error);
}
