/* ================================================================
   Quelullada Personalización — Frontend v2
   ================================================================ */

/* Contenedor principal — fuerza un bloque limpio dentro del form .cart
   y rompe cualquier flexbox que el theme aplique a form.cart */
.qlp-product-options {
	display: block;
	width: 100%;
	flex: 0 0 100%;        /* ocupa toda la fila si form.cart es flex */
	order: -1;             /* aparece antes que qty + boton si hay flex */
	clear: both;
	margin: 0 0 24px;
	padding: 0;
	box-sizing: border-box;
	font-family: inherit;
	color: #1a1a1a;
}

.qlp-product-options *,
.qlp-product-options *::before,
.qlp-product-options *::after {
	box-sizing: border-box;
}

.qlp-options-wrap {
	display: flex;
	flex-direction: column;
	gap: 22px;
	padding: 22px;
	background: #fafafa;
	border: 1px solid #ececec;
	border-radius: 12px;
}

.qlp-options-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-bottom: 14px;
	border-bottom: 1px solid #ececec;
	margin-bottom: -8px;
}

.qlp-options-title {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: #6b6b6b;
}

.qlp-options-title::before {
	content: "✦";
	margin-right: 6px;
	color: #2271b1;
}

/* ================================================================
   Cada Opción
   ================================================================ */

.qlp-option {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.qlp-option-label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	font-weight: 600;
	color: #1a1a1a;
	margin: 0;
	letter-spacing: -.01em;
}

.qlp-required {
	color: #e53935;
	font-style: normal;
	text-decoration: none;
	font-weight: 700;
}

.qlp-option-desc {
	font-size: 13px;
	color: #6b6b6b;
	margin: -4px 0 0;
	line-height: 1.4;
}

/* Badge de precio que aparece junto a cada valor */
.qlp-price-tag {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	color: #2e7d32;
	background: #e8f5e9;
	padding: 2px 7px;
	border-radius: 10px;
	letter-spacing: .02em;
	white-space: nowrap;
}

/* ================================================================
   SELECT
   ================================================================ */

.qlp-select {
	width: 100%;
	padding: 12px 38px 12px 14px;
	border: 1px solid #d4d4d4;
	border-radius: 8px;
	font-size: 14px;
	color: #1a1a1a;
	background-color: #fff;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 12px;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s;
}

.qlp-select:focus {
	border-color: #2271b1;
	outline: none;
	box-shadow: 0 0 0 3px rgba(34,113,177,.12);
}

/* ================================================================
   RADIO — botones tipo "pill"
   ================================================================ */

.qlp-radio-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.qlp-radio-option {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	border: 1.5px solid #d4d4d4;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	font-size: 14px;
	color: #333;
	transition: all .15s;
	user-select: none;
	margin: 0;
}

.qlp-radio-option:hover {
	border-color: #2271b1;
	background: #f5faff;
}

.qlp-radio-option input[type="radio"] {
	margin: 0;
	accent-color: #2271b1;
	cursor: pointer;
}

.qlp-radio-option:has(input:checked) {
	border-color: #2271b1;
	background: #eaf3fb;
	color: #1a1a1a;
	font-weight: 600;
}

.qlp-radio-label-text {
	line-height: 1;
}

/* ================================================================
   CHECKBOX — lista vertical limpia
   ================================================================ */

.qlp-checkbox-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.qlp-checkbox-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	border: 1px solid #e4e4e4;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	font-size: 14px;
	color: #1a1a1a;
	transition: all .15s;
	margin: 0;
}

.qlp-checkbox-option:hover {
	border-color: #c5c5c5;
	background: #fafafa;
}

.qlp-checkbox-option:has(input:checked) {
	border-color: #2271b1;
	background: #eaf3fb;
}

.qlp-checkbox-option input[type="checkbox"] {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	margin: 0;
	accent-color: #2271b1;
	cursor: pointer;
}

.qlp-checkbox-label-text {
	flex: 1;
	line-height: 1.3;
}

/* ================================================================
   TEXT
   ================================================================ */

.qlp-text-input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid #d4d4d4;
	border-radius: 8px;
	font-size: 14px;
	color: #1a1a1a;
	background: #fff;
	transition: border-color .15s, box-shadow .15s;
	font-family: inherit;
}

.qlp-text-input:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 3px rgba(34,113,177,.12);
}

.qlp-text-input::placeholder {
	color: #aaa;
}

/* ================================================================
   VISUAL SELECT — tarjetas con imagen
   ================================================================ */

.qlp-visual-select {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 10px;
}

.qlp-visual-item {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 7px;
	padding: 10px;
	border: 2px solid #e4e4e4;
	border-radius: 10px;
	background: #fff;
	cursor: pointer;
	transition: all .18s;
	user-select: none;
	overflow: hidden;
}

.qlp-visual-item::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 8px;
	pointer-events: none;
	transition: background .18s;
}

.qlp-visual-item:hover {
	border-color: #b8d4ed;
	transform: translateY(-2px);
	box-shadow: 0 4px 14px rgba(0,0,0,.06);
}

.qlp-visual-item.qlp-selected {
	border-color: #2271b1;
	background: #f5faff;
	box-shadow: 0 4px 16px rgba(34,113,177,.2);
}

.qlp-visual-item img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 6px;
	display: block;
	pointer-events: none;
}

.qlp-visual-initials {
	width: 100%;
	aspect-ratio: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #eaf3fb 0%, #d8e8f5 100%);
	border-radius: 6px;
	font-size: 26px;
	font-weight: 700;
	color: #2271b1;
	text-transform: uppercase;
}

.qlp-visual-label {
	font-size: 12px;
	font-weight: 500;
	color: #1a1a1a;
	line-height: 1.3;
	text-align: center;
	word-break: break-word;
}

.qlp-visual-check {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	background: #2271b1;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 14px;
	opacity: 0;
	transform: scale(.6);
	transition: all .18s;
	font-family: dashicons;
}

.qlp-visual-item.qlp-selected .qlp-visual-check {
	opacity: 1;
	transform: scale(1);
}

.qlp-visual-item:focus-visible {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 3px rgba(34,113,177,.18);
}

/* ================================================================
   IMAGE UPLOAD
   ================================================================ */

.qlp-image-upload-wrap {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.qlp-upload-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 18px;
	border: 2px dashed #c5c5c5;
	border-radius: 10px;
	background: #fff;
	color: #2271b1;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all .15s;
	margin: 0;
}

.qlp-upload-btn:hover {
	border-color: #2271b1;
	background: #f5faff;
}

.qlp-upload-btn .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.qlp-file-input {
	position: absolute;
	left: -9999px;
	opacity: 0;
}

.qlp-upload-preview {
	display: flex;
	align-items: center;
	gap: 10px;
}

.qlp-upload-preview:empty {
	display: none;
}

.qlp-upload-preview img {
	max-width: 200px;
	max-height: 150px;
	width: auto;
	height: auto;
	object-fit: cover;
	border-radius: 8px;
	border: 1px solid #e4e4e4;
}

.qlp-upload-hint {
	margin: 0;
	font-size: 11px;
	color: #888;
}

/* ================================================================
   PRICE SUMMARY — caja resumen del precio
   ================================================================ */

.qlp-price-summary {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 4px;
	padding: 14px 16px;
	background: #fff;
	border: 1px solid #ececec;
	border-radius: 10px;
}

.qlp-price-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 14px;
}

.qlp-price-label {
	color: #6b6b6b;
}

.qlp-price-value {
	color: #1a1a1a;
	font-weight: 500;
}

.qlp-price-modifier .qlp-price-value {
	color: #2e7d32;
	font-weight: 600;
}

.qlp-price-total {
	margin-top: 6px;
	padding-top: 10px;
	border-top: 1px solid #ececec;
	font-size: 16px;
}

.qlp-price-total .qlp-price-label {
	color: #1a1a1a;
}

.qlp-price-total .qlp-price-value {
	color: #1a1a1a;
	font-size: 18px;
	font-weight: 700;
}

/* ================================================================
   LIMPIAR LAYOUT — convivir con qty + botón "añadir al carrito"
   ================================================================ */

/* Si el theme aplica flex al form.cart, hacemos que qty y el botón
   se reagrupen abajo en una fila propia (no encima de las opciones). */
form.cart {
	flex-wrap: wrap !important;
	row-gap: 12px;
}

/* qty + botón debajo de nuestras opciones */
form.cart .quantity,
form.cart button.single_add_to_cart_button {
	float: none !important;
	clear: both;
	order: 1;
}

/* Espacio antes del botón "añadir al carrito" para que no se monte */
form.cart .single_add_to_cart_button {
	margin-left: 12px;
}

/* Validación visual */
.qlp-option.qlp-has-error .qlp-select,
.qlp-option.qlp-has-error .qlp-text-input,
.qlp-option.qlp-has-error .qlp-radio-option,
.qlp-option.qlp-has-error .qlp-checkbox-option,
.qlp-option.qlp-has-error .qlp-visual-item {
	border-color: #e53935;
}

.qlp-option-error {
	font-size: 12px;
	color: #e53935;
	margin: 4px 0 0;
	font-weight: 500;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 600px) {
	.qlp-options-wrap {
		padding: 16px;
		gap: 18px;
	}

	.qlp-visual-select {
		grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
		gap: 8px;
	}

	.qlp-visual-item {
		padding: 8px;
	}

	.qlp-radio-group {
		gap: 6px;
	}

	.qlp-radio-option {
		padding: 9px 12px;
		font-size: 13px;
	}

	.qlp-price-summary {
		padding: 12px;
	}

	.qlp-price-total .qlp-price-value {
		font-size: 16px;
	}
}

/* ================================================================
   COMPATIBILIDAD CON THEMES — evitar herencias raras
   ================================================================ */

.qlp-product-options input[type="radio"],
.qlp-product-options input[type="checkbox"] {
	transform: none !important;
	position: static !important;
}

.qlp-product-options button {
	font-family: inherit;
}

/* Contador de caracteres para campos de texto con límite */
.qlp-char-counter {
	display: block;
	margin-top: 4px;
	font-size: 12px;
	color: #888;
	text-align: right;
}

/* Campo ocultado por lógica condicional (refuerzo; el JS ya hace display:none) */
.qlp-option.qlp-hidden-by-logic {
	display: none !important;
}

/* ================================================================
   Fix de alineación qty + botón SOLO cuando hay bloque de
   personalización qlp en el formulario (usa :has, con fallback).
   No afecta a productos sin personalización.
   ================================================================ */
form.cart:has(.qlp-product-options),
.woocommerce-variation-add-to-cart:has(.qlp-product-options) {
	align-items: center;
	flex-wrap: wrap;
}

/* El bloque de personalización ocupa su propia fila completa. */
form.cart:has(.qlp-product-options) > .qlp-product-options,
.woocommerce-variation-add-to-cart:has(.qlp-product-options) > .qlp-product-options {
	flex: 0 0 100%;
	width: 100%;
	order: -1;
	align-self: stretch;
}

/* Cantidad: tamaño natural, centrada. */
form.cart:has(.qlp-product-options) > .quantity,
.woocommerce-variation-add-to-cart:has(.qlp-product-options) > .quantity {
	flex: 0 0 auto;
	align-self: center;
}
form.cart:has(.qlp-product-options) > .quantity .qty {
	height: auto;
	min-height: 0;
}

/* Botón "Añadir al carrito": altura natural, centrado. */
form.cart:has(.qlp-product-options) > .single_add_to_cart_button,
.woocommerce-variation-add-to-cart:has(.qlp-product-options) > .single_add_to_cart_button {
	flex: 1 1 auto;
	align-self: center;
	height: auto;
	min-height: 0;
}

/* ================================================================
   Estilizado de las VARIACIONES nativas de WooCommerce para que
   combinen con el bloque de personalización (.qlp-product-options).
   Solo afecta a la página de producto.
   ================================================================ */

/* Contenedor de la tabla de variaciones: tarjeta como el bloque qlp */
.single-product form.cart table.variations {
	width: 100%;
	border: 1px solid #eaeaea;
	border-radius: 14px;
	background: #fafafa;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0 0 20px;
	padding: 20px 22px;
	box-shadow: 0 1px 2px rgba(0,0,0,.03);
}

.single-product form.cart table.variations tbody,
.single-product form.cart table.variations tr {
	display: block;
	width: 100%;
}

/* Cada fila de variación (label arriba, control abajo) */
.single-product form.cart table.variations tr {
	margin-bottom: 16px;
}
.single-product form.cart table.variations tr:last-child {
	margin-bottom: 0;
}

/* Label de la variación (ej. "Elige la planta") */
.single-product form.cart table.variations th.label,
.single-product form.cart table.variations td.label {
	display: block;
	width: 100%;
	padding: 0 0 8px;
	font-size: 15px;
	font-weight: 600;
	color: #1a1a1a;
	text-align: left;
	vertical-align: top;
}
.single-product form.cart table.variations td.value {
	display: block;
	width: 100%;
	padding: 0;
}

/* Selector <select> de variación: mismo estilo que .qlp-select */
.single-product form.cart table.variations select {
	width: 100%;
	padding: 12px 38px 12px 14px;
	border: 1px solid #d4d4d4;
	border-radius: 8px;
	font-size: 14px;
	color: #1a1a1a;
	background-color: #fff;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 12px;
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s;
}
.single-product form.cart table.variations select:focus {
	border-color: #2271b1;
	outline: none;
	box-shadow: 0 0 0 3px rgba(34,113,177,.12);
}

/* Swatches (woo-variation-swatches): botones e imágenes/colores */
.single-product form.cart .woo-variation-swatches .variable-items-wrapper {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0;
}
.single-product form.cart .woo-variation-swatches .variable-item {
	border: 1.5px solid #d4d4d4 !important;
	border-radius: 10px !important;
	box-shadow: none !important;
	padding: 2px;
	transition: border-color .15s, box-shadow .15s;
	overflow: hidden;
}
.single-product form.cart .woo-variation-swatches .variable-item.selected,
.single-product form.cart .woo-variation-swatches .variable-item:hover {
	border-color: #2271b1 !important;
	box-shadow: 0 4px 14px rgba(34,113,177,.18) !important;
}
/* Swatch tipo "button" (texto, ej. "Un perro") */
.single-product form.cart .woo-variation-swatches .variable-item.button-variable-item {
	min-width: 44px;
	height: auto;
	padding: 8px 14px !important;
	border-radius: 8px !important;
	font-size: 14px;
	color: #1a1a1a;
	background: #fff;
}
.single-product form.cart .woo-variation-swatches .variable-item.button-variable-item.selected {
	background: #f5faff;
}
/* Swatch de imagen */
.single-product form.cart .woo-variation-swatches .variable-item.image-variable-item img {
	border-radius: 8px;
}

/* Texto de disponibilidad de stock */
.single-product form.cart .woocommerce-variation-availability .stock {
	font-size: 13px;
	color: #2e7d32;
	font-weight: 600;
	margin: 6px 0 0;
}

/* Enlace "Limpiar" (reset de variaciones) */
.single-product form.cart .reset_variations {
	display: inline-block;
	margin-top: 8px;
	font-size: 13px;
	color: #a5342b;
	text-decoration: none;
}
.single-product form.cart .reset_variations:hover {
	text-decoration: underline;
}

/* Precio de la variación seleccionada (si se muestra) */
.single-product form.cart .woocommerce-variation-price .price {
	font-size: 16px;
	font-weight: 700;
	color: #1a1a1a;
}

/* Fondo de filas impares en la tabla de variaciones (solicitado) */
.single-product form.cart table.variations tbody > tr:nth-child(odd) > td,
.single-product form.cart table.variations tbody > tr:nth-child(odd) > th {
	background-color: hsl(0deg 0% 100% / 7.1%);
}

/* ================================================================
   Imágenes más grandes (solicitado)
   ================================================================ */
/* Opciones de personalización visuales: grid con celdas más grandes */
.qlp-visual-select {
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
	gap: 14px !important;
}
@media (max-width: 600px) {
	.qlp-visual-select {
		grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
	}
}

/* Swatches de imagen en las variaciones: más grandes */
.single-product form.cart .woo-variation-swatches .variable-item.image-variable-item {
	width: 72px !important;
	height: 72px !important;
}
.single-product form.cart .woo-variation-swatches .variable-item.image-variable-item img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover;
	border-radius: 8px;
}
