/**
 * Cart + checkout: modern, full-width shipping options.
 * WooCommerce renders the methods inside a totals-table row
 * (tr.woocommerce-shipping-totals), which squeezes them into the value
 * cell - stack the row instead and style each method as a card.
 */

/* Stack the shipping row: heading above, options below, full table width */
.woocommerce table.shop_table tr.woocommerce-shipping-totals.shipping {
	display: block;
}

.woocommerce table.shop_table tr.woocommerce-shipping-totals.shipping > th,
.woocommerce table.shop_table tr.woocommerce-shipping-totals.shipping > td {
	display: block;
	width: 100%;
	text-align: start;
	padding-left: 0;
	padding-right: 0;
	border: none;
}

.woocommerce table.shop_table tr.woocommerce-shipping-totals.shipping > th {
	padding-bottom: 6px;
	font-size: 15px;
	font-weight: 600;
}

/* The options list */
ul#shipping_method.woocommerce-shipping-methods {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
	width: min(440px, 80vw);
}

ul#shipping_method.woocommerce-shipping-methods li {
	margin: 0;
	padding: 0;
	position: relative;
}

/* Hide the native radio - the card + custom dot replace it */
ul#shipping_method.woocommerce-shipping-methods li > input.shipping_method[type="radio"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	margin: 0;
	pointer-events: none;
}

/* Each method is a full-width selectable card */
ul#shipping_method.woocommerce-shipping-methods li > label {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	margin: 0;
	padding: 12px 14px;
	background-color: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	cursor: pointer;
	font-size: 15px;
	line-height: 1.4;
	color: #1f2937;
	box-sizing: border-box;
	transition: border-color 0.15s ease, background-color 0.15s ease,
		box-shadow 0.15s ease;
}

ul#shipping_method.woocommerce-shipping-methods li:hover > label {
	border-color: #9ca3af;
}

/* Custom radio dot (only when there is an actual radio to toggle) */
ul#shipping_method.woocommerce-shipping-methods
	li
	> input.shipping_method[type="radio"]
	+ label::before {
	content: "";
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border: 2px solid #d1d5db;
	border-radius: 50%;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Selected state */
ul#shipping_method.woocommerce-shipping-methods
	li
	> input.shipping_method[type="radio"]:checked
	+ label {
	border-color: #111827;
	background-color: #f9fafb;
	box-shadow: 0 0 0 1px #111827;
}

ul#shipping_method.woocommerce-shipping-methods
	li
	> input.shipping_method[type="radio"]:checked
	+ label::before {
	border-color: #111827;
	box-shadow: inset 0 0 0 4px #fff;
	background-color: #111827;
}

/* Price pushed to the far end of the card */
ul#shipping_method.woocommerce-shipping-methods li > label .woocommerce-Price-amount {
	margin-inline-start: auto;
	font-weight: 700;
	color: #111827;
}

/* Extra method descriptions added by shipping plugins below the card */
ul#shipping_method.woocommerce-shipping-methods li > label ~ *:not(input) {
	display: block;
	margin: 4px 2px 0;
	font-size: 13px;
	color: #6b7280;
}

/* Destination note under the options (cart) */
.woocommerce table.shop_table tr.woocommerce-shipping-totals.shipping .woocommerce-shipping-destination {
	margin-top: 10px;
	font-size: 13px;
	color: #6b7280;
}

/* Cart: collapsed shipping list — only the selected method is visible */
.woocommerce-cart tr.woocommerce-shipping-totals td > ul.woocommerce-shipping-methods:has(> li:nth-child(2))
	> li:not(:has(> input.shipping_method:checked)) {
	display: none;
}

.buldog-shipping-methods-wrap.buldog-shipping-collapsed:not(.buldog-shipping-expanded)
	ul.woocommerce-shipping-methods
	li:not(:has(input.shipping_method:checked)) {
	display: none;
}

.buldog-shipping-methods-wrap.buldog-shipping-expanded ul.woocommerce-shipping-methods > li {
	display: block;
}

.buldog-shipping-methods-wrap {
	width: min(440px, 80vw);
}

.buldog-shipping-change-btn {
	display: inline-block;
	margin-top: 10px;
	padding: 0.65em 1.35em;
	border: 1px solid #e23434;
	border-radius: 50px;
	background-color: #e23434;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	color: #fff;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.buldog-shipping-change-btn:hover,
.buldog-shipping-change-btn:focus {
	background-color: #ef4848;
	border-color: #c42a2a;
	color: #fff;
}

.buldog-shipping-methods-wrap.buldog-shipping-expanded .buldog-shipping-change-btn {
	display: inline-block;
}
