/*
 * Velora AI assistant — floating chat widget.
 * Uses the palette tokens from front.css (.velora-site scope).
 */

.velora-ico--sparkle { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.94 15.5a2 2 0 0 0-1.44-1.44l-6.13-1.58a.5.5 0 0 1 0-.96L8.5 9.94A2 2 0 0 0 9.94 8.5l1.58-6.13a.5.5 0 0 1 .96 0l1.58 6.13a2 2 0 0 0 1.44 1.44l6.13 1.58a.5.5 0 0 1 0 .96l-6.13 1.58a2 2 0 0 0-1.44 1.44l-1.58 6.13a.5.5 0 0 1-.96 0z'/%3E%3Cpath d='M20 3v4M22 5h-4'/%3E%3C/svg%3E"); }
.velora-ico--send { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.71 3.05a.5.5 0 0 0-.68.63l2.84 7.62a2 2 0 0 1 0 1.4l-2.84 7.62a.5.5 0 0 0 .68.63l18-8.5a.5.5 0 0 0 0-.9z'/%3E%3Cpath d='M6 12h16'/%3E%3C/svg%3E"); }
.velora-ico--close { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); }
.velora-ico--refresh { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E"); }

/* Launcher ---------------------------------------------------------------- */

.velora-chat {
	--chat-edge: 1.25rem;
	font-family: var(--sans);
	font-size: 1rem;
	line-height: 1.55;
}

.velora-chat__launcher {
	position: fixed;
	right: var(--chat-edge);
	bottom: var(--chat-edge);
	z-index: 60;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.45rem 1.25rem 0.45rem 0.45rem;
	border: 0;
	border-radius: 999px;
	background: var(--navy);
	color: var(--white);
	font: inherit;
	text-align: left;
	box-shadow: var(--shadow-lg);
	cursor: pointer;
	transition: transform 0.35s var(--ease-soft, ease), background-color 0.2s ease, bottom 0.45s var(--ease-soft, ease);
}

.velora-chat__launcher:hover {
	background: var(--navy-2);
	transform: translateY(-2px);
}

.velora-chat__launcher-icon {
	position: relative;
	display: grid;
	place-items: center;
	width: 2.9rem;
	height: 2.9rem;
	border-radius: 50%;
	background: var(--sage);
	color: var(--navy-deep);
}

.velora-chat__launcher-icon .velora-ico {
	width: 1.4rem;
	height: 1.4rem;
}

/* Soft "online" ring. */
.velora-chat__launcher-icon::after {
	content: "";
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid var(--sage);
	opacity: 0;
	animation: velora-chat-ping 3.2s var(--ease-soft, ease) 2s infinite;
}

.velora-chat__launcher-text {
	display: grid;
	line-height: 1.2;
}

.velora-chat__launcher-text strong {
	font-size: 1rem;
	font-weight: 700;
}

.velora-chat__launcher-text small {
	font-size: 0.8rem;
	color: rgba(255, 255, 255, 0.78);
}

.velora-chat__ai-tag {
	display: inline-block;
	padding: 0.05rem 0.45rem;
	border-radius: 999px;
	background: var(--sage);
	color: var(--navy-deep);
	font-family: var(--sans);
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	vertical-align: 0.15em;
}

.velora-chat.is-open .velora-chat__launcher {
	transform: scale(0.9);
	opacity: 0;
	pointer-events: none;
}

/* On computers the launcher rests as a round button and slides its label
   out on hover or keyboard focus (phones keep the icon-only button below). */
@media (hover: hover) and (min-width: 761px) {
	.velora-chat__launcher {
		gap: 0;
		padding: 0.45rem;
	}

	.velora-chat__launcher-text {
		max-width: 0;
		opacity: 0;
		overflow: hidden;
		white-space: nowrap;
		transition: max-width 0.4s var(--ease-soft, ease), opacity 0.25s ease, margin 0.4s var(--ease-soft, ease);
	}

	.velora-chat__launcher:hover .velora-chat__launcher-text,
	.velora-chat__launcher:focus-visible .velora-chat__launcher-text {
		max-width: 16rem;
		margin: 0 0.85rem 0 0.75rem;
		opacity: 1;
	}
}

@media (hover: hover) and (min-width: 761px) and (prefers-reduced-motion: reduce) {
	.velora-chat__launcher-text {
		transition: none;
	}
}

/* Keep back-to-top clear of the launcher. */
.velora-has-assistant .velora-totop {
	bottom: 5.4rem;
}

/* Panel ------------------------------------------------------------------- */

.velora-chat__panel {
	position: fixed;
	right: var(--chat-edge);
	bottom: var(--chat-edge);
	z-index: 70;
	display: flex;
	flex-direction: column;
	width: min(410px, calc(100vw - 2 * var(--chat-edge)));
	height: min(640px, calc(100vh - 2 * var(--chat-edge)));
	height: min(640px, calc(100dvh - 2 * var(--chat-edge)));
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	background: var(--paper);
	box-shadow: var(--shadow-lg);
	animation: velora-chat-in 0.4s var(--ease-soft, ease);
}

.velora-chat__panel[hidden] {
	display: none;
}

.velora-chat__head {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.9rem 0.8rem 0.9rem 1rem;
	background: var(--navy);
	color: var(--white);
}

.velora-chat__avatar {
	display: grid;
	flex-shrink: 0;
	place-items: center;
	width: 2.6rem;
	height: 2.6rem;
	border-radius: 50%;
	background: linear-gradient(140deg, var(--sage-bright), var(--sage));
	color: var(--navy-deep);
}

.velora-chat__who {
	flex: 1;
	min-width: 0;
}

.velora-chat__who h2 {
	margin: 0;
	color: var(--white);
	font-family: var(--serif);
	font-size: 1.15rem;
	line-height: 1.2;
}

.velora-chat__who p {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0.15rem 0 0;
	font-size: 0.78rem;
	color: rgba(255, 255, 255, 0.75);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.velora-chat__dot {
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--sage-bright);
	box-shadow: 0 0 0 3px rgba(202, 215, 160, 0.25);
}

.velora-chat__icon-btn {
	display: grid;
	place-items: center;
	width: 2.4rem;
	height: 2.4rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--white);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.velora-chat__icon-btn:hover {
	background: rgba(255, 255, 255, 0.12);
}

.velora-chat__icon-btn .velora-ico {
	width: 1.15rem;
	height: 1.15rem;
}

/* Messages ---------------------------------------------------------------- */

.velora-chat__log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 1.1rem 1rem 0.5rem;
	scroll-behavior: smooth;
}

.velora-chat__msg {
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	margin-bottom: 0.85rem;
	animation: velora-chat-msg 0.3s var(--ease-soft, ease);
}

.velora-chat__msg--user {
	justify-content: flex-end;
}

.velora-chat__mini-avatar {
	display: grid;
	flex-shrink: 0;
	place-items: center;
	width: 1.9rem;
	height: 1.9rem;
	border-radius: 50%;
	background: var(--sage-tint);
	color: var(--moss-deep);
}

.velora-chat__mini-avatar .velora-ico {
	width: 1rem;
	height: 1rem;
}

.velora-chat__bubble {
	max-width: 85%;
	padding: 0.7rem 0.95rem;
	border-radius: 18px;
	font-size: 0.97rem;
	overflow-wrap: anywhere;
}

.velora-chat__msg--assistant .velora-chat__bubble {
	border: 1px solid var(--line);
	border-bottom-left-radius: 6px;
	background: var(--white);
	color: var(--ink);
}

.velora-chat__msg--user .velora-chat__bubble {
	border-bottom-right-radius: 6px;
	background: var(--navy);
	color: var(--white);
}

.velora-chat__msg--ok .velora-chat__bubble {
	border-color: var(--sage);
	background: var(--sage-tint);
}

.velora-chat__msg--error .velora-chat__bubble {
	border-color: #e6c3b9;
	background: #fbf0ec;
}

.velora-chat__label {
	display: block;
	margin-bottom: 0.2rem;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--moss);
}

.velora-chat__bubble p,
.velora-chat__bubble ul {
	margin: 0 0 0.5rem;
}

.velora-chat__bubble > :last-child {
	margin-bottom: 0;
}

.velora-chat__bubble ul {
	padding-left: 1.15rem;
}

.velora-chat__bubble li {
	margin-bottom: 0.2rem;
}

.velora-chat__bubble a {
	color: var(--moss-deep);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.velora-chat__msg--user .velora-chat__bubble a {
	color: var(--sage-bright);
}

.velora-chat__dots {
	display: inline-flex;
	gap: 0.25rem;
	padding: 0.35rem 0.1rem;
}

.velora-chat__dots i {
	width: 0.45rem;
	height: 0.45rem;
	border-radius: 50%;
	background: var(--moss);
	opacity: 0.35;
	animation: velora-chat-dot 1.2s ease-in-out infinite;
}

.velora-chat__dots i:nth-child(2) {
	animation-delay: 0.15s;
}

.velora-chat__dots i:nth-child(3) {
	animation-delay: 0.3s;
}

/* Suggestion chips -------------------------------------------------------- */

.velora-chat__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	padding: 0 1rem 0.75rem;
}

.velora-chat__chips[hidden] {
	display: none;
}

.velora-chat__chip {
	padding: 0.45rem 0.85rem;
	border: 1px solid var(--sage);
	border-radius: 999px;
	background: var(--white);
	color: var(--navy);
	font: inherit;
	font-size: 0.86rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

.velora-chat__chip:hover {
	border-color: var(--moss);
	background: var(--sage-tint);
}

.velora-chat__chip:focus-visible {
	outline: 2px solid var(--navy);
	outline-offset: 2px;
}

/* Follow-up ideas after an answer: lighter, so the answer stays the focus. */
.velora-chat__chips.is-followups {
	padding-left: 3.1rem;
	animation: velora-chips-in 0.35s ease both;
}

.velora-chat__chips.is-followups .velora-chat__chip {
	border-style: dashed;
	font-weight: 500;
	text-align: left;
}

.velora-chat__chips.is-followups .velora-chat__chip::before {
	content: "↳ ";
	color: var(--moss);
}

/* One swipeable row, so follow-ups never push the answer out of view. */
.velora-chat__chips.is-followups {
	flex-wrap: nowrap;
	overflow-x: auto;
	padding-left: 1rem;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.velora-chat__chips.is-followups::-webkit-scrollbar {
	display: none;
}

.velora-chat__chips.is-followups .velora-chat__chip {
	flex: 0 0 auto;
	white-space: nowrap;
}

@keyframes velora-chips-in {
	from { opacity: 0; transform: translateY(4px); }
	to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.velora-chat__chips.is-followups { animation: none; }
}

/* Composer ---------------------------------------------------------------- */

.velora-chat__composer {
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	margin: 0 0.75rem;
	padding: 0.4rem 0.4rem 0.4rem 0.9rem;
	border: 1px solid var(--line);
	border-radius: 22px;
	background: var(--white);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.velora-chat__composer:focus-within {
	border-color: var(--moss);
	box-shadow: 0 0 0 4px rgba(176, 189, 135, 0.3);
}

.velora-chat__composer textarea {
	flex: 1;
	box-sizing: border-box;
	height: 2.4rem;
	min-height: 0;
	max-height: 140px;
	padding: 0.5rem 0;
	border: 0;
	outline: none;
	resize: none;
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-size: 1rem;
	line-height: 1.4;
}

.velora-site .velora-chat__composer textarea:focus-visible {
	outline: none;
}

.velora-chat__send {
	display: grid;
	flex-shrink: 0;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--moss);
	color: var(--white);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.velora-chat__send:hover {
	background: var(--moss-deep);
}

.velora-chat__send:disabled {
	opacity: 0.5;
	cursor: wait;
}

.velora-chat__send .velora-ico {
	width: 1.15rem;
	height: 1.15rem;
}

.velora-chat__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.3rem 0.75rem;
	padding: 0.6rem 1rem 0.75rem;
	font-size: 0.74rem;
	color: var(--muted);
}

.velora-chat__human {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.2rem 0;
	border: 0;
	background: none;
	color: var(--moss-deep);
	font: inherit;
	font-size: 0.82rem;
	font-weight: 700;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* Hand-off form ----------------------------------------------------------- */

.velora-chat__handoff {
	display: grid;
	gap: 0.3rem;
	margin: 0 0 0.9rem 2.4rem;
	padding: 0.95rem;
	border: 1px solid var(--sage);
	border-radius: 16px;
	background: var(--sage-tint);
	animation: velora-chat-msg 0.3s var(--ease-soft, ease);
}

.velora-chat__handoff-title {
	display: flex;
	gap: 0.45rem;
	margin: 0 0 0.35rem;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--navy);
}

.velora-chat__handoff-title .velora-ico {
	margin-top: 0.15rem;
	color: var(--moss);
}

.velora-chat__handoff label {
	margin-top: 0.25rem;
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--navy);
}

.velora-chat__handoff input,
.velora-chat__handoff textarea {
	width: 100%;
	box-sizing: border-box;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--white);
	color: var(--ink);
	font: inherit;
	font-size: 0.95rem;
}

.velora-chat__handoff input:focus,
.velora-chat__handoff textarea:focus {
	outline: none;
	border-color: var(--moss);
	box-shadow: 0 0 0 3px rgba(176, 189, 135, 0.35);
}

.velora-chat__handoff-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
}

.velora-chat__handoff-row span {
	display: grid;
	gap: 0.3rem;
}

.velora-chat__hint {
	font-size: 0.74rem;
	color: var(--muted);
}

.velora-chat__hp {
	position: absolute;
	left: -9999px;
}

.velora-chat__handoff-status {
	margin: 0.3rem 0 0;
	font-size: 0.85rem;
	font-weight: 600;
	color: #8a3a2a;
}

.velora-chat__handoff-actions {
	display: flex;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

.velora-chat__primary,
.velora-chat__ghost {
	padding: 0.6rem 1rem;
	border-radius: 999px;
	font: inherit;
	font-size: 0.9rem;
	font-weight: 700;
	cursor: pointer;
}

.velora-chat__primary {
	flex: 1;
	border: 0;
	background: var(--navy);
	color: var(--white);
}

.velora-chat__primary:hover {
	background: var(--navy-2);
}

.velora-chat__primary:disabled {
	opacity: 0.6;
	cursor: wait;
}

.velora-chat__ghost {
	border: 1px solid var(--line);
	background: var(--white);
	color: var(--navy);
}

/* Motion ------------------------------------------------------------------ */

@keyframes velora-chat-in {
	from {
		opacity: 0;
		transform: translateY(16px) scale(0.98);
	}
}

@keyframes velora-chat-msg {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}

@keyframes velora-chat-dot {
	0%, 80%, 100% {
		opacity: 0.35;
		transform: none;
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

@keyframes velora-chat-ping {
	0% {
		opacity: 0.7;
		transform: scale(1);
	}
	60%, 100% {
		opacity: 0;
		transform: scale(1.35);
	}
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 760px) {
	.velora-chat {
		--chat-edge: 1rem;
	}

	.velora-chat__launcher {
		padding: 0.35rem;
	}

	.velora-chat__launcher-text {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	/* Sit above the sticky call bar once it slides in. */
	.velora-has-assistant:has(.velora-callbar.is-visible) .velora-chat__launcher {
		bottom: 5.6rem;
	}

	.velora-has-assistant .velora-totop {
		bottom: 5.6rem;
		right: 5rem;
	}

	.velora-chat__panel {
		inset: 0;
		width: 100%;
		height: 100%;
		border: 0;
		border-radius: 0;
		padding-bottom: env(safe-area-inset-bottom);
	}

	html.velora-chat-open,
	html.velora-chat-open body {
		overflow: hidden;
	}
}

@media (prefers-reduced-motion: reduce) {
	.velora-chat__launcher-icon::after {
		display: none;
	}
}

@media print {
	.velora-chat {
		display: none !important;
	}
}
