.nblab-ai-chat {
	position: fixed;
	z-index: 99999;
	font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #0f172a;
	--nblab-primary: #0096cd;
	--nblab-primary-dark: #007fad;
	--nblab-surface: #ffffff;
	--nblab-muted: #64748b;
	--nblab-border: rgba(15, 23, 42, 0.08);
	--nblab-bg: #f1f5f9;
	-webkit-font-smoothing: antialiased;
}

.nblab-ai-chat--bottom-right {
	right: 20px;
	bottom: 20px;
}

.nblab-ai-chat--bottom-left {
	left: 20px;
	bottom: 20px;
}

.nblab-ai-chat__toggle {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: 0;
	cursor: pointer;
	background: linear-gradient(145deg, var(--nblab-primary) 0%, var(--nblab-primary-dark) 100%);
	color: #fff;
	box-shadow:
		0 4px 14px rgba(0, 150, 205, 0.45),
		0 12px 32px rgba(15, 23, 42, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.nblab-ai-chat__toggle:hover {
	transform: translateY(-2px) scale(1.02);
	box-shadow:
		0 6px 20px rgba(0, 150, 205, 0.5),
		0 16px 40px rgba(15, 23, 42, 0.2);
}

.nblab-ai-chat__toggle:active {
	transform: translateY(0) scale(0.98);
}

.nblab-ai-chat__toggle-icon {
	width: 24px;
	height: 24px;
	border-radius: 7px 7px 7px 2px;
	background: rgba(255, 255, 255, 0.98);
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.nblab-ai-chat__panel {
	position: absolute;
	bottom: 76px;
	width: min(416px, calc(100vw - 32px));
	max-height: min(580px, calc(100vh - 116px));
	background: var(--nblab-surface);
	border: 1px solid var(--nblab-border);
	border-radius: 20px;
	box-shadow:
		0 0 0 1px rgba(255, 255, 255, 0.6) inset,
		0 24px 56px rgba(15, 23, 42, 0.16),
		0 8px 24px rgba(15, 23, 42, 0.08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.nblab-ai-chat__panel[hidden] {
	display: none !important;
}

.nblab-ai-chat--bottom-right .nblab-ai-chat__panel {
	right: 0;
}

.nblab-ai-chat--bottom-left .nblab-ai-chat__panel {
	left: 0;
}

.nblab-ai-chat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 18px;
	background: linear-gradient(135deg, var(--nblab-primary) 0%, var(--nblab-primary-dark) 105%);
	color: #fff;
	flex-shrink: 0;
}

.nblab-ai-chat__head-title {
	font-weight: 600;
	font-size: 15px;
	letter-spacing: -0.02em;
}

.nblab-ai-chat__close {
	border: 0;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	width: 36px;
	height: 36px;
	border-radius: 10px;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

.nblab-ai-chat__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.nblab-ai-chat__messages {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 16px;
	background: linear-gradient(180deg, #f8fafc 0%, var(--nblab-bg) 50%);
	scroll-behavior: smooth;
}

.nblab-ai-chat__messages::-webkit-scrollbar {
	width: 6px;
}
.nblab-ai-chat__messages::-webkit-scrollbar-thumb {
	background: rgba(15, 23, 42, 0.12);
	border-radius: 6px;
}

.nblab-ai-chat__msg {
	max-width: 90%;
	padding: 12px 14px;
	border-radius: 16px;
	margin-bottom: 10px;
	white-space: pre-wrap;
	word-break: break-word;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nblab-ai-chat__msg--user {
	margin-left: auto;
	background: linear-gradient(145deg, var(--nblab-primary) 0%, var(--nblab-primary-dark) 100%);
	color: #fff;
	border-bottom-right-radius: 5px;
	box-shadow: 0 2px 12px rgba(0, 150, 205, 0.35);
}

.nblab-ai-chat__msg--assistant {
	margin-right: auto;
	background: #fff;
	border: 1px solid var(--nblab-border);
	color: #0f172a;
	border-bottom-left-radius: 5px;
}

.nblab-ai-chat__typing {
	display: flex;
	gap: 5px;
	padding: 8px 16px 12px;
	background: transparent;
}

.nblab-ai-chat__typing[hidden] {
	display: none !important;
}

.nblab-ai-chat__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--nblab-muted);
	animation: nblabTyping 1s infinite ease-in-out;
}

.nblab-ai-chat__typing span:nth-child(2) {
	animation-delay: 0.15s;
}
.nblab-ai-chat__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes nblabTyping {
	0%, 80%, 100% {
		transform: translateY(0);
		opacity: 0.35;
	}
	40% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

.nblab-ai-chat__form {
	display: block;
	padding: 14px;
	border-top: 1px solid var(--nblab-border);
	background: #fff;
	flex-shrink: 0;
}

.nblab-ai-chat__compose {
	display: flex;
	align-items: flex-end;
	gap: 10px;
}

.nblab-ai-chat__hp-wrap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.nblab-ai-chat__textarea {
	flex: 1;
	min-width: 0;
	min-height: 48px;
	max-height: 140px;
	border: 1px solid var(--nblab-border);
	border-radius: 14px;
	padding: 12px 14px;
	font: inherit;
	line-height: 1.45;
	resize: none;
	background: #f8fafc;
	color: #0f172a;
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) inset;
}

.nblab-ai-chat__textarea::placeholder {
	color: #94a3b8;
}

.nblab-ai-chat__textarea:hover {
	background: #fff;
}

.nblab-ai-chat__textarea:focus {
	outline: none;
	border-color: color-mix(in srgb, var(--nblab-primary) 55%, transparent);
	background: #fff;
	box-shadow:
		0 0 0 3px color-mix(in srgb, var(--nblab-primary) 22%, transparent),
		0 1px 2px rgba(15, 23, 42, 0.04) inset;
}

.nblab-ai-chat__send {
	flex-shrink: 0;
	align-self: flex-end;
	border: 0;
	border-radius: 14px;
	padding: 12px 18px;
	min-height: 48px;
	background: linear-gradient(145deg, var(--nblab-primary) 0%, var(--nblab-primary-dark) 100%);
	color: #fff;
	font-weight: 600;
	font-size: 13px;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 150, 205, 0.35);
	transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.nblab-ai-chat__send:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(0, 150, 205, 0.42);
}

.nblab-ai-chat__send:active {
	transform: translateY(0);
}

.nblab-ai-chat__send:disabled {
	opacity: 0.55;
	cursor: wait;
	transform: none;
}

.nblab-ai-chat__send-label {
	display: block;
}

.screen-reader-text {
	position: absolute;
	left: -9999px;
}

@supports not (color: color-mix(in srgb, white 50%, black)) {
	.nblab-ai-chat__textarea:focus {
		border-color: rgba(0, 150, 205, 0.55);
		box-shadow:
			0 0 0 3px rgba(0, 150, 205, 0.2),
			0 1px 2px rgba(15, 23, 42, 0.04) inset;
	}
}

@media (max-width: 782px) {
	/* Roditelj mora imati punu širinu ekrana — inače je "100%" panela = širina dugmeta (~58px). */
	.nblab-ai-chat {
		display: flex;
		flex-direction: column-reverse;
		align-items: stretch;
		left: 12px;
		right: 12px;
		width: auto;
		bottom: max(12px, env(safe-area-inset-bottom, 0px));
		pointer-events: none;
	}

	.nblab-ai-chat--bottom-right,
	.nblab-ai-chat--bottom-left {
		left: 12px;
		right: 12px;
	}

	.nblab-ai-chat__toggle {
		pointer-events: auto;
		flex-shrink: 0;
		align-self: flex-end;
	}

	.nblab-ai-chat--bottom-left .nblab-ai-chat__toggle {
		align-self: flex-start;
	}

	.nblab-ai-chat__panel {
		pointer-events: auto;
		position: relative;
		width: 100% !important;
		max-width: none !important;
		left: auto !important;
		right: auto !important;
		bottom: auto;
		margin-bottom: 12px;
		max-height: min(72vh, 560px);
		border-radius: 18px;
	}

	.nblab-ai-chat__messages {
		min-height: 120px;
	}

	.nblab-ai-chat__compose {
		flex-wrap: wrap;
	}

	.nblab-ai-chat__send {
		min-width: 88px;
	}
}
