/**
 * Artex Product Variations - Frontend styles
 * Admin defaults via CSS variables on non-Elementor instances.
 * Elementor widget styles apply via direct selectors (higher priority).
 */

.artex-pv-wrapper {
	display: block;
	width: 100%;
}

.artex-pv-form {
	margin: 0;
}

.artex-pv-attributes {
	display: flex;
	flex-direction: column;
	gap: var(--apv-wrapper-gap, 24px);
	margin-bottom: var(--apv-wrapper-gap, 24px);
}

/* Admin-only CSS variable defaults */
.artex-pv-wrapper:not([data-artex-elementor="1"]) {
	--apv-wrapper-gap: 24px;
	--apv-label-margin-bottom: 12px;
	--apv-swatch-size: 32px;
	--apv-swatch-gap: 8px;
	--apv-swatch-border-width: 2px;
	--apv-swatch-border-color: transparent;
	--apv-swatch-border-radius: 50%;
	--apv-swatch-selected-ring: 2px;
	--apv-swatch-selected-ring-color: #111111;
	--apv-button-gap: 8px;
	--apv-button-min-width: 48px;
	--apv-button-padding: 12px 16px;
	--apv-button-font-size: 14px;
	--apv-button-font-weight: 500;
	--apv-button-border-radius: 4px;
	--apv-button-border-width: 1px;
	--apv-button-bg: #f5f5f5;
	--apv-button-color: #111111;
	--apv-button-border-color: transparent;
	--apv-button-selected-bg: #ffffff;
	--apv-button-selected-color: #111111;
	--apv-button-selected-border: #111111;
	--apv-button-disabled-opacity: 0.4;
	--apv-select-padding: 12px 16px;
	--apv-select-font-size: 14px;
	--apv-select-border-radius: 4px;
	--apv-select-border-width: 1px;
	--apv-select-border-color: #cccccc;
	--apv-select-bg: #ffffff;
	--apv-select-color: #111111;
	--apv-atc-padding: 16px 24px;
	--apv-atc-font-size: 16px;
	--apv-atc-font-weight: 600;
	--apv-atc-border-radius: 4px;
	--apv-atc-bg: #111111;
	--apv-atc-color: #ffffff;
	--apv-atc-disabled-bg: #cccccc;
	--apv-atc-disabled-color: #666666;
	--apv-atc-width: 100%;
}

/* Attribute header */
.artex-pv-attribute__header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: var(--apv-label-margin-bottom, 12px);
	gap: 12px;
}

.artex-pv-attribute__label {
	color: var(--apv-label-color, #111);
}

.artex-pv-wrapper:not([data-artex-elementor="1"]) .artex-pv-attribute__label {
	font-size: var(--apv-label-font-size, 14px);
	font-weight: var(--apv-label-font-weight, 600);
}

.artex-pv-attribute__selected::before {
	content: ' ';
}

.artex-pv-attribute__selected:not(:empty)::before {
	content: ' ';
}

.artex-pv-attribute__selected {
	font-weight: var(--apv-selected-value-weight, 400);
	color: var(--apv-selected-value-color, #111);
}

.artex-pv-attribute__helpers {
	display: flex;
	gap: 16px;
	flex-shrink: 0;
}

.artex-pv-helper-link {
	font-size: 13px;
	color: var(--apv-label-color, #111);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.artex-pv-helper-link:hover {
	text-decoration: none;
}

/* Color swatches */
.artex-pv-swatches {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--apv-swatch-gap, 8px);
}

.artex-pv-swatch-item {
	display: block;
	flex: 0 0 auto;
	line-height: 0;
}

.artex-pv-swatch {
	display: block;
	width: var(--apv-swatch-size, 32px);
	height: var(--apv-swatch-size, 32px);
	min-width: var(--apv-swatch-size, 32px);
	max-width: var(--apv-swatch-size, 32px);
	min-height: var(--apv-swatch-size, 32px);
	max-height: var(--apv-swatch-size, 32px);
	aspect-ratio: 1 / 1;
	flex-shrink: 0;
	border-radius: 50%;
	border: var(--apv-swatch-border-width, 2px) solid var(--apv-swatch-border-color, transparent);
	background-color: var(--swatch-color, #ccc);
	padding: 0;
	margin: 0;
	cursor: pointer;
	position: relative;
	overflow: hidden;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
	box-shadow: 0 0 0 0 var(--apv-swatch-selected-ring-color, #111);
	appearance: none;
	-webkit-appearance: none;
	background-image: none;
	background-clip: padding-box;
	text-shadow: none;
	text-decoration: none;
	text-transform: none;
	font-size: 0;
	line-height: 0;
	vertical-align: top;
	box-sizing: border-box;
}

.artex-pv-swatch .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Isolamento da stili Elementor/tema */
.elementor .artex-pv-wrapper .artex-pv-swatches .artex-pv-swatch,
.elementor-widget-woocommerce-product-add-to-cart .artex-pv-wrapper .artex-pv-swatch,
.artex-pv-wrapper .artex-pv-swatch {
	display: block !important;
	width: var(--apv-swatch-size, 32px) !important;
	height: var(--apv-swatch-size, 32px) !important;
	min-width: var(--apv-swatch-size, 32px) !important;
	max-width: var(--apv-swatch-size, 32px) !important;
	min-height: var(--apv-swatch-size, 32px) !important;
	max-height: var(--apv-swatch-size, 32px) !important;
	padding: 0 !important;
	margin: 0 !important;
	border-radius: 50% !important;
	line-height: 0 !important;
	font-size: 0 !important;
	overflow: hidden !important;
	flex: none !important;
	align-self: auto !important;
}

.artex-pv-swatch:hover {
	transform: scale(1.05);
}

.artex-pv-swatch.is-selected {
	box-shadow: 0 0 0 var(--apv-swatch-selected-ring, 2px) var(--apv-swatch-selected-ring-color, #111) !important;
}

.artex-pv-swatch.is-disabled {
	opacity: 0.35;
	cursor: not-allowed;
	pointer-events: none;
}

/* Buttons */
.artex-pv-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: var(--apv-button-gap, 8px);
}

.artex-pv-wrapper .artex-pv-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--apv-button-min-width, 48px);
	border-style: solid;
	box-shadow: none;
	text-shadow: none;
	text-decoration: none;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
	line-height: 1.2;
}

/* Admin defaults for buttons */
.artex-pv-wrapper:not([data-artex-elementor="1"]) .artex-pv-btn {
	padding: var(--apv-button-padding, 12px 16px);
	font-size: var(--apv-button-font-size, 14px);
	font-weight: var(--apv-button-font-weight, 500);
	border-radius: var(--apv-button-border-radius, 4px);
	border-width: var(--apv-button-border-width, 1px);
	border-color: var(--apv-button-border-color, transparent);
	background-color: var(--apv-button-bg, #f5f5f5);
	color: var(--apv-button-color, #111);
}

.artex-pv-wrapper:not([data-artex-elementor="1"]) .artex-pv-btn:hover:not(.is-disabled):not(.is-selected) {
	opacity: 0.9;
}

.artex-pv-wrapper:not([data-artex-elementor="1"]) .artex-pv-btn.is-selected {
	background-color: var(--apv-button-selected-bg, #fff);
	color: var(--apv-button-selected-color, #111);
	border-color: var(--apv-button-selected-border, #111);
}

/* Elementor + theme isolation: keep background/color overridable but don't lock typography */
.artex-pv-wrapper[data-artex-elementor="1"] .artex-pv-btn {
	border-width: 1px;
	border-style: solid;
}

.artex-pv-wrapper .artex-pv-btn.is-disabled {
	opacity: var(--apv-button-disabled-opacity, 0.4);
	cursor: not-allowed;
	pointer-events: none;
}

/* Hidden WooCommerce variations table – keeps native selects for WC JS */
.artex-pv-variations-table {
	position: absolute;
	left: -9999px;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
	z-index: -1;
	pointer-events: none;
	clip: rect(0, 0, 0, 0);
}

.artex-pv-variations-table select {
	pointer-events: auto;
}

.artex-pv-select-mount select,
.artex-pv-select-mount .artex-pv-select,
.artex-pv-select-mount .artex-pv-wc-select {
	position: static;
	width: 100%;
	clip: auto;
	opacity: 1;
	pointer-events: auto;
}

/* Kit-style full-width buttons (2 columns) */
.artex-pv-attribute--button .artex-pv-buttons--kit {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--apv-button-gap, 8px);
}

.artex-pv-attribute--button .artex-pv-buttons--kit .artex-pv-btn {
	width: 100%;
}

/* Select */
.artex-pv-select {
	width: 100%;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23111' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	padding-right: 40px;
	cursor: pointer;
}

.artex-pv-wrapper:not([data-artex-elementor="1"]) .artex-pv-select {
	padding: var(--apv-select-padding, 12px 16px);
	font-size: var(--apv-select-font-size, 14px);
	border-radius: var(--apv-select-border-radius, 4px);
	border: var(--apv-select-border-width, 1px) solid var(--apv-select-border-color, #ccc);
	background-color: var(--apv-select-bg, #fff);
	color: var(--apv-select-color, #111);
}

/* Add to cart */
.artex-pv-atc-wrap {
	display: flex;
	align-items: stretch;
	gap: 12px;
	width: 100%;
}

.artex-pv-atc-wrap .quantity {
	flex-shrink: 0;
}

.artex-pv-atc {
	flex: 1;
	border: none;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
	text-align: center;
	line-height: 1.3;
	text-decoration: none;
	appearance: none;
	-webkit-appearance: none;
}

/* Disabled / incomplete ATC – works for admin AND Elementor */
.artex-pv-wrapper .artex-pv-atc:disabled,
.artex-pv-wrapper .artex-pv-atc.artex-pv-atc--incomplete {
	cursor: not-allowed;
	background-color: var(--apv-atc-disabled-bg, #cccccc) !important;
	color: var(--apv-atc-disabled-color, #666666) !important;
}

.artex-pv-wrapper[data-artex-elementor="1"] {
	--apv-atc-disabled-bg: #cccccc;
	--apv-atc-disabled-color: #666666;
	--apv-atc-bg: #111111;
	--apv-atc-color: #ffffff;
}

.artex-pv-wrapper[data-artex-elementor="1"] .artex-pv-atc:not(:disabled):not(.artex-pv-atc--incomplete) {
	background-color: var(--apv-atc-bg, #111111) !important;
	color: var(--apv-atc-color, #ffffff) !important;
}

.artex-pv-wrapper:not([data-artex-elementor="1"]) .artex-pv-atc {
	width: var(--apv-atc-width, 100%);
	padding: var(--apv-atc-padding, 16px 24px);
	font-size: var(--apv-atc-font-size, 16px);
	font-weight: var(--apv-atc-font-weight, 600);
	border-radius: var(--apv-atc-border-radius, 4px);
	background-color: var(--apv-atc-bg, #111);
	color: var(--apv-atc-color, #fff);
}

.artex-pv-atc:not(:disabled):not(.artex-pv-atc--incomplete):hover {
	opacity: 0.9;
}

/* Hidden native selects */
.artex-pv-hidden-select {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

.artex-pv-wrapper .woocommerce-variation-add-to-cart.artex-pv-atc-wrap--always-visible {
	display: flex !important;
}

.artex-pv-placeholder {
	padding: 24px;
	background: #f0f0f0;
	border: 2px dashed #ccc;
	text-align: center;
	color: #666;
	border-radius: 4px;
}

.artex-pv-wrapper .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

.artex-pv-wrapper .woocommerce-variation-price,
.artex-pv-wrapper .woocommerce-variation-availability {
	margin-bottom: 12px;
}

.artex-pv-wrapper .woocommerce-variation-description {
	margin-bottom: 12px;
}

.artex-pv-attribute--button .artex-pv-buttons--size {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: var(--apv-button-gap, 8px);
}

.artex-pv-attribute--button .artex-pv-buttons--size .artex-pv-btn {
	width: 100%;
}
