/* Sticky "Estimated total + Add to cart" bar on product pages (pdp-total-bar.js).
   Desktop: a floating panel under the order card column. Phones: full width
   at the bottom, like the cart page's Next Step bar. */

.qjr-total-bar {
	--qjr-total-bar-reserve: 0px;
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 260;
	box-sizing: border-box;
	border-top: 1px solid var(--wp--preset--color--border-default);
	background: var(--wp--preset--color--bg-base, #fff);
	box-shadow: 0 -6px 18px rgba(15, 41, 40, .1);
	color: var(--wp--preset--color--fg-primary);
	font-family: var(--wp--preset--font-family--body);
	visibility: hidden;
	transform: translateY(calc(100% + 24px));
	transition: transform 220ms var(--qjr-ease, ease), visibility 0s linear 220ms;
}

.qjr-total-bar.is-visible {
	visibility: visible;
	transform: none;
	transition: transform 220ms var(--qjr-ease, ease), visibility 0s;
}

.qjr-total-bar__inner {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px calc(16px + var(--qjr-total-bar-reserve)) calc(12px + env(safe-area-inset-bottom)) 16px;
}

.qjr-total-bar__total {
	display: flex;
	flex: 0 0 auto;
	flex-direction: column;
	line-height: 1.15;
	white-space: nowrap;
}

.qjr-total-bar__total[hidden] { display: none; }

.qjr-total-bar__label {
	color: var(--wp--preset--color--fg-secondary);
	font-size: .75rem;
	font-weight: 700;
}

.qjr-total-bar__amount {
	color: var(--wp--preset--color--bg-brand);
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.625rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	line-height: 1.05;
	white-space: nowrap;
}

.qjr-total-bar__toggle {
	align-self: flex-start;
	min-height: 24px;
	margin: 1px 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--bg-brand);
	font: inherit;
	font-size: .75rem;
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.qjr-total-bar__toggle[hidden] { display: none; }

.qjr-total-bar__toggle::after {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	margin: 0 0 2px 6px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(-135deg);
	vertical-align: middle;
}

.qjr-total-bar__toggle[aria-expanded="true"]::after {
	margin-bottom: 5px;
	transform: rotate(45deg);
}

.qjr-total-bar__cta {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 260px;
	min-height: 50px;
	margin-left: auto;
	padding: 12px 20px;
	border: 0;
	border-radius: 8px;
	background: var(--wp--preset--color--fg-accent);
	color: #14201F;
	font: inherit;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 150ms var(--qjr-ease, ease);
}

.qjr-total-bar__total[hidden] + .qjr-total-bar__cta { max-width: none; }
.qjr-total-bar__cta:hover { background: #B8912F; }
.qjr-total-bar__cta:disabled { background: #b5d2ce; color: #0f2928; cursor: wait; }

.qjr-total-bar :is(.qjr-total-bar__cta, .qjr-total-bar__toggle):focus-visible {
	outline: 3px solid var(--wp--preset--color--bg-brand);
	outline-offset: 3px;
}

/* Breakdown, opened from "See breakdown"; grows the bar upward. */
.qjr-total-bar__panel {
	max-height: min(55vh, 420px);
	overflow: auto;
	overscroll-behavior: contain;
	padding: 16px 16px 4px;
	border-bottom: 1px solid var(--wp--preset--color--border-default);
}

.qjr-total-bar__panel[hidden] { display: none; }

.qjr-total-bar__panel-title {
	margin: 0 0 8px;
	color: var(--wp--preset--color--fg-primary);
	font-size: .875rem;
	font-weight: 700;
}

.qjr-total-bar__lines {
	margin: 0;
	padding: 0;
	list-style: none;
}

.qjr-total-bar__lines li,
.qjr-total-bar__panel-total {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	padding: 5px 0;
	font-size: .9375rem;
	line-height: 1.35;
}

.qjr-total-bar__lines li span:last-child,
.qjr-total-bar__panel-total strong {
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
}

.qjr-total-bar__panel-total {
	margin: 6px 0 0;
	padding-top: 10px;
	border-top: 1px solid var(--wp--preset--color--border-default);
	color: var(--wp--preset--color--bg-brand);
	font-weight: 700;
}

.qjr-total-bar__panel-note {
	margin: 4px 0 10px;
	color: var(--wp--preset--color--fg-secondary);
	font-size: .8125rem;
}

/* "+$46.00 · 4mm and wider" after each priced change. */
.qjr-total-bar__chip {
	position: absolute;
	bottom: calc(100% + 10px);
	left: 16px;
	max-width: calc(100% - 32px);
	overflow: hidden;
	padding: 6px 12px;
	border-radius: 999px;
	background: var(--wp--preset--color--bg-brand-dark, #0F2928);
	box-shadow: 0 6px 16px rgba(15, 41, 40, .2);
	color: #fff;
	font-size: .8125rem;
	font-weight: 700;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 180ms ease, transform 180ms ease;
	pointer-events: none;
}

.qjr-total-bar__chip.is-shown {
	opacity: 1;
	transform: none;
}

.qjr-total-bar__status {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@media (min-width: 782px) {
	.qjr-total-bar {
		right: auto;
		bottom: 16px;
		border: 1px solid var(--wp--preset--color--border-default);
		border-radius: 12px;
		box-shadow: 0 12px 30px rgba(15, 41, 40, .18);
	}

	.qjr-total-bar__inner { padding: 12px 14px 12px 18px; }
	.qjr-total-bar__panel { padding: 18px 18px 4px; }
}

/* Small phones, especially with room kept for the chat bubble. */
@media (max-width: 360px) {
	.qjr-total-bar__inner { gap: 10px; padding-left: 12px; padding-right: calc(12px + var(--qjr-total-bar-reserve)); }
	.qjr-total-bar__amount { font-size: 1.375rem; }
	.qjr-total-bar__cta { padding-inline: 12px; font-size: .9375rem; }
}

/* The bar replaces the price-less sticky Add to cart button on phones. */
@media (max-width: 781px) {
	html.qjr-total-bar-on .qjr-order-card .single_add_to_cart_button {
		position: static;
		box-shadow: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.qjr-total-bar,
	.qjr-total-bar.is-visible,
	.qjr-total-bar__chip {
		transition: none;
	}
}

/* Phones: chat sits in the header next to the cart instead of the floating
   bubble (button in parts/header.html, shown by pdp-total-bar.js; NS-2188). */
.qjr-header-chat {
	position: relative;
	display: none;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--wp--preset--color--bg-brand-dark);
	cursor: pointer;
}

.qjr-header-chat:hover { background: #EEF1F3; }

.qjr-header-chat:focus-visible {
	outline: 3px solid var(--wp--preset--color--bg-brand);
	outline-offset: 2px;
}

.qjr-header-chat.is-online::after {
	content: "";
	position: absolute;
	top: 10px;
	right: 9px;
	width: 9px;
	height: 9px;
	border: 2px solid var(--wp--preset--color--bg-base, #fff);
	border-radius: 50%;
	background: #2E9A5B;
}

@media (max-width: 781px) {
	.qjr-header-chat:not([hidden]) { display: inline-flex; }

	/* Room for the extra icon: the account icon box matches the others (48px). */
	.qjr-header-actions:has(.qjr-header-chat:not([hidden])) .wp-block-woocommerce-customer-account a {
		justify-content: center;
		padding-inline: 0;
	}
}

/* Smallest phones: the logo would shrink below legibility, so the account
   icon steps back to the menu (Help & account > My account). */
@media (max-width: 359px) {
	.qjr-header-actions:has(.qjr-header-chat:not([hidden])) .wp-block-woocommerce-customer-account { display: none; }
}
