/* Assistente AI — floating chat widget. Uses the theme brand tokens with fallbacks. */
#nn-chat-root {
	--c-emerald: var(--nn-emerald, #c2185b);
	--c-emerald-dark: var(--nn-emerald-dark, #9a0e50);
	--c-emerald-soft: var(--nn-emerald-soft, #fce4ec);
	--c-ink: var(--nn-ink, #111827);
	--c-muted: var(--nn-muted, #6b7280);
	--c-border: var(--nn-border, #e5e7eb);
	--c-soft: var(--nn-soft, #f8fafc);
	--c-shadow: var(--nn-shadow-lg, 0 24px 60px rgba(15, 23, 42, .16));
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 1100;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Launcher */
.nn-chat-launcher {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	width: 3.6rem;
	height: 3.6rem;
	border: 0;
	border-radius: 999px;
	background: var(--c-emerald);
	color: #fff;
	box-shadow: var(--c-shadow);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .18s ease, background .18s ease;
	z-index: 1101;
}
.nn-chat-launcher::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 999px;
	box-shadow: 0 0 0 0 rgba(194,24,91, .45);
	animation: nn-chat-pulse 2.4s infinite;
}
.nn-chat-launcher:hover { background: var(--c-emerald-dark); transform: translateY(-2px); }
@keyframes nn-chat-pulse {
	0% { box-shadow: 0 0 0 0 rgba(194,24,91, .45); }
	70% { box-shadow: 0 0 0 14px rgba(194,24,91, 0); }
	100% { box-shadow: 0 0 0 0 rgba(194,24,91, 0); }
}
#nn-chat-root.nn-chat-open .nn-chat-launcher { transform: scale(.92); opacity: .9; }

/* Panel */
.nn-chat-panel {
	position: fixed;
	right: 1.25rem;
	bottom: 5.4rem;
	width: min(100vw - 2rem, 396px);
	height: min(78vh, 620px);
	max-height: calc(100vh - 7rem);
	background: #fff;
	border: 1px solid var(--c-border);
	border-radius: 1.25rem;
	box-shadow: var(--c-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	transform: translateY(14px) scale(.98);
	opacity: 0;
	transition: transform .2s ease, opacity .2s ease;
}
#nn-chat-root.nn-chat-open .nn-chat-panel {
	display: flex;
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* Header */
.nn-chat-head {
	display: flex;
	align-items: center;
	gap: .65rem;
	padding: .8rem .9rem;
	background: linear-gradient(135deg, var(--c-emerald), var(--c-emerald-dark));
	color: #fff;
}
.nn-chat-avatar {
	width: 2.3rem; height: 2.3rem;
	border-radius: 999px;
	background: rgba(255, 255, 255, .18);
	display: flex; align-items: center; justify-content: center;
	flex: 0 0 auto;
}
.nn-chat-head__txt { flex: 1 1 auto; min-width: 0; }
.nn-chat-head__title { font-weight: 800; font-size: .98rem; line-height: 1.1; }
.nn-chat-head__sub { font-size: .74rem; opacity: .9; }
.nn-chat-head__actions { display: flex; gap: .1rem; }
.nn-chat-iconbtn {
	background: transparent; border: 0; color: #fff; cursor: pointer;
	width: 1.9rem; height: 1.9rem; border-radius: 8px; opacity: .9;
	display: flex; align-items: center; justify-content: center;
}
.nn-chat-iconbtn:hover { background: rgba(255, 255, 255, .16); opacity: 1; }

/* Body */
.nn-chat-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: .9rem;
	background: var(--c-soft);
	display: flex;
	flex-direction: column;
	gap: .55rem;
}
.nn-chat-msg { display: flex; }
.nn-chat-msg--user { justify-content: flex-end; }
.nn-chat-msg--bot, .nn-chat-msg--studio { justify-content: flex-start; }
.nn-chat-msg--system { justify-content: center; }
.nn-chat-bubble {
	max-width: 84%;
	padding: .6rem .75rem;
	border-radius: 1rem;
	font-size: .9rem;
	line-height: 1.45;
	color: var(--c-ink);
	background: #fff;
	border: 1px solid var(--c-border);
	box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.nn-chat-msg--user .nn-chat-bubble {
	background: var(--c-emerald);
	border-color: var(--c-emerald);
	color: #fff;
	border-bottom-right-radius: .35rem;
}
.nn-chat-msg--bot .nn-chat-bubble { border-bottom-left-radius: .35rem; }
.nn-chat-msg--studio .nn-chat-bubble { background: var(--c-emerald-soft); border-color: var(--c-emerald-soft); }
.nn-chat-msg--system .nn-chat-bubble {
	background: transparent; border: 0; box-shadow: none;
	color: var(--c-muted); font-size: .78rem; text-align: center; font-style: italic;
}
.nn-chat-bubble a { color: var(--c-emerald-dark); font-weight: 600; }
.nn-chat-msg--user .nn-chat-bubble a { color: #fff; text-decoration: underline; }

/* Typing */
.nn-chat-typing { display: inline-flex; gap: 4px; align-items: center; }
.nn-chat-typing span {
	width: 7px; height: 7px; border-radius: 999px; background: var(--c-muted);
	opacity: .5; animation: nn-chat-blink 1.2s infinite both;
}
.nn-chat-typing span:nth-child(2) { animation-delay: .2s; }
.nn-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes nn-chat-blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* CTAs */
.nn-chat-ctas { display: flex; flex-wrap: wrap; gap: .4rem; margin: .15rem 0 .25rem; align-self: flex-start; }
.nn-chat-cta {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	border: 0;
	background: var(--c-emerald);
	color: #fff;
	font-weight: 700;
	font-size: .82rem;
	line-height: 1.1;
	padding: .55rem .95rem;
	border-radius: .7rem;
	cursor: pointer;
	font-family: inherit;
	box-shadow: 0 2px 8px rgba(194,24,91, .25);
	transition: background .15s ease, transform .12s ease;
}
.nn-chat-cta:hover { background: var(--c-emerald-dark); transform: translateY(-1px); }
.nn-chat-cta:active { transform: translateY(0); }

/* Register card */
.nn-chat-reg {
	background: #fff;
	border: 1px solid var(--c-border);
	border-radius: 1rem;
	padding: .85rem;
	display: flex;
	flex-direction: column;
	gap: .5rem;
	box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}
.nn-chat-reg__title { font-weight: 800; color: var(--c-ink); font-size: .95rem; }
.nn-chat-reg__sub { font-size: .8rem; color: var(--c-muted); margin-top: -.25rem; }
.nn-chat-input-field {
	width: 100%;
	border: 1px solid var(--c-border);
	border-radius: .7rem;
	padding: .6rem .7rem;
	font-size: .9rem;
	color: var(--c-ink);
	font-family: inherit;
	box-sizing: border-box;
}
.nn-chat-input-field:focus-visible { outline: 2px solid var(--c-emerald); outline-offset: 1px; border-color: var(--c-emerald); }
.nn-chat-reg__priv { display: flex; gap: .5rem; align-items: flex-start; font-size: .78rem; color: var(--c-muted); }
.nn-chat-reg__priv input { margin-top: .15rem; }
.nn-chat-reg__priv a { color: var(--c-emerald-dark); font-weight: 600; }
.nn-chat-reg__err { color: #b42318; font-size: .78rem; min-height: 0; }
.nn-chat-reg__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	border: 0;
	border-radius: .8rem;
	padding: .72rem 1rem;
	background: var(--c-emerald);
	color: #fff;
	font-weight: 700;
	font-size: .9rem;
	font-family: inherit;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(194,24,91, .25);
	transition: background .15s ease;
}
.nn-chat-reg__btn:hover { background: var(--c-emerald-dark); }
.nn-chat-reg__btn:disabled { opacity: .6; cursor: default; }

/* Input */
.nn-chat-input {
	display: flex;
	align-items: flex-end;
	gap: .5rem;
	padding: .65rem .7rem;
	border-top: 1px solid var(--c-border);
	background: #fff;
}
.nn-chat-textarea {
	flex: 1 1 auto;
	border: 1px solid var(--c-border);
	border-radius: 1rem;
	padding: .55rem .75rem;
	font-size: .9rem;
	font-family: inherit;
	color: var(--c-ink);
	resize: none;
	max-height: 110px;
	line-height: 1.4;
	box-sizing: border-box;
}
.nn-chat-textarea:focus-visible { outline: 2px solid var(--c-emerald); outline-offset: 1px; border-color: var(--c-emerald); }
.nn-chat-send {
	flex: 0 0 auto;
	width: 2.4rem; height: 2.4rem;
	border: 0; border-radius: 999px;
	background: var(--c-emerald); color: #fff;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.nn-chat-send:hover { background: var(--c-emerald-dark); }
.nn-chat-send:disabled { opacity: .6; cursor: default; }

.nn-chat-foot { padding: .35rem .9rem .55rem; font-size: .68rem; color: var(--c-muted); text-align: center; background: #fff; }

/* Mobile */
@media (max-width: 480px) {
	.nn-chat-panel {
		right: .5rem; left: .5rem; bottom: 4.9rem;
		width: auto;
		height: min(76vh, 600px);
	}
	.nn-chat-launcher { right: 1rem; bottom: 1rem; }
}

/* Lift the launcher above the theme's sticky mobile action bar (~64px). */
@media (max-width: 767px) {
	body:not(.nn-mbar-off) .nn-chat-launcher { bottom: calc(64px + 0.9rem); }
	body:not(.nn-mbar-off) .nn-chat-panel { bottom: calc(64px + 4.4rem); }
}

@media (prefers-reduced-motion: reduce) {
	.nn-chat-launcher::after { animation: none; }
	.nn-chat-panel { transition: none; }
}
