:root {
	/* Defaults used until JS detects the active theme's real button color
	   (see frontend-diagram.js). Safe fallback if JS can't run. */
	--pd-accent: #1d3557;
	--pd-accent-contrast: #ffffff;
	--pd-accent-strong: color-mix(in srgb, var(--pd-accent) 75%, black);

	/* Defaults until JS detects the site's actual footer colors. */
	--pd-footer-bg: #2c2c2c;
	--pd-footer-text: #ffffff;
}

.pd-storefront-wrap {
	max-width: 1200px;
	margin: 0 auto;
	padding: 20px;
}

.pd-storefront-app {
	display: flex;
	gap: 30px;
	align-items: flex-start;
	flex-wrap: wrap;
}

.pd-diagram-pane {
	flex: 1 1 55%;
	min-width: 300px;
	position: relative;
}

#pd-storefront-canvas {
	position: relative;
	width: 100%;
	cursor: zoom-in;
	/* padding-top (aspect ratio) is set inline per diagram — see templates/diagram-category.php */
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
	background-color: #f7f7f7;
	border: 1px solid #ddd;
}

.pd-diagram-hint {
	margin: 8px 0 0;
	font-size: 12px;
	color: #888;
	text-align: center;
}

.pd-storefront-pin {
	position: absolute !important;
	box-sizing: border-box !important; /* keeps border+padding inside the 30x30 box instead of adding to it */
	width: 30px !important;
	height: 30px !important;
	min-width: 0 !important;   /* overrides theme button min-width rules */
	max-width: none !important;
	margin: -15px 0 0 -15px !important; /* centers the 30px circle on its x/y coordinate */
	padding: 0 !important;      /* overrides theme button padding — this was the actual distortion */
	border-radius: 50% !important;
	background: var(--pd-accent);
	color: var(--pd-accent-contrast);
	border: none; /* unselected pins have no border — see .pd-pin-active/:hover below */
	font: inherit;
	font-size: 13px;
	line-height: 1;
	font-weight: bold;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba(0,0,0,0.4);
	appearance: none;
	-webkit-appearance: none;
	display: flex !important;
	align-items: center;
	justify-content: center;
}

.pd-storefront-pin.pd-pin-active,
.pd-storefront-pin:hover {
	background: var(--pd-accent-strong);
	border: 2px solid #fff;
	transform: scale(1.15);
}

.pd-list-pane {
	flex: 1 1 40%;
	min-width: 280px;
	border: 1px solid var(--pd-footer-bg);
	max-height: 640px;
	overflow-y: auto;
}

.pd-list-pane h2 {
	margin: 0;
	padding: 12px 16px;
	background: var(--pd-footer-text);
	color: var(--pd-footer-bg);
	border-bottom: 1px solid var(--pd-footer-bg);
}

.pd-part-row {
	display: flex;
	align-items: center; /* centers the number badge against the whole row height, top+bottom sub-rows combined */
	gap: 10px;
	padding: 10px 14px;
	background: var(--pd-footer-text);
	color: var(--pd-footer-bg);
	border-bottom: 1px solid var(--pd-footer-bg);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.pd-part-content {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.pd-part-top {
	display: flex;
	align-items: center;
}

.pd-part-bottom {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px 12px;
}

.pd-part-row:hover {
	/* a subtle shift toward the footer's own colors, rather than a plain
	   gray flash that would look mismatched against the inverted base */
	background: color-mix(in srgb, var(--pd-footer-text) 90%, var(--pd-footer-bg));
}

.pd-row-active,
.pd-row-active .pd-part-name,
.pd-row-active .pd-part-price,
.pd-row-active .pd-stock-qty,
.pd-row-active .pd-out-of-stock,
.pd-row-active .pd-part-link {
	background: var(--pd-footer-bg);
	color: var(--pd-footer-text) !important; /* !important since links/theme rules often set their own color with higher specificity */
}

.pd-part-number {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--pd-accent);
	color: var(--pd-accent-contrast);
	font-size: 13px;
	flex-shrink: 0;
}

.pd-part-number-none {
	background: #ddd;
	color: #ddd;
}

.pd-part-link {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-grow: 1;
	text-decoration: none;
	color: inherit;
}

.pd-part-link img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	flex-shrink: 0;
}

.pd-part-price {
	white-space: nowrap;
	font-size: 15px;
}

.pd-add-to-cart {
	white-space: nowrap;
}

.pd-stock-qty {
	font-size: 15px;
	color: #666;
	white-space: nowrap;
}

.pd-cart-form {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
}

.pd-qty-input {
	width: 52px;
	padding: 4px 6px;
	text-align: center;
}

.pd-out-of-stock {
	color: #999;
	font-size: 13px;
	white-space: nowrap;
}

.pd-reverse-lookup {
	margin: 16px 0;
	padding: 10px 14px;
	background: #f7f7f7;
	border-left: 3px solid var(--pd-accent);
}

.pd-reverse-lookup ul {
	margin: 6px 0 0;
	padding-left: 18px;
}

/* Lightbox */
#pd-lightbox {
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.85);
	z-index: 100000;
	flex-direction: column;
}

#pd-lightbox-toolbar {
	display: flex;
	gap: 8px;
	padding: 12px;
	justify-content: flex-end;
}

#pd-lightbox-toolbar button {
	padding: 6px 14px;
	cursor: pointer;
}

#pd-lightbox-viewport {
	flex-grow: 1;
	overflow: hidden;
	position: relative;
	cursor: grab;
	touch-action: none;
}

#pd-lightbox-canvas {
	position: absolute;
	/* width/height/left/top are set by JS to exactly match the image's real
	   aspect ratio within the available viewport — see frontend-diagram.js */
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
	transform-origin: center center;
	transition: transform 0.05s linear;
}
