/* COD Quick Order — Frontend Styles */

.codqo-wrapper {
	margin-top: 12px;
	clear: both;
}

.codqo-cod-button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	border-radius: 4px;
	padding: 12px 20px;
	font-weight: 600;
	border: 2px solid transparent;
	transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.codqo-cod-button .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.codqo-fee-note {
	font-size: 0.85em;
	color: #666;
	margin: 6px 0 0;
}

.codqo-button-emoji {
	font-size: 1.1em;
	line-height: 1;
}

.codqo-button-icon-img {
	width: 18px;
	height: 18px;
	object-fit: contain;
	vertical-align: middle;
}

/* Body-level rule: hide native Add to Cart button when a product is COD-only,
   while keeping quantity / variation selectors intact. */
body.codqo-hide-addtocart form.cart button.single_add_to_cart_button,
body.codqo-hide-addtocart form.cart .single_add_to_cart_button {
	display: none !important;
}

/* -----------------------------------------------------------------------
 * Inline order form
 * -------------------------------------------------------------------- */

.codqo-form-container {
	margin-top: 16px;
	max-width: 480px;
}

.codqo-order-form {
	padding: 20px;
	border: 1px solid var(--codqo-form-border, #e2e2e2);
	border-radius: 8px;
	background: var(--codqo-form-bg, #fafafa);
}

.codqo-form-title {
	margin-top: 0;
	font-size: 1.1em;
}

.codqo-product-preview {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	margin-bottom: 14px;
	padding-bottom: 14px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.codqo-product-preview__image img {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 6px;
	display: block;
}

.codqo-product-preview__info {
	flex: 1;
	min-width: 0;
}

.codqo-product-preview__name {
	display: block;
	font-size: 0.98em;
	margin-bottom: 2px;
}

.codqo-product-preview__price {
	display: block;
	font-size: 0.9em;
	color: #555;
	margin-bottom: 6px;
}

.codqo-variation-picker {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.codqo-variation-field label {
	display: block;
	font-size: 0.82em;
	font-weight: 600;
	margin-bottom: 3px;
	text-transform: capitalize;
}

.codqo-variation-field select {
	width: 100%;
	padding: 6px 8px;
	border: 1px solid #ccc;
	border-radius: var(--codqo-field-radius, 4px);
	box-sizing: border-box;
}

.codqo-form-messages {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-radius: 4px;
	margin-bottom: 12px;
	font-size: 0.92em;
}

.codqo-form-messages.codqo-error {
	display: flex;
	background: #fdecea;
	color: #611a15;
	border: 1px solid #f5c6cb;
}

.codqo-form-messages.codqo-success {
	display: flex;
	background: #e8f5e9;
	color: #1b5e20;
	border: 1px solid #c8e6c9;
}

.codqo-success-check {
	display: none;
	width: 22px;
	height: 22px;
	flex-shrink: 0;
}

.codqo-form-messages.codqo-success .codqo-success-check {
	display: block;
}

.codqo-success-check__circle {
	stroke: #2e7d32;
	stroke-width: 3;
	stroke-miterlimit: 10;
	stroke-dasharray: 151;
	stroke-dashoffset: 151;
	animation: codqo-check-circle 0.5s ease-out forwards;
}

.codqo-success-check__mark {
	stroke: #2e7d32;
	stroke-width: 4;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 32;
	stroke-dashoffset: 32;
	animation: codqo-check-mark 0.35s 0.35s ease-out forwards;
}

@keyframes codqo-check-circle {
	to { stroke-dashoffset: 0; }
}
@keyframes codqo-check-mark {
	to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.codqo-success-check__circle,
	.codqo-success-check__mark {
		animation: none;
		stroke-dashoffset: 0;
	}
}

.codqo-field-row {
	margin-bottom: 12px;
}

.codqo-field-row label {
	display: block;
	font-weight: 600;
	margin-bottom: 4px;
	font-size: 0.9em;
}

.codqo-field-row input[type="text"],
.codqo-field-row input[type="tel"],
.codqo-field-row input[type="email"],
.codqo-field-row input[type="number"],
.codqo-field-row select {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #ccc;
	border-radius: var(--codqo-field-radius, 4px);
	box-sizing: border-box;
}

.codqo-field-row input.codqo-invalid,
.codqo-field-row select.codqo-invalid {
	border-color: #d63638;
	background: #fff8f8;
}

.codqo-field-error {
	color: #d63638;
	font-size: 0.8em;
	margin-top: 4px;
	display: block;
}

.codqo-field-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.required {
	color: #d63638;
}

.codqo-variation-note {
	font-size: 0.85em;
	color: #8a6d3b;
	background: #fcf8e3;
	border: 1px solid #faebcc;
	padding: 8px 10px;
	border-radius: 4px;
}

.codqo-actions {
	display: flex;
	gap: 10px;
	align-items: center;
}

.codqo-privacy-note {
	font-size: 0.78em;
	color: #888;
	margin-top: 10px;
	margin-bottom: 0;
}

.codqo-submit-button[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

@media (max-width: 480px) {
	.codqo-field-grid {
		grid-template-columns: 1fr;
	}
	.codqo-form-container {
		max-width: 100%;
	}
}

/* -----------------------------------------------------------------------
 * Animation presets — subtle and accessible by design.
 * All respect prefers-reduced-motion.
 * -------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {

	.codqo-anim-pulse {
		animation: codqo-pulse 2.2s ease-in-out infinite;
	}
	@keyframes codqo-pulse {
		0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.35); }
		50% { box-shadow: 0 0 0 8px rgba(46, 125, 50, 0); }
	}

	.codqo-anim-glow {
		animation: codqo-glow 2.4s ease-in-out infinite;
	}
	@keyframes codqo-glow {
		0%, 100% { box-shadow: 0 0 4px rgba(46, 125, 50, 0.4); }
		50% { box-shadow: 0 0 14px rgba(46, 125, 50, 0.75); }
	}

	.codqo-anim-gradient {
		background-size: 200% 200%;
		background-image: linear-gradient(90deg, currentColor 0%, transparent 100%);
		animation: codqo-gradient 3s ease infinite;
	}
	@keyframes codqo-gradient {
		0% { background-position: 0% 50%; }
		50% { background-position: 100% 50%; }
		100% { background-position: 0% 50%; }
	}

	.codqo-anim-snake {
		position: relative;
		overflow: hidden;
	}
	.codqo-anim-snake::before {
		content: "";
		position: absolute;
		inset: -2px;
		border-radius: 6px;
		background: conic-gradient(from 0deg, transparent 0%, rgba(255,255,255,0.9) 8%, transparent 16%);
		animation: codqo-snake 2.6s linear infinite;
		pointer-events: none;
	}
	@keyframes codqo-snake {
		to { transform: rotate(360deg); }
	}

	/* A tasteful, very small rotation — deliberately NOT a large screen-shake,
	   which hurts usability and accessibility. */
	.codqo-anim-wiggle {
		animation: codqo-wiggle 3.2s ease-in-out infinite;
	}
	@keyframes codqo-wiggle {
		0%, 92%, 100% { transform: rotate(0deg); }
		94% { transform: rotate(-1.5deg); }
		96% { transform: rotate(1.5deg); }
		98% { transform: rotate(-1deg); }
	}

	/* "Shake" kept intentionally tiny (2px max offset) — a gentle nudge,
	   not a distracting vibration. */
	.codqo-anim-shake {
		animation: codqo-shake 3.5s ease-in-out infinite;
	}
	@keyframes codqo-shake {
		0%, 90%, 100% { transform: translateX(0); }
		91% { transform: translateX(-2px); }
		93% { transform: translateX(2px); }
		95% { transform: translateX(-1px); }
		97% { transform: translateX(1px); }
	}

	.codqo-anim-bounce {
		animation: codqo-bounce 2.8s ease-in-out infinite;
	}
	@keyframes codqo-bounce {
		0%, 80%, 100% { transform: translateY(0); }
		90% { transform: translateY(-4px); }
	}

	/* A soft diagonal light sweep across the button. */
	.codqo-anim-shine {
		position: relative;
		overflow: hidden;
	}
	.codqo-anim-shine::after {
		content: "";
		position: absolute;
		top: 0;
		left: -60%;
		width: 40%;
		height: 100%;
		background: linear-gradient(120deg, transparent, rgba(255,255,255,0.55), transparent);
		animation: codqo-shine 3s ease-in-out infinite;
		pointer-events: none;
	}
	@keyframes codqo-shine {
		0% { left: -60%; }
		40%, 100% { left: 130%; }
	}

	/* Ripple only fires on click via JS (.codqo-ripple-effect); this class
	   just prepares the button to contain it. */
	.codqo-anim-ripple {
		position: relative;
		overflow: hidden;
	}

	/* A very small, continuous vibration — distinct from "shake" by being
	   faster and multi-axis, but still capped at ~1px so it stays gentle
	   and accessible rather than a jarring "screen shake". */
	.codqo-anim-vibration {
		animation: codqo-vibration 0.35s ease-in-out infinite;
	}
	@keyframes codqo-vibration {
		0%, 100% { transform: translate(0, 0); }
		25% { transform: translate(1px, -1px); }
		50% { transform: translate(-1px, 1px); }
		75% { transform: translate(1px, 1px); }
	}

	/* A colorful rainbow streak chasing around the button's edge — same
	   "traveling border highlight" technique as the snake preset, just
	   with a full-spectrum arc instead of a single white highlight. The
	   button's own background/text stay fully visible underneath. */
	.codqo-anim-rainbow {
		position: relative;
		overflow: hidden;
	}
	.codqo-anim-rainbow::before {
		content: "";
		position: absolute;
		inset: -2px;
		border-radius: inherit;
		background: conic-gradient(
			from 0deg,
			transparent 0%,
			#ff0000 4%,
			#ff9900 9%,
			#ffee00 14%,
			#33cc33 19%,
			#3399ff 24%,
			#9933ff 29%,
			transparent 34%
		);
		animation: codqo-rainbow-spin 2.8s linear infinite;
		pointer-events: none;
	}
	@keyframes codqo-rainbow-spin {
		to { transform: rotate(360deg); }
	}
}

.codqo-ripple-effect {
	position: absolute;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.55);
	transform: scale(0);
	animation: codqo-ripple-grow 0.6s ease-out;
	pointer-events: none;
}
@keyframes codqo-ripple-grow {
	to {
		transform: scale(2.5);
		opacity: 0;
	}
}

/* When the OS/browser requests reduced motion, all animation classes
   fall back to a static button — accessibility takes priority. */
@media (prefers-reduced-motion: reduce) {
	.codqo-anim-pulse,
	.codqo-anim-glow,
	.codqo-anim-gradient,
	.codqo-anim-snake,
	.codqo-anim-wiggle,
	.codqo-anim-shake,
	.codqo-anim-bounce,
	.codqo-anim-shine,
	.codqo-anim-vibration,
	.codqo-anim-rainbow {
		animation: none !important;
	}
	.codqo-anim-snake::before,
	.codqo-anim-shine::after,
	.codqo-anim-rainbow::before {
		display: none !important;
	}
}

/* -----------------------------------------------------------------------
 * Sticky mobile bar
 * -------------------------------------------------------------------- */

.codqo-sticky-bar {
	display: none;
}

@media (max-width: 782px) {
	body.codqo-has-sticky-bar .codqo-sticky-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 9999;
		padding: 10px 14px;
		background: #fff;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
	}
	body.codqo-has-sticky-bar .codqo-sticky-bar__price {
		font-weight: 700;
		white-space: nowrap;
	}
	body.codqo-has-sticky-bar .codqo-sticky-bar__button {
		flex: 1;
		justify-content: center;
		margin: 0;
	}
	/* Prevent the sticky bar from covering page content. */
	body.codqo-has-sticky-bar {
		padding-bottom: 64px;
	}
}

/* -----------------------------------------------------------------------
 * Popup / modal form mode
 * -------------------------------------------------------------------- */

.codqo-wrapper[data-display="modal"] .codqo-form-container {
	margin-top: 0;
	max-width: none;
}

.codqo-wrapper[data-display="modal"] .codqo-modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: rgba(0, 0, 0, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.codqo-wrapper[data-display="modal"] .codqo-order-form {
	position: relative;
	width: 100%;
	max-width: 480px;
	max-height: 90vh;
	overflow-y: auto;
	border-radius: 12px;
	padding: 30px 24px 22px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.codqo-modal-close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: none;
	border: none;
	font-size: 26px;
	line-height: 1;
	color: #888;
	cursor: pointer;
	padding: 4px 8px;
}

.codqo-modal-close:hover {
	color: #222;
}

body.codqo-modal-open {
	overflow: hidden;
}

/* -----------------------------------------------------------------------
 * Payment method badges (product cards on shop/category/tag archives)
 * -------------------------------------------------------------------- */

.codqo-payment-badges {
	display: flex;
	gap: 6px;
	margin: 6px 0;
	flex-wrap: wrap;
}

.codqo-badge {
	display: inline-block;
	color: #fff;
	font-size: 0.7em;
	font-weight: 700;
	letter-spacing: 0.03em;
	padding: 3px 9px;
	border-radius: 999px;
	text-transform: uppercase;
	line-height: 1.4;
}

/* -----------------------------------------------------------------------
 * Success popup — shown after a COD order is placed, auto-closes itself
 * -------------------------------------------------------------------- */

.codqo-success-popup {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 100050;
}

.codqo-success-popup.is-visible {
	display: block;
}

.codqo-success-popup__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	animation: codqo-popup-fade-in 0.25s ease;
}

.codqo-success-popup__card {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(1);
	width: 90%;
	max-width: 400px;
	background: #fff;
	border-radius: 16px;
	padding: 34px 28px 26px;
	text-align: center;
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
	animation: codqo-popup-pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
	overflow: hidden;
}

.codqo-success-popup__card::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 5px;
	background: linear-gradient(90deg, #2e7d32, #43a047, #2e7d32);
	background-size: 200% 100%;
	animation: codqo-popup-shimmer 2.5s linear infinite;
}

.codqo-success-popup__close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	color: #aaa;
	cursor: pointer;
	padding: 4px 8px;
}

.codqo-success-popup__close:hover {
	color: #333;
}

.codqo-success-popup__icon {
	width: 68px;
	height: 68px;
	margin: 0 auto 14px;
}

.codqo-success-popup__icon svg {
	width: 100%;
	height: 100%;
}

.codqo-success-popup__circle {
	stroke: #2e7d32;
	stroke-width: 3;
	stroke-miterlimit: 10;
	stroke-dasharray: 151;
	stroke-dashoffset: 151;
	animation: codqo-check-circle 0.5s ease-out forwards;
}

.codqo-success-popup__check {
	stroke: #2e7d32;
	stroke-width: 4;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 32;
	stroke-dashoffset: 32;
	animation: codqo-check-mark 0.35s 0.4s ease-out forwards;
}

.codqo-success-popup__title {
	margin: 0 0 8px;
	font-size: 1.3em;
	color: #1b1b1b;
}

.codqo-success-popup__message {
	margin: 0 0 18px;
	color: #555;
	font-size: 0.95em;
	line-height: 1.5;
}

.codqo-success-popup__progress {
	height: 4px;
	background: #eee;
	border-radius: 999px;
	overflow: hidden;
}

.codqo-success-popup__progress-bar {
	display: block;
	height: 100%;
	width: 100%;
	background: #2e7d32;
	border-radius: 999px;
	transform-origin: left;
	animation-name: codqo-popup-countdown;
	animation-timing-function: linear;
	animation-fill-mode: forwards;
}

@keyframes codqo-popup-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes codqo-popup-pop-in {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
	100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes codqo-popup-shimmer {
	to { background-position: -200% 0; }
}

@keyframes codqo-popup-countdown {
	from { transform: scaleX(1); }
	to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
	.codqo-success-popup__backdrop,
	.codqo-success-popup__card,
	.codqo-success-popup__card::before,
	.codqo-success-popup__circle,
	.codqo-success-popup__check,
	.codqo-success-popup__progress-bar {
		animation: none !important;
	}
	.codqo-success-popup__circle,
	.codqo-success-popup__check {
		stroke-dashoffset: 0;
	}
}
