/* Genie chat widget (v3). Self-contained, scoped to .genie-* so it won't
   collide with theme styles. Matches the legacy "AI Assistant" look: a
   teal->blue gradient header (the Generis logo palette), light-gray bot
   bubbles with a bold "Genie:" label, a pill input and a round arrow send.
   Launcher bottom-right; panel is a floating rounded card. */

#genie-widget-root {
	--genie-teal: #41bdb2;
	--genie-cyan: #24c0e4;
	--genie-blue: #5bb6e6;
	--genie-grad: linear-gradient(115deg, #41bdb2 0%, #2bbcd6 52%, #5bb6e6 100%);
	--genie-ink: #2b2b2b;
	--genie-bot-bg: #ececec;
	--genie-line: #e2e6ea;
	--genie-link: #0094c6;
	--genie-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Open Sans", Helvetica, Arial, sans-serif;
}

/* ---------- launcher ---------- */
.genie-launcher {
	/* matches the legacy "AI Assistant" launcher exactly: white circle, teal
	   fa-comments icon, soft drop shadow, bottom:50/right:65. */
	position: fixed;
	right: 50px;
	bottom: 50px;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	color: #50c6cb;
	cursor: pointer;
	box-shadow: 0 2.1px 9.1px rgba(0, 0, 0, 0.25);
	z-index: 999999;
	transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.genie-launcher:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); }
.genie-launcher:focus-visible { outline: 3px solid var(--genie-cyan); outline-offset: 2px; }
.genie-launcher-open { filter: brightness(0.95); }

/* ---------- panel ---------- */
.genie-panel {
	position: fixed;
	right: 50px;
	bottom: 104px;
	width: 372px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 130px);
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(20, 40, 60, 0.3);
	overflow: hidden;
	z-index: 999999;
	font-family: var(--genie-font);
	font-size: 14px;
	color: var(--genie-ink);
	transform-origin: bottom right;
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.genie-hidden {
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	visibility: hidden;
}

/* ---------- header ---------- */
.genie-header {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px 18px;
	background: var(--genie-grad);
	color: #fff;
}
.genie-brand { display: flex; align-items: center; gap: 11px; }
.genie-logo {
	height: 26px;
	width: auto;
	display: block;
	padding: 5px;
	background: rgba(255, 255, 255, 0.9);
	border-radius: 8px;
}
.genie-title {
	font-weight: 700;
	font-size: 19px;
	letter-spacing: 0.2px;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.genie-close {
	position: absolute;
	right: 14px;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	border-radius: 6px;
	opacity: 0.92;
	transition: opacity 0.15s ease, background 0.15s ease;
}
.genie-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.18); }
.genie-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ---------- log ---------- */
.genie-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fff;
	scrollbar-width: thin;
	scrollbar-color: #cfd6dc transparent;
}
.genie-log::-webkit-scrollbar { width: 8px; }
.genie-log::-webkit-scrollbar-thumb { background: #cfd6dc; border-radius: 4px; }

.genie-msg {
	max-width: 86%;
	padding: 11px 14px;
	border-radius: 16px;
	line-height: 1.5;
	word-wrap: break-word;
	white-space: normal;
	animation: genie-pop 0.18s ease;
}
@keyframes genie-pop {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: translateY(0); }
}
.genie-bot {
	align-self: flex-start;
	background: var(--genie-bot-bg);
	color: var(--genie-ink);
	border-bottom-left-radius: 5px;
}
.genie-name { font-weight: 700; color: #1b1b1b; }
.genie-bot a { color: var(--genie-link); text-decoration: underline; }
.genie-bot a:hover { color: #006f95; }
.genie-user {
	align-self: flex-end;
	background: var(--genie-blue);
	color: #fff;
	border-bottom-right-radius: 5px;
}

/* ---------- typing dots ---------- */
.genie-typing { display: flex; gap: 4px; align-items: center; padding: 13px 16px; }
.genie-dot-anim {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9aa7b4;
	animation: genie-bounce 1.2s infinite ease-in-out both;
}
.genie-dot-anim:nth-child(2) { animation-delay: 0.15s; }
.genie-dot-anim:nth-child(3) { animation-delay: 0.3s; }
@keyframes genie-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
	40% { transform: scale(1); opacity: 1; }
}

/* ---------- feedback ---------- */
.genie-fb { align-self: flex-start; margin-top: -4px; padding-left: 4px; display: flex; gap: 6px; align-items: center; }
.genie-fb-btn {
	background: #fff;
	border: 1px solid #d6dbe0;
	border-radius: 6px;
	cursor: pointer;
	padding: 2px 7px;
	font-size: 13px;
	transition: background 0.15s ease;
}
.genie-fb-btn:hover { background: #f2f4f6; }
.genie-fb-thanks { font-size: 12px; color: #6b7280; }

/* ---------- input bar ---------- */
.genie-inputbar {
	display: flex;
	gap: 9px;
	align-items: center;
	padding: 12px 14px;
	border-top: 1px solid var(--genie-line);
	background: #fff;
}
.genie-input {
	flex: 1;
	border: 1px solid #ccd2d8;
	border-radius: 22px;
	padding: 10px 16px;
	font-family: var(--genie-font);
	font-size: 14px;
	color: var(--genie-ink);
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.genie-input::placeholder { color: #9aa3ac; }
.genie-input:focus { border-color: var(--genie-cyan); box-shadow: 0 0 0 3px rgba(36, 192, 228, 0.18); }
.genie-input:disabled { background: #f3f4f6; }
.genie-send {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex: none;
	border: none;
	border-radius: 50%;
	background: var(--genie-grad);
	color: #fff;
	cursor: pointer;
	transition: filter 0.15s ease, opacity 0.15s ease;
}
.genie-send:hover:not(:disabled) { filter: brightness(1.06); }
.genie-send:focus-visible { outline: 2px solid var(--genie-cyan); outline-offset: 2px; }
.genie-send:disabled { opacity: 0.5; cursor: default; }

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 480px) {
	.genie-panel {
		right: 0;
		bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
	}
	.genie-launcher { right: 16px; bottom: 16px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.genie-panel, .genie-launcher, .genie-msg, .genie-dot-anim { transition: none; animation: none; }
}

/* ---------- host-theme defense ----------
 * The widget mounts inside client themes (Generis runs X/Pro) whose global
 * element rules — input[type="text"]{}, form{margin-bottom:30px}, button{...} —
 * outrank our single-class selectors (input[type=text] is 0,1,1 vs .genie-input
 * 0,1,0) and bleed margins/padding in: a 30px gap under the input bar and an
 * off-centre send icon. Scope the resets to the root ID (1,1,0) so they outrank
 * any element/attribute selector a host theme can throw, and restore intended
 * box metrics. */
#genie-widget-root form,
#genie-widget-root input,
#genie-widget-root button { margin: 0; }
#genie-widget-root .genie-input { padding: 10px 16px; }
#genie-widget-root .genie-send { padding: 0; }
