/* Tu Sala – WhatsApp Flotante */

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

.tswa {
	--tswa-btn: #25D366;
	--tswa-head: #25D366;
	--tswa-head-text: #fff;
	--tswa-x: 24px;
	--tswa-y: 24px;

	position: fixed;
	z-index: 999990;
	right: var(--tswa-x);
	bottom: calc(var(--tswa-y) + env(safe-area-inset-bottom, 0px));
	font-family: inherit;
	font-size: 16px;
	line-height: 1.35;
	color: #1b1b1b;
	-webkit-font-smoothing: antialiased;
}
.tswa.tswa--left { right: auto; left: var(--tswa-x); }

.tswa p,
.tswa ul,
.tswa li { margin: 0; padding: 0; list-style: none; }
.tswa svg { display: block; }
.tswa .tswa__svg { width: 100%; height: 100%; }

/* ---------- Botón flotante ---------- */
.tswa .tswa__toggle {
	position: relative;
	display: grid;
	place-items: center;
	width: 62px;
	height: 62px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--tswa-btn);
	color: #fff;
	cursor: pointer;
	line-height: 1;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
	transition: transform .2s ease;
	-webkit-tap-highlight-color: transparent;
}
.tswa .tswa__toggle:hover,
.tswa .tswa__toggle:focus,
.tswa .tswa__toggle:active {
	background: var(--tswa-btn);
	color: #fff;
	transform: scale(1.06);
}
.tswa .tswa__toggle:focus-visible { outline: 3px solid #1b1b1b; outline-offset: 3px; }

/* Halo alrededor del botón */
.tswa .tswa__toggle::before {
	content: "";
	position: absolute;
	inset: -7px;
	z-index: -1;
	border-radius: 50%;
	background: var(--tswa-btn);
	opacity: .2;
}
/* Pulso suave cuando está cerrado */
.tswa.tswa--pulse:not(.is-open) .tswa__toggle::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: 50%;
	background: var(--tswa-btn);
	opacity: .45;
	animation: tswa-pulse 2.6s ease-out infinite;
}
@keyframes tswa-pulse {
	0%   { transform: scale(1);   opacity: .45; }
	70%  { transform: scale(1.7); opacity: 0; }
	100% { transform: scale(1.7); opacity: 0; }
}

.tswa .tswa__ico {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	transition: opacity .2s ease, transform .25s ease;
}
.tswa .tswa__ico svg { width: 34px; height: 34px; }
.tswa .tswa__ico--x { opacity: 0; transform: rotate(-90deg) scale(.6); }
.tswa .tswa__ico--x svg { width: 30px; height: 30px; }
.tswa.is-open .tswa__ico--wa { opacity: 0; transform: rotate(90deg) scale(.6); }
.tswa.is-open .tswa__ico--x { opacity: 1; transform: none; }

/* ---------- Ventana ---------- */
.tswa .tswa__panel {
	position: absolute;
	right: 0;
	bottom: calc(100% + 16px);
	display: flex;
	flex-direction: column;
	width: min(390px, calc(100vw - 32px));
	max-height: calc(100vh - 130px);
	max-height: calc(100dvh - 130px);
	overflow: hidden;
	border-radius: 26px;
	background: #fafafa;
	box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
	transform-origin: bottom right;
	visibility: hidden;
	opacity: 0;
	transform: translateY(14px) scale(.96);
	transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.tswa.tswa--left .tswa__panel { right: auto; left: 0; transform-origin: bottom left; }
.tswa.is-open .tswa__panel {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition-delay: 0s;
}

/* Encabezado */
.tswa .tswa__head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 20px 20px;
	background: var(--tswa-head);
	color: var(--tswa-head-text);
}
.tswa .tswa__head-icon {
	display: grid;
	place-items: center;
	flex: none;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .22);
}
.tswa .tswa__head-icon svg { width: 30px; height: 30px; }
.tswa .tswa__head-text { min-width: 0; padding-right: 30px; }
.tswa .tswa__title { font-size: 1.12rem; font-weight: 700; line-height: 1.2; color: inherit; }
.tswa .tswa__subtitle { margin-top: 4px; font-size: .92rem; line-height: 1.3; opacity: .92; color: inherit; }

.tswa .tswa__close {
	position: absolute;
	top: 14px;
	right: 14px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .25);
	color: var(--tswa-head-text);
	cursor: pointer;
	transition: background .15s ease;
}
.tswa .tswa__close:hover,
.tswa .tswa__close:focus,
.tswa .tswa__close:active { background: rgba(255, 255, 255, .4); color: var(--tswa-head-text); }
.tswa .tswa__close:focus-visible { outline: 2px solid var(--tswa-head-text); outline-offset: 2px; }
.tswa .tswa__close svg { width: 16px; height: 16px; }

/* Cuerpo */
.tswa .tswa__body { overflow-y: auto; padding: 14px 16px 12px; }
.tswa .tswa__list { display: grid; gap: 10px; }

.tswa .tswa__contact {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 14px 10px 10px;
	border: 1px solid #ececec;
	border-radius: 20px;
	background: #fff;
	color: #1b1b1b;
	text-decoration: none;
	box-shadow: none;
	transition: border-color .15s ease, transform .15s ease;
}
.tswa .tswa__contact:hover,
.tswa .tswa__contact:focus {
	border-color: var(--tswa-btn);
	background: #fff;
	color: #1b1b1b;
	transform: translateY(-1px);
	text-decoration: none;
}
.tswa .tswa__contact:focus-visible { outline: 3px solid var(--tswa-btn); outline-offset: 2px; }

.tswa .tswa__avatar {
	display: grid;
	place-items: center;
	flex: none;
	width: 52px;
	height: 52px;
	overflow: hidden;
	border-radius: 50%;
	background: var(--tswa-btn);
	color: #fff;
}
.tswa .tswa__avatar svg { width: 28px; height: 28px; }
.tswa .tswa__avatar img { width: 100%; height: 100%; object-fit: cover; }

.tswa .tswa__info { display: block; min-width: 0; flex: 1; }
.tswa .tswa__name { display: block; font-size: 1.02rem; font-weight: 700; line-height: 1.25; color: #1b1b1b; }
.tswa .tswa__desc { display: block; margin-top: 2px; font-size: .86rem; font-weight: 500; line-height: 1.3; color: #6f777b; }
.tswa .tswa__chev { flex: none; width: 16px; height: 16px; color: #b7bcbf; }

.tswa .tswa__footer { margin-top: 12px; text-align: center; font-size: .82rem; color: #8b9296; }

/* ---------- Visibilidad ---------- */
@media (max-width: 767px) {
	.tswa.tswa--hide-mobile { display: none !important; }
	.tswa .tswa__toggle { width: 58px; height: 58px; }
	.tswa .tswa__panel { bottom: calc(100% + 14px); }
}
@media (min-width: 768px) {
	.tswa.tswa--hide-desktop { display: none !important; }
}

/* ---------- Vista previa (panel de administración) ---------- */
.tswa.tswa--preview {
	position: static;
	display: block;
	width: 100%;
}
.tswa.tswa--preview .tswa__panel {
	position: relative;
	right: auto;
	bottom: auto;
	left: auto;
	width: 100%;
	max-height: none;
	visibility: visible;
	opacity: 1;
	transform: none;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.tswa.tswa--preview .tswa__toggle { margin: 18px 6px 6px auto; }
.tswa.tswa--preview.tswa--left .tswa__toggle { margin-left: 6px; margin-right: auto; }
.tswa.tswa--preview .tswa__item.is-off { display: none; }
.tswa.tswa--preview .tswa__contact { pointer-events: none; }
.tswa.tswa--preview .tswa__item.is-nophone .tswa__contact { opacity: .5; }
.tswa.tswa--preview .tswa__item.is-nophone .tswa__desc::after { content: " · sin número, no se mostrará"; color: #b32d2e; }
.tswa.tswa--preview .tswa__toggle::after { display: none; }

@media (prefers-reduced-motion: reduce) {
	.tswa *,
	.tswa *::before,
	.tswa *::after { transition: none !important; animation: none !important; }
}
