/**
 * Express Entry Hub - Guide Chat Widget (Gold Series / CT-Adopt)
 *
 * Self-contained (owns its bronze/steel palette via CSS custom properties with
 * hard fallbacks) so it renders correctly on any frontend page regardless of
 * whether the admin gold-series.css / dashboard frontend.css are loaded.
 *
 * @package ExpressEntryHub
 */

.eeh-chat-root,
.eeh-chat-root * {
	box-sizing: border-box;
	font-family: inherit;
}

/* ---------- Floating launcher (bronze orb) ---------- */
.eeh-chat-launcher {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #C2714A 0%, #D4845C 50%, #E09A72 100%);
	box-shadow: 0 8px 24px rgba(139, 69, 19, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	padding: 0;
}
.eeh-chat-launcher:hover,
.eeh-chat-launcher:focus-visible {
	transform: translateY(-2px) scale(1.05);
	box-shadow: 0 12px 30px rgba(139, 69, 19, 0.65);
	outline: none;
}
.eeh-chat-avatar {
	width: 38px;
	height: 38px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	background: rgba(255, 255, 255, 0.18);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.eeh-chat-live-dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #4ade80;
	border: 2px solid rgba(20, 16, 10, 0.9);
}
.eeh-chat-launcher .eeh-chat-label {
	position: absolute;
	right: calc(100% + 12px);
	top: 50%;
	transform: translateY(-50%);
	white-space: nowrap;
	background: rgba(20, 16, 10, 0.94);
	color: #fff;
	font-size: 12px;
	padding: 6px 10px;
	border-radius: 8px;
	border: 1px solid rgba(205, 133, 63, 0.4);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s ease;
}
.eeh-chat-launcher:hover .eeh-chat-label,
.eeh-chat-launcher:focus-visible .eeh-chat-label {
	opacity: 1;
}

/* Presence ring pulse */
.eeh-chat-launcher::before {
	content: "";
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 2px solid rgba(205, 133, 63, 0.45);
	animation: eeh-chat-ping 3s ease-out infinite;
	pointer-events: none;
}
.eeh-chat-launcher.eeh-thinking::before {
	border-color: rgba(255, 255, 255, 0.6);
	animation: eeh-chat-ping 1s ease-out infinite;
}
.eeh-chat-launcher.eeh-listening::before {
	border-color: rgba(74, 222, 128, 0.95);
	animation: eeh-chat-ping 1.1s ease-out infinite;
}
.eeh-chat-launcher.eeh-speaking::before {
	border-color: rgba(205, 133, 63, 0.95);
	animation: eeh-chat-spin 0.9s linear infinite;
}
.eeh-chat-launcher:disabled {
	cursor: default;
	opacity: 0.85;
}
@keyframes eeh-chat-ping {
	0% { transform: scale(0.92); opacity: 0.9; }
	70%, 100% { transform: scale(1.28); opacity: 0; }
}
@keyframes eeh-chat-spin {
	to { transform: rotate(360deg); }
}

/* ---------- Panel ---------- */
.eeh-chat-panel {
	position: fixed;
	right: 20px;
	bottom: 92px;
	z-index: 999999;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: min(540px, calc(100vh - 120px));
	display: none;
	flex-direction: column;
	background: rgba(28, 22, 14, 0.97);
	border: 1px solid rgba(205, 133, 63, 0.45);
	border-radius: 16px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
	overflow: hidden;
	color: #fff;
}
.eeh-chat-panel.eeh-open {
	display: flex;
}
.eeh-chat-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	border-bottom: 1px solid rgba(205, 133, 63, 0.35);
	background: linear-gradient(135deg, #C2714A 0%, #D4845C 100%);
}
.eeh-chat-avatar-sm {
	width: 34px;
	height: 34px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	font-size: 18px;
	background: rgba(255, 255, 255, 0.2);
}
.eeh-chat-head-txt {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	line-height: 1.25;
}
.eeh-chat-head-txt strong {
	font-size: 14px;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.eeh-chat-head-status {
	font-size: 11px;
	color: rgba(255, 255, 255, 0.85);
}
.eeh-chat-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 22px;
	cursor: pointer;
	line-height: 1;
	padding: 0 2px;
}

/* ---------- Messages ---------- */
.eeh-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: rgba(0, 0, 0, 0.12);
}
.eeh-chat-msg {
	max-width: 84%;
	padding: 9px 12px;
	border-radius: 12px;
	font-size: 13px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-break: break-word;
	animation: eeh-chat-in 0.18s ease;
}
@keyframes eeh-chat-in {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: translateY(0); }
}
.eeh-chat-msg.eeh-user {
	align-self: flex-end;
	background: linear-gradient(135deg, #C2714A 0%, #D4845C 100%);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.eeh-chat-msg.eeh-agent {
	align-self: flex-start;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(205, 133, 63, 0.25);
	color: #f5f5f5;
	border-bottom-left-radius: 4px;
}
.eeh-chat-msg.eeh-agent .eeh-chat-msg-name {
	display: block;
	font-size: 11px;
	font-weight: 700;
	color: #E09A72;
	margin-bottom: 3px;
}
.eeh-chat-msg.eeh-error {
	align-self: stretch;
	background: rgba(220, 38, 38, 0.15);
	border: 1px solid rgba(220, 38, 38, 0.35);
	color: #fca5a5;
	font-size: 12px;
}
.eeh-chat-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	padding: 8px 12px;
}
.eeh-chat-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.7);
	animation: eeh-chat-bounce 1.2s ease-in-out infinite;
}
.eeh-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.eeh-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes eeh-chat-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
	40% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Input row ---------- */
.eeh-chat-inputrow {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(205, 133, 63, 0.35);
	background: rgba(20, 16, 10, 0.9);
}
.eeh-chat-mic {
	flex-shrink: 0;
	background: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.18);
	color: #fff;
	border-radius: 10px;
	padding: 0 10px;
	font-size: 15px;
	cursor: pointer;
	line-height: 1;
}
.eeh-chat-mic.eeh-on {
	background: rgba(74, 222, 128, 0.3);
	border-color: #4ade80;
}
.eeh-chat-input {
	flex: 1;
	min-width: 0;
	padding: 9px 12px;
	border-radius: 10px;
	border: 1px solid rgba(205, 133, 63, 0.35);
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font-size: 13px;
	outline: none;
}
.eeh-chat-input::placeholder { color: rgba(255, 255, 255, 0.5); }
.eeh-chat-input:focus { border-color: rgba(205, 133, 63, 0.75); }
.eeh-chat-send {
	flex-shrink: 0;
	background: linear-gradient(135deg, #C2714A 0%, #D4845C 100%);
	border: none;
	color: #fff;
	border-radius: 10px;
	padding: 0 14px;
	font-weight: 700;
	font-size: 13px;
	cursor: pointer;
}
.eeh-chat-send:disabled { opacity: 0.6; cursor: default; }
.eeh-chat-send:not(:disabled):hover { filter: brightness(1.08); }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
	.eeh-chat-panel {
		right: 12px;
		bottom: 84px;
		left: 12px;
		width: auto;
		max-width: none;
		height: min(70vh, 560px);
	}
	.eeh-chat-launcher { right: 12px; bottom: 14px; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
	.eeh-chat-launcher::before,
	.eeh-chat-launcher.eeh-thinking::before,
	.eeh-chat-launcher.eeh-listening::before,
	.eeh-chat-launcher.eeh-speaking::before,
	.eeh-chat-typing span,
	.eeh-chat-msg { animation: none !important; }
}


/* ---------- Guide portrait avatar (Surface 2: CT guide-hostess.svg) ----------
   The orb + panel-head avatars render the guide portrait image (set inline via
   background-image) and clip it to the circle, falling back to the emoji text
   when no portrait is available. */
.eeh-chat-avatar,
.eeh-chat-avatar-sm {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
}

/* ==========================================================================
   WEBSITE GUIDE NAVIGATION CHIP
   The guide points the visitor to a page (gold chip shown when auto-nav is off).
   ========================================================================== */
.eeh-chat-nav {
	display: inline-block;
	margin: 6px 2px 2px 0;
	padding: 6px 14px;
	font-size: 12px;
	font-weight: 700;
	color: #fff;
	text-decoration: none;
	background: linear-gradient(135deg, #8B4513, #CD853F);
	border-radius: 999px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .28);
	transition: transform .15s ease, box-shadow .15s ease;
}
.eeh-chat-nav:hover,
.eeh-chat-nav:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(205, 133, 63, .45);
	text-decoration: none;
	color: #fff;
}
