/**
 * WooCommerce Direct Popup Checkout — frontend styles.
 * Primary color and radius are injected as CSS variables from settings.
 */

:root {
	--wdpc-primary: #15803d;
	--wdpc-radius: 14px;
	--wdpc-text: #1f2937;
	--wdpc-muted: #6b7280;
	--wdpc-border: #d1d5db;
	--wdpc-bg: #ffffff;
	--wdpc-error: #dc2626;
	--wdpc-success-bg: #dcfce7;
	--wdpc-success-text: #166534;
	--wdpc-overlay: rgba(17, 24, 39, 0.6);
}

/* ---------- Overlay ---------- */

.wdpc-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: var(--wdpc-overlay);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.wdpc-overlay.wdpc-open {
	display: flex;
}

/* ---------- Modal ---------- */

.wdpc-modal {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: 24px 22px 22px;
	background: var(--wdpc-bg);
	border-radius: var(--wdpc-radius);
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
	color: var(--wdpc-text);
	box-sizing: border-box;
}

.wdpc-animated .wdpc-modal {
	animation: wdpc-pop 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes wdpc-pop {
	from {
		opacity: 0;
		transform: translateY(14px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wdpc-animated .wdpc-modal {
		animation: none;
	}
}

/* ---------- Close button ---------- */

.wdpc-close {
	position: absolute;
	top: 10px;
	right: 12px;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--wdpc-muted);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.wdpc-close:hover,
.wdpc-close:focus {
	background: #f3f4f6;
	color: var(--wdpc-text);
	outline: none;
}

/* ---------- Title & product summary ---------- */

.wdpc-title {
	margin: 0 24px 14px 0;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--wdpc-text);
}

.wdpc-product {
	margin-bottom: 16px;
	padding: 12px 14px;
	background: #f9fafb;
	border: 1px solid var(--wdpc-border);
	border-radius: calc(var(--wdpc-radius) / 2);
	font-size: 14px;
	line-height: 1.5;
}

.wdpc-product:empty {
	display: none;
}

.wdpc-product .wdpc-product-name {
	font-weight: 600;
	display: block;
}

.wdpc-product .wdpc-product-total {
	color: var(--wdpc-primary);
	font-weight: 700;
}

/* ---------- Shipment options ---------- */

.wdpc-shipment {
	margin: 0 0 12px;
	padding: 10px 14px 12px;
	border: 1px solid var(--wdpc-border);
	border-radius: calc(var(--wdpc-radius) / 2);
}

.wdpc-shipment legend {
	padding: 0 6px;
	font-size: 14px;
	font-weight: 600;
	color: var(--wdpc-text);
}

.wdpc-ship-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 6px 0;
	font-size: 14px;
	cursor: pointer;
}

.wdpc-ship-label {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--wdpc-text);
}

.wdpc-ship-option input[type="radio"] {
	margin: 0;
	accent-color: var(--wdpc-primary);
	width: 16px;
	height: 16px;
}

.wdpc-ship-cost {
	font-weight: 600;
	color: var(--wdpc-text);
	white-space: nowrap;
}

.wdpc-total {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 0 14px;
	padding: 10px 14px;
	border: 1px solid var(--wdpc-border);
	border-radius: calc(var(--wdpc-radius) / 2);
	background: #f9fafb;
}

.wdpc-total-label {
	font-size: 15px;
	font-weight: 700;
}

.wdpc-total-amount {
	font-size: 17px;
	font-weight: 700;
	color: var(--wdpc-primary);
}

/* ---------- Fields ---------- */

.wdpc-field {
	margin: 0 0 14px;
}

.wdpc-field label {
	display: block;
	margin-bottom: 5px;
	font-size: 14px;
	font-weight: 600;
	color: var(--wdpc-text);
}

.wdpc-req {
	color: var(--wdpc-error);
}

.wdpc-field input,
.wdpc-field textarea {
	width: 100%;
	padding: 11px 12px;
	border: 1px solid var(--wdpc-border);
	border-radius: calc(var(--wdpc-radius) / 2);
	background: var(--wdpc-bg);
	color: var(--wdpc-text);
	font-size: 15px;
	line-height: 1.4;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wdpc-field textarea {
	resize: vertical;
	min-height: 74px;
}

.wdpc-field input:focus,
.wdpc-field textarea:focus {
	border-color: var(--wdpc-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wdpc-primary) 18%, transparent);
	outline: none;
}

.wdpc-field.wdpc-has-error input,
.wdpc-field.wdpc-has-error textarea {
	border-color: var(--wdpc-error);
}

.wdpc-error {
	display: none;
	margin-top: 4px;
	font-size: 13px;
	color: var(--wdpc-error);
}

.wdpc-error.wdpc-visible {
	display: block;
}

/* Honeypot — hidden from humans, visible to bots. */
.wdpc-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Messages ---------- */

.wdpc-msg {
	display: none;
	margin: 0 0 12px;
	padding: 10px 12px;
	border-radius: calc(var(--wdpc-radius) / 2);
	font-size: 14px;
	line-height: 1.5;
}

.wdpc-msg.wdpc-visible {
	display: block;
}

.wdpc-msg.wdpc-msg-success {
	background: var(--wdpc-success-bg);
	color: var(--wdpc-success-text);
	border: 1px solid #86efac;
}

.wdpc-msg.wdpc-msg-error {
	background: #fef2f2;
	color: var(--wdpc-error);
	border: 1px solid #fecaca;
}

/* ---------- Submit button ---------- */

.wdpc-submit {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 13px 16px;
	border: 0;
	border-radius: calc(var(--wdpc-radius) / 2);
	background: var(--wdpc-primary);
	color: #ffffff;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.1s ease;
}

.wdpc-submit:hover:not(:disabled) {
	filter: brightness(1.08);
}

.wdpc-submit:active:not(:disabled) {
	transform: scale(0.99);
}

.wdpc-submit:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.wdpc-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: wdpc-spin 0.7s linear infinite;
}

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

/* ---------- Body lock while popup open ---------- */

body.wdpc-locked {
	overflow: hidden;
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
	.wdpc-overlay {
		padding: 10px;
		align-items: flex-end;
	}

	.wdpc-modal {
		max-width: 100%;
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;
		padding: 20px 16px 18px;
	}

	.wdpc-title {
		font-size: 18px;
	}
}
