/**
 * Chat de Jóvenes Madrid.
 *
 * Todas las clases van prefijadas con jmchat para no chocar con Divi ni con
 * otros plugines. El z-index es alto a propósito: Divi usa elementos fijos.
 */

.jmchat {
	--jmchat-color: #2d6cdf;
	--jmchat-texto: #1d2327;
	--jmchat-fondo: #ffffff;
	--jmchat-gris: #f0f2f5;
	--jmchat-borde: #e2e5ea;

	position: fixed;
	bottom: 22px;
	z-index: 99998;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
}

.jmchat--right { right: 22px; }
.jmchat--left  { left: 22px; }

@media (min-width: 783px) {
	.jmchat--solo-movil { display: none; }
}

/* Botón flotante ------------------------------------------------------- */

.jmchat__boton {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--jmchat-color);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.jmchat__boton:hover,
.jmchat__boton:focus-visible {
	transform: scale(1.06);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.jmchat__boton:focus-visible {
	outline: 3px solid #fff;
	outline-offset: -6px;
}

.jmchat__boton-cerrar {
	display: none;
	font-size: 30px;
	line-height: 1;
}

.jmchat[data-estado="abierto"] .jmchat__boton-icono { display: none; }
.jmchat[data-estado="abierto"] .jmchat__boton-cerrar { display: block; }

/* Burbuja de aviso ----------------------------------------------------- */

.jmchat__burbuja {
	position: relative;
	max-width: 230px;
	margin-bottom: 12px;
	padding: 12px 30px 12px 14px;
	border-radius: 14px;
	background: var(--jmchat-fondo);
	color: var(--jmchat-texto);
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
	animation: jmchat-entrar 0.25s ease;
}

.jmchat--left .jmchat__burbuja { margin-right: auto; }
.jmchat--right .jmchat__burbuja { margin-left: auto; }

.jmchat__burbuja p { margin: 0; }

.jmchat__burbuja-cerrar {
	position: absolute;
	top: 4px;
	right: 6px;
	padding: 2px 5px;
	border: 0;
	background: none;
	color: #888;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
}

/* Panel ---------------------------------------------------------------- */

.jmchat__panel {
	display: flex;
	flex-direction: column;
	position: absolute;
	bottom: 72px;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 130px);
	overflow: hidden;
	border-radius: 16px;
	background: var(--jmchat-fondo);
	color: var(--jmchat-texto);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.26);
	animation: jmchat-entrar 0.22s ease;
}

.jmchat--right .jmchat__panel { right: 0; }
.jmchat--left  .jmchat__panel { left: 0; }

/*
 * Imprescindible: la regla de arriba pone display:flex y gana en
 * especificidad al [hidden]{display:none} del navegador, así que sin esto el
 * panel se ve abierto aunque el atributo hidden esté puesto.
 */
.jmchat__panel[hidden],
.jmchat__burbuja[hidden] {
	display: none;
}

.jmchat__cabecera {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--jmchat-color);
	color: #fff;
}

.jmchat__cabecera-texto {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.jmchat__cabecera-texto strong { font-size: 16px; }
.jmchat__cabecera-texto span { font-size: 12.5px; opacity: 0.85; }

.jmchat__reiniciar {
	padding: 4px 9px;
	border: 1px solid rgba(255, 255, 255, 0.55);
	border-radius: 20px;
	background: none;
	color: #fff;
	font-size: 12px;
	cursor: pointer;
}

.jmchat__cerrar {
	padding: 0 4px;
	border: 0;
	background: none;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

/* Mensajes ------------------------------------------------------------- */

.jmchat__mensajes {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--jmchat-gris);
	overscroll-behavior: contain;
}

.jmchat__mensaje {
	max-width: 85%;
	margin-bottom: 10px;
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.jmchat__mensaje--bot {
	background: var(--jmchat-fondo);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.jmchat__mensaje--user {
	margin-left: auto;
	background: var(--jmchat-color);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.jmchat__mensaje a { color: inherit; text-decoration: underline; }

.jmchat__enlace {
	display: inline-block;
	margin-top: 4px;
	padding: 8px 14px;
	border-radius: 20px;
	background: var(--jmchat-color);
	color: #fff !important;
	text-decoration: none !important;
	font-size: 14px;
}

.jmchat__escribiendo span {
	display: inline-block;
	width: 7px;
	height: 7px;
	margin-right: 3px;
	border-radius: 50%;
	background: #9aa0a6;
	animation: jmchat-punto 1.2s infinite ease-in-out;
}

.jmchat__escribiendo span:nth-child(2) { animation-delay: 0.15s; }
.jmchat__escribiendo span:nth-child(3) { animation-delay: 0.3s; }

/* Respuestas rápidas --------------------------------------------------- */

.jmchat__rapidas {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 12px 0;
	background: var(--jmchat-gris);
}

.jmchat__rapidas:empty { display: none; }

.jmchat__rapida {
	padding: 7px 13px;
	border: 1px solid var(--jmchat-color);
	border-radius: 20px;
	background: var(--jmchat-fondo);
	color: var(--jmchat-color);
	font-size: 13.5px;
	cursor: pointer;
}

.jmchat__rapida:hover,
.jmchat__rapida:focus-visible { background: var(--jmchat-color); color: #fff; }

/* Los botones que son enlace se distinguen: van rellenos. */
a.jmchat__rapida {
	background: var(--jmchat-color);
	color: #fff;
	text-decoration: none;
}

a.jmchat__rapida:hover { filter: brightness(1.12); }

/* Formulario ----------------------------------------------------------- */

.jmchat__formulario {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: var(--jmchat-gris);
}

.jmchat__entrada {
	flex: 1;
	max-height: 110px;
	padding: 10px 12px;
	border: 1px solid var(--jmchat-borde);
	border-radius: 20px;
	background: var(--jmchat-fondo);
	color: var(--jmchat-texto);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.4;
	resize: none;
}

.jmchat__entrada:focus {
	border-color: var(--jmchat-color);
	outline: none;
}

.jmchat__enviar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: var(--jmchat-color);
	color: #fff;
	cursor: pointer;
}

.jmchat__enviar[disabled] { opacity: 0.5; cursor: default; }

.jmchat__aviso {
	margin: 0;
	padding: 8px 14px 10px;
	background: var(--jmchat-gris);
	color: #6a7075;
	font-size: 11.5px;
	line-height: 1.35;
	text-align: center;
}

/* Disparador del shortcode -------------------------------------------- */

.jmchat-disparador {
	padding: 11px 22px;
	border: 0;
	border-radius: 24px;
	background: #2d6cdf;
	color: #fff;
	font-size: 15px;
	cursor: pointer;
}

/* Móvil ---------------------------------------------------------------- */

@media (max-width: 600px) {
	.jmchat__panel {
		position: fixed;
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border-radius: 0;
	}
}

/* Animaciones ---------------------------------------------------------- */

@keyframes jmchat-entrar {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes jmchat-punto {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.jmchat__panel,
	.jmchat__burbuja,
	.jmchat__boton,
	.jmchat__escribiendo span {
		animation: none;
		transition: none;
	}
}
