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

/* ── Wrapper ─────────────────────────────────────────────────────────── */
.nx-ai-searchv2 {
	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 2.5em;
}

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

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

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

.nxs-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);
}

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

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

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

/* ── Composer / search bar ───────────────────────────────────────────── */
.nxs-composer {
	padding: 0.8em 1em 0.65em;
	background: #fff;
	border-bottom: 1px solid #e2e4e7;
}

.nxs-input-row {
	display: flex;
	gap: 0.5em;
	align-items: stretch;
}

.nxs-input {
	flex: 1;
	padding: 0.65em 0.9em;
	font-size: 14px;
	font-family: inherit;
	border: 1px solid #c3c4c7;
	border-radius: 9px;
	outline: none;
	color: #1d2327;
	background: #f9fafb;
	transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
	min-width: 0;
	min-height: 40px;
}

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

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

.nxs-input:disabled {
	background: #f6f7f7;
	opacity: 0.7;
	cursor: not-allowed;
}

.nxs-search-btn {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.65em 1em;
	font-size: 13px;
	font-weight: 600;
	font-family: inherit;
	color: #fff;
	background: #2271b1;
	border: none;
	border-radius: 9px;
	cursor: pointer;
	transition: background 0.15s, transform 0.1s;
	white-space: nowrap;
	min-height: 40px;
}

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

.nxs-search-btn:active:not(:disabled) {
	transform: scale(0.97);
}

.nxs-search-btn:disabled {
	background: #c3c4c7;
	cursor: not-allowed;
}

.nxs-search-btn svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
	flex-shrink: 0;
}

/* Theme/Elementor hardening: preserve the public shortcode controls. */
.nx-ai-searchv2 .nxs-input-row {
	display: flex;
	align-items: stretch;
	gap: 0.5em;
}

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

.nx-ai-searchv2 button.nxs-search-btn {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4em;
	flex: 0 0 auto;
	min-height: 40px;
	margin: 0;
	padding: 0.65em 1em;
	border: 0;
	border-radius: 9px;
	background: #2271b1;
	color: #fff;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	text-align: center;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	position: relative;
}

.nx-ai-searchv2 button.nxs-search-btn svg {
	display: block;
	position: static;
	width: 16px;
	height: 16px;
	margin: 0;
	padding: 0;
	fill: currentColor;
	flex-shrink: 0;
	pointer-events: none;
	transform: none;
}

.nxs-hint {
	margin: 0.55em 0 0;
	font-size: 12px;
	color: #8c8f94;
	padding-left: 2px;
}

/* ── Result area ─────────────────────────────────────────────────────── */
.nxs-results {
	flex: 1;
	min-height: 220px;
	padding: 1.1em 1.1em 1.25em;
	background: #f8f9fa;
}

/* ── Loading state ───────────────────────────────────────────────────── */
.nxs-loading {
	display: flex;
	align-items: center;
	gap: 0.75em;
	padding: 1em 1.1em;
	background: #fff;
	border: 1px solid #e2e4e7;
	border-radius: 12px;
	color: #50575e;
	font-size: 14px;
}

.nxs-loading-dots {
	display: inline-flex;
	gap: 4px;
}

.nxs-ldot {
	display: inline-block;
	width: 7px;
	height: 7px;
	background: #8c8f94;
	border-radius: 50%;
	animation: nxs-bounce 1.2s ease-in-out infinite;
}

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

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

/* ── Error state ─────────────────────────────────────────────────────── */
.nxs-error-card {
	padding: 1em 1.1em;
	background: #fcf0f1;
	border: 1px solid #f5b2b5;
	border-left: 4px solid #d63638;
	border-radius: 8px;
	color: #d63638;
	font-size: 14px;
}

/* ── Empty / no results state ────────────────────────────────────────── */
.nxs-empty-card {
	padding: 2.1em 1.5em;
	background: #fff;
	border: 1px solid #e2e4e7;
	border-radius: 12px;
	text-align: center;
}

.nxs-empty-icon {
	font-size: 32px;
	display: block;
	margin-bottom: 0.5em;
	opacity: 0.5;
}

.nxs-empty-title {
	font-size: 16px;
	font-weight: 600;
	color: #1d2327;
	margin: 0 0 0.35em;
}

.nxs-empty-text {
	font-size: 13px;
	color: #50575e;
	margin: 0;
}

/* ── AI Answer card ──────────────────────────────────────────────────── */
.nxs-answer-card {
	background: #fff;
	border: 1px solid #e2e4e7;
	border-radius: 12px;
	padding: 1.25em 1.5em;
	margin-bottom: 1.1em;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
	animation: nxs-fadein 0.25s ease;
}

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

.nxs-answer-meta {
	display: flex;
	align-items: center;
	gap: 0.75em;
	margin-bottom: 0.75em;
}

.nxs-ai-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	background: #1f6aa7;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	padding: 3px 10px;
	border-radius: 12px;
}

.nxs-based-on {
	font-size: 12px;
	color: #50575e;
	opacity: 0.8;
}

.nxs-answer-text {
	font-size: 14.5px;
	line-height: 1.7;
	color: #1d2327;
	white-space: pre-wrap;
	word-break: break-word;
}

/* ── Sources section (accordion + cards) ─────────────────────────────── */
.nxs-sources-section {
	background: #fff;
	border: 1px solid #e2e4e7;
	border-radius: 12px;
	padding: 0.65em;
	animation: nxs-fadein 0.3s ease;
}

.nxs-sources-acc-trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	gap: 0.65em;
	min-height: 44px;
	padding: 0.55em 0.75em;
	font: inherit;
	font-size: 15px;
	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;
}

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

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

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

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

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

.nxs-sources-acc-panel {
	margin-top: 0.55em;
}

.nxs-source-cards {
	display: flex;
	flex-direction: column;
	gap: 0.55em;
}

/* ── Individual source card ──────────────────────────────────────────── */
.nxs-source-card {
	background: #fafbfc;
	border: 1px solid #e2e4e7;
	border-radius: 10px;
	padding: 0.65em 0.85em;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
	transition: box-shadow 0.15s, border-color 0.15s;
}

.nxs-source-card:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
	border-color: #c7d8e8;
}

.nxs-card-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75em;
	margin-bottom: 0.5em;
}

.nxs-card-title-row {
	display: flex;
	align-items: center;
	gap: 0.45em;
	flex: 1;
	min-width: 0;
}

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

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

/* ── Score badge ─────────────────────────────────────────────────────── */
.nxs-score-wrap {
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 3px;
}

.nxs-score-badge {
	font-size: 12px;
	font-weight: 700;
	padding: 2px 9px;
	border-radius: 12px;
	white-space: nowrap;
	background: #edfaef;
	color: #00a32a;
}

.nxs-score-badge--mid {
	background: #fef8e7;
	color: #996600;
}

.nxs-score-badge--low {
	background: #f5e6d3;
	color: #b26200;
}

/* Thin progress bar showing relative relevance */
.nxs-score-bar-wrap {
	height: 3px;
	background: #f0f0f1;
	border-radius: 2px;
	overflow: hidden;
	margin-bottom: 0.65em;
}

.nxs-score-bar {
	height: 100%;
	border-radius: 2px;
	background: linear-gradient(90deg, #2271b1, #135e96);
	transition: width 0.4s ease;
}

.nxs-score-bar--mid {
	background: linear-gradient(90deg, #dba617, #996600);
}

.nxs-score-bar--low {
	background: linear-gradient(90deg, #e67c12, #b26200);
}

/* ── Snippet ─────────────────────────────────────────────────────────── */
.nxs-source-snippet {
	font-size: 13px;
	color: #50575e;
	line-height: 1.6;
	margin-bottom: 0.5em;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

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

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

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

.nxs-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;
}

/* ── Card footer: download ──────────────────────────────────────────── */
.nxs-card-footer {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.4em;
}

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

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

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

/* ── Blocked state ───────────────────────────────────────────────────── */
.nxs-blocked {
	padding: 1em 1.1em;
	background: #fcf0f1;
	border: 1px solid #f5b2b5;
	border-left: 4px solid #d63638;
	border-radius: 10px;
	color: #d63638;
	font-size: 14px;
}

/* ── Enterprise agent search: tag toolbar ───────────────────────────── */
.nx-ai-searchv2.nx-ai-enterprise .nxe-agent-tagbar {
	padding: 0.55em 1.25rem;
	background: #f6f7f7;
	border-bottom: 1px solid #dcdcde;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em 0.75em;
	font-size: 13px;
}

.nx-ai-searchv2.nx-ai-enterprise .nxe-agent-tagbar-label {
	font-weight: 600;
	color: #50575e;
}

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

.nx-ai-searchv2.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-searchv2.nx-ai-enterprise .nxe-tag-chip.is-on {
	background: #1d2327;
	color: #fff;
	border-color: #1d2327;
}

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

.nx-ai-searchv2.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-searchv2.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-searchv2.nx-ai-enterprise .nxe-clear-tags-btn:hover {
	background: #f0f0f1;
}

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

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
	.nx-ai-searchv2 {
		margin: 1em auto 1.5em;
	}

	.nxs-shell {
		border-radius: 12px;
	}

	.nxs-subtitle {
		white-space: normal;
	}

	.nxs-search-btn span {
		display: none;
	}

	.nxs-search-btn {
		padding: 0.75em;
	}

	.nxs-results {
		padding: 0.85em;
	}

	.nxs-card-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.5em;
	}

	.nxs-score-wrap {
		align-items: flex-start;
	}
}
