/* CounterViz floating launcher + modal shell. */

.cviz-launcher {
	position: fixed;
	z-index: 99990;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 13px 20px;
	border: 0;
	border-radius: 999px;
	background: #0f766e;
	color: #fff;
	font: 600 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cviz-launcher:hover,
.cviz-launcher:focus-visible {
	background: #0d5f59;
	transform: translateY(-2px);
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
}

.cviz-launcher:focus-visible {
	outline: 3px solid #99f6e4;
	outline-offset: 2px;
}

.cviz-launcher__icon {
	display: inline-flex;
}

.cviz-launcher--bottom-right { right: 24px; bottom: 24px; }
.cviz-launcher--bottom-left  { left: 24px;  bottom: 24px; }
.cviz-launcher--top-right    { right: 24px; top: 24px; }
.cviz-launcher--top-left     { left: 24px;  top: 24px; }

@media (max-width: 600px) {
	.cviz-launcher { padding: 12px 16px; font-size: 14px; }
	.cviz-launcher--bottom-right,
	.cviz-launcher--bottom-left { bottom: 16px; }
	.cviz-launcher--bottom-right { right: 16px; }
	.cviz-launcher--bottom-left { left: 16px; }
}

/* ---- modal ---- */

/* Hard overrides throughout the modal: themes/plugins apply generic width,
   max-width, and margin rules to unknown elements (e.g. a 420px max-width was
   observed from the Woo/theme stack), and an injected overlay must win. */
.cviz-modal {
	position: fixed !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	z-index: 99999;
}

.cviz-modal[hidden] {
	display: none !important;
}

.cviz-modal__backdrop {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	background: rgba(15, 23, 42, 0.6);
	backdrop-filter: blur(2px);
}

.cviz-modal__dialog {
	position: absolute !important;
	inset: 28px !important;
	width: auto !important;
	height: auto !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
	overflow: hidden;
}

.cviz-modal__body {
	flex: 1;
	min-height: 0;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

/* Very short windows can't fit everything — fall back to scrolling there. */
@media (max-height: 480px) {
	.cviz-modal__body {
		overflow: auto;
		-webkit-overflow-scrolling: touch;
	}
}

/* ---- fit-to-modal layout: the app fills the modal, the catalog rail
       scrolls internally, and the stage (canvas/photo) scales to fit. ---- */

.cviz-modal .counterviz-app {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	/* .cviz-root's `margin: 0 auto` would shrink the app to fit-content
	   inside the modal's flex column — force it to fill instead. */
	width: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.cviz-modal .cviz-header {
	flex: 0 0 auto;
	/* Keep the tab row clear of the modal's close button. */
	padding-right: 52px;
}

.cviz-modal .cviz-body {
	flex: 1 1 auto;
	min-height: 0;
}

@media (min-width: 900px) {
	.cviz-modal .cviz-body {
		grid-template-rows: minmax(0, 1fr);
		align-items: stretch;
	}
	.cviz-modal .cviz-rail {
		position: static;
		max-height: none;
		min-height: 0;
		overflow-y: auto;
	}
	.cviz-modal .cviz-main {
		min-height: 0;
		overflow: hidden;
	}
}

@media (max-width: 899px) {
	.cviz-modal .cviz-body {
		display: flex;
		flex-direction: column;
		min-height: 0;
	}
	.cviz-modal .cviz-main {
		flex: 0 0 auto;
	}
	.cviz-modal .cviz-rail {
		flex: 1 1 0;
		min-height: 130px;
		overflow-y: auto;
	}
}

/* Canvas centered when height-capped narrower than the column. */
.cviz-modal .cviz-canvaswrap {
	margin-inline: auto;
	max-width: 100%;
}

/* Photo stage: contain the image within the modal's height budget. */
.cviz-modal .cviz-photostage {
	width: fit-content;
	max-width: 100%;
	margin-inline: auto;
}

.cviz-modal .cviz-photo__img {
	width: auto;
	max-width: 100%;
	max-height: max(220px, calc(100vh - 420px));
}

.cviz-modal__close {
	position: absolute;
	top: 10px;
	right: 12px;
	z-index: 5;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: rgba(15, 23, 42, 0.08);
	color: #1e293b;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.cviz-modal__close:hover,
.cviz-modal__close:focus-visible {
	background: rgba(15, 23, 42, 0.16);
}

.cviz-modal-open,
.cviz-modal-open body {
	overflow: hidden;
}

@media (max-width: 782px) {
	.cviz-modal__dialog {
		inset: 0 !important;
		border-radius: 0;
	}
}
