/* ============================================================
   Orbit AI — chat widget (inline + floating launcher)
   Brand: #046BD2 (blue), #1F1988 (navy), Roboto
   ============================================================ */
.oai-chat {
	--oai-blue: #046BD2;
	--oai-navy: #1F1988;
	--oai-grad: linear-gradient(135deg, #1F1988 0%, #046BD2 100%);
	--oai-bg: #ffffff;
	--oai-panel: #eef2f9;
	--oai-bot: #ffffff;
	--oai-text: #1b2333;
	--oai-muted: #8a94a6;
	--oai-border: #e6ebf3;
	--oai-height: 620px;

	display: flex;
	flex-direction: column;
	height: var(--oai-height);
	max-height: 84vh;
	width: 100%;
	max-width: 440px;
	margin: 0 auto;
	background: var(--oai-bg);
	border: 1px solid var(--oai-border);
	border-radius: 22px;
	overflow: hidden;
	box-shadow: 0 24px 60px -18px rgba(31, 25, 136, 0.34), 0 8px 20px -12px rgba(4, 107, 210, 0.2);
	font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-weight: 400;
	color: var(--oai-text);
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
}
.oai-chat *, .oai-chat *::before, .oai-chat *::after { box-sizing: border-box; }

/* ---- Isolate the widget from the host theme (font-weight, transforms, button/input resets) ---- */
.oai-chat, .oai-chat p, .oai-chat span, .oai-chat div, .oai-chat li, .oai-chat textarea, .oai-chat button,
.oai-widget-float, .oai-widget-float span, .oai-widget-float button {
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	font-style: normal;
}
.oai-chat button, .oai-chat input, .oai-chat textarea,
.oai-widget-float button {
	font-family: inherit;
	font-weight: 400;
	min-height: 0;
	line-height: 1.4;
	margin: 0;
	text-decoration: none;
}
.oai-messages, .oai-bubble, .oai-foot, .oai-status, .oai-time { font-weight: 400; }

/* ---------- Header ---------- */
.oai-head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 13px;
	padding: 17px 18px;
	background: var(--oai-grad);
	color: #fff;
	flex: 0 0 auto;
	overflow: hidden;
}
.oai-head::before {
	content: "";
	position: absolute; inset: 0;
	background:
		radial-gradient(150px 150px at 85% -30%, rgba(255,255,255,.22), transparent 70%),
		radial-gradient(120px 120px at 10% 130%, rgba(76,227,143,.18), transparent 70%);
	pointer-events: none;
}
.oai-avatar {
	position: relative; z-index: 1;
	width: 44px; height: 44px;
	display: grid; place-items: center;
	background: rgba(255,255,255,0.16);
	border: 1.5px solid rgba(255,255,255,0.32);
	border-radius: 50%;
	flex: 0 0 auto;
	box-shadow: 0 4px 12px -4px rgba(0,0,0,.25);
}
.oai-avatar svg { width: 22px; height: 22px; }
.oai-titles { display: flex; flex-direction: column; line-height: 1.3; z-index: 1; margin-right: auto; }
.oai-botname { font-size: 16.5px; font-weight: 600; letter-spacing: .01em; }
.oai-status { font-size: 12px; opacity: .95; display: inline-flex; align-items: center; gap: 6px; }
.oai-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ce38f; display: inline-block; animation: oai-pulse 2s infinite; }
@keyframes oai-pulse { 0%{box-shadow:0 0 0 0 rgba(76,227,143,.6)} 70%{box-shadow:0 0 0 6px rgba(76,227,143,0)} 100%{box-shadow:0 0 0 0 rgba(76,227,143,0)} }
.oai-reset, .oai-close {
	z-index: 1;
	width: 32px; height: 32px;
	place-items: center;
	background: rgba(255,255,255,0.14);
	border: none; border-radius: 50%;
	color: #fff; cursor: pointer;
	padding: 0;
	flex: 0 0 auto;
	transition: background .15s ease, transform .3s ease;
}
.oai-reset { display: grid; }   /* a "new chat" button, always available */
.oai-close { display: none; }   /* only shown inside the popup (rule below) */
.oai-reset:hover { background: rgba(255,255,255,0.28); transform: rotate(-180deg); }
.oai-close:hover { background: rgba(255,255,255,0.28); transform: rotate(90deg); }

/* ---------- Messages ---------- */
.oai-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 22px 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	position: relative;
	background-color: var(--oai-panel);
	background-image:
		radial-gradient(rgba(31,25,136,.05) 1px, transparent 1.4px),
		linear-gradient(180deg, #f3f6fc 0%, var(--oai-panel) 22%);
	background-size: 22px 22px, 100% 100%;
	scroll-behavior: smooth;
}

.oai-msg { display: flex; align-items: flex-start; gap: 9px; max-width: 100%; animation: oai-in .3s cubic-bezier(.2,.7,.3,1) both; }
.oai-msg.oai-user { justify-content: flex-end; }
@keyframes oai-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

/* Small per-message avatar for the bot */
.oai-ava {
	flex: 0 0 auto;
	width: 30px; height: 30px;
	display: grid; place-items: center;
	background: var(--oai-grad);
	color: #fff;
	border-radius: 50%;
	box-shadow: 0 4px 10px -4px rgba(4,107,210,.5);
	margin-top: 2px;
	overflow: hidden;
}
.oai-ava svg { width: 15px; height: 15px; }

/* Avatar as a real photo (technician image) */
.oai-avatar.oai-has-img { background: transparent; padding: 0; overflow: hidden; }
.oai-avatar.oai-has-img img,
.oai-ava.oai-has-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.oai-ava.oai-has-img { background: #e9eef6; box-shadow: 0 3px 9px -4px rgba(31,25,136,.35); }

.oai-col { display: flex; flex-direction: column; gap: 4px; max-width: 82%; min-width: 0; }
.oai-user .oai-col { align-items: flex-end; }

.oai-bubble {
	padding: 11px 15px;
	border-radius: 18px;
	font-size: 14.5px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.oai-bot .oai-bubble {
	background: var(--oai-bot);
	color: var(--oai-text);
	border: 1px solid var(--oai-border);
	border-bottom-left-radius: 5px;
	box-shadow: 0 3px 12px -6px rgba(31,25,136,.2);
}
.oai-user .oai-bubble {
	background: var(--oai-grad);
	color: #fff;
	border-bottom-right-radius: 5px;
	box-shadow: 0 6px 16px -6px rgba(4,107,210,.5);
}
.oai-bubble a { color: inherit; text-decoration: underline; }
.oai-bubble strong { font-weight: 600; }
.oai-bubble ul { margin: 6px 0; padding-left: 20px; }
.oai-bubble li { margin: 3px 0; }
.oai-bubble p { margin: 0 0 8px; }
.oai-bubble p:last-child { margin-bottom: 0; }

.oai-time { font-size: 10.5px; color: var(--oai-muted); padding: 0 6px; }

/* Typing indicator */
.oai-typing { display: inline-flex; gap: 5px; align-items: center; padding: 3px 2px; }
.oai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--oai-blue); opacity: .55; animation: oai-blink 1.3s infinite both; }
.oai-typing i:nth-child(2){ animation-delay: .18s; }
.oai-typing i:nth-child(3){ animation-delay: .36s; }
@keyframes oai-blink { 0%,80%,100%{ transform: scale(.6); opacity:.35 } 40%{ transform: scale(1); opacity:1 } }

/* Starter chips */
.oai-starters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 2px 39px; }
.oai-starter {
	background: #fff;
	border: 1px solid var(--oai-border);
	color: var(--oai-navy);
	padding: 9px 14px;
	border-radius: 22px;
	font-size: 13px; font-weight: 500;
	cursor: pointer;
	transition: all .16s ease;
	font-family: inherit;
	box-shadow: 0 2px 6px -2px rgba(31,25,136,.1);
}
.oai-starter:hover { border-color: var(--oai-blue); background: #f0f6ff; transform: translateY(-1px); box-shadow: 0 6px 14px -6px rgba(4,107,210,.35); }

/* ---------- Input ---------- */
.oai-input {
	display: flex;
	align-items: flex-end;
	gap: 9px;
	padding: 13px 14px;
	background: var(--oai-bg);
	border-top: 1px solid var(--oai-border);
	flex: 0 0 auto;
}
.oai-input textarea {
	flex: 1 1 auto;
	min-width: 0; /* allow the textarea to shrink so the send button never gets pushed off */
	resize: none;
	border: 1px solid var(--oai-border);
	border-radius: 24px;
	padding: 12px 16px;
	font-size: 14.5px;
	font-family: inherit;
	line-height: 1.4;
	max-height: 132px;
	outline: none;
	color: var(--oai-text);
	background: #f4f7fb;
	overflow-y: auto;
	scrollbar-width: none; /* Firefox: no scrollbar arrows */
	transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.oai-input textarea::-webkit-scrollbar { width: 0; height: 0; display: none; } /* kill OS scroll arrows */
.oai-input textarea:focus { border-color: var(--oai-blue); background: #fff; box-shadow: 0 0 0 4px rgba(4,107,210,.1); }
.oai-input textarea:disabled { background: #f1f2f4; cursor: not-allowed; }
.oai-chat .oai-input button {
	flex: 0 0 auto;
	width: 46px !important; height: 46px !important;
	min-width: 46px !important; min-height: 46px !important;
	padding: 0 !important;
	border: none !important;
	border-radius: 50% !important;
	background-color: transparent !important;
	background-image: var(--oai-grad) !important;
	color: #fff !important;
	display: grid; place-items: center;
	cursor: pointer;
	transition: transform .12s ease, box-shadow .15s ease, opacity .15s ease;
	box-shadow: 0 8px 18px -6px rgba(4,107,210,.6);
}
.oai-chat .oai-input button:hover:not(:disabled) { transform: translateY(-1px) scale(1.05); }
.oai-chat .oai-input button:active:not(:disabled) { transform: scale(.92); }
.oai-chat .oai-input button:disabled { background-image: none !important; background-color: #c2cad6 !important; box-shadow: none; cursor: not-allowed; }
.oai-input button svg { width: 20px; height: 20px; }

/* Harden the remaining themed buttons against host-theme overrides */
.oai-chat .oai-starter { background: #fff; color: var(--oai-navy); text-transform: none; }
.oai-chat .oai-starter:hover { background: #f0f6ff; }
.oai-head .oai-close { border: none !important; padding: 0 !important; box-shadow: none !important; }

.oai-foot {
	padding: 0 14px 11px;
	font-size: 11px;
	color: var(--oai-muted);
	text-align: center;
	background: var(--oai-bg);
	flex: 0 0 auto;
}
.oai-foot b { color: var(--oai-navy); font-weight: 600; }

/* Scrollbar */
.oai-messages::-webkit-scrollbar { width: 8px; }
.oai-messages::-webkit-scrollbar-thumb { background: #cdd7e6; border-radius: 8px; }
.oai-messages::-webkit-scrollbar-thumb:hover { background: #b4c1d6; }

/* ============================================================
   Floating launcher (support-bubble mode)
   ============================================================ */
.oai-widget-float {
	position: fixed;
	z-index: 99998;
	bottom: 22px;
	right: 22px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 14px;
	/* The wrapper spans a large (mostly-empty) area — especially on mobile where
	   the closed popup still occupies space. Let clicks pass THROUGH the wrapper
	   so it never blocks the site's own buttons; only the button + open popup are
	   interactive. */
	pointer-events: none;
}
.oai-widget-float .oai-launcher { pointer-events: auto; }
.oai-widget-float.oai-open .oai-popup { pointer-events: auto; }
.oai-widget-float.oai-left { right: auto; left: 22px; align-items: flex-start; }

.oai-launcher {
	width: 62px; height: 62px;
	border: none; border-radius: 50%;
	background: var(--oai-grad, linear-gradient(135deg,#1F1988,#046BD2));
	color: #fff;
	cursor: pointer;
	display: grid; place-items: center;
	box-shadow: 0 14px 30px -8px rgba(4,107,210,.65), 0 4px 12px -4px rgba(31,25,136,.5);
	transition: transform .18s cubic-bezier(.2,.8,.3,1.2), box-shadow .2s ease;
	position: relative;
	order: 2;
}
.oai-widget-float .oai-launcher {
	background-color: transparent !important;
	background-image: var(--oai-grad, linear-gradient(135deg,#1F1988,#046BD2)) !important;
	border: none !important;
	min-width: 0 !important; min-height: 0 !important;
	padding: 0 !important;
	color: #fff !important;
	text-transform: none !important;
	letter-spacing: normal !important;
}
.oai-launcher:hover { transform: scale(1.07); }
.oai-launcher:active { transform: scale(.94); }
/* Stack both icons in the same grid cell so each stays perfectly centered. */
.oai-launcher .oai-ic-chat,
.oai-launcher .oai-ic-close { grid-area: 1 / 1; place-self: center; transition: opacity .18s ease, transform .18s ease; }
.oai-launcher .oai-ic-chat { display: grid; place-items: center; width: 100%; height: 100%; }
.oai-launcher svg { width: 28px; height: 28px; }
.oai-launcher .oai-ic-close { opacity: 0; transform: rotate(-45deg) scale(.6); }

/* ---- Label pill: "Ask Orbit AI / Instant answers" next to the bubble ---- */
.oai-launcher-row {
	display: flex;
	align-items: center;
	order: 2;
	pointer-events: none;
}
.oai-widget-float.oai-left .oai-launcher-row { flex-direction: row-reverse; }

.oai-launcher-pill {
	pointer-events: auto;
	display: flex;
	align-items: center;
	gap: 10px;
	/* The avatar overlaps the pill's trailing edge, so pad that side extra.
	   Themes commonly reset button margins, hence !important here — the same
	   reason the launcher button below needs it. */
	padding: 9px 40px 9px 17px !important;
	margin: 0 -30px 0 0 !important;
	background: #fff !important;
	border: none !important;
	border-radius: 999px;
	box-shadow: 0 12px 28px -10px rgba(16,42,67,.34), 0 2px 8px -2px rgba(16,42,67,.14);
	cursor: pointer;
	font-family: inherit;
	line-height: 1.15;
	text-align: left;
	white-space: nowrap;
	transition: transform .2s cubic-bezier(.2,.8,.3,1.2), box-shadow .2s ease, opacity .2s ease;
}
.oai-widget-float.oai-left .oai-launcher-pill {
	padding: 9px 17px 9px 40px !important;
	margin: 0 0 0 -30px !important;
}
.oai-launcher-pill:hover {
	transform: translateY(-2px);
	box-shadow: 0 18px 34px -10px rgba(16,42,67,.42), 0 3px 10px -2px rgba(16,42,67,.18);
}
.oai-launcher-pill:active { transform: translateY(0) scale(.985); }

.oai-pill-spark { display: grid; place-items: center; flex: 0 0 auto; color: #1F86F0; }
.oai-launcher-pill .oai-pill-spark svg { width: 21px; height: 21px; }

.oai-pill-text { display: flex; flex-direction: column; gap: 2px; }
.oai-pill-title {
	font-size: 15px;
	font-weight: 800;
	color: #1F86F0;
	letter-spacing: .1px;
}
.oai-pill-sub {
	font-size: 12.5px;
	font-weight: 500;
	color: #6b7280;
}

/* The avatar must sit on top of the pill's overlapped edge. */
.oai-widget-float .oai-launcher { z-index: 2; }

/* Hide the pill while the chat is open. */
.oai-widget-float.oai-open .oai-launcher-pill {
	opacity: 0 !important;
	transform: translateX(14px) scale(.94);
	pointer-events: none;
}
.oai-widget-float.oai-open.oai-left .oai-launcher-pill { transform: translateX(-14px) scale(.94); }

/* Launcher showing the technician photo */
.oai-launcher-avatar { overflow: hidden; padding: 0; }
.oai-launcher-avatar .oai-ic-chat img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.oai-launcher-dot { position: absolute; right: 3px; bottom: 3px; width: 13px; height: 13px; border-radius: 50%; background: #4ce38f; border: 2.5px solid #fff; z-index: 2; }
.oai-widget-float.oai-open .oai-launcher-avatar { background: var(--oai-navy); }
.oai-launcher::before {
	content: ""; position: absolute; inset: 0; border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(4,107,210,.45);
	animation: oai-ring 2.4s ease-out infinite;
}
@keyframes oai-ring { 0%{box-shadow:0 0 0 0 rgba(4,107,210,.5)} 70%{box-shadow:0 0 0 16px rgba(4,107,210,0)} 100%{box-shadow:0 0 0 0 rgba(4,107,210,0)} }

/* Attention-grabbing motion so visitors notice the chat is there: gentle breathe + periodic wiggle. */
@keyframes oai-attention {
	0%, 60%, 100% { transform: scale(1); }
	30% { transform: scale(1.07); }
	68% { transform: scale(1.16) rotate(-9deg); }
	78% { transform: scale(1.16) rotate(9deg); }
	88% { transform: scale(1.16) rotate(0deg); }
}
.oai-launcher { animation: oai-attention 3.6s ease-in-out infinite; }
.oai-launcher:hover,
.oai-widget-float.oai-open .oai-launcher { animation: none; }

.oai-popup {
	order: 1;
	width: 400px;
	max-width: calc(100vw - 32px);
	opacity: 0;
	transform: translateY(16px) scale(.96);
	transform-origin: bottom right;
	pointer-events: none;
	transition: opacity .22s ease, transform .22s cubic-bezier(.2,.8,.3,1.1);
}
.oai-widget-float.oai-left .oai-popup { transform-origin: bottom left; }
.oai-popup .oai-chat { margin: 0; height: min(620px, calc(100vh - 130px)); max-height: none; }

.oai-widget-float.oai-open .oai-popup { opacity: 1; transform: none; pointer-events: auto; }
.oai-widget-float.oai-open .oai-launcher::before { animation: none; }
.oai-widget-float.oai-open .oai-launcher .oai-ic-chat { opacity: 0; transform: rotate(45deg) scale(.6); }
.oai-widget-float.oai-open .oai-launcher .oai-ic-close { opacity: 1; transform: rotate(0) scale(1); }

.oai-popup .oai-close { display: grid; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
	.oai-chat { border-radius: 16px; }
	.oai-col { max-width: 84%; }
	.oai-widget-float { bottom: 16px; right: 16px; }
	.oai-widget-float.oai-left { left: 16px; }
	.oai-popup { width: calc(100vw - 24px); }
	.oai-popup .oai-chat { height: min(78vh, calc(100vh - 110px)); }
	.oai-launcher { width: 56px; height: 56px; }
	.oai-launcher-pill { padding: 8px 36px 8px 14px !important; margin: 0 -28px 0 0 !important; }
	.oai-widget-float.oai-left .oai-launcher-pill { padding: 8px 14px 8px 36px !important; margin: 0 0 0 -28px !important; }
	.oai-launcher-pill .oai-pill-spark svg { width: 18px; height: 18px; }
	.oai-pill-title { font-size: 13.5px; }
	.oai-pill-sub { font-size: 11.5px; }
}
/* Very narrow screens: keep only the bubble so nothing overflows. */
@media (max-width: 380px) {
	.oai-launcher-pill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.oai-msg, .oai-launcher, .oai-launcher::before, .oai-dot { animation: none !important; }
	.oai-popup { transition: opacity .15s ease; }
}
