/**
 * Sesli AI Chat — estilos del widget de chat.
 * Los colores se administran con variables CSS; cada tema (classic/ocean/midnight)
 * define su propia paleta con la clase .sesli-chat-root--theme-*.
 */
.sesli-chat-root {
	--sesli-primary: #7c3aed;
	--sesli-secondary: #06b6d4;
	--sesli-grad: linear-gradient(135deg, var(--sesli-primary), var(--sesli-secondary));
	--sesli-glow: rgba(124, 58, 237, 0.5);
	--sesli-glow-strong: rgba(124, 58, 237, 0.65);
	--sesli-bg: #ffffff;
	--sesli-bg-soft: #f4f2fb;
	--sesli-bubble-ai: #f4f2fb;
	--sesli-border: #e8e5f5;
	--sesli-input-border: #e4e0f4;
	--sesli-text: #1f2333;
	--sesli-text-soft: #6b7280;
	--sesli-tint-a: rgba(124, 58, 237, 0.06);
	--sesli-tint-b: rgba(6, 182, 212, 0.06);
	--sesli-scroll: #d6d3e8;
	--sesli-hover: rgba(124, 58, 237, 0.08);
	--sesli-focus: rgba(124, 58, 237, 0.15);
	--sesli-radius: 18px;
	--sesli-shadow: 0 24px 60px -12px rgba(30, 27, 75, 0.35), 0 8px 24px -8px rgba(30, 27, 75, 0.18);
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

/* -------------------------------------------------- */
/* Paletas de temas                                       */
/* -------------------------------------------------- */
/* Océano — azul profundo y turquesa */
.sesli-chat-root--theme-ocean {
	--sesli-primary: #0284c7;
	--sesli-secondary: #14b8a6;
	--sesli-grad: linear-gradient(135deg, #0369a1, #0ea5e9 55%, #14b8a6);
	--sesli-glow: rgba(2, 132, 199, 0.5);
	--sesli-glow-strong: rgba(2, 132, 199, 0.68);
	--sesli-bg-soft: #eef7fb;
	--sesli-bubble-ai: #eef7fb;
	--sesli-border: #dceef7;
	--sesli-input-border: #cfe7f2;
	--sesli-text: #0f2a3d;
	--sesli-text-soft: #5b7a8e;
	--sesli-tint-a: rgba(2, 132, 199, 0.06);
	--sesli-tint-b: rgba(20, 184, 166, 0.07);
	--sesli-scroll: #c3dde8;
	--sesli-hover: rgba(2, 132, 199, 0.08);
	--sesli-focus: rgba(2, 132, 199, 0.16);
	--sesli-shadow: 0 24px 60px -12px rgba(12, 74, 110, 0.35), 0 8px 24px -8px rgba(12, 74, 110, 0.18);
}

/* Medianoche — modo oscuro */
.sesli-chat-root--theme-midnight {
	--sesli-primary: #a78bfa;
	--sesli-secondary: #22d3ee;
	--sesli-grad: linear-gradient(135deg, #7c3aed, #6d28d9 55%, #0e7490);
	--sesli-glow: rgba(139, 92, 246, 0.55);
	--sesli-glow-strong: rgba(139, 92, 246, 0.75);
	--sesli-bg: #0f172a;
	--sesli-bg-soft: #1e293b;
	--sesli-bubble-ai: #1e293b;
	--sesli-border: #334155;
	--sesli-input-border: #334155;
	--sesli-text: #e2e8f0;
	--sesli-text-soft: #94a3b8;
	--sesli-tint-a: rgba(139, 92, 246, 0.09);
	--sesli-tint-b: rgba(34, 211, 238, 0.07);
	--sesli-scroll: #475569;
	--sesli-hover: rgba(139, 92, 246, 0.15);
	--sesli-focus: rgba(139, 92, 246, 0.25);
	--sesli-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6), 0 8px 24px -8px rgba(0, 0, 0, 0.45);
}

/* -------------------------------------------------- */
/* Modo silencioso: el administrador desactivó la voz con una sola clave  */
/* -------------------------------------------------- */
.sesli-chat-root--no-voice .sesli-chat-sound-btn,
.sesli-chat-root--no-voice .sesli-chat-mic-btn,
.sesli-chat-root--no-voice .sesli-chat-speak-msg-btn {
	display: none;
}

.sesli-chat-root--no-voice .sesli-chat-speaking {
	display: none !important;
}

.sesli-chat-root--right { right: 20px; }
.sesli-chat-root--left { left: 20px; }

/* -------------------------------------------------- */
/* Botón de inicio                                       */
/* -------------------------------------------------- */
.sesli-chat-launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 62px;
	height: 62px;
	border: none;
	border-radius: 50%;
	background: var(--sesli-grad);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 10px 28px -6px var(--sesli-glow);
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.sesli-chat-launcher:hover {
	transform: scale(1.08);
	box-shadow: 0 14px 34px -6px var(--sesli-glow-strong);
}

.sesli-chat-launcher:active { transform: scale(0.96); }
.sesli-chat-launcher:focus-visible { outline: 3px solid var(--sesli-secondary); outline-offset: 3px; }

.sesli-chat-launcher-icon {
	display: flex;
	width: 30px;
	height: 30px;
}

.sesli-chat-launcher-ring {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--sesli-primary);
	opacity: 0;
	animation: sesli-pulse 2.6s ease-out infinite;
	pointer-events: none;
}

.sesli-chat-root--open .sesli-chat-launcher-ring { display: none; }

@keyframes sesli-pulse {
	0%   { transform: scale(1); opacity: 0.7; }
	70%  { transform: scale(1.7); opacity: 0; }
	100% { transform: scale(1.7); opacity: 0; }
}

/* -------------------------------------------------- */
/* Panel                                                 */
/* -------------------------------------------------- */
.sesli-chat-panel {
	position: fixed;
	bottom: 96px;
	width: 384px;
	max-width: calc(100vw - 28px);
	height: min(620px, calc(100vh - 130px));
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	background: var(--sesli-bg);
	border-radius: var(--sesli-radius);
	box-shadow: var(--sesli-shadow);
	overflow: hidden;
	transform-origin: bottom;
	transform: translateY(16px) scale(0.96);
	opacity: 0;
	visibility: hidden;
	transition: transform 0.24s cubic-bezier(0.34, 1.3, 0.64, 1), opacity 0.2s ease, visibility 0.24s;
}

.sesli-chat-root--right .sesli-chat-panel { right: 0; }
.sesli-chat-root--left .sesli-chat-panel { left: 0; }

.sesli-chat-panel--visible {
	transform: translateY(0) scale(1);
	opacity: 1;
	visibility: visible;
}

.sesli-chat-panel[hidden] { display: none; }

/* -------------------------------------------------- */
/* Encabezado                                            */
/* -------------------------------------------------- */
.sesli-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	color: #fff;
	background: var(--sesli-grad);
	flex-shrink: 0;
}

.sesli-chat-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	backdrop-filter: blur(4px);
	flex-shrink: 0;
}

.sesli-chat-avatar svg { width: 26px; height: 26px; }

.sesli-chat-header-info { flex: 1; min-width: 0; }

.sesli-chat-title {
	display: block;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.1px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sesli-chat-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11.5px;
	opacity: 0.92;
}

.sesli-chat-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
	animation: sesli-dot-blink 1.8s infinite;
}

@keyframes sesli-dot-blink {
	0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
	50%      { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0); }
}

.sesli-chat-header-actions {
	display: flex;
	gap: 4px;
	flex-shrink: 0;
}

.sesli-chat-icon-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: rgba(255, 255, 255, 0.9);
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.sesli-chat-icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.sesli-chat-icon-btn:active { transform: scale(0.9); }
.sesli-chat-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sesli-chat-icon-btn svg { width: 18px; height: 18px; }

.sesli-chat-sound-btn .sesli-icon-sound-off { display: none; }
.sesli-chat-sound-btn.is-muted .sesli-icon-sound-on { display: none; }
.sesli-chat-sound-btn.is-muted .sesli-icon-sound-off { display: block; }

.sesli-chat-clear-btn.is-armed { background: rgba(255, 255, 255, 0.28); color: #fff; }

/* -------------------------------------------------- */
/* Mensajes                                              */
/* -------------------------------------------------- */
.sesli-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	background:
		radial-gradient(1200px 400px at 100% 0%, var(--sesli-tint-a), transparent 60%),
		radial-gradient(900px 400px at 0% 100%, var(--sesli-tint-b), transparent 60%),
		var(--sesli-bg);
	scroll-behavior: smooth;
}

.sesli-chat-messages::-webkit-scrollbar { width: 6px; }
.sesli-chat-messages::-webkit-scrollbar-thumb { background: var(--sesli-scroll); border-radius: 99px; }
.sesli-chat-messages::-webkit-scrollbar-track { background: transparent; }

.sesli-chat-msg {
	display: flex;
	margin-bottom: 10px;
	animation: sesli-msg-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sesli-msg-in {
	from { opacity: 0; transform: translateY(10px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.sesli-chat-msg--user { justify-content: flex-end; }
.sesli-chat-msg--assistant { justify-content: flex-start; }
.sesli-chat-msg--error { justify-content: flex-start; }

.sesli-chat-bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	word-break: break-word;
	white-space: pre-wrap;
}

.sesli-chat-msg--user .sesli-chat-bubble {
	background: var(--sesli-grad);
	color: #fff;
	border-bottom-right-radius: 5px;
	box-shadow: 0 6px 16px -6px var(--sesli-glow);
}

.sesli-chat-msg--assistant .sesli-chat-bubble {
	background: var(--sesli-bubble-ai);
	color: var(--sesli-text);
	border: 1px solid var(--sesli-border);
	border-bottom-left-radius: 5px;
}

.sesli-chat-msg--error .sesli-chat-bubble {
	background: #fef2f2;
	color: #b91c1c;
	border: 1px solid #fecaca;
	border-bottom-left-radius: 5px;
	font-size: 13px;
}

/* Indicador de escribiendo */
.sesli-chat-typing {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 12px 16px;
	margin-bottom: 10px;
	background: var(--sesli-bubble-ai);
	border: 1px solid var(--sesli-border);
	border-bottom-left-radius: 5px;
	border-radius: 16px;
	width: fit-content;
	animation: sesli-msg-in 0.25s ease;
}

.sesli-chat-typing-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--sesli-primary);
	opacity: 0.4;
	animation: sesli-typing-bounce 1.2s infinite ease-in-out;
}

.sesli-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.sesli-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes sesli-typing-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
	30%           { transform: translateY(-5px); opacity: 1; }
}

/* Indicador de voz (entre los mensajes y la barra de entrada) */
.sesli-chat-speaking {
	display: none;
	align-items: center;
	gap: 10px;
	padding: 8px 14px;
	border-top: 1px solid var(--sesli-border);
	background: var(--sesli-hover);
	color: var(--sesli-primary);
	font-size: 12.5px;
	font-weight: 600;
	flex-shrink: 0;
	animation: sesli-msg-in 0.25s ease;
}

.sesli-chat-root--speaking .sesli-chat-speaking { display: flex; }

.sesli-chat-wave {
	display: flex;
	align-items: center;
	gap: 3px;
	height: 18px;
}

.sesli-chat-wave span {
	width: 3px;
	height: 5px;
	border-radius: 2px;
	background: var(--sesli-primary);
	animation: sesli-wave 0.9s infinite ease-in-out;
}

.sesli-chat-wave span:nth-child(1) { animation-delay: 0s; }
.sesli-chat-wave span:nth-child(2) { animation-delay: 0.15s; }
.sesli-chat-wave span:nth-child(3) { animation-delay: 0.3s; }
.sesli-chat-wave span:nth-child(4) { animation-delay: 0.45s; }
.sesli-chat-wave span:nth-child(5) { animation-delay: 0.6s; }

@keyframes sesli-wave {
	0%, 100% { height: 5px; }
	50%      { height: 17px; }
}

.sesli-chat-stop-speak {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px;
	border: none;
	border-radius: 99px;
	background: var(--sesli-primary);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.15s ease, filter 0.15s ease;
}

.sesli-chat-stop-speak:hover { filter: brightness(1.1); transform: scale(1.05); }
.sesli-chat-stop-speak:active { transform: scale(0.95); }
.sesli-chat-stop-speak:focus-visible { outline: 2px solid var(--sesli-secondary); outline-offset: 2px; }

.sesli-chat-stop-speak svg { width: 12px; height: 12px; fill: currentColor; }

/* -------------------------------------------------- */
/* Barra de entrada                                      */
/* -------------------------------------------------- */
.sesli-chat-inputbar {
	padding: 10px 12px 8px;
	border-top: 1px solid var(--sesli-border);
	background: var(--sesli-bg);
	flex-shrink: 0;
}

.sesli-chat-input-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--sesli-bg-soft);
	border: 1.5px solid var(--sesli-input-border);
	border-radius: 99px;
	padding: 4px 4px 4px 16px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sesli-chat-input-wrap:focus-within {
	border-color: var(--sesli-primary);
	box-shadow: 0 0 0 3px var(--sesli-focus);
}

.sesli-chat-input {
	flex: 1;
	min-width: 0;
	border: none;
	outline: none;
	background: transparent;
	font-size: 14px;
	color: var(--sesli-text);
	padding: 8px 0;
}

.sesli-chat-input::placeholder { color: var(--sesli-text-soft); }

.sesli-chat-mic-btn,
.sesli-chat-send-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	flex-shrink: 0;
	transition: transform 0.15s ease, background 0.15s ease;
}

.sesli-chat-mic-btn {
	background: transparent;
	color: var(--sesli-text-soft);
	position: relative;
}

.sesli-chat-mic-btn:hover { color: var(--sesli-primary); background: var(--sesli-hover); }
.sesli-chat-mic-btn:focus-visible { outline: 2px solid var(--sesli-primary); outline-offset: 2px; }

.sesli-chat-mic-btn svg { width: 20px; height: 20px; }

.sesli-chat-send-btn {
	background: var(--sesli-grad);
	color: #fff;
	box-shadow: 0 4px 12px -2px var(--sesli-glow);
}

.sesli-chat-send-btn:hover { transform: scale(1.07); }
.sesli-chat-send-btn:active { transform: scale(0.92); }
.sesli-chat-send-btn:focus-visible { outline: 2px solid var(--sesli-secondary); outline-offset: 2px; }
.sesli-chat-send-btn svg { width: 18px; height: 18px; }

.sesli-chat-hint {
	margin: 6px 4px 0;
	font-size: 11px;
	color: var(--sesli-text-soft);
	text-align: center;
}

/* Modo de escucha */
.sesli-chat-root--listening .sesli-chat-mic-btn {
	color: #fff;
	background: #ef4444;
	animation: sesli-mic-pulse 1.4s infinite;
}

.sesli-chat-root--listening .sesli-chat-input-wrap {
	border-color: #ef4444;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

@keyframes sesli-mic-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
	50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* -------------------------------------------------- */
/* Mobil                                              */
/* -------------------------------------------------- */
@media (max-width: 480px) {
	.sesli-chat-root { bottom: 14px; }
	.sesli-chat-root--right { right: 14px; }
	.sesli-chat-root--left { left: 14px; }

	.sesli-chat-panel {
		position: fixed;
		bottom: 84px;
		width: calc(100vw - 28px);
		height: calc(100vh - 100px);
		max-height: calc(100vh - 100px);
	}
}

/* -------------------------------------------------- */
/* Insignia de sin leer                                  */
/* -------------------------------------------------- */
.sesli-chat-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 99px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
	opacity: 0;
	transform: scale(0.5);
	transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
	pointer-events: none;
}

.sesli-chat-badge.is-visible {
	opacity: 1;
	transform: scale(1);
}

/* -------------------------------------------------- */
/* Chips de sugerencias                                    */
/* -------------------------------------------------- */
.sesli-chat-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 2px 14px;
	animation: sesli-msg-in 0.3s ease;
}

.sesli-chat-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1.5px solid var(--sesli-input-border);
	border-radius: 99px;
	background: var(--sesli-bg);
	color: var(--sesli-primary);
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.sesli-chat-chip::before {
	content: "💬";
	font-size: 11px;
}

.sesli-chat-chip:hover {
	border-color: var(--sesli-primary);
	background: var(--sesli-hover);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px -4px var(--sesli-glow);
}

.sesli-chat-chip:active { transform: scale(0.96); }
.sesli-chat-chip:focus-visible { outline: 2px solid var(--sesli-secondary); outline-offset: 2px; }

/* -------------------------------------------------- */
/* Botón "escuchar" por mensaje                          */
/* -------------------------------------------------- */
.sesli-chat-msg-actions {
	display: flex;
	justify-content: flex-start;
	padding: 4px 0 0;
}

.sesli-chat-speak-msg-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border: none;
	border-radius: 99px;
	background: transparent;
	color: var(--sesli-text-soft);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sesli-chat-speak-msg-btn:hover {
	background: var(--sesli-hover);
	color: var(--sesli-primary);
}

.sesli-chat-speak-msg-btn:active { transform: scale(0.92); }
.sesli-chat-speak-msg-btn:focus-visible { outline: 2px solid var(--sesli-secondary); outline-offset: 2px; }
.sesli-chat-speak-msg-btn svg { width: 15px; height: 15px; }

.sesli-chat-speak-msg-wave {
	display: none;
	align-items: center;
	gap: 2px;
	height: 12px;
}

.sesli-chat-speak-msg-wave span {
	width: 2.5px;
	height: 4px;
	border-radius: 2px;
	background: currentColor;
	animation: sesli-wave 0.9s infinite ease-in-out;
}

.sesli-chat-speak-msg-wave span:nth-child(1) { animation-delay: 0s; }
.sesli-chat-speak-msg-wave span:nth-child(2) { animation-delay: 0.15s; }
.sesli-chat-speak-msg-wave span:nth-child(3) { animation-delay: 0.3s; }

.sesli-chat-msg--speaking .sesli-chat-speak-msg-btn {
	background: var(--sesli-hover);
	color: var(--sesli-primary);
}

.sesli-chat-msg--speaking .sesli-chat-speak-msg-btn svg { display: none; }
.sesli-chat-msg--speaking .sesli-chat-speak-msg-wave { display: inline-flex; }

/* -------------------------------------------------- */
/* Cursor de escritura en vivo                           */
/* -------------------------------------------------- */
.sesli-chat-msg--assistant .sesli-chat-bubble.is-streaming::after {
	content: "";
	display: inline-block;
	width: 7px;
	height: 14px;
	margin-left: 3px;
	vertical-align: -2px;
	border-radius: 2px;
	background: var(--sesli-primary);
	animation: sesli-caret-blink 0.9s infinite;
}

@keyframes sesli-caret-blink {
	0%, 100% { opacity: 1; }
	50%      { opacity: 0.15; }
}

/* -------------------------------------------------- */
/* Pulso del micrófono                                    */
/* -------------------------------------------------- */
.sesli-mic-pulse {
	display: none;
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid #ef4444;
}

.sesli-chat-root--listening .sesli-mic-pulse {
	display: block;
	animation: sesli-mic-pulse 1.4s infinite;
}

/* -------------------------------------------------- */
/* Accesibilidad / movimiento reducido                    */
/* -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.sesli-chat-launcher-ring,
	.sesli-chat-status-dot,
	.sesli-chat-typing-dot,
	.sesli-chat-wave span,
	.sesli-chat-root--listening .sesli-chat-mic-btn {
		animation: none !important;
	}

	.sesli-chat-panel,
	.sesli-chat-msg {
		transition: none;
		animation: none;
	}
}
