/* NCK Chat widget */

.nck-chat {
	--nck-accent: #1b5fa8;
	--nck-radius: 14px;
	--nck-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);

	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
}

.nck-chat--right { right: 20px; }
.nck-chat--left  { left: 20px; }

.nck-chat *,
.nck-chat *::before,
.nck-chat *::after { box-sizing: border-box; }

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

.nck-chat__launcher {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.75rem 1.15rem;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--nck-accent);
	border: 0;
	border-radius: 999px;
	box-shadow: var(--nck-shadow);
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nck-chat__launcher:hover { transform: translateY(-1px); }
.nck-chat__launcher:focus-visible { outline: 3px solid rgba(27, 95, 168, 0.45); outline-offset: 2px; }
.nck-chat__launcher svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nck-chat.is-open .nck-chat__launcher { display: none; }

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

.nck-chat__panel {
	display: none;
	flex-direction: column;
	width: min(380px, calc(100vw - 32px));
	height: min(560px, calc(100vh - 120px));
	background: #fff;
	color: #16181d;
	border-radius: var(--nck-radius);
	box-shadow: var(--nck-shadow);
	overflow: hidden;
}

.nck-chat.is-open .nck-chat__panel { display: flex; }

.nck-chat__head {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.9rem 1rem;
	color: #fff;
	background: var(--nck-accent);
}

.nck-chat__title { font-weight: 700; font-size: 0.98rem; }

.nck-chat__havatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	flex: 0 0 auto;
	background: #fff;
	border: 2px solid rgba(255, 255, 255, 0.55);
}

.nck-chat__botrow {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 92%;
	align-self: flex-start;
}

.nck-chat__botrow .nck-chat__msg { max-width: 100%; }

.nck-chat__mavatar {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	flex: 0 0 auto;
	background: #fff;
	border: 1px solid #e6e8ec;
}

.nck-chat__status {
	font-size: 0.75rem;
	opacity: 0.85;
	display: block;
	font-weight: 400;
}

.nck-chat__end {
	margin-left: auto;
	font: inherit;
	font-size: 0.72rem;
	padding: 0.3rem 0.6rem;
	color: #fff;
	background: rgba(255, 255, 255, 0.16);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
}

.nck-chat__end:hover { background: rgba(255, 255, 255, 0.28); }

.nck-chat__close {
	margin-left: 0.4rem;
	width: 30px;
	height: 30px;
	font: inherit;
	font-size: 1.15rem;
	line-height: 1;
	color: #fff;
	background: rgba(255, 255, 255, 0.16);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
}

.nck-chat__close:hover { background: rgba(255, 255, 255, 0.28); }

/* ---------- pre-chat identity ---------- */

.nck-chat__ident {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 1.25rem;
	background: #f7f8fa;
}

.nck-chat__ident[hidden] { display: none; }

.nck-chat__ident-intro {
	margin: 0 0 0.25rem;
	font-size: 0.9rem;
	color: #374151;
}

.nck-chat__ident input {
	padding: 0.65rem 0.8rem;
	font: inherit;
	font-size: 0.95rem;
	border: 1px solid #dfe3e8;
	border-radius: 10px;
	background: #fff;
}

.nck-chat__ident input:focus { outline: 2px solid var(--nck-accent); outline-offset: 1px; }

.nck-chat__ident-go {
	margin-top: 0.25rem;
	padding: 0.65rem;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--nck-accent);
	border: 0;
	border-radius: 10px;
	cursor: pointer;
}

/* ---------- log ---------- */

.nck-chat__log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 1rem;
	background: #f7f8fa;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
}

.nck-chat__msg {
	max-width: 85%;
	padding: 0.6rem 0.8rem;
	border-radius: 12px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.nck-chat__msg a { color: var(--nck-accent); }

.nck-chat__msg--bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e6e8ec;
	border-bottom-left-radius: 4px;
}

.nck-chat__msg--operator {
	border-left: 3px solid #1a9e55;
}

.nck-chat__op {
	display: block;
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #1a9e55;
	margin-bottom: 0.2rem;
}

.nck-chat__msg--visitor {
	align-self: flex-end;
	color: #fff;
	background: var(--nck-accent);
	border-bottom-right-radius: 4px;
}

.nck-chat__sources {
	align-self: flex-start;
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	max-width: 92%;
}

.nck-chat__source {
	font-size: 0.8rem;
	padding: 0.35rem 0.6rem;
	background: #fff;
	border: 1px solid #dfe3e8;
	border-radius: 999px;
	color: var(--nck-accent);
	text-decoration: none;
}

.nck-chat__source:hover { border-color: var(--nck-accent); }

.nck-chat__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	padding: 0 1rem 0.75rem;
	background: #f7f8fa;
}

.nck-chat__chip {
	font: inherit;
	font-size: 0.8rem;
	padding: 0.4rem 0.7rem;
	background: #fff;
	border: 1px solid #dfe3e8;
	border-radius: 999px;
	cursor: pointer;
	color: inherit;
}

.nck-chat__chip:hover { border-color: var(--nck-accent); color: var(--nck-accent); }

/* ---------- typing ---------- */

.nck-chat__typing {
	align-self: flex-start;
	display: none;
	gap: 4px;
	padding: 0.7rem 0.85rem;
	background: #fff;
	border: 1px solid #e6e8ec;
	border-radius: 12px;
}

.nck-chat.is-typing .nck-chat__typing { display: flex; }

.nck-chat__typing span {
	width: 6px;
	height: 6px;
	background: #9aa3ae;
	border-radius: 50%;
	animation: nck-bounce 1.2s infinite ease-in-out;
}

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

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

@media (prefers-reduced-motion: reduce) {
	.nck-chat__typing span { animation: none; }
	.nck-chat__launcher { transition: none; }
}

/* ---------- composer ---------- */

.nck-chat__form {
	display: flex;
	gap: 0.5rem;
	padding: 0.75rem;
	background: #fff;
	border-top: 1px solid #e6e8ec;
}

.nck-chat__input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 0.6rem 0.75rem;
	font: inherit;
	font-size: 0.95rem;
	color: inherit;
	background: #f7f8fa;
	border: 1px solid #dfe3e8;
	border-radius: 10px;
}

.nck-chat__input:focus { outline: 2px solid var(--nck-accent); outline-offset: 1px; }

.nck-chat__send {
	flex: 0 0 auto;
	padding: 0.6rem 0.95rem;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--nck-accent);
	border: 0;
	border-radius: 10px;
	cursor: pointer;
}

.nck-chat__send[disabled] { opacity: 0.5; cursor: default; }

.nck-chat__foot {
	padding: 0 0.75rem 0.7rem;
	font-size: 0.72rem;
	color: #6b7280;
	background: #fff;
	text-align: center;
}

.nck-chat__humanbtn {
	font: inherit;
	font-size: inherit;
	padding: 0;
	border: 0;
	background: none;
	color: var(--nck-accent);
	text-decoration: underline;
	cursor: pointer;
}

@media (max-width: 480px) {
	.nck-chat { bottom: 12px; }
	.nck-chat--right { right: 12px; }
	.nck-chat--left  { left: 12px; }
	.nck-chat__panel { height: min(76vh, calc(100vh - 90px)); }
}
