/* ==========================================================================
   HK XperTech AI Chat Bot — Frontend Widget Styles
   ========================================================================== */

#hkxac-widget-root {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--hkxac-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
	--hkxac-shadow-lg: 0 20px 45px -10px rgba(0,0,0,.28), 0 8px 16px -8px rgba(0,0,0,.15);
}

#hkxac-widget-root.hkxac-pos-right { right: 24px; }
#hkxac-widget-root.hkxac-pos-left  { left: 24px; }

.hkxac-hidden { display: none !important; }
html.hkxac-body-locked,
body.hkxac-body-locked { overflow: hidden !important; height: 100% !important; overscroll-behavior: none; }

/* ---------------- Toggle button ---------------- */
#hkxac-toggle-btn {
	position: relative;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--hkxac-primary, #D9A22D);
	border: none;
	box-shadow: var(--hkxac-shadow-lg);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: transform .18s ease, box-shadow .18s ease;
}
#hkxac-toggle-btn:hover { transform: scale(1.06); }
#hkxac-toggle-btn:active { transform: scale(0.97); }

.hkxac-toggle-icon-open,
.hkxac-toggle-icon-close {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity .15s ease, transform .2s ease;
}
.hkxac-toggle-icon-open img { width: 34px; height: 34px; object-fit: contain; border-radius: 50%; }
.hkxac-toggle-icon-close { opacity: 0; transform: scale(.5) rotate(-45deg); color: #fff; }

#hkxac-widget-root.hkxac-open .hkxac-toggle-icon-open { opacity: 0; transform: scale(.5) rotate(45deg); }
#hkxac-widget-root.hkxac-open .hkxac-toggle-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

.hkxac-unread-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 999px;
	background: #E5484D;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
	animation: hkxac-badge-pop .25s ease;
	z-index: 3;
}
@keyframes hkxac-badge-pop {
	from { transform: scale(0); }
	to { transform: scale(1); }
}

/* Pulsing "wave" rings so visitors instantly recognize this is a live chat button */
.hkxac-pulse-ring {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--hkxac-primary, #D9A22D);
	opacity: .55;
	animation: hkxac-pulse 2.6s ease-out infinite;
	z-index: 0;
	pointer-events: none;
}
.hkxac-pulse-ring-delay { animation-delay: 1.3s; }
#hkxac-widget-root.hkxac-open .hkxac-pulse-ring { display: none; }
@keyframes hkxac-pulse {
	0%   { transform: scale(1);   opacity: .45; }
	80%  { transform: scale(1.9); opacity: 0; }
	100% { transform: scale(1.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.hkxac-pulse-ring { animation: none; display: none; }
}

/* ---------------- Chat window ---------------- */
#hkxac-chat-window {
	position: absolute;
	bottom: 78px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: 72vh;
	background: var(--hkxac-chat-bg, #ffffff);
	border-radius: 20px;
	box-shadow: var(--hkxac-shadow-lg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom var(--hkxac-origin-side, right);
	animation: hkxac-window-in .22s cubic-bezier(.2,.9,.3,1.2);
}
.hkxac-pos-right #hkxac-chat-window { right: 0; --hkxac-origin-side: right; }
.hkxac-pos-left  #hkxac-chat-window { left: 0; --hkxac-origin-side: left; }

@keyframes hkxac-window-in {
	from { opacity: 0; transform: translateY(16px) scale(.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- Header ---------------- */
#hkxac-chat-header {
	background: var(--hkxac-header-bg, #08363B);
	color: var(--hkxac-header-text, #ffffff);
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.hkxac-header-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.hkxac-header-avatar { position: relative; flex-shrink: 0; display: flex; }

.hkxac-header-logo {
	width: 36px; height: 36px; border-radius: 50%; object-fit: contain;
	background: rgba(255,255,255,.15);
	border: 2px solid rgba(255,255,255,.25);
}
.hkxac-online-dot {
	position: absolute;
	bottom: -1px;
	right: -1px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #22C55E;
	border: 2px solid var(--hkxac-header-bg, #08363B);
}
.hkxac-header-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.hkxac-header-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hkxac-header-status { font-size: 11.5px; opacity: .8; }

/* ---------------- Messages ---------------- */
#hkxac-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background:
		radial-gradient(circle at 15% 8%, rgba(217,162,45,.04), transparent 40%),
		var(--hkxac-chat-bg, #ffffff);
}
#hkxac-messages::-webkit-scrollbar { width: 6px; }
#hkxac-messages::-webkit-scrollbar-thumb { background: #d8dde0; border-radius: 999px; }
#hkxac-messages::-webkit-scrollbar-track { background: transparent; }

.hkxac-msg {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	animation: hkxac-msg-in .22s ease;
}
@keyframes hkxac-msg-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}
.hkxac-msg-bot { justify-content: flex-start; }
.hkxac-msg-user { justify-content: flex-end; }

.hkxac-msg-avatar {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	object-fit: contain;
	background: #eef1f2;
	flex-shrink: 0;
	margin-bottom: 2px;
}

.hkxac-bubble {
	max-width: 76%;
	padding: 11px 15px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.hkxac-bubble p { margin: 0 0 6px; }
.hkxac-bubble p:last-child { margin-bottom: 0; }
.hkxac-bubble ul { margin: 4px 0; padding-left: 18px; }
.hkxac-bubble li { margin-bottom: 3px; }
.hkxac-bubble a { color: inherit; text-decoration: underline; }
.hkxac-bubble code {
	background: rgba(0,0,0,.08);
	padding: 1px 5px;
	border-radius: 4px;
	font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
	font-size: 12.5px;
}

.hkxac-msg-bot .hkxac-bubble {
	background: var(--hkxac-bot-bubble, #F1F5F4);
	color: var(--hkxac-bot-bubble-text, #08363B);
	border-bottom-left-radius: 4px;
}
.hkxac-msg-user .hkxac-bubble {
	background: var(--hkxac-user-bubble, #08363B);
	color: var(--hkxac-user-bubble-text, #ffffff);
	border-bottom-right-radius: 4px;
}
.hkxac-msg-error .hkxac-bubble {
	background: #FDEDEE;
	color: #B42318;
	border: 1px solid #F6C4C7;
}

/* Typing indicator, rendered as a bot bubble */
.hkxac-typing-bubble {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 13px 15px !important;
}
.hkxac-typing-bubble span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	opacity: .45;
	animation: hkxac-blink 1.2s infinite ease-in-out;
}
.hkxac-typing-bubble span:nth-child(2) { animation-delay: .2s; }
.hkxac-typing-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes hkxac-blink {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------------- Input row ---------------- */
#hkxac-input-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid #e6e9ec;
	flex-shrink: 0;
	background: var(--hkxac-chat-bg, #ffffff);
}
#hkxac-input-field {
	flex: 1;
	border: 1.5px solid #e2e6e8;
	border-radius: 18px;
	padding: 10px 15px;
	font-size: 14px;
	font-family: inherit;
	outline: none;
	resize: none;
	max-height: 90px;
	line-height: 1.4;
	transition: border-color .15s ease;
}
#hkxac-input-field:focus { border-color: var(--hkxac-primary, #D9A22D); }

#hkxac-send-btn {
	background: var(--hkxac-primary, #D9A22D);
	color: #fff;
	border: none;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	box-shadow: 0 2px 6px rgba(0,0,0,.18);
	transition: opacity .15s ease, transform .12s ease, box-shadow .15s ease;
}
#hkxac-send-btn svg { margin-left: 1px; }
#hkxac-send-btn:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 4px 10px rgba(0,0,0,.22); }
#hkxac-send-btn:active:not(:disabled) { transform: scale(0.96); }
#hkxac-send-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------------- Footer ---------------- */
#hkxac-footer {
	text-align: center;
	font-size: 11px;
	color: #9aa4a8;
	padding: 7px 0 11px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	flex-shrink: 0;
}

/* ---------------- Mobile: fullscreen chat like WhatsApp/Instagram ---------------- */
@media (max-width: 640px) {
	#hkxac-widget-root.hkxac-open #hkxac-chat-window {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100vh;   /* fallback for older browsers */
		height: 100dvh;  /* adjusts automatically when the mobile keyboard opens */
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
		animation: hkxac-window-in-mobile .18s ease;
	}

	#hkxac-widget-root.hkxac-open #hkxac-toggle-btn {
		display: none;
	}

	#hkxac-chat-header {
		padding-top: max(16px, env(safe-area-inset-top));
	}

	#hkxac-input-row {
		padding-bottom: max(12px, env(safe-area-inset-bottom));
	}

	#hkxac-messages {
		padding-bottom: 22px;
	}
}

@keyframes hkxac-window-in-mobile {
	from { opacity: 0; }
	to   { opacity: 1; }
}
