/*
 * UInvest AI Assistant — widget styles.
 *
 * Palette is driven by the four variables below; they are set to match the
 * site's existing monochrome buttons and Roboto body font. Change --uia-accent
 * alone to re-skin the whole widget.
 */

.uia-root {
	--uia-accent: #000;
	--uia-accent-hover: #222;
	--uia-panel: #0e0e0e;
	--uia-panel-soft: #1b1b1b;
	--uia-text: #f4f4f4;
	--uia-text-dim: rgba(244, 244, 244, 0.6);
	--uia-radius: 16px;
	--uia-font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

	font-family: var(--uia-font);
	position: fixed;
	inset-inline-end: 24px;
	inset-block-end: 24px;
	z-index: 99998; /* under WP admin bar, over page content */
}

.uia-root *,
.uia-root *::before,
.uia-root *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------- launcher */

.uia-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px 12px 14px;
	border: 0;
	border-radius: 999px;
	background: var(--uia-accent);
	color: #fff;
	font: 500 14px/1 var(--uia-font);
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
	transition: background 0.18s ease, transform 0.18s ease;
}

.uia-launcher:hover {
	background: var(--uia-accent-hover);
	transform: translateY(-1px);
}

.uia-launcher[hidden] {
	display: none;
}

/* The "avatar": a slowly rotating ring, standing in for a face. */
.uia-orb {
	position: relative;
	width: 20px;
	height: 20px;
	flex: 0 0 20px;
}

.uia-orb span {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 1.5px solid currentColor;
	opacity: 0.9;
}

.uia-orb span:nth-child(2) {
	inset: 4px;
	opacity: 0.5;
	animation: uia-spin 3.4s linear infinite;
	border-style: dashed;
}

@keyframes uia-spin {
	to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
	.uia-orb span:nth-child(2) { animation: none; }
}

/* ---------------------------------------------------------------- panel */

.uia-panel {
	width: min(380px, calc(100vw - 32px));
	height: min(620px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: var(--uia-radius);
	background: var(--uia-panel);
	color: var(--uia-text);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

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

.uia-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.uia-tabs {
	display: flex;
	gap: 18px;
}

.uia-tab {
	position: relative;
	padding: 0 0 4px;
	border: 0;
	background: none;
	color: var(--uia-text-dim);
	font: 500 13px/1.4 var(--uia-font);
	cursor: pointer;
}

.uia-tab[aria-selected="true"] {
	color: var(--uia-text);
}

.uia-tab[aria-selected="true"]::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	height: 2px;
	background: currentColor;
}

.uia-close {
	width: 28px;
	height: 28px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: var(--uia-text);
	cursor: pointer;
}

.uia-close:hover {
	background: rgba(255, 255, 255, 0.16);
}

/* --------------------------------------------------------------- thread */

.uia-body {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.uia-thread {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scrollbar-width: thin;
}

.uia-msg {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.uia-msg.is-bot {
	align-self: flex-start;
	background: var(--uia-panel-soft);
	border-bottom-left-radius: 4px;
}

.uia-msg.is-user {
	align-self: flex-end;
	background: #fff;
	color: #111;
	border-bottom-right-radius: 4px;
}

.uia-msg.is-error {
	align-self: stretch;
	max-width: 100%;
	background: rgba(220, 80, 80, 0.14);
	color: #ffd9d9;
	font-size: 13px;
}

/* Typing indicator */
.uia-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 12px 14px;
	border-radius: 14px;
	background: var(--uia-panel-soft);
}

.uia-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--uia-text-dim);
	animation: uia-bounce 1.2s ease-in-out infinite;
}

.uia-typing i:nth-child(2) { animation-delay: 0.15s; }
.uia-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes uia-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.uia-typing i { animation: none; }
}

/* Starter chips */
.uia-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 18px 12px;
}

.uia-chip {
	padding: 7px 13px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 999px;
	background: none;
	color: var(--uia-text);
	font: 400 12.5px/1.3 var(--uia-font);
	cursor: pointer;
	transition: background 0.15s ease;
}

.uia-chip:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* Composer */
.uia-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.uia-composer textarea {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	resize: none;
	padding: 10px 12px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.05);
	color: var(--uia-text);
	font: 400 14px/1.4 var(--uia-font);
}

.uia-composer textarea::placeholder {
	color: var(--uia-text-dim);
}

.uia-composer textarea:focus,
.uia-form input:focus,
.uia-form textarea:focus {
	outline: 2px solid rgba(255, 255, 255, 0.35);
	outline-offset: 1px;
}

.uia-send {
	height: 40px;
	padding: 0 16px;
	border: 0;
	border-radius: 12px;
	background: #fff;
	color: #111;
	font: 500 13px/1 var(--uia-font);
	cursor: pointer;
}

.uia-send:disabled {
	opacity: 0.45;
	cursor: default;
}

.uia-notice {
	padding: 0 18px 12px;
	font-size: 11px;
	line-height: 1.4;
	color: var(--uia-text-dim);
}

/* ----------------------------------------------------------------- form */

.uia-form {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 18px;
}

.uia-form input,
.uia-form textarea {
	width: 100%;
	padding: 11px 13px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.05);
	color: var(--uia-text);
	font: 400 14px/1.4 var(--uia-font);
}

.uia-form textarea {
	min-height: 96px;
	resize: vertical;
}

.uia-form button[type="submit"] {
	margin-top: 4px;
	padding: 12px;
	border: 0;
	border-radius: 12px;
	background: #fff;
	color: #111;
	font: 500 14px/1 var(--uia-font);
	cursor: pointer;
}

.uia-form button[type="submit"]:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Honeypot — off-screen rather than display:none, which some bots skip. */
.uia-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.uia-done {
	flex: 1;
	display: grid;
	place-content: center;
	gap: 10px;
	justify-items: center;
	padding: 24px;
	text-align: center;
	font-size: 14.5px;
}

/* ----------------------------------------------------------------- misc */

.uia-root[dir="rtl"] .uia-msg.is-bot { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.uia-root[dir="rtl"] .uia-msg.is-user { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }

@media (max-width: 480px) {
	.uia-root {
		inset-inline-end: 12px;
		inset-block-end: 12px;
	}
	.uia-panel {
		height: min(560px, calc(100vh - 90px));
	}
}
