/**
 * Design Layers panel — Canva-style adjustable stack.
 */

.cpbpwc-layers-panel {
	position: absolute;
	top: 168px;
	right: 12px;
	z-index: 40;
	width: 248px;
	max-height: min(58vh, 420px);
	display: flex;
	flex-direction: column;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
	font-family: var(--cpb-font-sans);
	overflow: hidden;
	pointer-events: auto;
}

.cpbpwc-layers-panel.is-collapsed {
	max-height: none;
}

.cpbpwc-layers-panel.is-collapsed .cpbpwc-layers-panel__toolbar,
.cpbpwc-layers-panel.is-collapsed .cpbpwc-layers-panel__hint,
.cpbpwc-layers-panel.is-collapsed .cpbpwc-layers-panel__list,
.cpbpwc-layers-panel.is-collapsed .cpbpwc-layers-panel__empty {
	display: none;
}

.cpbpwc-layers-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 14px;
	border-bottom: 1px solid #e2e8f0;
	background: #f8fafc;
}

.cpbpwc-layers-panel__title {
	font-size: 13px;
	font-weight: 600;
	color: #0f172a;
	letter-spacing: 0.01em;
}

.cpbpwc-layers-panel__toggle {
	width: 28px;
	height: 28px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	background: #fff;
	color: #334155;
	cursor: pointer;
	line-height: 1;
	font-size: 16px;
}

.cpbpwc-layers-panel__toolbar {
	display: flex;
	gap: 4px;
	padding: 8px 10px 4px;
}

.cpbpwc-layers-btn {
	flex: 1;
	min-height: 32px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	background: #fff;
	color: #334155;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.cpbpwc-layers-btn:hover {
	background: #f1f5f9;
	border-color: #cbd5e1;
}

.cpbpwc-layers-panel__hint {
	margin: 0;
	padding: 2px 14px 8px;
	font-size: 11px;
	color: #94a3b8;
}

.cpbpwc-layers-panel__list {
	list-style: none;
	margin: 0;
	padding: 4px 8px 10px;
	overflow-y: auto;
	flex: 1 1 auto;
}

.cpbpwc-layers-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 8px;
	margin: 0 0 6px;
	border-radius: 10px;
	border: 1.5px solid #e8eef5;
	cursor: pointer;
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
	user-select: none;
}

.cpbpwc-layers-item:hover {
	border-color: #cbd5e1;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.cpbpwc-layers-item.is-active {
	border-color: #3b82f6;
	background: #eff6ff;
	box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.cpbpwc-layers-item.is-dragging {
	opacity: 0.55;
	border-style: dashed;
}

.cpbpwc-layers-item.is-drop-before {
	box-shadow: inset 0 2px 0 0 #3b82f6;
}

.cpbpwc-layers-item.is-drop-after {
	box-shadow: inset 0 -2px 0 0 #3b82f6;
}

.cpbpwc-layers-item.is-locked {
	cursor: default;
	background: #f8fafc;
	opacity: 0.95;
}

.cpbpwc-layers-item.is-locked:hover {
	box-shadow: none;
	border-color: #e8eef5;
}

/* Keep full blue selection on Main image (locked + active); hover must not strip it. */
.cpbpwc-layers-item.is-active.is-locked,
.cpbpwc-layers-item.is-active.is-locked:hover {
	border-color: #3b82f6;
	background: #eff6ff;
	box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
	opacity: 1;
}

.cpbpwc-layers-item__grip {
	flex: 0 0 auto;
	width: 14px;
	height: 18px;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	grid-template-rows: repeat(3, 1fr);
	gap: 2px;
	align-content: center;
	cursor: grab;
	opacity: 0.45;
}

.cpbpwc-layers-item__grip span {
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: #64748b;
	display: block;
}

.cpbpwc-layers-item__grip--locked {
	opacity: 0;
	pointer-events: none;
	cursor: default;
}

.cpbpwc-layers-item:active .cpbpwc-layers-item__grip {
	cursor: grabbing;
}

.cpbpwc-layers-item__thumb {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 8px;
	border: 1px solid #e2e8f0;
	background: #f1f5f9 center / cover no-repeat;
	overflow: hidden;
}

.cpbpwc-layers-item__thumb--text {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #0f172a;
	color: #fff;
	font-size: 9px;
	font-weight: 600;
	line-height: 1.1;
	text-align: center;
	padding: 2px;
	border-color: #0f172a;
}

.cpbpwc-layers-item__thumb--empty {
	background: repeating-linear-gradient(
		45deg,
		#f1f5f9,
		#f1f5f9 4px,
		#e2e8f0 4px,
		#e2e8f0 8px
	);
}

.cpbpwc-layers-item__meta {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.cpbpwc-layers-item__type {
	font-size: 10px;
	font-weight: 600;
	color: #94a3b8;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.cpbpwc-layers-item.is-active .cpbpwc-layers-item__type {
	color: #3b82f6;
}

.cpbpwc-layers-item__label {
	font-size: 12px;
	font-weight: 500;
	color: #0f172a;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cpbpwc-layers-item.is-active .cpbpwc-layers-item__label {
	color: #0f172a;
}

.cpbpwc-layers-item__lock {
	margin-left: auto;
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: #94a3b8;
	flex-shrink: 0;
}

.cpbpwc-layers-panel__empty {
	margin: 0;
	padding: 14px;
	font-size: 12px;
	color: #64748b;
	text-align: center;
}

.cpbpwc-layers-panel.is-reordering .cpbpwc-layers-item:not(.is-dragging):not(.is-locked) {
	cursor: copy;
}

.imageBoxDR.cpbpwc-layer-selected,
.boxDR.cpbpwc-layer-selected {
	outline: 2px solid #3b82f6;
	outline-offset: 1px;
}

/* Canva-style right-click layer menu */
.cpbpwc-layers-context {
	position: fixed;
	z-index: 10050;
	min-width: 240px;
	padding: 6px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 12px 36px rgba(15, 23, 42, 0.18);
	font-family: var(--cpb-font-sans);
	pointer-events: auto;
	display: none;
}

.cpbpwc-layers-context.is-open {
	display: block;
}

.cpbpwc-layers-context[hidden] {
	display: none !important;
}

.cpbpwc-layers-context__item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 9px 10px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: #0f172a;
	font-size: 13px;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
}

.cpbpwc-layers-context__item:hover:not(.is-disabled):not(:disabled) {
	background: #f1f5f9;
}

.cpbpwc-layers-context__item.is-disabled,
.cpbpwc-layers-context__item:disabled {
	opacity: 0.4;
	cursor: default;
}

.cpbpwc-layers-context__icon {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #475569;
}

.cpbpwc-layers-context__label {
	flex: 1 1 auto;
	min-width: 0;
}

.cpbpwc-layers-context__kbd {
	flex: 0 0 auto;
	font-family: inherit;
	font-size: 11px;
	font-weight: 500;
	color: #94a3b8;
	background: none;
}

.cpbpwc-layers-context__sep {
	height: 1px;
	margin: 4px 6px;
	background: #e2e8f0;
}

.cpbpwc-layers-panel.is-flash {
	animation: cpbpwc-layers-flash 0.9s ease;
}

@keyframes cpbpwc-layers-flash {
	0%,
	100% {
		box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
	}
	40% {
		box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45),
			0 12px 32px rgba(15, 23, 42, 0.14);
	}
}

body.cpbpwc-advance-builder-page .cpbpwc-canvas-overlay-dock {
	position: relative;
}

@media (max-width: 900px) {
	.cpbpwc-layers-panel,
	.cpbpwc-layers-panel.is-stacked {
		position: static !important;
		top: auto;
		right: auto;
		left: auto;
		bottom: auto;
		width: 100%;
		max-width: none;
		max-height: 280px;
		margin: 12px 0 0;
		z-index: 5;
	}
}

/* Hidden while a cart design is shown as a static preview. */
.cpbpwc-layers-panel.is-builder-hidden,
.cpbpwc-layers-panel[hidden] {
	display: none !important;
}
