/**
 * Zenth Configurador — Widget Elementor (panel de personalización).
 *
 * Layout de dos columnas: header + preview "EN VIVO" a la izquierda, wizard de
 * pasos a la derecha (nombre del paso + flechas + opciones en thumbnails +
 * barra de progreso), y abajo las acciones (dual-btn: Cotizar + Descargar).
 * El contenido (pasos + opciones) viene del CPT; este CSS controla solo lo
 * visual. Usa tokens --cr-* del child theme con fallbacks (standalone).
 *
 * ─────────────────────────────────────────────────────────────────────────
 * ÍNDICE
 *   §1  Wrapper + variables locales → .zenth-configurador (+ widget overrides)
 *   §2  Stage (grid 2-col)          → .zenth-configurador__stage
 *   §3  Preview                     → imagen fija + gradiente + loader + badge EN VIVO
 *   §3b Lupa de zoom (hover)        → lente que sigue al cursor + hint (solo desktop)
 *   §4  Wizard                      → head + step-meta (eyebrow + nombre del paso)
 *   §5  Navegación                  → flechas prev/next (patrón timeline)
 *   §6  Panels + opciones           → carrusel de thumbnails + check seleccionado
 *   §7  Barra de progreso           → track + fill + markers (patrón timeline)
 *   §8  Acciones (dual-btn)         → botones Cotizar (primary) + Descargar (ghost)
 *   §9  Toast                       → aviso flotante .zenth-cfg-toast
 *   §10 Responsive                  → TODOS los @media de tamaño + a11y
 * ─────────────────────────────────────────────────────────────────────────
 * BREAKPOINTS (desktop es la base, sin media query)
 *   Tablet        → max-width: 1024px   (stage pasa a 1 columna)
 *   Mobile-small  → max-width: 600px    (cards del carrusel a ~2 visibles)
 *   Mobile-xs     → max-width: 480px    (acciones apiladas vertical)
 *
 *   Todos los @media de tamaño viven en §10, ordenados de más ancho a más
 *   angosto (1024 → 600 → 480). Al final, accesibilidad
 *   (prefers-reduced-motion), que NO es breakpoint de tamaño y va aparte.
 *   Los @keyframes (zcfg-spin, zcfg-live) viajan junto a su componente (§3).
 * ─────────────────────────────────────────────────────────────────────────
 */


/* ═══════════════════════════════════════════════════════════════════════
   §1 · WRAPPER + VARIABLES LOCALES
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador {
	--cfg-radius: 12px;
	--cfg-preview-ratio: 4 / 3;
	--cfg-opt-basis: 30%; /* ancho de cada card del carrusel: ~3 visibles + peek */
	--cfg-lens-size: 180px; /* diámetro de la lupa de zoom (hover, solo desktop) */

	display: flex;
	flex-direction: column;
	gap: clamp(24px, 3vw, 44px);
	width: 100%;
	color: var(--cr-color-white, #fff);
	font-family: var(--cr-font-body, 'Montserrat', system-ui, sans-serif);
}

.elementor-widget-zenth_configurador {
    width: 100% !important;
    margin-top: 5rem;
}
.elementor-widget-zenth_configurador .elementor-widget-container { width: 100%; }


/* El header (eyebrow + título) NO es parte del widget: se arma en Elementor
   con los patrones de sections.css, como en los demás widgets. */


/* ═══════════════════════════════════════════════════════════════════════
   §2 · STAGE (grid 2-col)
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__stage {
	display: grid;
	grid-template-columns: 1.05fr 0.95fr;
	gap: clamp(24px, 3vw, 48px);
	align-items: start;
	width: 100%;
}


/* ═══════════════════════════════════════════════════════════════════════
   §3 · PREVIEW — imagen fija + gradiente + loader + badge EN VIVO
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__preview {
	position: relative;
	width: 100%;
	aspect-ratio: var(--cfg-preview-ratio, 4 / 3);
	border-radius: var(--cfg-radius, 12px);
	overflow: hidden;
	background: var(--cr-color-darker, #0f0f0f);
}

/* Gradiente POR DELANTE de la imagen: funde con el fondo negro en los 4 lados
   para que el preview se integre sin bordes duros. Un solo ::before con 4
   linear-gradient apilados (abajo el más fuerte; top/laterales sutiles). El
   badge (z-3) y el loader (z-4) quedan por encima de este gradiente (z-1). */
.zenth-configurador__preview::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background:
		linear-gradient(to top,    var(--cr-color-black, #000) 0%, transparent 48%),
		linear-gradient(to bottom, var(--cr-color-black, #000) 0%, transparent 20%),
		linear-gradient(to right,  var(--cr-color-black, #000) 0%, transparent 15%),
		linear-gradient(to left,   var(--cr-color-black, #000) 0%, transparent 15%);
}

/* Overlay oscuro DEBAJO del spinner mientras carga (backdrop del loader). */
.zenth-configurador__preview.is-loading::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 2;
	background: #000;
	pointer-events: none;
}

.zenth-configurador__preview-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Loader del preview: anillo blanco centrado mientras carga la nueva imagen de
   la combinación (al elegir una opción). Visible con .is-loading en el stage. */
.zenth-configurador__loader {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 4;
	width: 50px;
	aspect-ratio: 1;
	border-radius: 50%;
	border: 8px solid;
	border-color: var(--cr-color-white, #fff) #0000;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 200ms ease;
	animation: zcfg-spin 1s infinite;
}
.zenth-configurador__preview.is-loading .zenth-configurador__loader {
	opacity: 1;
	visibility: visible;
}
/* El translate se repite en el keyframe para no perder el centrado al rotar. */
@keyframes zcfg-spin {
	to { transform: translate(-50%, -50%) rotate(0.5turn); }
}

.zenth-configurador__badge {
	position: absolute;
	top: 16px;
	left: 16px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 14px;
	border-radius: 6px;
	background: var(--cr-color-primary, #c00000);
	color: var(--cr-color-white, #fff);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	line-height: 1;
}

/* Punto "EN VIVO": late con un anillo que se expande y desvanece (efecto live). */
.zenth-configurador__badge::before {
	content: '';
	flex: 0 0 auto;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--cr-color-white, #fff);
	animation: zcfg-live 1.5s ease-in-out infinite;
}
@keyframes zcfg-live {
	0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); opacity: 1; }
	70%  { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0); opacity: 0.55; }
	100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); opacity: 1; }
}


/* ═══════════════════════════════════════════════════════════════════════
   §3b · LUPA DE ZOOM (hover) — lente que sigue al cursor sobre el preview
   ───────────────────────────────────────────────────────────────────────
   Solo desktop con mouse: el JS crea la lente + el hint y los gatea con
   matchMedia('(hover:hover) and (pointer:fine)'), así que en táctil no existen.
   La lente usa la imagen FULL de la combinación actual como background y la
   amplía por el nivel de zoom (data-zoom-level). El background-image / -size /
   -position los calcula y setea el JS en cada mousemove; acá solo el aspecto.
   ═══════════════════════════════════════════════════════════════════════ */

/* Cursor de precisión cuando la lupa está disponible (clase la pone el JS). */
.zenth-configurador__preview.has-zoom { cursor: crosshair; }

/* Lente: círculo que flota sobre el preview. pointer-events:none para que los
   mousemove sigan llegando al contenedor (si no, la lente se "comería" el move
   y el zoom se trabaría). z-5 → por encima de gradiente (z1), badge (z3) y
   loader (z4). */
.zenth-configurador__lens {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 5;
	width: var(--cfg-lens-size, 180px);
	height: var(--cfg-lens-size, 180px);
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.85);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
	background-color: var(--cr-color-darker, #0f0f0f);
	background-repeat: no-repeat;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 160ms ease, visibility 160ms ease;
}
.zenth-configurador__lens.is-active {
	opacity: 1;
	visibility: visible;
}

/* Hint de descubribilidad: ícono de lupa abajo-derecha (lo crea el JS). Se
   desvanece mientras la lente está activa para no estorbar la vista. */
.zenth-configurador__zoom-hint {
	position: absolute;
	right: 14px;
	bottom: 14px;
	z-index: 4;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	color: var(--cr-color-white, #fff);
	pointer-events: none;
	transition: opacity 200ms ease;
}
.zenth-configurador__zoom-hint svg {
	display: block;
	width: 18px;
	height: 18px;
}
.zenth-configurador__preview.is-zooming .zenth-configurador__zoom-hint { opacity: 0; }


/* ═══════════════════════════════════════════════════════════════════════
   §4 · WIZARD — head + step-meta
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__wizard {
	display: flex;
	flex-direction: column;
	gap: clamp(18px, 2.4vw, 30px);
	width: 100%;
	min-width: 0;
}

.zenth-configurador__wizard-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.zenth-configurador__step-meta {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.zenth-configurador__step-eyebrow {
	color: var(--cr-color-text-muted, #81817f);
	font-size: clamp(12px, 1vw, 14px);
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.zenth-configurador__step-name {
	font-family: var(--cr-font-display, 'Super Brigade', Impact, sans-serif);
	font-style: italic;
	font-size: clamp(28px, 3.6vw, 52px);
	line-height: 1;
	text-transform: uppercase;
	color: var(--cr-color-white, #fff);
}


/* ═══════════════════════════════════════════════════════════════════════
   §5 · NAVEGACIÓN — flechas prev/next (patrón timeline)
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__nav {
	display: flex;
	gap: 10px;
	flex-shrink: 0;
}

.zenth-configurador__nav-prev,
.zenth-configurador__nav-next {
	display: grid;
	place-items: center;
	width: clamp(40px, 3.4vw, 52px);
	height: clamp(40px, 3.4vw, 52px);
	border-radius: 50%;
	cursor: pointer;
	transition: background 250ms ease, border-color 250ms ease, transform 250ms ease, opacity 250ms ease;
}

.zenth-configurador__nav-prev {
	background: var(--cr-color-primary, #c00000);
	border: 1px solid var(--cr-color-primary, #c00000);
	color: var(--cr-color-white, #fff);
}
/* :focus espeja a :hover (prefijo `button` → 0,2,1) para ganarle al fondo
   "rosado" que el tema padre mete en [type=button]:focus (0,2,0). */
.zenth-configurador__nav-prev:hover,
button.zenth-configurador__nav-prev:focus { background: var(--cr-color-primary-hover, #e60000); }

.zenth-configurador__nav-next {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.6);
	color: var(--cr-color-white, #fff);
}
.zenth-configurador__nav-next:hover,
button.zenth-configurador__nav-next:focus { border-color: var(--cr-color-white, #fff); background: rgba(255, 255, 255, 0.06); }

.zenth-configurador__nav-prev.is-disabled,
.zenth-configurador__nav-next.is-disabled {
	pointer-events: none;
}

.zenth-configurador__nav-prev svg,
.zenth-configurador__nav-next svg { display: block; }


/* ═══════════════════════════════════════════════════════════════════════
   §6 · PANELS + OPCIONES — carrusel de thumbnails
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__panels { width: 100%; }
.zenth-configurador__panel[hidden] { display: none; }

/* Carrusel horizontal con peek: se ven ~3 cards y asoman las siguientes.
   Scroll/drag horizontal en touch, o rueda+shift en desktop. Sin JS: el peek
   (la card cortada en el borde) avisa que hay más; scroll-snap alinea. */
.zenth-configurador__options {
	display: flex;
	gap: clamp(10px, 1.2vw, 16px);
	overflow-x: auto;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;            /* Firefox: ocultar scrollbar */
	padding-bottom: 2px;
	cursor: grab;                     /* arrastrar para recorrer las opciones (JS) */
}
.zenth-configurador__options.is-dragging { cursor: grabbing; }
.zenth-configurador__options::-webkit-scrollbar { display: none; } /* WebKit */

.zenth-configurador__option {
	flex: 0 0 var(--cfg-opt-basis, 30%); /* card del carrusel: no se encoge */
	min-width: 0;                        /* clave: sin esto, un nombre largo (1 línea)
	                                        ensancha la card por encima del 30% y rompe
	                                        las proporciones del swatch. Con min-width:0
	                                        la card mantiene su ancho y el label trunca. */
	scroll-snap-align: start;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	text-align: left;
	-webkit-appearance: none;
	appearance: none;
}

.zenth-configurador__option-media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4;
	overflow: hidden;
	border-radius: 10px;
	border: 2px solid transparent;
	background: var(--cr-color-darker, #0f0f0f);
	transition: border-color var(--cr-transition-base, 250ms ease);
}

.zenth-configurador__option-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Nombre del material, debajo del swatch (el flex column lo separa con su gap).
   Viaja también en data-label para la cotización/PDF. Una sola línea con ellipsis
   para que todas las cards del carrusel mantengan la misma altura (nombres largos
   se recortan en vez de empujar la card). */
.zenth-configurador__option-label {
	display: block;
	font-size: clamp(11px, 0.95vw, 13px);
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.25;
	text-align: center;
	color: var(--cr-color-text-muted, #81817f);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: color var(--cr-transition-base, 250ms ease);
}

.zenth-configurador__option:focus, .zenth-configurador__option:hover {
    background-color: transparent;
}

.zenth-configurador__option:hover .zenth-configurador__option-media {
    border-color: rgba(255, 255, 255, 0.3);
}

.zenth-configurador__option.is-selected .zenth-configurador__option-media { border-color: var(--cr-color-primary, #c00000); }
.zenth-configurador__option.is-selected .zenth-configurador__option-label { color: var(--cr-color-white, #fff); }

.zenth-configurador__option:focus-visible .zenth-configurador__option-media {
	outline: 2px solid var(--cr-color-primary, #c00000);
	outline-offset: 2px;
}

/* Check rojo en la opción seleccionada. */
.zenth-configurador__option.is-selected .zenth-configurador__option-media::after {
	content: '';
	position: absolute;
	top: 8px;
	right: 8px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--cr-color-primary, #c00000) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / 14px no-repeat;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.zenth-configurador__empty {
	color: var(--cr-color-text-muted, #81817f);
	font-size: 14px;
	margin: 0;
}


/* ═══════════════════════════════════════════════════════════════════════
   §7 · BARRA DE PROGRESO — track + fill + markers (patrón timeline)
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__progress {
	position: relative;
	height: 16px;
	display: flex;
	align-items: center;
}

.zenth-configurador__progress-track {
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 100%;
	height: 3px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.2);
}

.zenth-configurador__progress-fill {
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: var(--cfg-progress, 0%);
	height: 3px;
	border-radius: 2px;
	background: var(--cr-color-primary, #c00000);
	transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Los puntos (markers) se ocultan: el diseño usa una barra limpia (track +
   fill por paso). La navegación entre pasos la dan las flechas del head. */
.zenth-configurador__markers {
	display: none;
}

.zenth-configurador__marker {
	width: 12px;
	height: 12px;
	padding: 0;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-radius: 50%;
	background: var(--cr-color-black, #000);
	cursor: pointer;
	transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.zenth-configurador__marker.is-done {
	background: var(--cr-color-primary, #c00000);
	border-color: var(--cr-color-primary, #c00000);
}

.zenth-configurador__marker.is-active {
	background: var(--cr-color-primary, #c00000);
	border-color: var(--cr-color-primary, #c00000);
	transform: scale(1.25);
}


/* ═══════════════════════════════════════════════════════════════════════
   §8 · ACCIONES (dual-btn) — Cotizar (primary) + Descargar (ghost)
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-configurador__actions {
	display: inline-flex;
	align-self: center;
	flex-direction: row;
	align-items: stretch;
	gap: 0;
	max-width: 100%;
	overflow: hidden;
}

.zenth-configurador__btn {
	-webkit-appearance: none;
	appearance: none;
	border: 0;
	margin: 0;
	cursor: pointer;
	border-radius: 6rem;
	border: 2px solid  var(--cr-color-primary, #c00000);
	padding: 16px 3rem;
	font-family: inherit;
	font-size: clamp(12px, 1vw, 13px);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	line-height: 1;
	transition: background var(--cr-transition-base, 250ms ease), color var(--cr-transition-base, 250ms ease);
}

.zenth-configurador__btn--primary {
    z-index: 1;
	background: var(--cr-color-primary, #c00000);
	color: var(--cr-color-white, #fff);
}
.zenth-configurador__btn--primary:hover,
button.zenth-configurador__btn--primary:focus { background: var(--cr-color-primary-hover, #e60000); }

.zenth-configurador__btn--ghost {
    z-index: 0;
    padding-left: 7rem !important;
    margin-left: -5rem !important;
	background: transparent;
	color: var(--cr-color-white, #fff);
}
.zenth-configurador__btn--ghost:hover,
button.zenth-configurador__btn--ghost:focus { background: rgba(255, 255, 255, 0.08); }

.zenth-configurador__btn:focus-visible { outline: 2px solid var(--cr-color-white, #fff); outline-offset: -4px; }

.zenth-configurador__btn.is-disabled { opacity: 0.5; pointer-events: none; }


/* ═══════════════════════════════════════════════════════════════════════
   §9 · TOAST — aviso flotante
   ───────────────────────────────────────────────────────────────────────
   Nodo único inyectado por configurador.js (.zenth-cfg-toast en <body>).
   Aparece abajo-centro al intentar avanzar sin elegir una opción; se auto-
   oculta a los ~3s. Va por encima del header y no captura clicks.
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-cfg-toast {
	position: fixed;
	left: 50%;
	bottom: clamp(20px, 5vh, 40px);
	z-index: 100001;
	max-width: min(90vw, 420px);
	padding: 14px 22px;
	border-radius: 10px;
	background: var(--cr-color-darker, #0f0f0f);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-left: 3px solid var(--cr-color-primary, #c00000);
	color: var(--cr-color-white, #fff);
	font-family: var(--cr-font-body, 'Montserrat', system-ui, sans-serif);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	text-align: center;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateX(-50%) translateY(14px);
	transition: opacity 280ms ease,
				transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
				visibility 0s linear 280ms;
}

.zenth-cfg-toast.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
	transition: opacity 280ms ease,
				transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}


/* ═══════════════════════════════════════════════════════════════════════
   §10 · RESPONSIVE — todos los @media, de más ancho a más angosto
   ───────────────────────────────────────────────────────────────────────
   Tiers:  Tablet (≤1024) → Mobile-small (≤600) → Mobile-xs (≤480)
   El cascade max-width va de mayor a menor. Las reglas base correspondientes
   viven en sus secciones (§2 stage, §6 options, §8 acciones) ANTES de acá.
   Al final, accesibilidad (prefers-reduced-motion), que NO consolida con los
   de tamaño.
   ═══════════════════════════════════════════════════════════════════════ */

/* ───────────────────────── TABLET · max-width: 1024px ─────────────────── */
@media (max-width: 1024px) {
	/* §2 · Stage colapsa de dos columnas a una sola */
	.zenth-configurador__stage { grid-template-columns: 1fr; }
}

/* ─────────────────────── MOBILE-SMALL · max-width: 600px ──────────────── */
@media (max-width: 600px) {
	/* §6 · Carrusel: cards más anchas → ~2 visibles + peek */
	.zenth-configurador { --cfg-opt-basis: 46%; } /* ~2 visibles + peek */
}

/* ─────────────────────── MOBILE-XS · max-width: 480px ─────────────────── */
@media (max-width: 480px) {
	/* §8 · Acciones (dual-btn) se apilan vertical y a todo el ancho */
	.zenth-configurador__actions {
		flex-direction: column;
		width: 100%;
		border-radius: 24px;
	}
}

/* ─────────────────── ACCESIBILIDAD · prefers-reduced-motion ───────────── */
@media (prefers-reduced-motion: reduce) {
	.zenth-configurador__progress-fill,
	.zenth-configurador__marker,
	.zenth-configurador__option-media,
	.zenth-configurador__btn,
	.zenth-configurador__nav-prev,
	.zenth-configurador__nav-next,
	.zenth-configurador__lens,
	.zenth-configurador__zoom-hint {
		transition: none;
	}
	.zenth-configurador__loader,
	.zenth-configurador__badge::before {
		animation: none;
	}
	.zenth-cfg-toast,
	.zenth-cfg-toast.is-visible {
		transition: none;
	}
}
