/**
 * YBD Modal COD - Frontend
 */

/* ---------- Botón ---------- */
.ybd-mcod-button-wrap {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 100%;
	margin-top: 12px;
}

.ybd-mcod-qty {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	font-weight: 600;
}

.ybd-mcod-qty input {
	width: 90px;
	padding: 8px 10px;
	border: 1px solid #d7dbe0;
	border-radius: 8px;
	background: #fff;
}

.ybd-mcod-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: var(--ybd-btn-width, 100%);
	max-width: 100%;
	padding: 16px 22px;
	border: 0;
	border-radius: var(--ybd-btn-radius, 10px);
	background: var(--ybd-btn-bg, #25d366);
	color: var(--ybd-btn-color, #fff);
	font-family: inherit;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	box-shadow: 0 12px 28px rgba(0, 0, 0, .16), inset 0 1px 0 rgba(255, 255, 255, .18);
	transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
	-webkit-tap-highlight-color: transparent;
}

.ybd-mcod-button:hover {
	transform: translateY(-1px);
	filter: brightness(1.04);
	box-shadow: 0 16px 34px rgba(0, 0, 0, .2), inset 0 1px 0 rgba(255, 255, 255, .22);
	color: var(--ybd-btn-color, #fff);
}

.ybd-mcod-button:active {
	transform: translateY(0);
	filter: brightness(.97);
}

.ybd-mcod-button:disabled {
	opacity: .7;
	cursor: wait;
}

.ybd-mcod-button-content {
	display: inline-flex;
	align-items: center;
	gap: 12px;
}

.ybd-mcod-icon {
	width: 24px;
	height: 24px;
	flex: 0 0 auto;
}

.ybd-mcod-button-text {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	line-height: 1.15;
}

.ybd-mcod-button-text strong {
	font-weight: 800;
}

.ybd-mcod-button-text small {
	margin-top: 4px;
	font-size: .7em;
	font-weight: 500;
	opacity: .92;
	letter-spacing: .03em;
}

/* Ocultar el botón nativo solo si JS está activo */
form.cart.ybd-mcod-active .single_add_to_cart_button,
form.cart.ybd-mcod-active button[name="add-to-cart"] {
	display: none !important;
}

form.ybd-mcod-active.ybd-mcod-hide-qty .quantity {
	display: none !important;
}

/* Cantidad nativa de WooCommerce, alineada con el nuevo diseño */
form.cart.ybd-mcod-active .ybd-mcod-qty-label {
	display: block;
	margin: 0 0 6px;
	font-size: 14px;
	font-weight: 700;
	color: #2c333c;
}

form.cart.ybd-mcod-active .quantity {
	display: inline-flex;
	align-items: center;
	margin: 0 0 4px;
}

form.cart.ybd-mcod-active .quantity input.qty {
	width: 92px;
	min-height: 48px;
	padding: 12px 14px;
	border: 1px solid #d7dbe0;
	border-radius: 12px;
	background: #fff;
	color: #12161c;
	font-size: 16px;
	line-height: 1.3;
	text-align: center;
}

/* ---------- Modal ---------- */
.ybd-mcod-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.ybd-mcod-modal.is-open {
	display: flex;
}

.ybd-mcod-overlay {
	position: absolute;
	inset: 0;
	background: rgba(12, 16, 22, .62);
	backdrop-filter: blur(3px);
}

.ybd-mcod-dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 720px;
	max-height: calc(100vh - 32px);
	overflow: hidden;
	border-top: 4px solid var(--ybd-accent, #25d366);
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 32px 90px rgba(0, 0, 0, .32);
	-webkit-font-smoothing: antialiased;
	animation: ybd-mcod-in .22s ease both;
}

.ybd-mcod-dialog-content {
	max-height: calc(100vh - 36px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

body.ybd-mcod-lock {
	overflow: hidden;
}

@keyframes ybd-mcod-in {
	from { opacity: 0; transform: translateY(12px) scale(.985); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Cabecera ---------- */
.ybd-mcod-header {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 20px 26px;
	background: #fff;
	border-bottom: 1px solid #eef0f3;
}

.ybd-mcod-header h2 {
	margin: 0;
	font-size: 22px;
	font-weight: 800;
	line-height: 1.25;
	color: #12161c;
}

.ybd-mcod-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: #f2f4f7;
	color: #3b4450;
	font-size: 27px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
}

.ybd-mcod-close:hover {
	background: #e6e9ee;
}

/* ---------- Cuerpo ---------- */
.ybd-mcod-body {
	padding: 22px 26px 26px;
}

.ybd-mcod-hero,
.ybd-mcod-footer-banner {
	display: block;
	width: 100%;
	background: #f3f4f6;
}

.ybd-mcod-hero img,
.ybd-mcod-footer-banner img {
	display: block;
	width: 100%;
	height: auto;
}

/* ---------- Carrito ---------- */
.ybd-mcod-cart-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
}

.ybd-mcod-cart-table td {
	padding: 14px 8px;
	border-bottom: 1px solid #eef0f3;
	vertical-align: middle;
}

.ybd-mcod-cart-table tr:last-child td {
	border-bottom: 0;
}

.ybd-mcod-cart-image img {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 12px;
	display: block;
}

.ybd-mcod-cart-info {
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-size: 15px;
}

.ybd-mcod-cart-name {
	font-weight: 700;
	color: #12161c;
	line-height: 1.35;
}

.ybd-mcod-cart-qty,
.ybd-mcod-cart-info .variation {
	font-size: 13px;
	color: #6b7480;
}

.ybd-mcod-cart-subtotal {
	text-align: right;
	font-size: 15px;
	font-weight: 700;
	white-space: nowrap;
	color: #12161c;
}

.ybd-mcod-cart-remove {
	width: 34px;
	text-align: center;
}

.ybd-mcod-remove {
	width: 30px;
	height: 30px;
	border: 0;
	border-radius: 50%;
	background: #fff0f0;
	color: #d93025;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease;
}

.ybd-mcod-remove:hover {
	background: #ffe0e0;
}

/* ---------- Totales ---------- */
.ybd-mcod-totals {
	margin: 16px 0 20px;
	padding: 14px 18px;
	border-radius: 14px;
	background: #f7f8fa;
}

.ybd-mcod-total-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 5px 0;
	font-size: 15px;
	color: #4a535f;
}

.ybd-mcod-total-final {
	margin-top: 6px;
	padding-top: 12px;
	border-top: 1px solid #e3e7ec;
	font-size: 19px;
	font-weight: 800;
	color: #12161c;
}

.ybd-mcod-total-final .woocommerce-Price-amount {
	color: var(--ybd-accent, #25d366);
}

/* ---------- Formulario ---------- */
.ybd-mcod-form {
	margin: 0;
}

.ybd-mcod-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px 18px;
}

.ybd-mcod-field {
	display: flex;
	flex-direction: column;
	gap: 7px;
	min-width: 0;
}

.ybd-mcod-field--full {
	grid-column: 1 / -1;
}

.ybd-mcod-field label {
	font-size: 14px;
	font-weight: 700;
	color: #2c333c;
}

.ybd-mcod-req {
	color: #d93025;
	font-weight: 800;
}

.ybd-mcod-field input,
.ybd-mcod-field select,
.ybd-mcod-field textarea {
	width: 100%;
	box-sizing: border-box;
	min-height: 50px;
	padding: 14px 16px;
	border: 1px solid #d7dbe0;
	border-radius: 12px;
	background: #fff;
	color: #12161c;
	font-family: inherit;
	font-size: 16px;
	line-height: 1.35;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.ybd-mcod-field select {
	padding-right: 40px;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='m6 9 6 6 6-6' stroke='%23555f6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
}

.ybd-mcod-field textarea {
	resize: vertical;
	min-height: 80px;
}

.ybd-mcod-field input:focus,
.ybd-mcod-field select:focus,
.ybd-mcod-field textarea:focus {
	outline: none;
	border-color: var(--ybd-accent, #25d366);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ybd-accent, #25d366) 20%, transparent);
}

.ybd-mcod-field .is-invalid {
	border-color: #d93025;
	box-shadow: 0 0 0 3px rgba(217, 48, 37, .12);
}

/* ---------- Envío ---------- */
.ybd-mcod-shipping-methods {
	margin: 14px 0 4px;
}

.ybd-mcod-shipping-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ybd-mcod-shipping-option {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 13px 15px;
	border: 1px solid #d7dbe0;
	border-radius: 12px;
	cursor: pointer;
	font-size: 15px;
	transition: border-color .15s ease, background .15s ease;
}

.ybd-mcod-shipping-option:hover {
	border-color: var(--ybd-accent, #25d366);
}

.ybd-mcod-shipping-option:has(input:checked) {
	border-color: var(--ybd-accent, #25d366);
	background: color-mix(in srgb, var(--ybd-accent, #25d366) 7%, #fff);
}

.ybd-mcod-shipping-option input {
	accent-color: var(--ybd-accent, #25d366);
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
}

.ybd-mcod-shipping-label {
	flex: 1 1 auto;
	min-width: 0;
}

.ybd-mcod-shipping-price {
	font-weight: 700;
	white-space: nowrap;
}

.ybd-mcod-no-shipping {
	margin: 12px 0 0;
	padding: 10px 12px;
	border-radius: 10px;
	background: #fff4e5;
	color: #8a4b00;
	font-size: 13px;
}

/* ---------- Términos ---------- */
.ybd-mcod-terms {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 16px 0 8px;
	font-size: 14px;
	line-height: 1.45;
	color: #3b4450;
	cursor: pointer;
}

.ybd-mcod-terms input {
	width: 18px;
	height: 18px;
	margin: 1px 0 0;
	accent-color: var(--ybd-accent, #25d366);
	flex: 0 0 auto;
}

.ybd-mcod-terms a {
	color: var(--ybd-accent, #25d366);
	text-decoration: underline;
}

/* ---------- Errores ---------- */
.ybd-mcod-error {
	display: none;
	margin: 12px 0 0;
	padding: 12px 14px;
	border-radius: 12px;
	background: #fdecea;
	color: #a61b16;
	font-size: 14px;
	line-height: 1.45;
}

.ybd-mcod-error.is-visible {
	display: block;
}

/* ---------- Botón submit ---------- */
.ybd-mcod-submit {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	margin-top: 16px;
	padding: 17px 22px;
	border: 0;
	border-radius: var(--ybd-btn-radius, 10px);
	background: var(--ybd-accent, #25d366);
	color: #fff;
	font-family: inherit;
	font-size: 18px;
	font-weight: 800;
	cursor: pointer;
	transition: filter .15s ease, transform .15s ease;
}

.ybd-mcod-submit:hover {
	filter: brightness(1.04);
	transform: translateY(-1px);
}

.ybd-mcod-submit:disabled {
	opacity: .75;
	cursor: wait;
	transform: none;
}

.ybd-mcod-submit-spinner {
	display: none;
	width: 18px;
	height: 18px;
	margin-left: 10px;
	border: 2px solid rgba(255, 255, 255, .45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ybd-mcod-spin .8s linear infinite;
}

.ybd-mcod-submit.is-loading .ybd-mcod-submit-spinner {
	display: inline-block;
}

.ybd-mcod-secure {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	margin: 14px 0 0;
	font-size: 13px;
	color: #7b8490;
}

.ybd-mcod-secure svg {
	width: 16px;
	height: 16px;
}

/* ---------- Honeypot ---------- */
.ybd-mcod-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

/* ---------- Loader ---------- */
.ybd-mcod-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 60px 20px;
}

.ybd-mcod-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid #e3e7ec;
	border-top-color: var(--ybd-accent, #25d366);
	border-radius: 50%;
	animation: ybd-mcod-spin .8s linear infinite;
}

@keyframes ybd-mcod-spin {
	to { transform: rotate(360deg); }
}

/* ---------- Toast ---------- */
.ybd-mcod-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 1000000;
	max-width: min(92vw, 420px);
	padding: 12px 16px;
	border-radius: 10px;
	background: #12161c;
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
	transform: translate(-50%, 16px);
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}

.ybd-mcod-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ---------- Shortcode ---------- */
.ybd-mcod-shortcode {
	max-width: 520px;
}

.ybd-mcod-shortcode .variations {
	width: 100%;
	margin-bottom: 10px;
}

.ybd-mcod-shortcode .variations th,
.ybd-mcod-shortcode .variations td {
	padding: 6px 0;
	text-align: left;
	vertical-align: middle;
}

.ybd-mcod-shortcode .variations select {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #d7dbe0;
	border-radius: 10px;
	background: #fff;
	font-size: 15px;
}

.ybd-mcod-shortcode .woocommerce-variation-price {
	margin: 6px 0;
	font-weight: 700;
}

.ybd-mcod-shortcode-placeholder {
	display: inline-block;
	padding: 6px 10px;
	border: 1px dashed #b9c0c9;
	border-radius: 6px;
	background: #f7f8fa;
	color: #6b7480;
	font-size: 12px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
	.ybd-mcod-modal {
		padding: 10px;
		align-items: flex-end;
	}

	.ybd-mcod-dialog {
		max-width: none;
		max-height: calc(100vh - 20px);
		max-height: calc(100dvh - 20px);
		border-radius: 20px 20px 0 0;
	}

	.ybd-mcod-dialog-content {
		max-height: calc(100vh - 24px);
		max-height: calc(100dvh - 24px);
	}

	.ybd-mcod-grid {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.ybd-mcod-header {
		padding: 16px 18px;
	}

	.ybd-mcod-header h2 {
		font-size: 20px;
	}

	.ybd-mcod-body {
		padding: 18px 18px 22px;
	}

	.ybd-mcod-cart-image img {
		width: 54px;
		height: 54px;
	}

	.ybd-mcod-field input,
	.ybd-mcod-field select,
	.ybd-mcod-field textarea {
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ybd-mcod-dialog,
	.ybd-mcod-submit-spinner,
	.ybd-mcod-spinner {
		animation: none;
	}

	.ybd-mcod-button,
	.ybd-mcod-submit,
	.ybd-mcod-toast {
		transition: none;
	}
}
