/* Woo Image Swatches */

:root {
	--wis-size: 110px;
	--wis-gap: 8px;
	--wis-radius: 8px;
	--wis-ratio: 1 / 1; /* kvadrat — prati WooCommerce sličice varijacija */
	--wis-bg: #fff;
	--wis-border: #e6e6e6; /* tanki svijetli okvir */
	--wis-border-hover: #bdbdbd;
	--wis-border-active: #111;
	--wis-accent: #111;
}

/* Sakrij originalni dropdown kad su swatchevi aktivni (dodaje JS). */
.wis-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;
}

.wis-wrap {
	margin: 4px 0 2px;
}

.wis-selected-name {
	font-size: 0.9em;
	margin-bottom: 6px;
	min-height: 1.2em;
	color: #444;
}

.wis-selected-name:empty {
	display: none;
}

.wis-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(var(--wis-size), 1fr));
	gap: var(--wis-gap);
	max-width: calc((var(--wis-size) + var(--wis-gap)) * 6);
}

.wis-swatch {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: var(--wis-ratio);
	padding: 7px;
	margin: 0;
	border: 1px solid var(--wis-border) !important;
	border-radius: var(--wis-radius);
	background: var(--wis-bg) !important;
	background-image: none !important;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
	overflow: hidden;
	box-shadow: none !important;
	transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
	box-sizing: border-box;
}

.wis-swatch:hover {
	border-color: var(--wis-border-hover) !important;
	background: var(--wis-bg) !important;
	transform: translateY(-1px);
}

.wis-swatch:focus-visible {
	outline: 2px solid var(--wis-accent);
	outline-offset: 2px;
}

.wis-swatch img {
	width: 100%;
	height: 100%;
	object-fit: contain; /* cijela majica vidljiva, bez rezanja */
	border-radius: calc(var(--wis-radius) - 3px);
	display: block;
}

.wis-swatch .wis-noimg {
	font-size: 0.7em;
	line-height: 1.1;
	text-align: center;
	color: #555;
	text-transform: uppercase;
}

.wis-swatch.wis-active {
	border-color: var(--wis-border-active) !important;
	box-shadow: 0 0 0 1px var(--wis-border-active) !important;
}

.wis-swatch.wis-active::after {
	content: "";
	position: absolute;
	right: 3px;
	bottom: 3px;
	width: 14px;
	height: 14px;
	background: var(--wis-accent);
	border-radius: 50%;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
	background-size: 10px 10px;
	background-position: center;
	background-repeat: no-repeat;
}

/* "Prikaži više" — skriveni viškovi dok grid nije proširen. */
.wis-swatches.wis-collapsible .wis-swatch.wis-extra {
	display: none;
}

.wis-swatches.wis-expanded .wis-swatch.wis-extra {
	display: flex;
}

.wis-toggle {
	margin-top: 8px;
	padding: 4px 0;
	background: none;
	border: none;
	color: var(--wis-accent);
	font-size: 0.85em;
	text-decoration: underline;
	cursor: pointer;
}

.wis-toggle:hover {
	opacity: 0.7;
}

/* ---------- Label gumbi (npr. veličine) ---------- */

.wis-swatches.wis-kind-label {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	max-width: none;
}

.wis-swatch--label {
	width: auto;
	height: auto;
	min-width: 46px;
	aspect-ratio: auto;
	padding: 9px 14px !important;
	font-size: 0.95em;
	font-weight: 500;
	line-height: 1;
	color: #222;
	text-transform: uppercase;
}

.wis-swatch--label.wis-active {
	background: var(--wis-border-active) !important;
	border-color: var(--wis-border-active) !important;
	color: #fff !important;
}

/* Kvačica se ne crta na label gumbima. */
.wis-swatch--label.wis-active::after {
	display: none;
}

/* ---------- Nedostupne vrijednosti ---------- */

.wis-swatch.wis-disabled {
	opacity: 0.35;
	cursor: not-allowed;
	pointer-events: auto; /* dopusti hover/tooltip, klik blokira JS */
}

.wis-swatch--label.wis-disabled {
	text-decoration: line-through;
}

/* ---------- Zaliha ---------- */

.wis-stock {
	margin-top: 8px;
	font-size: 0.9em;
	font-weight: 500;
	color: #2c7a2c;
	min-height: 1.2em;
}

.wis-stock:empty {
	display: none;
}

.wis-stock.wis-stock--out {
	color: #b3261e;
}

/* ---------- Mobitel ---------- */

@media ( max-width: 782px ) {
	/* Presloži WooCommerce tablicu varijacija: labela (npr. "Veličina:") na svoj red,
	   kućice ispod punom širinom — inače stoje jedno do drugog i gumbi izađu iz ekrana. */
	table.variations tr {
		display: block;
		margin-bottom: 10px;
	}

	table.variations th.label,
	table.variations td.value {
		display: block;
		width: 100%;
		padding-left: 0;
		padding-right: 0;
		text-align: left;
	}

	table.variations th.label {
		padding-bottom: 4px;
	}

	.wis-swatches.wis-kind-label {
		max-width: calc( 100vw - 32px );
		gap: 6px;
	}

	.wis-swatch--label {
		min-width: 42px;
		padding: 8px 11px !important;
		font-size: 0.9em;
	}
}
