/**
 * IARA Chat Widget styles.
 * Scoped under #iara-chat-root to avoid theme/Elementor collisions.
 */

#iara-chat-root,
#iara-chat-root * {
	box-sizing: border-box;
}

#iara-chat-root {
	--iara-teal: #00838F;
	--iara-teal-dark: #006b75;
	--iara-navy: #1B2D3A;
	--iara-bg: #F5F7FA;
	--iara-border: #E2E8F0;
	font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Floating launcher button ──
   Background/border/colour are forced with !important and #iara-chat-root
   specificity so a host theme or Elementor button style cannot strip the fill
   and leave a transparent launcher that vanishes over a white page section. */
#iara-chat-root .iara-chat-launcher {
	position: fixed;
	bottom: 28px;
	right: 24px;
	z-index: 9999;
	border: none !important;
	border-radius: 50px;
	background: var(--iara-teal) !important;
	background-color: var(--iara-teal) !important;
	background-image: none !important;
	color: #fff !important;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	box-shadow: 0 6px 20px rgba(0, 131, 143, 0.45), 0 2px 6px rgba(0,0,0,0.12);
	transition: transform 0.22s cubic-bezier(.34,1.56,.64,1),
	            background 0.18s ease,
	            opacity 0.22s ease,
	            width 0.3s cubic-bezier(.34,1.56,.64,1),
	            padding 0.3s ease,
	            border-radius 0.3s ease;
	padding: 0 22px 0 16px;
	height: 52px;
	white-space: nowrap;
	overflow: hidden;
}

/* Pill text label */
.iara-chat-launcher .iara-launcher-label {
	font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.25;
	color: #fff !important;
	transition: opacity 0.2s ease, max-width 0.3s ease;
	max-width: 190px;
	opacity: 1;
	overflow: hidden;
}

.iara-chat-launcher .iara-launcher-label-text {
	display: block;
	white-space: nowrap;
	animation: iara-label-fade 0.35s ease;
}

@keyframes iara-label-fade {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: translateY(0); }
}

#iara-chat-root .iara-chat-launcher svg {
	width: 24px;
	height: 24px;
	fill: #fff !important;
	flex-shrink: 0;
	transition: transform 0.22s ease;
}

/* Hover: slight lift + brighter shadow */
#iara-chat-root .iara-chat-launcher:hover {
	background: var(--iara-teal-dark) !important;
	background-color: var(--iara-teal-dark) !important;
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 10px 28px rgba(0, 131, 143, 0.5), 0 3px 8px rgba(0,0,0,0.14);
}

.iara-chat-launcher:active {
	transform: translateY(0) scale(0.97);
}

.iara-chat-launcher:focus-visible {
	outline: 3px solid rgba(0, 131, 143, 0.45);
	outline-offset: 3px;
}

/* When chat is open → collapse to circle */
.iara-chat-launcher.is-collapsed {
	width: 52px;
	height: 52px;
	padding: 0;
	border-radius: 50%;
}

.iara-chat-launcher.is-collapsed .iara-launcher-label {
	max-width: 0;
	opacity: 0;
	padding: 0;
	overflow: hidden;
}

.iara-chat-launcher.is-collapsed svg {
	transform: rotate(90deg);
}

/* Attention pulse — runs once 3 s after page load, stops on first click */
@keyframes iara-pulse-ring {
	0%   { box-shadow: 0 6px 20px rgba(0,131,143,0.45), 0 0 0 0   rgba(0,131,143,0.55); }
	60%  { box-shadow: 0 6px 20px rgba(0,131,143,0.45), 0 0 0 12px rgba(0,131,143,0); }
	100% { box-shadow: 0 6px 20px rgba(0,131,143,0.45), 0 0 0 0   rgba(0,131,143,0); }
}

.iara-chat-launcher.iara-pulse {
	animation: iara-pulse-ring 1.4s ease-out 2;
}

/* ── Chat window ── */
.iara-chat-window {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 9999;
	width: 380px;
	height: 520px;
	max-height: calc(100vh - 48px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.iara-chat-window.is-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* ── Header ── */
.iara-chat-header {
	background: var(--iara-navy);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.iara-chat-title {
	font-size: 15px;
	font-weight: 600;
	margin: 0;
	line-height: 1.2;
}

.iara-chat-close {
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	width: 32px;
	height: 32px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

.iara-chat-close:hover {
	background: rgba(255, 255, 255, 0.12);
}

.iara-chat-close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.6);
}

.iara-chat-close svg {
	width: 18px;
	height: 18px;
	fill: #fff;
}

/* ── Messages ── */
.iara-chat-messages {
	flex: 1;
	overflow-y: auto;
	background: var(--iara-bg);
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.iara-msg {
	max-width: 82%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.45;
	word-wrap: break-word;
}

.iara-msg-bot {
	background: #fff;
	border: 1px solid var(--iara-border);
	color: var(--iara-navy);
	border-bottom-left-radius: 4px;
}

/* Row wrapping a bot bubble + its logo avatar */
.iara-msg-row-bot {
	align-self: flex-start;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 100%;
}

.iara-msg-row-bot .iara-msg-bot {
	max-width: 100%;
}

.iara-msg-avatar {
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	object-fit: cover;
	background: #fff;
	border: 1px solid var(--iara-border);
}

.iara-msg-user {
	align-self: flex-end;
	background: var(--iara-teal);
	color: #fff;
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}

/* ── Bot message rich formatting ── */
.iara-msg-bot p {
	margin: 0 0 8px;
	line-height: 1.55;
}

.iara-msg-bot p:last-child {
	margin-bottom: 0;
}

.iara-msg-bot ul {
	margin: 4px 0 8px;
	padding-left: 18px;
	list-style: disc;
}

.iara-msg-bot ul:last-child {
	margin-bottom: 0;
}

.iara-msg-bot li {
	margin-bottom: 4px;
	line-height: 1.5;
}

.iara-msg-bot li:last-child {
	margin-bottom: 0;
}

.iara-msg-bot strong {
	font-weight: 700;
	color: var(--iara-navy);
}

.iara-msg-bot em {
	font-style: italic;
}

.iara-msg-bot code {
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 12px;
	background: #eef2f7;
	border-radius: 4px;
	padding: 1px 5px;
}

/* Links inside bot replies. Forced with !important and root specificity so a
   host theme cannot strip the colour/underline and make them read as plain
   text — links must always look clickable. */
#iara-chat-root .iara-msg-bot a {
	color: var(--iara-teal) !important;
	text-decoration: underline !important;
	text-underline-offset: 2px;
	word-break: break-word;
	font-weight: 600;
}

#iara-chat-root .iara-msg-bot a:hover {
	color: var(--iara-teal-dark) !important;
	text-decoration: underline !important;
}

/* ── Typing indicator ── */
.iara-typing {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--iara-border);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	padding: 12px 14px;
	display: inline-flex;
	gap: 4px;
}

.iara-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9aa7b4;
	animation: iara-bounce 1.2s infinite ease-in-out;
}

.iara-typing span:nth-child(2) { animation-delay: 0.18s; }
.iara-typing span:nth-child(3) { animation-delay: 0.36s; }

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

/* ── Input ── */
.iara-chat-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--iara-border);
	background: #fff;
	flex-shrink: 0;
}

.iara-chat-input textarea {
	flex: 1;
	resize: none;
	border: 1px solid var(--iara-border);
	border-radius: 10px;
	padding: 9px 12px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	max-height: 96px;
	color: var(--iara-navy);
	outline: none;
	transition: border-color 0.15s ease;
}

.iara-chat-input textarea:focus {
	border-color: var(--iara-teal);
}

/* The send button background and icon colour are forced with !important so a
   host theme / Elementor cannot override them and leave the arrow invisible
   (it used to appear white-on-white until hover). */
#iara-chat-root .iara-chat-send {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 10px;
	background: var(--iara-teal) !important;
	color: #fff !important;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

#iara-chat-root .iara-chat-send:hover:not(:disabled) {
	background: var(--iara-teal-dark) !important;
}

#iara-chat-root .iara-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

#iara-chat-root .iara-chat-send:focus-visible {
	outline: 2px solid rgba(0, 131, 143, 0.4);
	outline-offset: 1px;
}

#iara-chat-root .iara-chat-send svg {
	width: 18px;
	height: 18px;
	fill: #fff !important;
}

#iara-chat-root .iara-chat-send svg path {
	fill: #fff !important;
}

/* ── Mobile ── */
@media (max-width: 480px) {
	.iara-chat-window {
		width: 100%;
		height: 85vh;
		max-height: 85vh;
		bottom: 0;
		right: 0;
		border-radius: 12px 12px 0 0;
	}

	.iara-chat-launcher {
		bottom: 16px;
		right: 16px;
		height: 48px;
		padding: 0 18px 0 13px;
		font-size: 14px;
	}

	.iara-chat-launcher.is-collapsed {
		width: 48px;
		height: 48px;
		padding: 0;
	}
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
	.iara-chat-window,
	.iara-chat-launcher,
	.iara-typing span {
		transition: none;
		animation: none;
	}
}
