/**
 * Necta Swatches - Frontend Styles
 *
 * Styles for swatches on product pages and in Bundles.
 *
 * @package Necta\Swatches
 * @since 1.0.0
 */

/* ==========================================================================
   Hidden Original Dropdown
   ========================================================================== */

.ns-hidden-dropdown {
	position: absolute !important;
	opacity: 0 !important;
	pointer-events: none !important;
	height: 0 !important;
	width: 0 !important;
	overflow: hidden !important;
}

/* ==========================================================================
   Swatches Container
   ========================================================================== */

.ns-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ns-gap, 8px);
	margin: 8px 0 16px;
}

/* ==========================================================================
   Base Swatch Styles
   ========================================================================== */

.ns-swatch {
	position: relative;
	cursor: pointer;
	transition: all 0.2s ease;
	border: var(--ns-border-width, 2px) solid var(--ns-border-color, transparent);
	border-radius: var(--ns-border-radius, 6px);
	box-sizing: border-box;
}

/* Hover effect (when enabled) */
.ns-hover-lift .ns-swatch:hover {
	transform: translateY(-1px);
}

/* Shadow (when enabled) */
.ns-has-shadow .ns-swatch {
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.ns-has-shadow .ns-swatch:hover {
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.ns-swatch.ns-selected {
	border-color: var(--ns-border-color-selected, #000);
}

.ns-swatch.ns-disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

.ns-swatch.ns-out-of-stock {
	position: relative;
}

/* Out of stock - cross line */
.ns-swatch.ns-out-of-stock::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 2px;
	background: rgba(0, 0, 0, 0.5);
	transform: rotate(-45deg);
}

/* Out of stock - fade (alternative) */
.ns-swatches[data-oos="fade"] .ns-swatch.ns-out-of-stock::after {
	display: none;
}

.ns-swatches[data-oos="fade"] .ns-swatch.ns-out-of-stock {
	opacity: 0.3;
}

/* ==========================================================================
   Shape Variants
   ========================================================================== */

.ns-shape-square .ns-swatch {
	border-radius: 0;
}

.ns-shape-square .ns-swatch-color,
.ns-shape-square .ns-swatch-image {
	border-radius: 0;
}

.ns-shape-rounded .ns-swatch {
	border-radius: var(--ns-border-radius, 6px);
}

.ns-shape-pill .ns-swatch {
	border-radius: 9999px;
}

.ns-shape-pill .ns-swatch-color,
.ns-shape-pill .ns-swatch-image {
	border-radius: 9999px;
}

.ns-shape-circle .ns-swatch {
	border-radius: 50%;
}

.ns-shape-circle .ns-swatch-color,
.ns-shape-circle .ns-swatch-image {
	border-radius: 50%;
}

/* ==========================================================================
   Size Variants
   ========================================================================== */

/* Small */
.ns-size-small .ns-swatch-color {
	width: 24px;
	height: 24px;
}

.ns-size-small .ns-swatch-image {
	width: 28px;
	height: 28px;
}

.ns-size-small .ns-swatch-label {
	padding: 6px 10px;
	font-size: 12px;
}

/* Medium (default) */
.ns-size-medium .ns-swatch-color {
	width: 32px;
	height: 32px;
}

.ns-size-medium .ns-swatch-image {
	width: 40px;
	height: 40px;
}

.ns-size-medium .ns-swatch-label {
	padding: 8px 16px;
	font-size: var(--ns-font-size, 14px);
}

/* Large */
.ns-size-large .ns-swatch-color {
	width: 40px;
	height: 40px;
}

.ns-size-large .ns-swatch-image {
	width: 56px;
	height: 56px;
}

.ns-size-large .ns-swatch-label {
	padding: 10px 20px;
	font-size: 16px;
}

/* ==========================================================================
   Color Swatch
   ========================================================================== */

.ns-swatch-color {
	display: block;
	border-radius: calc(var(--ns-border-radius, 6px) - 2px);
	border: 1px solid rgba(0, 0, 0, 0.1);
}

.ns-swatches-color .ns-swatch {
	padding: 2px;
}

.ns-swatches-color .ns-swatch.ns-selected {
	box-shadow: 0 0 0 1px #fff inset;
}

/* ==========================================================================
   Image Swatch
   ========================================================================== */

.ns-swatch-image {
	display: block;
	object-fit: cover;
	border-radius: calc(var(--ns-border-radius, 6px) - 2px);
}

.ns-swatches-image .ns-swatch,
.ns-swatches-image_global .ns-swatch {
	padding: 2px;
	background: #fff;
}

/* ==========================================================================
   Button/Label Swatch
   ========================================================================== */

.ns-swatch-label {
	display: block;
	font-size: var(--ns-font-size, 14px);
	font-weight: var(--ns-font-weight, 500);
	line-height: 1.2;
	white-space: nowrap;
	color: var(--ns-text-color, #333);
}

.ns-swatches-button .ns-swatch,
.ns-swatches-label .ns-swatch {
	background: var(--ns-bg-color, #fff);
}

.ns-swatches-button .ns-swatch:hover,
.ns-swatches-label .ns-swatch:hover {
	background: color-mix(in srgb, var(--ns-bg-color, #fff) 95%, #000);
}

.ns-swatches-button .ns-swatch.ns-selected,
.ns-swatches-label .ns-swatch.ns-selected {
	background: var(--ns-bg-color-selected, #000);
	border-color: var(--ns-border-color-selected, #000);
}

.ns-swatches-button .ns-swatch.ns-selected .ns-swatch-label,
.ns-swatches-label .ns-swatch.ns-selected .ns-swatch-label {
	color: var(--ns-text-color-selected, #fff);
}

/* ==========================================================================
   Tooltips
   ========================================================================== */

.ns-swatch[data-tooltip] {
	position: relative;
}

.ns-swatch[data-tooltip]::before {
	content: attr(data-tooltip);
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	padding: 6px 10px;
	background: #333;
	color: #fff;
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
	border-radius: 4px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s, visibility 0.2s;
	z-index: 100;
}

.ns-swatch[data-tooltip]::after {
	content: '';
	position: absolute;
	bottom: calc(100% + 4px);
	left: 50%;
	transform: translateX(-50%);
	border: 4px solid transparent;
	border-top-color: #333;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s, visibility 0.2s;
	z-index: 100;
}

.ns-swatch[data-tooltip]:hover::before,
.ns-swatch[data-tooltip]:hover::after {
	opacity: 1;
	visibility: visible;
}

/* ==========================================================================
   Integration with WooCommerce
   ========================================================================== */

/* Variation form row */
.variations tr {
	display: flex;
	flex-direction: column;
	margin-bottom: 16px;
}

.variations tr .label {
	margin-bottom: 4px;
}

.variations tr .label label {
	font-weight: 600;
	font-size: 14px;
}

/* Reset button styling */
.reset_variations {
	margin-left: auto;
}

/* ==========================================================================
   Integration with Necta Bundles
   ========================================================================== */

/* Inside bundle offers */
.nb-offer-variants .ns-swatches,
.necta-bundle-variants .ns-swatches {
	margin: 8px 0;
}

.nb-offer-variants .ns-swatch-color,
.necta-bundle-variants .ns-swatch-color {
	width: 28px;
	height: 28px;
}

.nb-offer-variants .ns-swatch-image,
.necta-bundle-variants .ns-swatch-image {
	width: 32px;
	height: 32px;
}

.nb-offer-variants .ns-swatch-label,
.necta-bundle-variants .ns-swatch-label {
	padding: 6px 12px;
	font-size: 13px;
}

/* ==========================================================================
   Price Display
   ========================================================================== */

/* Price element - hidden by default */
.ns-swatch-price {
	display: none;
	font-size: 11px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
}

.ns-swatch-price:empty {
	display: none !important;
}

/* Price position: below */
.ns-swatches.ns-price-below .ns-swatch {
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.ns-swatches.ns-price-below .ns-swatch-price {
	display: block;
	color: #666;
	margin-top: 2px;
}

/* Positive/negative price styling */
.ns-swatch-price.ns-price-positive {
	color: #dc2626;
}

.ns-swatch-price.ns-price-negative {
	color: #16a34a;
}

/* Price position: badge */
.ns-swatches.ns-price-badge .ns-swatch {
	position: relative;
}

.ns-swatches.ns-price-badge .ns-swatch-price {
	display: block;
	position: absolute;
	top: -8px;
	right: -8px;
	padding: 2px 5px;
	background: #1f2937;
	color: #fff;
	border-radius: 10px;
	font-size: 10px;
	z-index: 1;
}

.ns-swatches.ns-price-badge .ns-swatch-price:empty {
	display: none !important;
}

/* Price position: tooltip - integrated with existing tooltip */
.ns-swatches.ns-price-tooltip .ns-swatch-price {
	display: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
	.ns-swatches {
		gap: 6px;
	}

	.ns-swatch-color {
		width: 28px;
		height: 28px;
	}

	.ns-swatch-image {
		width: 36px;
		height: 36px;
	}

	.ns-swatch-label {
		padding: 6px 12px;
		font-size: 13px;
	}

	/* Tooltips on mobile - show on tap */
	.ns-swatch[data-tooltip]::before,
	.ns-swatch[data-tooltip]::after {
		display: none;
	}
}
