/**
 * Shared design tokens and patterns for Noulek public Chat + Search widgets.
 */

.nx-ai-chatv2,
.nx-ai-searchv2 {
	--noulek-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--noulek-text: #1d1d1f;
	--noulek-text-secondary: #6e6e73;
	--noulek-surface: #ffffff;
	--noulek-surface-muted: #f5f5f7;
	--noulek-border: rgba(0, 0, 0, 0.08);
	--noulek-border-strong: rgba(0, 0, 0, 0.12);
	--noulek-accent: #0066cc;
	--noulek-accent-hover: #0055b3;
	--noulek-accent-soft: #e8f2ff;
	--noulek-radius-sm: 10px;
	--noulek-radius-md: 14px;
	--noulek-radius-lg: 18px;
	--noulek-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
	--noulek-shadow-md: 0 8px 28px rgba(0, 0, 0, 0.08);
	--noulek-focus-ring: 0 0 0 3px rgba(0, 102, 204, 0.18);
}

/* ── Fullscreen overlay (Chat + Search) ───────────────────────────── */
.nx-ai-chatv2.nxc--expanded,
.nx-ai-searchv2.nxs--expanded {
	position: fixed;
	inset: 0.75rem;
	z-index: 100000;
	max-width: none;
	margin: 0;
}

body.noulek-widget-body-lock {
	overflow: hidden;
}

.noulek-widget-fullscreen-btn {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 1px solid #e5e7eb;
	border-radius: 9px;
	background: #fafafa;
	color: #6e6e73;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.noulek-widget-fullscreen-btn:hover,
.noulek-widget-fullscreen-btn:focus-visible {
	background: #f3f4f6;
	border-color: #d1d5db;
	color: #1d1d1f;
	outline: none;
}

.noulek-widget-fullscreen-btn:focus-visible {
	box-shadow: var(--noulek-focus-ring, 0 0 0 3px rgba(0, 102, 204, 0.18));
}

.noulek-widget-fullscreen-btn__icon {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.noulek-widget-fullscreen-btn__icon--collapse {
	display: none;
}

.nx-ai-chatv2.nxc--expanded .noulek-widget-fullscreen-btn__icon--expand,
.nx-ai-searchv2.nxs--expanded .noulek-widget-fullscreen-btn__icon--expand {
	display: none;
}

.nx-ai-chatv2.nxc--expanded .noulek-widget-fullscreen-btn__icon--collapse,
.nx-ai-searchv2.nxs--expanded .noulek-widget-fullscreen-btn__icon--collapse {
	display: block;
}

/* ── Shared empty state ─────────────────────────────────────────────── */
.noulek-widget-empty {
	text-align: center;
	padding: 1.5rem 1.25rem 1.25rem;
}

.noulek-widget-empty__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin: 0 auto 1rem;
	border-radius: 999px;
	background: var(--noulek-accent-soft);
	color: var(--noulek-accent);
}

.noulek-widget-empty__icon svg {
	width: 1.35rem;
	height: 1.35rem;
	fill: currentColor;
}

.noulek-widget-empty__title {
	margin: 0 0 0.45rem;
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: -0.02em;
	color: var(--noulek-text);
}

.noulek-widget-empty__body {
	margin: 0 auto 1.15rem;
	max-width: 28rem;
	font-size: 0.9375rem;
	line-height: 1.55;
	color: var(--noulek-text-secondary);
}

/* ── Shared suggestion chips ────────────────────────────────────────── */
.noulek-widget-suggestions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
}

.noulek-suggestion-chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0.5rem 0.85rem;
	border: 1px solid var(--noulek-border-strong);
	border-radius: 999px;
	background: var(--noulek-surface);
	color: var(--noulek-text);
	font-family: inherit;
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1.35;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.noulek-suggestion-chip:hover {
	border-color: rgba(0, 102, 204, 0.28);
	background: #fafcff;
}

.noulek-suggestion-chip:focus-visible {
	outline: none;
	box-shadow: var(--noulek-focus-ring);
}

.noulek-suggestion-chip:active {
	transform: scale(0.98);
}

/* ── Sources accordion (Chat + Search) ─────────────────────────────── */
.noulek-sources-acc {
	margin-top: 0.75em;
	width: 100%;
	max-width: none;
}

.noulek-sources-acc__trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin: 0;
	padding: 0.12rem 0;
	border: none;
	background: transparent;
	color: var(--noulek-text-secondary, #6e6e73);
	font-family: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.3;
	cursor: pointer;
	transition: color 0.15s ease;
}

.noulek-sources-acc__trigger:hover {
	color: var(--noulek-text, #1d1d1f);
}

.noulek-sources-acc__trigger:focus-visible {
	outline: none;
	border-radius: 4px;
	box-shadow: var(--noulek-focus-ring, 0 0 0 3px rgba(0, 102, 204, 0.18));
}

.noulek-sources-acc__chevron {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 0.625rem;
	line-height: 1;
	opacity: 0.72;
	transition: opacity 0.15s ease;
}

.noulek-sources-acc__trigger[aria-expanded="true"] .noulek-sources-acc__chevron {
	opacity: 0.9;
}

.noulek-sources-acc__panel {
	margin-top: 0.5rem;
}

.noulek-sources-acc__panel[hidden] {
	display: none !important;
}

.noulek-sources-acc__panel:not([hidden]) {
	animation: noulek-sources-acc-in 0.22s ease;
}

@keyframes noulek-sources-acc-in {
	from {
		opacity: 0;
		transform: translateY(-2px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ── Safe Markdown (Chat + Search, shared with Embed renderer) ─────── */
.noulek-public-md,
.nxc-bubble .noulek-public-md,
.nxs-answer-text .noulek-public-md {
	font-weight: 400;
	letter-spacing: -0.01em;
}

.noulek-public-md.noulek-embed-md,
.nxc-bubble .noulek-embed-md,
.nxs-answer-text .noulek-embed-md {
	margin: 0;
}

.nxc-bubble .noulek-embed-md__p,
.nxs-answer-text .noulek-embed-md__p {
	margin: 0 0 0.65em;
}

.nxc-bubble .noulek-embed-md__p:last-child,
.nxs-answer-text .noulek-embed-md__p:last-child {
	margin-bottom: 0;
}

.nxc-bubble .noulek-embed-md__list,
.nxs-answer-text .noulek-embed-md__list {
	margin: 0 0 0.65em 1.15em;
	padding: 0;
}

.nxc-bubble .noulek-embed-md__list li,
.nxs-answer-text .noulek-embed-md__list li {
	margin: 0.25em 0;
}

.nxc-bubble .noulek-embed-md__heading,
.nxs-answer-text .noulek-embed-md__heading {
	margin: 0.85em 0 0.4em;
	font-size: 0.95em;
	font-weight: 600;
	line-height: 1.35;
	color: var(--noulek-text, #1d1d1f);
}

.nxc-bubble .noulek-embed-md__heading:first-child,
.nxs-answer-text .noulek-embed-md__heading:first-child {
	margin-top: 0;
}

.nxc-bubble .noulek-embed-md__blockquote,
.nxs-answer-text .noulek-embed-md__blockquote {
	margin: 0 0 0.65em;
	padding-left: 0.75em;
	border-left: 3px solid var(--noulek-border-strong, rgba(0, 0, 0, 0.12));
	color: var(--noulek-text-secondary, #6e6e73);
}

.nxc-bubble .noulek-embed-md__link,
.nxs-answer-text .noulek-embed-md__link {
	color: var(--noulek-accent, #0066cc);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.nxc-bubble .noulek-embed-md strong,
.nxs-answer-text .noulek-embed-md strong {
	font-weight: 600;
}

/* Chat markdown tables (macOS-style); Search keeps legacy rules below */
.nxc-bubble .noulek-embed-md__table-wrap {
	margin: 0.5em 0 0.75em;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid #e9edf2;
	border-radius: 8px;
	background: #fff;
}

.nxc-bubble .noulek-embed-md__table-wrap:last-child {
	margin-bottom: 0;
}

.nxc-bubble .noulek-embed-md__table {
	width: 100%;
	min-width: min(100%, 16rem);
	border-collapse: collapse;
	border-spacing: 0;
	font-size: 0.8125rem;
	line-height: 1.45;
	letter-spacing: -0.01em;
	color: var(--noulek-text, #1d1d1f);
}

.nxc-bubble .noulek-embed-md__table th,
.nxc-bubble .noulek-embed-md__table td {
	padding: 11px 16px;
	border: 0;
	border-bottom: 1px solid #e9edf2;
	vertical-align: middle;
}

.nxc-bubble .noulek-embed-md__table thead th {
	font-weight: 600;
	font-size: 0.8125rem;
	color: #6e6e73;
	background: #f7f8fa;
	border-bottom: 1px solid #e9edf2;
	white-space: nowrap;
}

.nxc-bubble .noulek-embed-md__table tbody tr {
	background: #fff;
}

.nxc-bubble .noulek-embed-md__table tbody tr:hover td {
	background: #f9fafb;
}

.nxc-bubble .noulek-embed-md__table tbody tr:last-child td {
	border-bottom: 0;
}

.nxc-bubble .noulek-embed-md__table tbody tr.noulek-embed-md__row--total td {
	border-top: 1px solid #e9edf2;
	border-bottom: 0;
	font-weight: 600;
	background: #fff;
}

.nxc-bubble .noulek-embed-md__table tbody tr.noulek-embed-md__row--total:hover td {
	background: #f9fafb;
}

.nxc-bubble .noulek-embed-md__cell--align-right,
.nxc-bubble .noulek-embed-md__cell--num {
	text-align: right;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.nxc-bubble .noulek-embed-md__cell--align-center {
	text-align: center;
}

.nxc-bubble .noulek-embed-md__cell--align-left {
	text-align: left;
}

.nxc-bubble .noulek-embed-md__cell--header-num {
	text-align: right;
}

/* Search: unchanged compact table styling (out of scope for this UX pass) */
.nxs-answer-text .noulek-embed-md__table-wrap {
	margin: 0 0 0.65em;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.nxs-answer-text .noulek-embed-md__table {
	width: 100%;
	min-width: min(100%, 12rem);
	border-collapse: collapse;
	font-size: 0.8125rem;
	line-height: 1.45;
}

.nxs-answer-text .noulek-embed-md__table th,
.nxs-answer-text .noulek-embed-md__table td {
	padding: 0.4em 0.6em;
	border: 1px solid var(--noulek-border-strong, rgba(0, 0, 0, 0.1));
	vertical-align: top;
}

.nxs-answer-text .noulek-embed-md__table th {
	font-weight: 600;
	font-size: 0.78rem;
	color: var(--noulek-text-secondary, #6e6e73);
	background: var(--noulek-surface-muted, rgba(0, 0, 0, 0.03));
}

.nxs-answer-text .noulek-embed-md__cell--align-right,
.nxs-answer-text .noulek-embed-md__cell--num {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.noulek-src-card__fragments {
	margin-top: 0.35rem;
}

.noulek-src-fragments-list {
	margin: 0.35rem 0 0;
	padding-left: 1rem;
	font-size: 0.8125rem;
	line-height: 1.45;
	color: var(--noulek-text-secondary, #6e6e73);
}

.noulek-src-fragments-list__label {
	font-weight: 600;
	color: var(--noulek-text, #1d1d1f);
}
