/*
 * flex:1 (not height:100%) so this correctly shares its parent's height
 * with siblings when there are any — on the live page it's the sole child
 * of noti-chat-page.php's flex-1 min-h-0 wrapper (behaves identically to
 * height:100% there), but the sandboxed test page (test-page.php) adds a
 * banner + a settings panel as siblings BEFORE this, and a fixed
 * height:100% would then overflow the parent instead of yielding space to
 * them.
 */
.noti-chat-root {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	max-width: 48rem;
	margin: 0 auto;
	width: 100%;
	font-family: 'Inter', sans-serif;
}

.noti-chat-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 1.5rem 0.5rem;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.noti-chat-empty {
	margin: auto;
	text-align: center;
	max-width: 32rem;
	padding: 1rem;
}

.noti-chat-empty-avatar {
	width: 56px;
	height: 56px;
	margin: 0 auto 1rem;
	border-radius: 9999px;
	background: linear-gradient(135deg, #4F10B8, #3B0993);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.4rem;
	box-shadow: 0 10px 25px rgba(79, 16, 184, 0.35);
}

.noti-chat-empty h1 {
	font-size: 1.4rem;
	font-weight: 900;
	color: #0f172a;
	margin-bottom: 0.5rem;
}

.noti-chat-empty p {
	color: #64748b;
	font-size: 0.9rem;
	font-weight: 500;
	margin-bottom: 1.25rem;
}

.noti-chat-suggestions {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.noti-chat-suggestions button {
	text-align: left;
	background: #fff;
	border: 1px solid rgba(148, 163, 184, 0.4);
	border-radius: 0.75rem;
	padding: 0.65rem 1rem;
	font-size: 0.85rem;
	font-weight: 600;
	color: #334155;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.noti-chat-suggestions button:hover {
	border-color: #4F10B8;
	background: rgba(79, 16, 184, 0.04);
}

.noti-chat-row {
	display: flex;
	gap: 0.75rem;
	max-width: 100%;
}

.noti-chat-row.is-user {
	justify-content: flex-end;
}

.noti-chat-bubble {
	font-size: 0.9rem;
	line-height: 1.55;
	font-weight: 500;
	white-space: pre-wrap;
	word-break: break-word;
}

.noti-chat-row.is-user .noti-chat-bubble {
	background: #4F10B8;
	color: #fff;
	padding: 0.65rem 1rem;
	border-radius: 1rem 1rem 0.25rem 1rem;
	max-width: 80%;
}

.noti-chat-row.is-assistant .noti-chat-bubble {
	color: #1e293b;
	padding-top: 0.35rem;
	max-width: 80%;
}

.noti-chat-typing {
	display: inline-flex;
	gap: 4px;
	padding-top: 0.5rem;
}

.noti-chat-typing span {
	width: 6px;
	height: 6px;
	border-radius: 9999px;
	background: #94a3b8;
	animation: noti-chat-bounce 1.2s infinite ease-in-out;
}

.noti-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.noti-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

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

.noti-chat-form {
	flex-shrink: 0;
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	background: #fff;
	border: 1px solid rgba(148, 163, 184, 0.4);
	border-radius: 1.25rem;
	padding: 0.5rem 0.5rem 0.5rem 0.75rem;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.noti-chat-send {
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	border-radius: 9999px;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.15s ease, opacity 0.15s ease;
}

/*
 * Pinned to the page's top-right, not the input bar — a "+" sitting next to
 * the textarea reads as "attach a file" (the universal convention), which
 * is exactly the confusion this was moved to avoid. Fixed positioning
 * keeps it aligned with noti-chat-page.php's minimal top bar regardless of
 * how tall the message list gets.
 */
.noti-chat-new {
	position: fixed;
	top: 10px;
	right: 16px;
	z-index: 20;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	height: 36px;
	padding: 0 0.85rem;
	border-radius: 9999px;
	border: 1px solid rgba(148, 163, 184, 0.4);
	background: #fff;
	color: #475569;
	font-family: 'Inter', sans-serif;
	font-size: 0.75rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
	transition: background 0.15s ease, border-color 0.15s ease;
}

.noti-chat-new:hover {
	background: #f8fafc;
	border-color: rgba(148, 163, 184, 0.7);
}

@media (max-width: 520px) {
	.noti-chat-new span {
		display: none;
	}
	.noti-chat-new {
		padding: 0;
		width: 36px;
		justify-content: center;
	}
}

.noti-chat-send {
	background: #4F10B8;
	color: #fff;
}

.noti-chat-send:hover {
	background: #3B0993;
}

.noti-chat-send:disabled {
	opacity: 0.4;
	cursor: default;
}

.noti-chat-input {
	flex: 1 1 auto;
	border: none;
	outline: none;
	resize: none;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 500;
	line-height: 1.4;
	max-height: 160px;
	padding: 0.4rem 0;
}

.noti-chat-disclaimer {
	text-align: center;
	font-size: 0.7rem;
	color: #94a3b8;
	font-weight: 500;
	margin-top: 0.6rem;
}

.noti-chat-error {
	color: #dc2626;
	font-size: 0.8rem;
	font-weight: 600;
}

/*
 * Deliberately NOT styled like a Noti message row (no avatar column, its
 * own background/border) — must read as a distinct, clearly-labeled slot,
 * never as part of Noti's own answer.
 */
.noti-chat-sponsor {
	max-width: 80%;
	background: #fffbeb;
	border: 1px solid #fde68a;
	border-radius: 0.85rem;
	padding: 0.75rem 1rem;
}

.noti-chat-sponsor-label {
	display: inline-block;
	font-size: 0.65rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #92400e;
	background: #fef3c7;
	border-radius: 9999px;
	padding: 0.15rem 0.5rem;
	margin-bottom: 0.5rem;
}

.noti-chat-sponsor-body {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
}

.noti-chat-sponsor-logo {
	width: 36px;
	height: 36px;
	border-radius: 0.5rem;
	object-fit: cover;
	flex-shrink: 0;
}

.noti-chat-sponsor-text strong {
	display: block;
	font-size: 0.85rem;
	font-weight: 800;
	color: #1e293b;
}

.noti-chat-sponsor-text p {
	margin: 0.15rem 0 0;
	font-size: 0.8rem;
	color: #57534e;
	line-height: 1.4;
}

.noti-chat-sponsor-cta {
	display: inline-block;
	margin-top: 0.6rem;
	font-size: 0.75rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: #92400e;
	text-decoration: underline;
}

@media (max-width: 520px) {
	.noti-chat-sponsor {
		max-width: 100%;
	}
}

/* Sandboxed test page (includes/test-page.php) — a persistent, hard-to-miss
   banner so an admin never mistakes this for the live production chat. */
.noti-test-banner {
	flex-shrink: 0;
	background: #fef3c7;
	border-bottom: 1px solid #fde68a;
	color: #78350f;
	font-family: 'Inter', sans-serif;
	font-size: 0.8rem;
	font-weight: 600;
	padding: 0.6rem 1rem;
	text-align: center;
}

.noti-test-banner-badge {
	display: inline-block;
	background: #92400e;
	color: #fff;
	font-size: 0.65rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	border-radius: 9999px;
	padding: 0.15rem 0.6rem;
	margin-right: 0.5rem;
}

.noti-test-settings {
	flex-shrink: 0;
	font-family: 'Inter', sans-serif;
	border-bottom: 1px solid rgba(148, 163, 184, 0.3);
	background: #f8fafc;
	padding: 0.5rem 1rem;
}

.noti-test-settings summary {
	cursor: pointer;
	font-size: 0.8rem;
	font-weight: 700;
	color: #334155;
	padding: 0.35rem 0;
}

.noti-test-settings form {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 0.5rem 0 0.75rem;
}

.noti-test-settings label {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	font-size: 0.75rem;
	font-weight: 700;
	color: #475569;
}

.noti-test-settings input,
.noti-test-settings textarea {
	font-family: 'Inter', sans-serif;
	font-size: 0.8rem;
	font-weight: 500;
	color: #1e293b;
	border: 1px solid rgba(148, 163, 184, 0.4);
	border-radius: 0.5rem;
	padding: 0.5rem 0.65rem;
	resize: vertical;
}

.noti-test-settings button {
	align-self: flex-start;
	background: #334155;
	color: #fff;
	border: none;
	border-radius: 0.5rem;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	padding: 0.5rem 1rem;
	cursor: pointer;
}

.noti-test-settings button:hover {
	background: #1e293b;
}

.noti-test-settings .description {
	font-size: 0.7rem;
	color: #94a3b8;
	font-weight: 500;
	margin: -0.25rem 0 0;
}

.noti-test-model-notes {
	list-style: none;
	margin: 0;
	padding: 0.5rem 0.65rem;
	background: #fff;
	border: 1px solid rgba(148, 163, 184, 0.3);
	border-radius: 0.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.noti-test-model-notes li {
	font-size: 0.75rem;
	font-weight: 500;
	color: #475569;
}

.noti-test-model-notes li strong {
	color: #1e293b;
	font-weight: 700;
}

.noti-compare-model-row {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0.6rem;
}

@media (max-width: 720px) {
	.noti-compare-model-row {
		grid-template-columns: 1fr;
	}
}

/*
 * 3-column live comparator (includes/test-page.php) — unlike the single
 * noti-chat-root thread, this needs the page's full width to give each
 * model column room, so it isn't centered/max-width-capped the way
 * noti-chat-root is.
 */
.noti-compare-root {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	padding: 0 1rem;
	font-family: 'Inter', sans-serif;
}

/*
 * Hidden by default (desktop shows every column at once via the grid below,
 * so there's nothing to switch between) — only display:flex'd back on under
 * the mobile breakpoint further down, where it becomes the way to pick
 * which single column is showing.
 */
.noti-compare-tabs {
	display: none;
	gap: 0.4rem;
	overflow-x: auto;
	padding: 0.75rem 0 0;
	flex-shrink: 0;
	-webkit-overflow-scrolling: touch;
}

.noti-compare-tab {
	flex-shrink: 0;
	padding: 0.5rem 0.9rem;
	border-radius: 9999px;
	border: 1px solid rgba(148, 163, 184, 0.4);
	background: #fff;
	font-family: 'Inter', sans-serif;
	font-size: 0.75rem;
	font-weight: 700;
	color: #475569;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.noti-compare-tab.is-active {
	background: #4F10B8;
	border-color: #4F10B8;
	color: #fff;
}

.noti-compare-columns {
	flex: 1 1 auto;
	min-height: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
	gap: 1rem;
	padding: 1rem 0;
}

.noti-compare-col {
	display: flex;
	flex-direction: column;
	min-height: 0;
	border: 1px solid rgba(148, 163, 184, 0.35);
	border-radius: 0.75rem;
	background: #fff;
	overflow: hidden;
}

.noti-compare-col-header {
	flex-shrink: 0;
	font-size: 0.75rem;
	font-weight: 800;
	color: #fff;
	background: #4F10B8;
	padding: 0.5rem 0.75rem;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.noti-compare-col-messages {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 0.85rem;
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
}

.noti-compare-row {
	display: flex;
	max-width: 100%;
}

.noti-compare-row.is-user {
	justify-content: flex-end;
}

.noti-compare-bubble {
	font-size: 0.85rem;
	line-height: 1.5;
	font-weight: 500;
	white-space: pre-wrap;
	word-break: break-word;
	max-width: 100%;
}

.noti-compare-row.is-user .noti-compare-bubble {
	background: #4F10B8;
	color: #fff;
	padding: 0.5rem 0.75rem;
	border-radius: 0.85rem 0.85rem 0.2rem 0.85rem;
}

.noti-compare-row.is-assistant .noti-compare-bubble {
	color: #1e293b;
}

/*
 * Mobile: 3 columns side by side has no room to breathe, and stacking all 3
 * full-height panels would mean scrolling through 3 separate chat threads
 * just to see one reply — so instead, show one column at a time (full
 * available height, like a normal single chat) with the tab bar above to
 * switch. Nothing is destroyed on switch: a hidden column keeps its history
 * and scroll position, .noti-compare-tab click handlers in noti-compare.js
 * just toggle which .is-active column is visible.
 */
@media (max-width: 900px) {
	.noti-compare-root {
		padding: 0 0.75rem;
	}

	.noti-compare-tabs {
		display: flex;
	}

	.noti-compare-columns {
		display: flex;
		flex-direction: column;
		min-height: 0;
	}

	.noti-compare-col {
		display: none;
	}

	.noti-compare-col.is-active {
		display: flex;
		flex: 1 1 auto;
		min-height: 0;
	}

	/* The active tab already names the model — repeating it as a header
	   inside the single visible column would just be the same label twice. */
	.noti-compare-col-header {
		display: none;
	}
}

.noti-compare-form {
	flex-shrink: 0;
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	background: #fff;
	border: 1px solid rgba(148, 163, 184, 0.4);
	border-radius: 1.25rem;
	padding: 0.5rem 0.5rem 0.5rem 0.75rem;
	margin-bottom: 0.75rem;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.noti-compare-input {
	flex: 1 1 auto;
	border: none;
	outline: none;
	resize: none;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 500;
	line-height: 1.4;
	max-height: 160px;
	padding: 0.4rem 0;
}

.noti-compare-send {
	flex-shrink: 0;
	width: 34px;
	height: 34px;
	border-radius: 9999px;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	background: #4F10B8;
	color: #fff;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.noti-compare-send:hover {
	background: #3B0993;
}

.noti-compare-send:disabled {
	opacity: 0.4;
	cursor: default;
}

/*
 * iOS Safari auto-zooms the page on focus for any text input under 16px —
 * these are otherwise sized to match the rest of the compact desktop UI
 * (0.9rem/0.8rem, i.e. ~13-14px), so bump them to exactly 16px only where
 * it matters (mobile, and only on the fields people actually type into).
 * Also give the send button and tab pills a real touch target (Apple/Google
 * both recommend ~44px) instead of the tighter desktop sizing.
 */
@media (max-width: 900px) {
	.noti-compare-input,
	.noti-test-settings input,
	.noti-test-settings textarea {
		font-size: 16px;
	}

	.noti-compare-send {
		width: 44px;
		height: 44px;
	}

	.noti-compare-tab {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
	}
}
