/**
 * ESEO AI Assistant — public chat widget.
 * Scoped with .eseo-chat to avoid theme conflicts.
 */

.eseo-chat,
.eseo-chat * {
	box-sizing: border-box;
}

.eseo-chat {
	--eseo-primary: #0b3b36;
	--eseo-accent: #c9a227;
	--eseo-ink: #13201e;
	--eseo-muted: #5d6b68;
	--eseo-line: #dfe7e4;
	--eseo-surface: #ffffff;
	--eseo-soft: #f3f7f5;
	--eseo-danger: #b42318;
	--eseo-radius: 18px;
	position: fixed;
	bottom: 22px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--eseo-ink);
	-webkit-font-smoothing: antialiased;
}

.eseo-chat--right {
	right: 22px;
}

.eseo-chat--left {
	left: 22px;
}

.eseo-chat [hidden] {
	display: none !important;
}

.eseo-chat button,
.eseo-chat input,
.eseo-chat textarea,
.eseo-chat select {
	font: inherit;
}

.eseo-chat input,
.eseo-chat textarea,
.eseo-chat select {
	color: inherit;
}

.eseo-chat button {
	cursor: pointer;
}

.eseo-chat :focus-visible {
	outline: 3px solid var(--eseo-accent);
	outline-offset: 2px;
}

/* Launcher */
.eseo-chat-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 56px;
	padding: 0 20px 0 16px;
	border: 0;
	border-radius: 999px;
	background: var(--eseo-primary);
	color: #fff;
	box-shadow: 0 12px 30px rgba(11, 59, 54, 0.28), 0 2px 6px rgba(0, 0, 0, 0.12);
	transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.eseo-chat-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 36px rgba(11, 59, 54, 0.34), 0 3px 8px rgba(0, 0, 0, 0.14);
}

.eseo-chat-launcher-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
}

.eseo-chat-launcher-label {
	font-weight: 650;
	letter-spacing: 0.01em;
	white-space: nowrap;
}

/* Panel */
.eseo-chat-panel {
	position: absolute;
	bottom: 72px;
	display: flex;
	flex-direction: column;
	width: 390px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 120px);
	overflow: hidden;
	background: var(--eseo-surface);
	border: 1px solid rgba(15, 45, 41, 0.12);
	border-radius: var(--eseo-radius);
	box-shadow: 0 26px 70px rgba(7, 30, 27, 0.28), 0 6px 20px rgba(7, 30, 27, 0.12);
	animation: eseo-chat-in 0.22s ease both;
}

.eseo-chat--right .eseo-chat-panel {
	right: 0;
}

.eseo-chat--left .eseo-chat-panel {
	left: 0;
}

@keyframes eseo-chat-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.eseo-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 16px 15px;
	background:
		radial-gradient(120% 160% at 100% 0%, rgba(201, 162, 39, 0.28), transparent 55%),
		linear-gradient(135deg, var(--eseo-primary), #0f4a43 72%);
	color: #fff;
	flex: 0 0 auto;
}

.eseo-chat-brand {
	display: flex;
	align-items: center;
	gap: 11px;
	min-width: 0;
}

.eseo-chat-logo {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 12px;
	background: var(--eseo-accent);
	color: #1f2a12;
	font-weight: 800;
	font-size: 19px;
	letter-spacing: -0.03em;
	flex: 0 0 auto;
}

.eseo-chat-brand h2 {
	margin: 0;
	padding: 0;
	font-size: 15.5px;
	font-weight: 700;
	line-height: 1.25;
	color: #fff;
	letter-spacing: 0.01em;
}

.eseo-chat-brand p {
	margin: 2px 0 0;
	font-size: 12px;
	line-height: 1.35;
	color: rgba(255, 255, 255, 0.78);
}

.eseo-chat-header-actions {
	display: flex;
	gap: 4px;
	flex: 0 0 auto;
}

.eseo-chat-icon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: inherit;
	opacity: 0.85;
}

.eseo-chat-icon-button:hover {
	background: rgba(255, 255, 255, 0.13);
	opacity: 1;
}

.eseo-chat-body {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	background: var(--eseo-soft);
}

.eseo-chat-messages {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 16px 14px 6px;
	scrollbar-width: thin;
	scrollbar-color: #c6d3cf transparent;
}

.eseo-chat-messages::-webkit-scrollbar {
	width: 7px;
}

.eseo-chat-messages::-webkit-scrollbar-thumb {
	background: #c6d3cf;
	border-radius: 99px;
}

.eseo-msg {
	display: flex;
	margin: 0 0 12px;
}

.eseo-msg--user {
	justify-content: flex-end;
}

.eseo-msg--system {
	justify-content: center;
}

.eseo-msg-bubble {
	max-width: 86%;
	padding: 11px 13px;
	border-radius: 15px 15px 15px 5px;
	background: #fff;
	color: var(--eseo-ink);
	border: 1px solid rgba(15, 45, 41, 0.08);
	box-shadow: 0 1px 2px rgba(7, 30, 27, 0.04);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font-size: 14px;
	line-height: 1.52;
}

.eseo-msg--user .eseo-msg-bubble {
	border-radius: 15px 15px 5px 15px;
	background: var(--eseo-primary);
	color: #fff;
	border-color: transparent;
}

.eseo-msg--system .eseo-msg-bubble {
	max-width: 96%;
	background: #fff6e0;
	border-color: #f0d48a;
	color: #5f4600;
	font-size: 12.5px;
	text-align: center;
}

.eseo-msg-time {
	display: block;
	margin-top: 5px;
	font-size: 10.5px;
	opacity: 0.58;
}

.eseo-msg-sources {
	margin: 8px 0 0;
	padding: 8px 0 0;
	border-top: 1px solid rgba(15, 45, 41, 0.1);
}

.eseo-msg-sources-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.eseo-msg-sources-label {
	display: block;
	margin-bottom: 3px;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: var(--eseo-muted);
}

.eseo-msg-sources li {
	margin: 0;
}

.eseo-msg-sources a {
	display: inline-block;
	padding: 2px 0;
	color: #0a5c52;
	font-size: 12.5px;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.eseo-msg-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 9px;
}

.eseo-msg-action {
	padding: 6px 10px;
	border: 1px solid rgba(11, 59, 54, 0.24);
	border-radius: 999px;
	background: #fff;
	color: var(--eseo-primary);
	font-size: 12px;
	font-weight: 650;
}

.eseo-msg-action:hover {
	background: var(--eseo-primary);
	color: #fff;
}

/* Suggestions */
.eseo-chat-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 4px 14px 10px;
	flex: 0 0 auto;
}

.eseo-suggestion {
	padding: 6px 10px;
	border: 1px solid rgba(11, 59, 54, 0.18);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.85);
	color: var(--eseo-primary);
	font-size: 12px;
	line-height: 1.35;
	text-align: left;
}

.eseo-suggestion:hover {
	background: #fff;
	border-color: var(--eseo-primary);
}

/* Typing */
.eseo-chat-typing {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 16px 8px;
	flex: 0 0 auto;
}

.eseo-typing-dots {
	display: inline-flex;
	gap: 3px;
	padding: 8px 11px;
	border-radius: 14px 14px 14px 5px;
	background: #fff;
	border: 1px solid rgba(15, 45, 41, 0.08);
}

.eseo-typing-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #8aa19b;
	animation: eseo-typing 1.1s infinite ease-in-out;
}

.eseo-typing-dots span:nth-child(2) {
	animation-delay: 0.14s;
}

.eseo-typing-dots span:nth-child(3) {
	animation-delay: 0.28s;
}

@keyframes eseo-typing {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
	30% { transform: translateY(-4px); opacity: 1; }
}

.eseo-chat-offline {
	margin: 0 14px 8px;
	padding: 8px 10px;
	border: 1px solid #f0d48a;
	border-radius: 10px;
	background: #fff6e0;
	color: #5f4600;
	font-size: 12px;
}

/* Composer */
.eseo-chat-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--eseo-line);
	background: #fff;
	flex: 0 0 auto;
}

.eseo-chat-form textarea {
	flex: 1 1 auto;
	min-height: 42px;
	max-height: 120px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var(--eseo-line);
	border-radius: 12px;
	background: var(--eseo-soft);
	color: var(--eseo-ink);
	resize: none;
	font-size: 14px;
	line-height: 1.45;
}

.eseo-chat-form textarea:focus {
	outline: 2px solid var(--eseo-accent);
	outline-offset: 0;
	background: #fff;
}

.eseo-chat-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: var(--eseo-primary);
	color: #fff;
	flex: 0 0 auto;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.eseo-chat-send:hover {
	transform: translateY(-1px);
}

.eseo-chat-send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
}

/* Footer */
.eseo-chat-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 7px 12px 9px;
	background: #fff;
	flex: 0 0 auto;
}

.eseo-chat-human {
	padding: 4px 0;
	border: 0;
	background: transparent;
	color: var(--eseo-primary);
	font-size: 12px;
	font-weight: 650;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.eseo-chat-branding {
	font-size: 10.5px;
	color: #5f6b68;
	letter-spacing: 0.02em;
}

/* Lead panel */
.eseo-chat-lead {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	flex-direction: column;
	padding: 16px;
	background: #fff;
	overflow-y: auto;
	animation: eseo-chat-in 0.18s ease both;
}

.eseo-chat-lead-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 4px;
}

.eseo-chat-lead-head h3 {
	margin: 0;
	padding: 0;
	font-size: 17px;
	line-height: 1.3;
	color: var(--eseo-ink);
}

.eseo-chat-lead .eseo-chat-icon-button {
	color: var(--eseo-ink);
	opacity: 0.7;
}

.eseo-chat-lead .eseo-chat-icon-button:hover {
	background: var(--eseo-soft);
	opacity: 1;
}

.eseo-chat-lead-intro {
	margin: 0 0 12px;
	color: var(--eseo-muted);
	font-size: 12.5px;
	line-height: 1.45;
}

.eseo-lead-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.eseo-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.eseo-field label {
	font-size: 12px;
	font-weight: 650;
	color: #31413e;
}

.eseo-field input[type="text"],
.eseo-field input[type="email"],
.eseo-field input[type="url"],
.eseo-field textarea {
	width: 100%;
	margin: 0;
	padding: 9px 10px;
	border: 1px solid var(--eseo-line);
	border-radius: 9px;
	background: #fff;
	color: var(--eseo-ink);
	font-size: 13.5px;
	line-height: 1.4;
}

.eseo-field textarea {
	resize: vertical;
	min-height: 84px;
}

.eseo-field input:focus,
.eseo-field textarea:focus {
	outline: 2px solid var(--eseo-accent);
	outline-offset: 0;
	border-color: var(--eseo-accent);
}

.eseo-field-checkbox label {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-weight: 450;
	font-size: 12px;
	line-height: 1.45;
	color: var(--eseo-muted);
}

.eseo-field-checkbox input {
	margin: 2px 0 0;
	width: 16px;
	height: 16px;
	flex: 0 0 auto;
}

.eseo-field-checkbox a {
	color: var(--eseo-primary);
	text-decoration: underline;
}

.eseo-field-error {
	min-height: 0;
	color: var(--eseo-danger);
	font-size: 11.5px;
}

.eseo-field-error:empty {
	display: none;
}

.eseo-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
	opacity: 0 !important;
}

.eseo-lead-status {
	font-size: 12px;
	line-height: 1.45;
}

.eseo-lead-status.is-error {
	color: var(--eseo-danger);
}

.eseo-lead-status.is-success {
	color: #0a6b3f;
}

.eseo-lead-submit {
	width: 100%;
	min-height: 42px;
	border: 0;
	border-radius: 10px;
	background: var(--eseo-primary);
	color: #fff;
	font-weight: 700;
	font-size: 14px;
}

.eseo-lead-submit:hover {
	background: #0a4d46;
}

.eseo-lead-submit:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* Utilities */
.eseo-sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* Mobile */
@media (max-width: 540px) {
	.eseo-chat {
		bottom: 14px;
		right: 14px;
		left: auto;
	}

	.eseo-chat--left {
		left: 14px;
		right: auto;
	}

	.eseo-chat-launcher {
		min-height: 52px;
		padding: 0 16px 0 13px;
	}

	.eseo-chat-launcher-label {
		display: none;
	}

	.eseo-chat-launcher-icon {
		width: 30px;
		height: 30px;
	}

	.eseo-chat-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
	}

	.eseo-chat--right .eseo-chat-panel,
	.eseo-chat--left .eseo-chat-panel {
		right: 0;
		left: 0;
	}

	.eseo-chat-header {
		padding-top: max(16px, env(safe-area-inset-top));
	}

	.eseo-chat-form {
		padding-bottom: max(10px, env(safe-area-inset-bottom));
	}

	.eseo-chat-lead {
		padding-top: max(16px, env(safe-area-inset-top));
		padding-bottom: max(16px, env(safe-area-inset-bottom));
	}

	/* Keep form controls at 16px so iOS does not zoom the page on focus. */
	.eseo-chat-form textarea,
	.eseo-chat .eseo-field input,
	.eseo-chat .eseo-field textarea,
	.eseo-chat .eseo-field select {
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.eseo-chat-panel,
	.eseo-chat-lead {
		animation: none;
	}

	.eseo-chat-launcher,
	.eseo-chat-send {
		transition: none;
	}

	.eseo-typing-dots span {
		animation: none;
		opacity: 0.7;
	}
}
