/**
 * Whatshub — look & feel inspirado en la app WhatsApp (colores y jerarquía habituales del chat).
 */

.whatshub {
	--wa-header: #008069;
	--wa-header-dark: #075e54;
	--wa-bubble: #ffffff;
	--wa-screen: #ece5dd;
	--wa-screen-tint: rgba(0, 0, 0, 0.04);
	--wa-green: #25d366;
	--wa-green-hover: #20bd5a;
	--wa-text: #111b21;
	--wa-text-muted: #667781;
	--wa-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);

	position: fixed;
	z-index: 999998;
	font-family: "Segoe UI", "Helvetica Neue", Helvetica, "Apple Color Emoji", Arial, sans-serif;
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
}

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

/* Temas que fuerzan display en divs pueden ignorar [hidden]; reforzamos el estado cerrado. */
.whatshub__backdrop[hidden],
.whatshub__dialog[hidden] {
	display: none !important;
}

/* Esquinas del widget (coincide con button_position en PHP). */
.whatshub--bottom-right {
	bottom: 1.25rem;
	right: 1.25rem;
	left: auto;
	top: auto;
}

.whatshub--bottom-left {
	bottom: 1.25rem;
	left: 1.25rem;
	right: auto;
	top: auto;
}

.whatshub--top-right {
	top: 1.25rem;
	right: 1.25rem;
	left: auto;
	bottom: auto;
}

.whatshub--top-left {
	top: 1.25rem;
	left: 1.25rem;
	right: auto;
	bottom: auto;
}

/* Botón flotante tipo FAB de WhatsApp */
.whatshub__launcher {
	position: relative;
	z-index: 2;
	pointer-events: auto;
	touch-action: manipulation;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.7rem 1.1rem 0.7rem 0.85rem;
	border: 0;
	border-radius: 999px;
	background: var(--wa-green);
	color: #fff;
	font-size: 0.95rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(37, 211, 102, 0.45), 0 2px 6px rgba(0, 0, 0, 0.18);
	transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.whatshub__launcher::before {
	content: "";
	position: absolute;
	inset: -4px;
	border-radius: inherit;
	border: 2px solid rgba(37, 211, 102, 0.35);
	animation: whatshub-pulse 2.4s ease-out infinite;
	pointer-events: none;
}

@keyframes whatshub-pulse {
	0% {
		transform: scale(1);
		opacity: 0.7;
	}
	70% {
		transform: scale(1.08);
		opacity: 0;
	}
	100% {
		transform: scale(1.12);
		opacity: 0;
	}
}

.whatshub__launcher:hover {
	background: var(--wa-green-hover);
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.whatshub__launcher:hover::before {
	animation: none;
	opacity: 0;
}

.whatshub__launcher:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
	box-shadow: 0 0 0 3px var(--wa-header), 0 4px 12px rgba(37, 211, 102, 0.45);
}

.whatshub__launcher-icon {
	display: flex;
	line-height: 0;
	filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.12));
}

.whatshub__launcher-text {
	white-space: nowrap;
}

/*
 * Dock: botón + panel en la misma esquina. Abajo: el modal queda encima del FAB;
 * arriba: el modal queda debajo del FAB. Con el modal abierto el FAB se oculta
 * y el panel ocupa su sitio.
 */
.whatshub.whatshub--modal-open .whatshub__launcher {
	display: none !important;
}

.whatshub__dock {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	position: relative;
	z-index: 1000003;
	max-width: min(318px, calc(100vw - 2rem));
}

/* Abajo: primer hijo (botón) pegado a la esquina; el modal se apila hacia arriba. */
.whatshub--bottom-right .whatshub__dock,
.whatshub--bottom-left .whatshub__dock {
	flex-direction: column-reverse;
	align-items: stretch;
}

.whatshub--bottom-right .whatshub__dock {
	align-items: flex-end;
}

.whatshub--bottom-left .whatshub__dock {
	align-items: flex-start;
}

/* Arriba: botón primero, modal debajo. */
.whatshub--top-right .whatshub__dock {
	flex-direction: column;
	align-items: flex-end;
}

.whatshub--top-left .whatshub__dock {
	flex-direction: column;
	align-items: flex-start;
}

/* Overlay */
.whatshub__backdrop {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	background: rgba(17, 27, 33, 0.46);
	backdrop-filter: blur(1px);
	pointer-events: auto;
}

/* Ventana: fluye en el dock (misma posición que el widget), no centrada en pantalla. */
.whatshub__dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: min(318px, calc(100vw - 2rem));
	max-height: min(56vh, 420px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--wa-screen);
	border-radius: 9px;
	box-shadow: 0 12px 40px rgba(11, 20, 26, 0.35), 0 2px 8px rgba(0, 0, 0, 0.12);
	color: var(--wa-text);
}

/* Cabecera verde como barra de chat */
.whatshub__topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.4rem;
	flex-shrink: 0;
	padding: 0.45rem 0.45rem 0.45rem 0.65rem;
	background: linear-gradient(180deg, #00a884 0%, var(--wa-header) 55%, var(--wa-header-dark) 100%);
	color: #fff;
	min-height: 2.65rem;
}

.whatshub__topbar-main {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	min-width: 0;
	flex: 1;
}

.whatshub__avatar {
	flex-shrink: 0;
	width: 2rem;
	height: 2rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	border: 1px solid rgba(255, 255, 255, 0.28);
	color: #fff;
}

.whatshub__avatar-icon {
	width: 18px;
	height: 18px;
	opacity: 0.95;
}

.whatshub__topbar-text {
	min-width: 0;
}

.whatshub__dialog-title {
	margin: 0;
	font-size: 0.92rem;
	font-weight: 600;
	line-height: 1.25;
	color: #fff;
	letter-spacing: 0.01em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.whatshub__topbar-sub {
	margin: 0.05rem 0 0;
	font-size: 0.68rem;
	font-weight: 400;
	color: rgba(255, 255, 255, 0.88);
	line-height: 1.2;
}

.whatshub__close {
	flex-shrink: 0;
	border: 0;
	background: transparent;
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	color: rgba(255, 255, 255, 0.92);
	padding: 0.35rem 0.55rem;
	border-radius: 50%;
	transition: background 0.15s ease;
}

.whatshub__close:hover {
	background: rgba(0, 0, 0, 0.12);
	color: #fff;
}

.whatshub__close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.85);
	outline-offset: 2px;
}

/* Cuerpo: fondo tipo pantalla de chat */
.whatshub__dialog-body {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	padding: 0;
	background-color: var(--wa-screen);
	background-image: radial-gradient(circle at 20% 20%, var(--wa-screen-tint) 0%, transparent 45%),
		radial-gradient(circle at 80% 60%, var(--wa-screen-tint) 0%, transparent 40%);
}

/* Burbuja entrante (texto intro) */
.whatshub__bubble {
	flex-shrink: 0;
	max-width: 100%;
	margin-bottom: 0;
	padding: 5px;
	background: var(--wa-bubble);
	border-radius: 0 7.5px 7.5px 7.5px;
	box-shadow: var(--wa-shadow);
	position: relative;
}

.whatshub__bubble::after {
	content: "";
	position: absolute;
	left: -6px;
	top: 0;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 0 6px 8px 0;
	border-color: transparent #fff transparent transparent;
	filter: drop-shadow(-0.5px 0.5px 0 rgba(0, 0, 0, 0.04));
}

.whatshub__intro {
	margin: 0;
	font-size: 0.78rem;
	line-height: 1.38;
	color: var(--wa-text);
}

/* Tarjeta blanca del formulario HubSpot */
.whatshub__form-card {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--wa-bubble);
	border-radius: 6px;
	box-shadow: var(--wa-shadow);
	padding: 0;
}

.whatshub__form-status {
	flex-shrink: 0;
	margin: 0;
	min-height: 1.15em;
	font-size: 0.72rem;
	line-height: 1.4;
	color: var(--wa-text-muted);
}

.whatshub__form-status--error {
	color: #b91c1c;
	font-weight: 500;
}

.whatshub__form-status:empty {
	margin-bottom: 0;
	min-height: 0;
}

/* Variables para formularios HubSpot recientes (cuando respetan tema del contenedor). */
.whatshub__hubspot-shell.whatshub-hs-vars {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	--hsf-global__font-size: 13px;
	--hsf-global__color: #111b21;
	--hsf-row__spacing: 0.35rem;
	--hsf-field__border-radius: 8px;
	--hsf-button__padding: 7px 14px;
	--hsf-button__border-radius: 999px;
	--hsf-button__background-color: #25d366;
	--hsf-button__background-hover: #20bd5a;
	--hsf-button__color: #ffffff;
}

.whatshub__form {
	flex: 1;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	max-height: min(38vh, 260px);
	font-size: 13px;
	line-height: 1.35;
}

/* HubSpot suele inyectar iframes; damos aire al contenido */
.whatshub__form .hs-form-frame,
.whatshub__form iframe {
	max-width: 100% !important;
}

body.whatshub-modal-open {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.whatshub__launcher::before {
		animation: none;
		display: none;
	}

	.whatshub__launcher {
		transition: none;
	}
}

@media (max-width: 480px) {
	.whatshub__launcher-text {
		max-width: 42vw;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.whatshub--bottom-right,
	.whatshub--bottom-left {
		left: 0.5rem;
		right: 0.5rem;
		width: auto;
	}

	.whatshub--bottom-right .whatshub__dock,
	.whatshub--bottom-left .whatshub__dock {
		max-width: none;
		width: 100%;
	}

	.whatshub__dialog {
		max-height: min(78vh, 620px);
		border-radius: 10px;
	}
}
