/**
 * Noulek AI — Public chat shortcode styles.
 * Scoped to .nx-ai-chatv2; no dependency on admin.css.
 * Compatible with all major WordPress themes.
 */

/* ── Wrapper reset ───────────────────────────────────────────────────── */
.nx-ai-chatv2 {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: #1d2327;
	max-width: 860px;
	margin: 1.5em auto;
}

.nx-ai-chatv2 *,
.nx-ai-chatv2 *::before,
.nx-ai-chatv2 *::after {
	box-sizing: inherit;
}

/* ── Shell ───────────────────────────────────────────────────────────── */
.nxc-shell {
	display: flex;
	flex-direction: column;
	height: 600px;
	border: 1px solid #dcdcde;
	border-radius: 14px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.09);
}

.nxc-shell--blocked .nxc-messages {
	background: #fff;
	align-items: center;
	justify-content: center;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.nxc-header {
	flex-shrink: 0;
	padding: 0.9em 1.25em;
	background: linear-gradient(135deg, #1d2327 0%, #2c3338 100%);
	color: #fff;
	display: flex;
	align-items: center;
	gap: 0.75em;
}

.nxc-header-icon {
	width: 38px;
	height: 38px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 19px;
	flex-shrink: 0;
	border: 1px solid rgba(255, 255, 255, 0.12);
}

.nxc-header-text {
	flex: 1;
	min-width: 0;
}

.nxc-title {
	margin: 0 0 0.1em;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.25;
	color: #fff;
	border: none;
	padding: 0;
}

.nxc-subtitle {
	margin: 0;
	font-size: 12px;
	opacity: 0.68;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: #fff;
}

/* ── Messages area ───────────────────────────────────────────────────── */
.nxc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 1.25em 1.25em 0.75em;
	display: flex;
	flex-direction: column;
	gap: 1em;
	background: #f8f9fa;
	scroll-behavior: smooth;
}

.nxc-messages::-webkit-scrollbar {
	width: 6px;
}

.nxc-messages::-webkit-scrollbar-track {
	background: transparent;
}

.nxc-messages::-webkit-scrollbar-thumb {
	background: #c3c4c7;
	border-radius: 3px;
}

/* ── Conversation turns ──────────────────────────────────────────────── */
.nxc-turn {
	display: flex;
	flex-direction: column;
	max-width: 100%;
	animation: nxc-fadein 0.2s ease;
}

@keyframes nxc-fadein {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.nxc-turn--user { align-items: flex-end; }
.nxc-turn--assistant { align-items: flex-start; }
.nxc-turn--welcome { align-items: flex-start; }

/* ── Bubbles ─────────────────────────────────────────────────────────── */
.nxc-bubble {
	padding: 0.7em 1em;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.65;
	word-break: break-word;
	max-width: 72%;
}

.nxc-turn--user .nxc-bubble {
	background: #2271b1;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.nxc-turn--assistant .nxc-bubble {
	background: #fff;
	color: #1d2327;
	border: 1px solid #e2e4e7;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.nxc-turn--welcome .nxc-bubble {
	background: #f0f6fc;
	border: 1px solid #c7e0f5;
	border-bottom-left-radius: 4px;
	color: #135e96;
	font-style: italic;
}

/* ── Loading dots ────────────────────────────────────────────────────── */
.nxc-bubble--loading {
	display: inline-flex;
	gap: 5px;
	align-items: center;
	padding: 0.85em 1.15em;
	min-width: 64px;
}

.nxc-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: #c3c4c7;
	border-radius: 50%;
	animation: nxc-bounce 1.3s ease-in-out infinite;
}

.nxc-dot:nth-child(2) { animation-delay: 0.18s; }
.nxc-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes nxc-bounce {
	0%, 80%, 100% { transform: translateY(0); background: #c3c4c7; }
	40%            { transform: translateY(-5px); background: #8c8f94; }
}

/* ── Error banner ────────────────────────────────────────────────────── */
.nxc-error {
	flex-shrink: 0;
	padding: 0.55em 1.25em;
	background: #fcf0f1;
	border-top: 1px solid #f5b2b5;
	color: #d63638;
	font-size: 13px;
	display: flex;
	align-items: center;
	gap: 0.5em;
}

.nxc-error[hidden] { display: none; }

.nxc-error-close {
	margin-left: auto;
	background: none;
	border: none;
	cursor: pointer;
	color: #d63638;
	font-size: 15px;
	padding: 0 4px;
	line-height: 1;
	flex-shrink: 0;
}

.nxc-error-close:hover { opacity: 0.7; }

/* ── Referenced sources (accordion + cards) ─────────────────────────── */
.nxc-sources-wrap {
	margin-top: 0.55em;
	width: 100%;
	max-width: 560px;
}

.nxc-sources-acc-trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	gap: 0.65em;
	min-height: 44px;
	padding: 0.55em 0.8em;
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: #1d2327;
	background: linear-gradient(180deg, #f6f7f7 0%, #eceff1 100%);
	border: 1px solid #c3c4c7;
	border-radius: 10px;
	cursor: pointer;
	text-align: left;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.nxc-sources-acc-trigger:hover {
	border-color: #8c8f94;
	background: #f0f0f1;
}

.nxc-sources-acc-trigger:focus {
	outline: none;
}

.nxc-sources-acc-trigger:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.nxc-sources-acc-title {
	flex: 1;
	min-width: 0;
}

.nxc-sources-acc-chevron {
	flex-shrink: 0;
	font-size: 11px;
	color: #50575e;
	line-height: 1;
}

.nxc-sources-acc-panel {
	margin-top: 0.45em;
	transition: opacity 0.2s ease;
}

.nxc-source-cards {
	display: flex;
	flex-direction: column;
	gap: 0.45em;
}

.nxc-source-card {
	background: #fff;
	border: 1px solid #e2e4e7;
	border-radius: 10px;
	padding: 0.6em 0.85em;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
	transition: box-shadow 0.15s, border-color 0.15s;
}

.nxc-source-card:hover {
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
	border-color: #c7d8e8;
}

.nxc-source-header {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0.35em;
	margin-bottom: 0.35em;
	min-width: 0;
}

.nxc-source-rank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.55em;
	height: 1.55em;
	padding: 0 0.35em;
	font-size: 11px;
	font-weight: 800;
	color: #fff;
	background: #2271b1;
	border-radius: 6px;
	flex-shrink: 0;
}

.nxc-source-title {
	font-weight: 600;
	font-size: 13px;
	color: #1d2327;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nxc-source-score {
	flex-shrink: 0;
	margin-left: auto;
	font-size: 11px;
	font-weight: 700;
	padding: 2px 9px;
	border-radius: 12px;
	background: #edfaef;
	color: #00a32a;
	white-space: nowrap;
}

.nxc-source-score--mid {
	background: #fef8e7;
	color: #996600;
}

.nxc-source-score--low {
	background: #f5e6d3;
	color: #b26200;
}

.nxc-source-snippet {
	font-size: 12.5px;
	color: #50575e;
	line-height: 1.55;
	margin-bottom: 0.45em;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.nxc-source-docs-meta {
	display: flex;
	flex-direction: column;
	gap: 0.35em;
	margin-bottom: 0.45em;
}

.nxc-source-category {
	font-size: 11.5px;
	font-weight: 600;
	color: #50575e;
}

.nxc-source-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3em;
}

.nxc-tag-chip {
	display: inline-block;
	font-size: 10.5px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 999px;
	background: #e8f4fc;
	color: #135e96;
	border: 1px solid #c7e0f5;
}

.nxc-source-footer {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.4em;
}

.nxc-badge {
	display: inline-block;
	background: #f0f0f1;
	color: #50575e;
	font-size: 11px;
	font-weight: 500;
	padding: 2px 9px;
	border-radius: 10px;
}

.nxc-download-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	font-weight: 600;
	color: #2271b1;
	text-decoration: none;
	padding: 3px 10px;
	border: 1px solid #c7e0f5;
	border-radius: 5px;
	background: #f0f6fc;
	margin-left: auto;
	transition: background 0.15s, color 0.15s;
}

.nxc-download-btn:hover {
	background: #daeeff;
	color: #135e96;
	text-decoration: none;
}

/* ── Composer ────────────────────────────────────────────────────────── */
.nxc-composer {
	flex-shrink: 0;
	display: flex;
	align-items: flex-end;
	gap: 0.5em;
	padding: 0.7em 1em;
	background: #fff;
	border-top: 1px solid #e2e4e7;
}

.nxc-input {
	flex: 1;
	padding: 0.6em 0.85em;
	border: 1px solid #c3c4c7;
	border-radius: 9px;
	font-size: 14px;
	font-family: inherit;
	line-height: 1.5;
	resize: none;
	outline: none;
	min-height: 40px;
	max-height: 120px;
	overflow-y: auto;
	color: #1d2327;
	background: #f9fafb;
	transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.nxc-input:focus {
	border-color: #2271b1;
	background: #fff;
	box-shadow: 0 0 0 2.5px rgba(34, 113, 177, 0.14);
}

.nxc-input:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.nxc-input::placeholder {
	color: #8c8f94;
}

.nxc-send-btn {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
	border-radius: 9px;
	border: none;
	background: #2271b1;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s, transform 0.1s;
}

.nxc-send-btn:hover:not(:disabled) {
	background: #135e96;
}

.nxc-send-btn:active:not(:disabled) {
	transform: scale(0.93);
}

.nxc-send-btn:disabled {
	background: #c3c4c7;
	cursor: not-allowed;
}

.nxc-send-btn svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

/* Theme/Elementor hardening: keep the shortcode composer layout authoritative. */
.nx-ai-chatv2 .nxc-composer {
	display: flex;
	align-items: flex-end;
	gap: 0.5em;
}

.nx-ai-chatv2 textarea.nxc-input {
	display: block;
	width: 100%;
	min-width: 0;
	margin: 0;
	box-shadow: none;
	appearance: none;
	-webkit-appearance: none;
}

.nx-ai-chatv2 button.nxc-send-btn {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 40px;
	width: 40px;
	min-width: 40px;
	max-width: 40px;
	height: 40px;
	min-height: 40px;
	max-height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 9px;
	background: #2271b1;
	color: #fff;
	line-height: 1;
	text-align: center;
	text-decoration: none;
	overflow: hidden;
	position: relative;
}

.nx-ai-chatv2 button.nxc-send-btn svg {
	display: block;
	position: static;
	width: 18px;
	height: 18px;
	margin: 0;
	padding: 0;
	fill: currentColor;
	pointer-events: none;
	transform: none;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
	.nx-ai-chatv2 {
		margin: 0;
	}

	.nxc-shell {
		height: 88vh;
		border-radius: 0;
		border-left: none;
		border-right: none;
	}

	.nxc-bubble {
		max-width: 86%;
	}

	.nxc-sources-wrap {
		max-width: 100%;
	}
}

/* ═══════════════════════════════════════════════════════════════════════
   [noulek_chat_history] — sidebar-style conversation list (scoped BEM)
   ═══════════════════════════════════════════════════════════════════════ */

.noulek-chat-history {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: #1d2327;
	width: 100%;
	max-width: 380px;
	margin: 0 auto 1.25em;
	background: #fff;
	border: 1px solid #e2e4e7;
	border-radius: 14px;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
	overflow: hidden;
}

.noulek-chat-history__header {
	padding: 0.9em 1em 0.65em;
	background: linear-gradient(135deg, #1d2327 0%, #2c3338 100%);
	color: #fff;
}

.noulek-chat-history__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: #fff;
	border: none;
	padding: 0;
}

.noulek-chat-history__nav {
	padding: 0.5em 0 0.35em;
	max-height: min(70vh, 520px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.noulek-chat-history__group {
	padding: 0 0.65em 0.55em;
}

.noulek-chat-history__group-title {
	margin: 0.5em 0 0.35em;
	padding: 0 0.35em;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #8c8f94;
}

.noulek-chat-history__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.noulek-chat-history__item {
	margin: 0;
	padding: 0;
	border-radius: 10px;
}

.noulek-chat-history__item + .noulek-chat-history__item {
	margin-top: 3px;
}

.noulek-chat-history__link {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5em;
	padding: 0.55em 0.55em 0.55em 0.65em;
	text-decoration: none;
	color: inherit;
	border-radius: 10px;
	transition: background 0.12s ease, box-shadow 0.12s ease;
	border: 1px solid transparent;
}

.noulek-chat-history__link:hover {
	background: #f0f6fc;
	border-color: #d5e5f5;
}

.noulek-chat-history__link:focus {
	outline: none;
}

.noulek-chat-history__link:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 1px;
}

.noulek-chat-history__item--active .noulek-chat-history__link {
	background: #e8f4fc;
	border-color: #9ec2e8;
	box-shadow: inset 3px 0 0 #2271b1;
}

.noulek-chat-history__item-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.2em;
}

.noulek-chat-history__item-title {
	font-weight: 600;
	font-size: 13.5px;
	color: #1d2327;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.noulek-chat-history__preview {
	font-size: 12px;
	color: #646970;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.noulek-chat-history__date {
	flex-shrink: 0;
	font-size: 10.5px;
	color: #8c8f94;
	white-space: nowrap;
	padding-top: 2px;
	max-width: 42%;
	text-align: right;
	overflow: hidden;
	text-overflow: ellipsis;
}

.noulek-chat-history__empty {
	padding: 1.5em 1.25em 1.75em;
	text-align: center;
}

.noulek-chat-history__empty-title {
	margin: 0 0 0.5em;
	font-size: 14px;
	font-weight: 600;
	color: #50575e;
}

.noulek-chat-history__empty-hint {
	margin: 0;
	font-size: 13px;
	color: #8c8f94;
	line-height: 1.5;
}

.noulek-chat-history__login-required {
	margin: 0;
	padding: 1.25em 1.1em;
	text-align: center;
	font-size: 14px;
	color: #50575e;
}

@media (max-width: 640px) {
	.noulek-chat-history {
		max-width: 100%;
		border-radius: 12px;
	}

	.noulek-chat-history__date {
		max-width: 38%;
		font-size: 10px;
	}
}

/* ── Enterprise agent: optional tag chips (under .nx-ai-chatv2.nx-ai-enterprise) ─ */
.nx-ai-chatv2.nx-ai-enterprise .nxe-agent-tagbar {
	flex-shrink: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em 0.75em;
	padding: 0.55em 1rem;
	background: #f6f7f7;
	border-bottom: 1px solid #dcdcde;
	font-size: 13px;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-agent-tagbar-label {
	font-weight: 600;
	color: #50575e;
	margin-right: 0.25em;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-agent-tag-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-tag-chip {
	border: 1px solid #c3c4c7;
	background: #fff;
	color: #2c3338;
	border-radius: 999px;
	padding: 0.2em 0.65em;
	font-size: 12px;
	cursor: pointer;
	line-height: 1.3;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-tag-chip.is-on {
	background: #1d2327;
	color: #fff;
	border-color: #1d2327;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-tag-chip:hover {
	border-color: #8c8f94;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-category-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.25em;
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 999px;
	padding: 0.1em 0.5em;
	font-size: 11px;
	font-weight: 500;
	margin-left: 0.5em;
	white-space: nowrap;
	vertical-align: middle;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-clear-tags-btn {
	margin-left: auto;
	border: 1px solid #c3c4c7;
	background: none;
	color: #50575e;
	border-radius: 999px;
	padding: 0.2em 0.65em;
	font-size: 12px;
	cursor: pointer;
	line-height: 1.3;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-clear-tags-btn:hover {
	background: #f0f0f1;
}

.nx-ai-chatv2.nx-ai-enterprise .nxe-no-tags {
	font-style: italic;
	color: #8c8f94;
	font-weight: 400;
}
