/**
 * Polcar Catalog Bridge — embed styles.
 */

/* Collapse wrapper spacing added by page builders around the shortcode. */
.elementor-widget-container:has(> .polcar-bridge),
.wp-block-shortcode:has(> .polcar-bridge),
.wp-block-html:has(> .polcar-bridge) {
	margin: 0 !important;
	padding: 0 !important;
	line-height: 0 !important;
	font-size: 0 !important;
}

.polcar-bridge {
	--polcar-bridge-height: 100vh;
	/* Set by catalog-embed.js: width of a classic (non-overlay) scrollbar.
	   100vw includes it, so subtract it to avoid horizontal overflow. */
	--polcar-bridge-sbw: 0px;
	position: relative;
	display: block;
	width: calc(100vw - var(--polcar-bridge-sbw));
	max-width: calc(100vw - var(--polcar-bridge-sbw));
	margin-left: calc(50% - 50vw + var(--polcar-bridge-sbw) / 2);
	margin-right: calc(50% - 50vw + var(--polcar-bridge-sbw) / 2);
	line-height: 0;
	font-size: 0;
}

/* Restore readable typography for the JS-disabled fallback link (the root
   collapses font-size to 0 for iframe whitespace control). */
.polcar-bridge noscript p {
	margin: 16px;
	font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.polcar-bridge__shell {
	position: relative;
	width: 100%;
	height: var(--polcar-bridge-height);
	min-height: 480px;
	overflow: hidden;
	background: #fff;
}

/* Prefer dynamic viewport units on browsers that have them. */
@supports (height: 100dvh) {
	.polcar-bridge__shell {
		height: min(var(--polcar-bridge-height), 100dvh);
	}
}

.polcar-bridge__iframe {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* Loader overlay */

.polcar-bridge__loader {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: grid;
	place-items: center;
	background: rgba(255, 255, 255, 0.94);
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.polcar-bridge__loader.is-hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.polcar-bridge__spinner {
	width: 42px;
	height: 42px;
	border: 3px solid rgba(15, 23, 42, 0.12);
	border-top-color: #c2001f; /* Polcar red */
	border-radius: 50%;
	animation: polcar-bridge-spin 0.9s linear infinite;
}

.polcar-bridge__loader-text {
	margin: 14px 0 0;
	color: #475569;
	font: 600 0.95rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
	text-align: center;
}

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

/* ------------------------------------------------------------------ *
 * Quick-order panel + catalog split layout
 * ------------------------------------------------------------------ */

.polcar-bridge--shop {
	position: relative;
	display: flex;
	align-items: stretch;
}

.polcar-bridge--shop.polcar-bridge--panel-right {
	flex-direction: row-reverse;
}

.polcar-bridge__frame {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	height: var(--polcar-bridge-height);
}

@supports (height: 100dvh) {
	.polcar-bridge__frame {
		height: min(var(--polcar-bridge-height), 100dvh);
	}
}

.polcar-bridge--shop .polcar-bridge__shell {
	height: 100%;
}

/* Panel column (desktop) */
.polcar-bridge__panel {
	flex: 0 0 auto;
	width: clamp(260px, 24vw, 360px);
	height: var(--polcar-bridge-height);
	overflow-y: auto;
	background: #fff;
	font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

@supports (height: 100dvh) {
	.polcar-bridge__panel {
		height: min(var(--polcar-bridge-height), 100dvh);
	}
}

.polcar-bridge--panel-left .polcar-bridge__panel {
	border-right: 1px solid #e5e7eb;
}

.polcar-bridge--panel-right .polcar-bridge__panel {
	border-left: 1px solid #e5e7eb;
}

.polcar-bridge__panel {
	background: linear-gradient(180deg, #fbfbfc 0%, #ffffff 120px);
}

.polcar-bridge__panel-inner {
	padding: 22px 18px;
}

.polcar-bridge__panel-title {
	position: relative;
	margin: 0 0 6px;
	padding-left: 14px;
	font-size: 1.12rem;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: #0f172a;
}

/* Red accent bar before the title. */
.polcar-bridge__panel-title::before {
	content: "";
	position: absolute;
	left: 0;
	top: 2px;
	bottom: 2px;
	width: 4px;
	border-radius: 4px;
	background: #c2001f;
}

.polcar-bridge__panel-help {
	margin: 0 0 16px;
	font-size: 0.88rem;
	line-height: 1.5;
	color: #64748b;
}

.polcar-bridge__lookup {
	display: flex;
	gap: 8px;
}

.polcar-bridge__code {
	flex: 1 1 auto;
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid #d5dbe3;
	border-radius: 9px;
	font: inherit;
	color: #0f172a;
	background: #fff;
	box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.polcar-bridge__code::placeholder {
	color: #9aa5b1;
}

.polcar-bridge__code:focus {
	outline: none;
	border-color: #c2001f;
	box-shadow: 0 0 0 3px rgba(194, 0, 31, 0.15);
}

.polcar-bridge__lookup-btn {
	flex: 0 0 auto;
	padding: 11px 18px;
	border: 0;
	border-radius: 9px;
	background: linear-gradient(180deg, #d4001f 0%, #b3001b 100%);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(194, 0, 31, 0.25);
	transition: filter 0.15s ease, transform 0.05s ease;
}

.polcar-bridge__lookup-btn:hover {
	filter: brightness(1.05);
}

.polcar-bridge__lookup-btn:active {
	transform: translateY(1px);
}

/* Panel header: home-linked logo (left) + login / account (right). */
.polcar-bridge__panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

.polcar-bridge__logo {
	display: inline-flex;
	align-items: center;
	min-width: 0;
}

.polcar-bridge__logo img,
.polcar-bridge__logo .custom-logo {
	max-height: 44px;
	width: auto;
	height: auto;
	display: block;
}

.polcar-bridge__logo-text {
	font-weight: 800;
	font-size: 1rem;
	color: #0f172a;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: color 0.15s ease;
}

.polcar-bridge__logo-text:hover {
	color: #c2001f;
}

.polcar-bridge__account {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
}

.polcar-bridge__account-name {
	font-size: 0.85rem;
	font-weight: 600;
	color: #334155;
}

.polcar-bridge__login-toggle,
.polcar-bridge__logout {
	padding: 7px 13px;
	border: 1px solid #d5dbe3;
	border-radius: 8px;
	background: #fff;
	color: #0f172a;
	font: inherit;
	font-weight: 600;
	font-size: 0.85rem;
	line-height: 1.2;
	cursor: pointer;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.polcar-bridge__login-toggle:hover,
.polcar-bridge__logout:hover {
	border-color: #c2001f;
	color: #c2001f;
}

/* Inline form: expands in the normal flow (pushing content down) so it is
   never clipped by the panel's own scroll container or covered by the iframe. */
.polcar-bridge__login-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0 0 16px;
	padding: 14px;
	background: #f8fafc;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
}

.polcar-bridge__login-form[hidden] {
	display: none;
}

.polcar-bridge__login-user,
.polcar-bridge__login-pass {
	padding: 9px 12px;
	border: 1px solid #d5dbe3;
	border-radius: 8px;
	font: inherit;
	color: #0f172a;
	background: #fff;
}

.polcar-bridge__login-user:focus,
.polcar-bridge__login-pass:focus {
	outline: none;
	border-color: #c2001f;
	box-shadow: 0 0 0 3px rgba(194, 0, 31, 0.15);
}

.polcar-bridge__login-submit {
	padding: 9px 14px;
	border: 0;
	border-radius: 8px;
	background: linear-gradient(180deg, #d4001f 0%, #b3001b 100%);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.polcar-bridge__login-error {
	color: #c2001f;
	font-size: 0.82rem;
	line-height: 1.4;
}

.polcar-bridge__login-error:empty {
	display: none;
}

.polcar-bridge__result {
	margin-top: 18px;
	min-height: 1.5em;
	color: #64748b;
	font-size: 0.9rem;
}

/* Result card */
.polcar-bridge__card {
	position: relative;
	padding: 18px;
	border: 1px solid #eaecef;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
	animation: polcar-bridge-card-in 0.2s ease;
}

@keyframes polcar-bridge-card-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.polcar-bridge__card--loading {
	color: #64748b;
	text-align: center;
}

.polcar-bridge__card-title {
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.3;
	color: #0f172a;
	overflow-wrap: anywhere;
	padding-right: 28px;
}

.polcar-bridge__card-code {
	margin-top: 3px;
	font-size: 0.8rem;
	font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
	color: #8a94a3;
}

/* Stock as a pill badge. */
.polcar-bridge__card-stock {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 12px;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 600;
}

.polcar-bridge__card-stock::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
}

.polcar-bridge__card-stock.is-in {
	color: #15803d;
	background: #e7f6ec;
}

.polcar-bridge__card-stock.is-out {
	color: #b91c1c;
	background: #fdecec;
}

.polcar-bridge__card-stock.is-unknown {
	color: #64748b;
	background: #eef1f4;
}

.polcar-bridge__card-price {
	margin-top: 12px;
	font-size: 1.6rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: #0f172a;
}

.polcar-bridge__card-price.is-unavailable {
	font-size: 0.95rem;
	font-weight: 600;
	color: #64748b;
}

.polcar-bridge__card-actions {
	display: flex;
	gap: 10px;
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid #f0f2f5;
}

.polcar-bridge__card-qty {
	width: 64px;
	padding: 11px 8px;
	border: 1px solid #d5dbe3;
	border-radius: 9px;
	font: inherit;
	font-weight: 600;
	text-align: center;
	color: #0f172a;
}

.polcar-bridge__card-qty:focus {
	outline: none;
	border-color: #c2001f;
	box-shadow: 0 0 0 3px rgba(194, 0, 31, 0.15);
}

.polcar-bridge__card-add {
	flex: 1 1 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 16px;
	border: 0;
	border-radius: 9px;
	background: linear-gradient(180deg, #17914a 0%, #15803d 100%);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(21, 128, 61, 0.28);
	transition: filter 0.15s ease, transform 0.05s ease;
}

.polcar-bridge__card-add:hover:not(:disabled) {
	filter: brightness(1.06);
}

.polcar-bridge__card-add:active:not(:disabled) {
	transform: translateY(1px);
}

.polcar-bridge__card-add:disabled {
	background: #e2e6eb;
	color: #9aa5b1;
	box-shadow: none;
	cursor: not-allowed;
}

.polcar-bridge__card-reason {
	margin-top: 12px;
	padding: 8px 12px;
	border-radius: 8px;
	background: #fdecec;
	font-size: 0.85rem;
	color: #b3001b;
}

/* Mobile toggle tab (hidden on desktop) */
.polcar-bridge__panel-toggle {
	display: none;
}

/* Card close button — only shown for the mobile popup. */
.polcar-bridge__card-close {
	display: none;
}

/* Mobile: catalog full-width with a compact sticky search bar at the top;
   the result appears as a small popup over the catalog. */
@media (max-width: 782px) {
	.polcar-bridge--shop {
		display: block;
	}

	/* The panel becomes a slim bar that stays at the top while scrolling. */
	.polcar-bridge--shop .polcar-bridge__panel {
		position: sticky;
		top: 0;
		z-index: 6;
		width: 100%;
		height: auto;
		background: #fff;
		border: 0;
		border-bottom: 1px solid #e5e7eb;
		box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
	}

	.polcar-bridge__panel-inner {
		padding: 8px 10px;
	}

	/* No room for the heading / helper text in the bar. */
	.polcar-bridge__panel-title,
	.polcar-bridge__panel-help {
		display: none;
	}

	/* Keep the logo + login compact above the search bar. */
	.polcar-bridge__panel-header {
		margin-bottom: 8px;
	}

	.polcar-bridge__logo img,
	.polcar-bridge__logo .custom-logo {
		max-height: 30px;
	}

	.polcar-bridge__login-toggle,
	.polcar-bridge__logout {
		padding: 6px 10px;
		font-size: 0.8rem;
	}

	/* Compact inline form in the slim mobile bar. */
	.polcar-bridge__login-form {
		margin: 8px 0 0;
		padding: 10px;
	}

	.polcar-bridge__code {
		padding: 10px 12px;
		border-radius: 8px;
	}

	.polcar-bridge__lookup-btn {
		padding: 10px 14px;
		border-radius: 8px;
	}

	/* Catalog fills the space under the bar. */
	.polcar-bridge--shop .polcar-bridge__frame {
		width: 100%;
		height: calc(min(var(--polcar-bridge-height), 100dvh) - 60px);
	}

	/* Result floats as a popup near the top and hides when empty. */
	.polcar-bridge__result {
		position: fixed;
		left: 50%;
		top: 64px;
		transform: translateX(-50%);
		width: min(94vw, 400px);
		margin: 0;
		z-index: 2147482000;
	}

	.polcar-bridge__result:empty {
		display: none;
	}

	.polcar-bridge__result .polcar-bridge__card {
		box-shadow: 0 18px 50px rgba(15, 23, 42, 0.3);
	}

	.polcar-bridge__card-close {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 8px;
		right: 8px;
		width: 30px;
		height: 30px;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: #f1f3f5;
		color: #475569;
		font-size: 20px;
		line-height: 1;
		cursor: pointer;
	}
}

/* Toasts */

.polcar-bridge-toasts {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-items: center;
	transform: translateX(-50%);
	width: min(92vw, 480px);
	pointer-events: none;
}

.polcar-bridge-toast {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 14px 16px;
	border-radius: 8px;
	background: #0f172a;
	color: #fff;
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 0.22s ease, transform 0.22s ease;
	pointer-events: auto;
	font: 600 0.95rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.polcar-bridge-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.polcar-bridge-toast--success {
	background: #14532d;
}

.polcar-bridge-toast--error {
	background: #7f1d1d;
}

.polcar-bridge-toast--info {
	background: #1e3a5f;
}

.polcar-bridge-toast__text {
	flex: 1;
	min-width: 0;
	overflow-wrap: anywhere;
}

.polcar-bridge-toast__action {
	flex-shrink: 0;
	padding: 8px 12px;
	border: 0;
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	font: inherit;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.polcar-bridge-toast__action:hover,
.polcar-bridge-toast__action:focus {
	background: rgba(255, 255, 255, 0.28);
	color: #fff;
}

.polcar-bridge-toast__close {
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: rgba(255, 255, 255, 0.75);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.polcar-bridge-toast__close:hover,
.polcar-bridge-toast__close:focus {
	color: #fff;
	background: rgba(255, 255, 255, 0.12);
}

/* Small screens */

@media (max-width: 600px) {
	.polcar-bridge-toasts {
		bottom: 12px;
	}

	.polcar-bridge-toast {
		padding: 12px 14px;
	}
}

/* Accessibility */

@media (prefers-reduced-motion: reduce) {
	.polcar-bridge__loader,
	.polcar-bridge-toast {
		transition: none;
	}

	.polcar-bridge__spinner {
		animation-duration: 1.6s;
	}
}
