/* Hingenia Soporte — Widget */
.hs-widget-root {
	--hs-primary: #005A9C;
	--hs-radius: 18px;
	--hs-bg: #ffffff;
	--hs-text: #0f172a;
	--hs-muted: #64748b;
	--hs-border: rgba(15, 23, 42, 0.08);
	--hs-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
	position: fixed;
	bottom: 24px;
	z-index: 9999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.hs-widget-root.hs-pos-right { right: 24px; }
.hs-widget-root.hs-pos-left  { left: 24px; }

/* FAB */
.hs-fab {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--hs-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--hs-shadow);
	transition: transform .2s ease, box-shadow .2s ease;
}
.hs-fab:hover { transform: scale(1.05); }
.hs-fab:focus-visible { outline: 3px solid rgba(0, 90, 156, 0.4); outline-offset: 3px; }

.hs-fab-dot {
	position: absolute;
	top: 6px;
	right: 8px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #22c55e;
	border: 2px solid #fff;
}

/* Panel */
.hs-panel {
	position: absolute;
	bottom: 76px;
	width: 360px;
	max-width: calc(100vw - 32px);
	background: var(--hs-bg);
	border-radius: var(--hs-radius);
	box-shadow: var(--hs-shadow);
	overflow: hidden;
	transform-origin: bottom right;
	animation: hs-pop-in .22s ease-out;
}
.hs-pos-right .hs-panel { right: 0; }
.hs-pos-left  .hs-panel { left: 0; transform-origin: bottom left; }

@keyframes hs-pop-in {
	from { opacity: 0; transform: translateY(10px) scale(.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.hs-panel-header {
	background: var(--hs-primary);
	color: #fff;
	padding: 18px 20px 16px;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}
.hs-panel-title strong { display: block; font-size: 16px; line-height: 1.3; }
.hs-panel-title small { display: block; font-size: 12.5px; opacity: .85; margin-top: 4px; line-height: 1.4; }

.hs-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	margin-top: -2px;
}
.hs-close:hover { opacity: .8; }

.hs-panel-body {
	padding: 14px 14px 16px;
	max-height: 70vh;
	display: flex;
	flex-direction: column;
}

.hs-view { display: none; flex-direction: column; gap: 8px; }
.hs-view.is-active { display: flex; }

/* Options */
.hs-option {
	all: unset;
	cursor: pointer;
	display: grid;
	grid-template-columns: 44px 1fr auto;
	gap: 12px;
	align-items: center;
	padding: 12px 14px;
	background: #f8fafc;
	border: 1px solid var(--hs-border);
	border-radius: 14px;
	transition: background .15s ease, border-color .15s ease, transform .1s ease;
	color: var(--hs-text);
	text-decoration: none;
}
.hs-option:hover { background: #f1f5f9; border-color: rgba(0, 90, 156, 0.2); }
.hs-option:active { transform: scale(.99); }

.hs-option-group-title {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--hs-muted);
	text-transform: uppercase;
	letter-spacing: .04em;
	padding: 12px 4px 4px;
}

.hs-avatar {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--hs-primary);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background-size: cover;
	background-position: center;
	flex-shrink: 0;
}
.hs-avatar-wa { background-color: #25D366; }
.hs-avatar-ai { background-color: var(--hs-primary); }

.hs-option-info { display: flex; flex-direction: column; gap: 2px; }
.hs-option-name { font-weight: 600; font-size: 14px; }
.hs-option-role { font-size: 12.5px; color: var(--hs-muted); }
.hs-option-pill {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 100px;
	margin-top: 4px;
	width: fit-content;
}
.hs-pill-ai { background: rgba(0, 90, 156, 0.1); color: var(--hs-primary); }
.hs-pill-wa { background: rgba(34, 197, 94, 0.12); color: #15803d; }

.hs-option-arrow { color: var(--hs-muted); font-size: 20px; line-height: 1; padding-right: 4px; }

/* AI Chat View */
.hs-back {
	all: unset;
	cursor: pointer;
	color: var(--hs-primary);
	font-size: 13px;
	font-weight: 600;
	padding: 4px 0;
	width: fit-content;
}
.hs-back:hover { text-decoration: underline; }

.hs-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 4px 12px;
	border-bottom: 1px solid var(--hs-border);
}
.hs-chat-header strong { display: block; font-size: 14px; }
.hs-chat-header small { display: block; font-size: 11.5px; }
.hs-online-pill { color: #16a34a; font-weight: 600; }
.hs-online-pill::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #22c55e;
	margin-right: 5px;
	vertical-align: middle;
}

.hs-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px 4px;
	min-height: 200px;
	max-height: 360px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.hs-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.hs-msg-bot {
	background: #f1f5f9;
	color: var(--hs-text);
	border-bottom-left-radius: 4px;
	align-self: flex-start;
}
.hs-msg-user {
	background: var(--hs-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
	align-self: flex-end;
}
.hs-msg-typing {
	background: #f1f5f9;
	color: var(--hs-muted);
	align-self: flex-start;
	font-style: italic;
	font-size: 13px;
}

.hs-chat-escalate {
	padding: 8px 0;
	border-top: 1px solid var(--hs-border);
	text-align: center;
}
.hs-escalate-link {
	color: #15803d;
	font-weight: 600;
	font-size: 13px;
	text-decoration: none;
}
.hs-escalate-link:hover { text-decoration: underline; }

.hs-chat-form {
	display: flex;
	gap: 6px;
	padding: 10px 4px 4px;
	border-top: 1px solid var(--hs-border);
}
.hs-chat-input {
	flex: 1;
	border: 1px solid var(--hs-border);
	border-radius: 100px;
	padding: 10px 16px;
	font-size: 14px;
	outline: none;
	background: #f8fafc;
	transition: border-color .15s, background .15s;
}
.hs-chat-input:focus {
	border-color: var(--hs-primary);
	background: #fff;
}
.hs-chat-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--hs-primary);
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform .1s, opacity .15s;
}
.hs-chat-send:hover { transform: scale(1.05); }
.hs-chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* Mobile */
@media (max-width: 640px) {
	.hs-widget-root {
		bottom: calc(20px + var(--hs-mobile-offset, 0px));
	}
	.hs-widget-root.hs-pos-right { right: 16px; }
	.hs-widget-root.hs-pos-left  { left: 16px; }

	.hs-panel {
		width: calc(100vw - 32px);
		max-width: 380px;
	}
	.hs-panel-body { max-height: 65vh; }
}

/* Mobile sticky bar de single-course no choque (logueado tiene mobile-nav abajo) */
body.tutor-dashboard-page .hs-widget-root,
body.logged-in.single-courses .hs-widget-root {
	bottom: calc(80px + var(--hs-mobile-offset, 0px));
}
