/* Webshero Floating Contact — chat-style widget */

.wsfc,
.wsfc *,
.wsfc *::before,
.wsfc *::after { box-sizing: border-box; }

.wsfc {
	--wsfc-bg: #DE1C1D;
	--wsfc-text: #FFFFFF;
	--wsfc-panel-bg: #FFFFFF;
	--wsfc-panel-text: #1A1308;
	--wsfc-panel-width: 380px;
	--wsfc-panel-height: 640px;
	--wsfc-z: 990;
	--wsfc-fab-size: 48px;
	--wsfc-edge: 24px;
	font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Floating Action Button (chat trigger) ---------- */
.wsfc__trigger {
	position: fixed;
	left: var(--wsfc-edge);
	bottom: var(--wsfc-edge);
	z-index: calc(var(--wsfc-z) + 20);
	padding: 14px 22px 14px 18px;
	margin: 0;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: var(--wsfc-bg);
	color: var(--wsfc-text);
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
	font-family: inherit;
	font-weight: 700;
	font-size: 0.85rem;
	letter-spacing: 0.04em;
	line-height: 1;
	white-space: nowrap;
	transition: transform .3s cubic-bezier(.22,.61,.36,1), box-shadow .25s ease, filter .25s ease, background-color .25s ease, padding .25s ease, gap .25s ease;
}

.wsfc__trigger:hover,
.wsfc__trigger:focus-visible {
	outline: none;
	transform: translateY(-2px);
	box-shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}

.wsfc__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	flex-shrink: 0;
	transition: opacity .2s ease, transform .25s ease;
}
.wsfc__icon--close {
	position: absolute;
	left: 50%;
	top: 50%;
	margin: -11px 0 0 -11px;
	opacity: 0;
	transform: scale(0.6);
}

/* When open: collapse to a compact circle showing only the X */
.wsfc.is-open .wsfc__trigger {
	padding: 0;
	width: var(--wsfc-fab-size);
	height: var(--wsfc-fab-size);
	border-radius: 50%;
	gap: 0;
}
.wsfc.is-open .wsfc__icon--chat {
	opacity: 0;
	transform: scale(0.6);
}
.wsfc.is-open .wsfc__icon--close {
	opacity: 1;
	transform: scale(1);
}
.wsfc.is-open .wsfc__label {
	max-width: 0;
	opacity: 0;
	margin-left: -10px;
}

.wsfc__label {
	display: inline-block;
	max-width: 320px;
	opacity: 1;
	overflow: hidden;
	transition: max-width .3s ease, opacity .2s ease, margin-left .25s ease;
}

/* Subtle pulse to attract attention (only when closed) */
.wsfc:not(.is-open) .wsfc__trigger::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 999px;
	box-shadow: 0 0 0 0 var(--wsfc-bg);
	animation: wsfc-pulse 2.4s ease-out infinite;
	opacity: 0.55;
	pointer-events: none;
}
@keyframes wsfc-pulse {
	0%   { box-shadow: 0 0 0 0 var(--wsfc-bg); opacity: 0.55; }
	70%  { box-shadow: 0 0 0 18px var(--wsfc-bg); opacity: 0; }
	100% { box-shadow: 0 0 0 0 var(--wsfc-bg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.wsfc:not(.is-open) .wsfc__trigger::after { animation: none; }
}

/* ---------- Backdrop (mobile only) ---------- */
.wsfc-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	visibility: hidden;
	transition: opacity .3s ease, visibility .3s ease;
	z-index: calc(var(--wsfc-z) + 5);
}
.wsfc.is-open .wsfc-backdrop { opacity: 1; visibility: visible; }

@media (min-width: 769px) {
	.wsfc-backdrop { display: none; }
}

/* ---------- Chat panel ---------- */
.wsfc-panel {
	position: fixed;
	left: var(--wsfc-edge);
	bottom: calc(var(--wsfc-edge) + var(--wsfc-fab-size) + 16px);
	width: var(--wsfc-panel-width);
	max-width: calc(100vw - (var(--wsfc-edge) * 2));
	height: auto;
	max-height: calc(100vh - (var(--wsfc-edge) * 2) - var(--wsfc-fab-size) - 24px);
	/* dvh = viewport visible real en móvil (100vh incluye la zona de la barra del navegador) */
	max-height: calc(100dvh - (var(--wsfc-edge) * 2) - var(--wsfc-fab-size) - 24px);
	background: var(--wsfc-panel-bg);
	color: var(--wsfc-panel-text);
	z-index: calc(var(--wsfc-z) + 10);
	border-radius: 16px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.96);
	transform-origin: bottom left;
	transition: opacity .25s ease, transform .3s cubic-bezier(.22,.61,.36,1), visibility .3s ease;
	pointer-events: none;
}

.wsfc.is-open .wsfc-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Panel header */
.wsfc-panel__header {
	padding: 16px 20px 14px;
	background: var(--wsfc-bg);
	color: var(--wsfc-text);
	display: flex;
	align-items: flex-start;
	gap: 14px;
	flex-shrink: 0;
}
.wsfc-panel__heading {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
	flex: 1 1 auto;
}
.wsfc-panel__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	letter-spacing: 0;
	color: inherit;
	line-height: 1.25;
}
.wsfc-panel__subtitle {
	margin: 0;
	font-size: 0.8rem;
	line-height: 1.4;
	color: rgba(255, 255, 255, 0.82);
}

.wsfc-panel__close {
	width: 32px;
	height: 32px;
	flex-shrink: 0;
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background-color .2s ease;
}
.wsfc-panel__close:hover,
.wsfc-panel__close:focus-visible {
	background: rgba(255, 255, 255, 0.18);
	outline: none;
}

/* Body */
.wsfc-panel__body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 20px 20px 18px;
	background: #ffffff;
	/* Firefox scrollbar */
	scrollbar-width: thin;
	scrollbar-color: var(--wsfc-bg) transparent;
}

/* WebKit (Chrome, Safari, Edge) custom scrollbar */
.wsfc-panel__body::-webkit-scrollbar {
	width: 8px;
}
.wsfc-panel__body::-webkit-scrollbar-track {
	background: transparent;
}
.wsfc-panel__body::-webkit-scrollbar-thumb {
	background-color: var(--wsfc-bg);
	border-radius: 999px;
}
.wsfc-panel__body::-webkit-scrollbar-thumb:hover {
	background-color: var(--wsfc-bg);
	filter: brightness(0.9);
}

/* Intro paragraph (replaces the chat bubble) */
.wsfc-panel__intro {
	margin: 0 0 12px;
	font-size: 0.88rem;
	line-height: 1.5;
	color: rgba(0, 0, 0, 0.65);
}

.wsfc-panel__form {
	padding: 0;
	margin: 0;
}

.wsfc-panel__missing {
	margin: 0;
	padding: 14px;
	background: #fff6f6;
	border-left: 3px solid var(--wsfc-bg);
	color: #6b1313;
	font-size: 0.88rem;
	border-radius: 0 8px 8px 0;
}

/* ---------- CF7 form styling (chat look) ---------- */
.wsfc-panel .wpcf7 { margin: 0; padding: 0; }
.wsfc-panel .wpcf7 form { margin: 0; display: flex; flex-direction: column; }
.wsfc-panel .wpcf7 form > .ws-cf7-row--submit { order: 99; }
/* Aceptación de privacidad: compacta y con el enlace legible también al pasar el ratón */
/* Especificidad mayor que `.wsfc-panel .ws-cf7-row` (declarada después): la aceptación necesita aire arriba y abajo. */
.wsfc-panel .wpcf7 .ws-cf7-row.ws-cf7-row--legal { font-size: 0.84rem; line-height: 1.35; margin: 18px 0 18px; }
.wsfc-panel .ws-cf7-row--legal .wpcf7-list-item { margin: 0; }
.wsfc-panel .ws-cf7-row--legal .wpcf7-list-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.wsfc-panel .ws-cf7-row--legal input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; flex-shrink: 0; accent-color: var(--wsfc-bg); appearance: auto; -webkit-appearance: auto; }
.wsfc-panel .ws-cf7-row--legal .wpcf7-list-item-label { display: block; }
.wsfc-panel .ws-cf7-row--legal a { color: var(--wsfc-bg); text-decoration: underline; text-underline-offset: 2px; }
.wsfc-panel .ws-cf7-row--legal a:hover, .wsfc-panel .ws-cf7-row--legal a:focus-visible { color: #9A0E0F; }
/* El wrap de CF7 es inline: metía 16 px de caja de línea bajo cada campo (fila 55 px con input de 39). En bloque, la fila mide lo que el campo. */
.wsfc-panel .ws-cf7-row { margin: 0 0 12px; line-height: 1; }
.wsfc-panel .ws-cf7-row .wpcf7-form-control-wrap { display: block; }
/* CF7 aplica autop al contenido del formulario: cada campo va dentro de un <p> con el margen de párrafo del tema (16 px) → 55 px por fila con un input de 39. */
.wsfc-panel .ws-cf7-row > p { margin: 0; padding: 0; line-height: 1; }
.wsfc-panel .ws-cf7-row > br { display: none; }
.wsfc-panel .ws-cf7-row input, .wsfc-panel .ws-cf7-row select, .wsfc-panel .ws-cf7-row textarea { display: block; }
.wsfc-panel .ws-cf7-row--legal { line-height: 1.35; }
.wsfc-panel .ws-cf7-row:last-of-type { margin-bottom: 0; }

.wsfc-panel .wpcf7 input[type="text"],
.wsfc-panel .wpcf7 input[type="email"],
.wsfc-panel .wpcf7 input[type="tel"],
.wsfc-panel .wpcf7 input[type="url"],
.wsfc-panel .wpcf7 select,
.wsfc-panel .wpcf7 textarea {
	width: 100%;
	padding: 9px 12px;
	font-family: inherit;
	font-size: 0.88rem;
	color: var(--wsfc-panel-text);
	background: #f4f4f1;
	border: 1px solid transparent;
	border-radius: 10px;
	outline: none;
	box-shadow: none;
	transition: border-color .2s ease, background-color .2s ease;
	appearance: none;
	-webkit-appearance: none;
}

.wsfc-panel .wpcf7 select {
	background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231A1308' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 12px 12px;
	padding-right: 36px;
	cursor: pointer;
}
.wsfc-panel .wpcf7 select:focus {
	background-color: #ffffff;
	border-color: var(--wsfc-bg);
}
.wsfc-panel .wpcf7 input::placeholder,
.wsfc-panel .wpcf7 textarea::placeholder {
	color: rgba(0, 0, 0, 0.42);
	font-weight: 400;
}
.wsfc-panel .wpcf7 input:focus,
.wsfc-panel .wpcf7 textarea:focus,
.wsfc-panel .wpcf7 select:focus {
	border-color: var(--wsfc-bg);
	background-color: #ffffff;
}
.wsfc-panel .wpcf7 textarea {
	resize: vertical;
	height: 64px;
	min-height: 64px;
	line-height: 1.45;
}

.wsfc-panel .wpcf7 .ws-cf7-row--submit { margin-top: 8px; }

.wsfc-panel .wpcf7 input[type="submit"],
.wsfc-panel .wpcf7 button[type="submit"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 20px;
	font-family: inherit;
	font-weight: 700;
	font-size: 0.82rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wsfc-text);
	background: var(--wsfc-bg);
	border: 1px solid var(--wsfc-bg);
	border-radius: 999px;
	cursor: pointer;
	box-shadow: none;
	text-shadow: none;
	transition: background-color .25s ease, color .25s ease, border-color .25s ease, transform .25s ease;
	width: auto;
	min-height: 0;
	height: auto;
}
.wsfc-panel .wpcf7 input[type="submit"]:hover,
.wsfc-panel .wpcf7 button[type="submit"]:hover,
.wsfc-panel .wpcf7 input[type="submit"]:focus,
.wsfc-panel .wpcf7 button[type="submit"]:focus {
	background: transparent;
	color: var(--wsfc-bg);
	transform: translateY(-1px);
	outline: none;
}

.wsfc-panel .wpcf7-not-valid-tip {
	color: #C62121;
	font-size: 0.78rem;
	margin-top: 4px;
}
.wsfc-panel .wpcf7-response-output {
	order: 98;
	margin: 4px 0 6px !important;
	padding: 9px 12px !important;
	border-radius: 8px !important;
	border-width: 1px !important;
	border-style: solid !important;
	font-size: 0.85rem;
	background: #f7f7f7;
}
.wsfc-panel .wpcf7 form.sent .wpcf7-response-output { border-color: #86BD41 !important; background: #f3f9eb; color: #2d5a14; }
.wsfc-panel .wpcf7 form.failed .wpcf7-response-output,
.wsfc-panel .wpcf7 form.aborted .wpcf7-response-output,
.wsfc-panel .wpcf7 form.invalid .wpcf7-response-output,
.wsfc-panel .wpcf7 form.unaccepted .wpcf7-response-output { border-color: #C62121 !important; background: #fdf1f1; color: #6b1313; }
.wsfc-panel .wpcf7-spinner { background-color: var(--wsfc-bg); }


/* ---------- Body lock (mobile) ---------- */
@media (max-width: 768px) {
	body.wsfc-open { overflow: hidden; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
	.wsfc { --wsfc-edge: 16px; --wsfc-fab-size: 56px; }
	/* Móvil: el panel ocupa toda la pantalla (dvh = viewport visible real), sin esquinas ni márgenes;
	   se cierra con la X de la cabecera. El botón flotante se oculta mientras está abierto. */
	.wsfc-panel {
		inset: 0;
		width: 100%;
		height: 100vh;
		height: 100dvh;
		max-width: none;
		max-height: none;
		border-radius: 0;
		transform: translateY(24px);
		transform-origin: bottom center;
	}
	.wsfc.is-open .wsfc-panel { transform: translateY(0); }
	.wsfc.is-open .wsfc__trigger { display: none; }
	.wsfc-panel__header { padding: 18px 20px 16px; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
	.wsfc-panel__title { font-size: 1.05rem; }
	.wsfc-panel__body { padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; }
	.wsfc-panel__form { flex: 1 1 auto; display: flex; flex-direction: column; }
	.wsfc-panel .wpcf7 { flex: 1 1 auto; display: flex; flex-direction: column; }
	.wsfc-panel .wpcf7 form { flex: 1 1 auto; }
	.wsfc-panel .wpcf7 .ws-cf7-row.ws-cf7-row--legal { margin: 14px 0 0; }
	.wsfc-panel .wpcf7 .ws-cf7-row--submit { margin-top: auto; padding-top: 16px; }
	/* En pantalla completa el hueco sobrante lo ocupa el textarea (es donde el usuario escribe), no un vacío entre la aceptación y el botón. */
	.wsfc-panel .wpcf7 .ws-cf7-row:has(textarea) { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 96px; }
	.wsfc-panel .wpcf7 .ws-cf7-row:has(textarea) > p, .wsfc-panel .wpcf7 .ws-cf7-row:has(textarea) .wpcf7-form-control-wrap { flex: 1 1 auto; display: flex; flex-direction: column; }
	.wsfc-panel .wpcf7 .ws-cf7-row:has(textarea) textarea { flex: 1 1 auto; height: auto; min-height: 96px; }
	.wsfc-panel .ws-cf7-row--submit { margin-top: auto; padding-top: 8px; }
	.wsfc-panel .wpcf7 input[type="submit"], .wsfc-panel .wpcf7 button[type="submit"] { width: 100%; padding: 14px 20px; font-size: 0.9rem; }
}

/* El panel se dimensiona al contenido (sin scroll en 768 px de alto o más), así que el CTA ya no
   necesita ser sticky: cuando el mensaje de CF7 aparece, va encima del botón (order) y el JS lo lleva a la vista. */
.wsfc-panel .ws-cf7-row--submit { margin: 4px 0 0; padding: 0; }
.wsfc-panel .ws-cf7-row--submit p { margin: 0; }

/* ---------- Cloudflare Turnstile en la fila del botón ---------- */
/* El plugin de Turnstile inyecta el widget justo antes del botón con un margen inline de -15 px pensado
   para su <br> (aquí oculto): con el widget visible dejaba la caja pegada al botón. En «interaction-only»
   el widget mide 0 hasta que hace falta un reto o falla; el JS marca la fila con .wsfc-turnstile-visible
   cuando tiene alto real y solo entonces lleva el mismo aire que el resto de filas (12 px). El tamaño
   «flexible» del widget (ajuste del plugin) ocupa todo el ancho del formulario. */
.wsfc-panel .ws-cf7-row--submit .cf7-cf-turnstile { margin: 0 !important; }
.wsfc-panel .ws-cf7-row--submit.wsfc-turnstile-visible .cf7-cf-turnstile { margin: 0 0 12px !important; }
/* El <br> espaciador que el plugin muestra junto al widget visible va dentro del wrap (no es hijo directo de la fila): metía 16 px más. */
.wsfc-panel .ws-cf7-row--submit .cf7-cf-turnstile br { display: none; }

@media print {
	.wsfc { display: none !important; }
}
