/*
 * Voxel Collection Export - frontend styling.
 *
 * The checkbox keeps a real <input type="checkbox">, so native semantics,
 * keyboard operation and screen-reader behaviour are preserved. The input is
 * taken out of the visual flow and a sibling .vce-box is painted in its place;
 * focus and checked state are both mirrored onto that box.
 *
 * Selectors are kept intentionally stable (.vce-item / .vce-box) because
 * Elementor generates per-widget colour CSS against them.
 */

.vce-check {
	--vce-size: 20px;
	--vce-radius: 4px;
	--vce-border: currentColor;
	--vce-fill: currentColor;
	--vce-tick: #fff;

	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	line-height: 1;
	margin: 0;
	-webkit-user-select: none;
	user-select: none;
}

/*
 * Visually hidden but still focusable. `appearance:none` matters: without it a
 * theme rule that resets position/opacity on inputs brings the native control
 * back into view.
 */
.vce-check input.vce-item,
input.vce-item {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	border: 0;
	opacity: 0;
	pointer-events: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
}

.vce-check .vce-box {
	display: inline-block;
	position: relative;
	flex: 0 0 auto;
	box-sizing: border-box;
	width: var(--vce-size);
	height: var(--vce-size);
	border: 1px solid var(--vce-border);
	border-radius: var(--vce-radius);
	background-color: transparent;
	transition: background-color .15s ease, border-color .15s ease;
}

.vce-check .vce-box::after {
	content: "";
	position: absolute;
	left: 34%;
	top: 14%;
	width: 26%;
	height: 52%;
	box-sizing: border-box;
	border: solid var(--vce-tick);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(0);
	transform-origin: center;
	transition: transform .15s ease;
}

/* Checked: filled box + visible tick. This is the default that was missing. */
.vce-check input.vce-item:checked + .vce-box {
	background-color: var(--vce-fill);
	border-color: var(--vce-fill);
}

.vce-check input.vce-item:checked + .vce-box::after {
	transform: rotate(45deg) scale(1);
}

/* Indeterminate: filled box with a dash, for partial Select All. */
.vce-check input.vce-item:indeterminate + .vce-box {
	background-color: var(--vce-fill);
	border-color: var(--vce-fill);
}

.vce-check input.vce-item:indeterminate + .vce-box::after {
	left: 22%;
	top: 46%;
	width: 56%;
	height: 0;
	border-width: 0 0 2px 0;
	transform: none;
}

/* Keyboard focus is mirrored onto the painted box. */
.vce-check input.vce-item:focus-visible + .vce-box {
	outline: 2px solid var(--vce-fill);
	outline-offset: 2px;
}

.vce-check input.vce-item:disabled + .vce-box {
	opacity: .5;
	cursor: not-allowed;
}

.vce-check-label {
	line-height: 1.3;
}

/* ---------- Select all ---------- */

.vce-select-all {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.vce-btn {
	cursor: pointer;
	border: 1px solid currentColor;
	background: transparent;
	color: inherit;
	border-radius: 4px;
	padding: 6px 12px;
	font: inherit;
	line-height: 1.3;
}

.vce-btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.vce-count {
	opacity: .75;
	font-size: .9em;
	font-variant-numeric: tabular-nums;
}

/* ---------- Export button ---------- */

/*
 * The wrapper is a full-width flex column so the Alignment control has
 * something to align within; the button itself sizes to its content unless a
 * Width control says otherwise.
 */
.vce-export {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	width: 100%;
}

.vce-export-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	max-width: 100%;
	cursor: pointer;
	border: 0;
	border-radius: 4px;
	padding: 10px 16px;
	font: inherit;
	line-height: 1.3;
	text-align: center;
	/* Default: the label stays on one line. "Download to Excel" wrapping to
	   two lines was the reported symptom; the Text wrapping control overrides. */
	white-space: nowrap;
	background-color: #0e8f9e;
	color: #fff;
	/* Elementor's Alignment control sets align-items on the wrapper; stretch
	   must make the button fill, not leave it shrink-wrapped. */
	align-self: auto;
}

.vce-export[style*="stretch"] .vce-export-btn,
.vce-export > .vce-export-btn {
	flex: 0 0 auto;
}

.vce-export-label {
	display: inline-block;
}

/*
 * Elementor renders icons as an inline <svg viewBox="..."> with no width or
 * height. Without an explicit size such an SVG resolves to 100% of its
 * container and swallows the button, pushing the label onto a second line.
 */
.vce-export-icon {
	--vce-icon-size: 18px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: var(--vce-icon-size);
	height: var(--vce-icon-size);
	line-height: 0;
}

.vce-export-icon svg {
	width: 100%;
	height: 100%;
	display: block;
	fill: currentColor;
}

.vce-export-icon i {
	font-size: var(--vce-icon-size);
	line-height: 1;
}

.vce-export-btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.vce-export-btn[disabled] {
	opacity: .5;
	cursor: not-allowed;
}

.vce-export-btn[aria-busy="true"] .vce-export-label::after {
	content: "";
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-left: 8px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	vertical-align: -1px;
	animation: vce-spin .7s linear infinite;
}

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

/* ---------- Message dialog ---------- */

.vce-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.vce-modal[hidden] {
	display: none;
}

.vce-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(16, 22, 26, .55);
}

.vce-modal-panel {
	position: relative;
	max-width: 380px;
	width: 100%;
	background: #fff;
	color: #16202a;
	border-radius: 8px;
	padding: 24px;
	text-align: center;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
	animation: vce-modal-in .16s ease-out;
}

@keyframes vce-modal-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

.vce-modal-title {
	margin: 0 0 10px;
	font-size: 1.15em;
	font-weight: 600;
	line-height: 1.3;
}

.vce-modal-text {
	margin: 0 0 20px;
	line-height: 1.5;
	opacity: .85;
}

.vce-modal-actions {
	display: flex;
	justify-content: center;
}

.vce-modal-ok {
	cursor: pointer;
	border: 0;
	border-radius: 4px;
	padding: 9px 28px;
	font: inherit;
	line-height: 1.3;
	background-color: #0e8f9e;
	color: #fff;
}

.vce-modal-ok:focus-visible {
	outline: 2px solid #16202a;
	outline-offset: 2px;
}

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

.vce-notice {
	padding: 10px 14px;
	border: 1px dashed currentColor;
	border-radius: 4px;
	opacity: .7;
	font-size: .9em;
}

@media (prefers-reduced-motion: reduce) {
	.vce-check .vce-box,
	.vce-check .vce-box::after,
	.vce-export-btn[aria-busy="true"] .vce-export-label::after,
	.vce-modal-panel {
		transition: none;
		animation: none;
	}
}
