/**
 * Color Swatches by Jopa — Frontend styles
 */

.csbj-wrapper {
	margin: 0 0 1.25em;
}

.csbj-attr-label {
	display: block;
	margin-bottom: 0.5em;
	font-weight: 600;
}

.csbj-selected-name {
	font-weight: 400;
	color: #555;
}

.csbj-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

/* ------------------------------------------------------------------
 * Botón (contenedor clickeable)
 * Forzamos la disposición horizontal con !important porque algunos
 * temas (Hello Elementor, etc.) aplican `button { display: block }`
 * y romperían el layout en producción (ícono arriba, texto abajo).
 * ------------------------------------------------------------------ */
.csbj-wrapper .csbj-swatch {
	position: relative;
	display: inline-flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center;
	justify-content: center;
	width: auto;
	max-width: none;
	padding: 0;
	margin: 0;
	border: 2px solid #ddd;
	border-style: solid;
	background: transparent;
	cursor: pointer;
	box-sizing: border-box;
	line-height: 1;
	transition: transform 0.15s ease, box-shadow 0.15s ease,
		border-color 0.15s ease, background-color 0.15s ease;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.csbj-swatch:focus-visible {
	box-shadow: 0 0 0 3px rgba( 0, 0, 0, 0.25 );
}

/* Estado activo */
.csbj-swatch.is-active {
	border-color: #111;
	box-shadow: 0 0 0 2px #111;
}

/* ------------------------------------------------------------------
 * Color (la "muestra" coloreada dentro del botón)
 * ------------------------------------------------------------------ */
.csbj-wrapper .csbj-swatch-color {
	display: block;
	width: 36px;
	height: 36px;
	flex: 0 0 auto !important;
	background-color: #eee;
	background-clip: padding-box;
}

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

.csbj-shape-square .csbj-swatch-color {
	border-radius: 4px;
}

/* ------------------------------------------------------------------
 * Modo "swatch suelto" (sin texto): el botón abraza el color
 * ------------------------------------------------------------------ */
.csbj-wrapper:not( .csbj-with-label ) .csbj-swatch:hover {
	transform: scale( 1.08 );
}

.csbj-wrapper:not( .csbj-with-label ).csbj-shape-circle .csbj-swatch {
	border-radius: 50%;
}

.csbj-wrapper:not( .csbj-with-label ).csbj-shape-square .csbj-swatch {
	border-radius: 6px;
}

/* ------------------------------------------------------------------
 * Modo "chip" (nombre dentro del botón)
 * ------------------------------------------------------------------ */
.csbj-with-label .csbj-swatch {
	gap: 8px;
	padding: 5px 12px 5px 6px;
	border-radius: 8px;
	background-color: #f4f4f5;
}

.csbj-with-label .csbj-swatch:hover {
	filter: brightness( 0.97 );
}

.csbj-with-label .csbj-swatch-text {
	display: inline-block;
	flex: 0 1 auto;
	font-size: 14px;
	line-height: 1.2;
	color: #1a1a1a;
	white-space: nowrap;
}

/* ------------------------------------------------------------------
 * Tooltip (solo en modo swatch suelto)
 * ------------------------------------------------------------------ */
.csbj-tooltip {
	position: absolute;
	bottom: calc( 100% + 8px );
	left: 50%;
	transform: translateX( -50% );
	background: #111;
	color: #fff;
	font-size: 12px;
	line-height: 1;
	white-space: nowrap;
	padding: 6px 8px;
	border-radius: 4px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.15s ease, visibility 0.15s ease;
	z-index: 20;
}

.csbj-tooltip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX( -50% );
	border: 5px solid transparent;
	border-top-color: #111;
}

/* Mostrar tooltip solo si el wrapper lo habilita */
.csbj-wrapper[data-tooltip="1"] .csbj-swatch:hover .csbj-tooltip,
.csbj-wrapper[data-tooltip="1"] .csbj-swatch:focus-visible .csbj-tooltip {
	opacity: 1;
	visibility: visible;
}

/* En modo chip el nombre ya está visible: no hace falta tooltip */
.csbj-with-label .csbj-tooltip {
	display: none;
}

/* ------------------------------------------------------------------
 * Aviso en el editor
 * ------------------------------------------------------------------ */
.csbj-notice {
	padding: 12px 16px;
	background: #fff8e1;
	border: 1px dashed #e0c068;
	color: #6b5400;
	border-radius: 4px;
	font-size: 13px;
}

/* Texto accesible oculto (por si el tema no lo define) */
.csbj-swatch .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	white-space: nowrap;
}
