/*!
 * com_esechatbot widget styles
 * ESE — 2026
 */

#ese-chatbot-root {
	--ese-primary: #d97706;
	--ese-secondary: #0891b2;
	--ese-bg: #ffffff;
	--ese-bg-dark: #1f2937;
	--ese-text: #1f2937;
	--ese-muted: #6b7280;
	--ese-border: #e5e7eb;
	--ese-bubble-user: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
	--ese-bubble-ai: #f3f4f6;
	--ese-shadow: 0 12px 36px rgba(0, 0, 0, .18);
	--ese-radius: 18px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ese-text);
	font-size: 14px;
	line-height: 1.45;
}

#ese-chatbot-root *,
#ese-chatbot-root *::before,
#ese-chatbot-root *::after {
	box-sizing: border-box;
}

.ese-toggle {
	position: fixed;
	bottom: 28px;
	width: 72px;
	height: 72px;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--ese-primary) 0%, #c41a25 100%);
	color: #fff;
	font-size: 30px;
	cursor: pointer;
	box-shadow: var(--ese-shadow);
	z-index: 9998;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s ease, box-shadow .2s ease;
	padding: 0;
}
.ese-toggle:hover { transform: scale(1.08); }
.ese-toggle:focus-visible { outline: 3px solid #1e3a8a; outline-offset: 3px; }
.ese-pos-right { right: 28px; }
.ese-pos-left  { left: 28px; }

.ese-chat {
	position: fixed;
	bottom: 100px;
	width: 390px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 120px);
	background: var(--ese-bg);
	border-radius: var(--ese-radius);
	box-shadow: var(--ese-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	z-index: 9999;
	transform-origin: bottom right;
	animation: eseOpen .28s cubic-bezier(.34, 1.56, .64, 1);
}
.ese-pos-right + .ese-chat { right: 28px; }
.ese-pos-left + .ese-chat  { left: 28px;  transform-origin: bottom left; }
.ese-chat.open { display: flex; }

@keyframes eseOpen {
	from { transform: scale(.85); opacity: 0; }
	to   { transform: scale(1);   opacity: 1; }
}

.ese-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--ese-primary) 0%, var(--ese-secondary) 100%);
	color: #fff;
}
.ese-avatar {
	width: 40px; height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,.25);
	display: flex; align-items: center; justify-content: center;
	font-size: 18px;
}
.ese-title { flex: 1; min-width: 0; }
.ese-title strong { display:block; font-size: 14px; }
.ese-title small  { font-size: 11px; opacity: .85; }

.ese-lang {
	display: flex; gap: 4px;
}
.ese-lang button {
	background: rgba(255,255,255,.18);
	color: #fff;
	border: 0;
	padding: 4px 8px;
	border-radius: 6px;
	font-size: 11px;
	cursor: pointer;
	font-weight: 600;
}
.ese-lang button.active { background: #fff; color: var(--ese-primary); }
.ese-lang button:focus-visible { outline: 2px solid #fff; }

.ese-news {
	background: #fef3c7;
	color: #92400e;
	font-size: 12px;
	padding: 8px 14px;
	overflow: hidden;
	white-space: nowrap;
	position: relative;
}
.ese-news-track {
	display: inline-block;
	padding-left: 100%;
	animation: eseTicker 60s linear infinite;
}
.ese-news a { color: inherit; text-decoration: none; margin-right: 28px; }
@keyframes eseTicker {
	0%   { transform: translateX(0); }
	100% { transform: translateX(-100%); }
}

.ese-msgs {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #fafafa;
}
.ese-msg {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	white-space: pre-wrap;
}
.ese-msg.user {
	align-self: flex-end;
	background: var(--ese-bubble-user);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.ese-msg.ai {
	align-self: flex-start;
	background: var(--ese-bubble-ai);
	color: var(--ese-text);
	border-bottom-left-radius: 4px;
}
.ese-msg.error {
	align-self: flex-start;
	background: #fee2e2;
	color: #991b1b;
	border-bottom-left-radius: 4px;
}
.ese-msg.thinking {
	color: var(--ese-muted);
	font-style: italic;
}
.ese-msg a {
	color: inherit;
	text-decoration: underline;
}

.ese-qr {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 14px 6px;
}
.ese-qr button {
	background: #fff;
	border: 1px solid var(--ese-border);
	border-radius: 14px;
	padding: 6px 11px;
	font-size: 12px;
	cursor: pointer;
	color: var(--ese-text);
	transition: background .15s ease, border-color .15s ease;
}
.ese-qr button:hover { background: #fef3c7; border-color: var(--ese-primary); }
.ese-qr button:focus-visible { outline: 2px solid var(--ese-primary); }

.ese-input {
	display: flex;
	gap: 6px;
	padding: 10px 12px;
	border-top: 1px solid var(--ese-border);
	background: #fff;
}
.ese-input textarea {
	flex: 1;
	border: 1px solid var(--ese-border);
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	min-height: 36px;
	max-height: 100px;
	outline: none;
	color: var(--ese-text);
	background: #fff;
}
.ese-input textarea:focus { border-color: var(--ese-primary); }
.ese-input button {
	background: var(--ese-primary);
	color: #fff;
	border: 0;
	border-radius: 10px;
	padding: 0 14px;
	cursor: pointer;
	font-weight: 600;
}
.ese-input button:disabled {
	background: var(--ese-muted);
	cursor: not-allowed;
}
.ese-input button:focus-visible { outline: 2px solid #1e3a8a; outline-offset: 2px; }

.ese-footer {
	padding: 6px 14px;
	font-size: 11px;
	color: var(--ese-muted);
	text-align: center;
	border-top: 1px solid var(--ese-border);
	background: #fafafa;
}

/* Typing indicator */
.ese-dots span {
	display: inline-block;
	width: 6px; height: 6px; margin: 0 1px;
	background: var(--ese-muted);
	border-radius: 50%;
	animation: eseDots 1.2s infinite;
}
.ese-dots span:nth-child(2) { animation-delay: .15s; }
.ese-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes eseDots {
	0%, 60%, 100% { transform: translateY(0); opacity: .3; }
	30%           { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 480px) {
	.ese-chat {
		right: 16px !important;
		left: 16px !important;
		width: calc(100vw - 32px);
		bottom: 90px;
	}
	.ese-pos-right, .ese-pos-left { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	.ese-chat, .ese-toggle, .ese-news-track, .ese-dots span {
		animation: none !important;
		transition: none !important;
	}
}

/* Language selector dropdown (replaces the EN/IT/ES buttons for the 11-language edition) */
.ese-lang-select {
	background: rgba(255,255,255,.18);
	color: #fff;
	border: 1px solid rgba(255,255,255,.35);
	border-radius: 6px;
	padding: 4px 6px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	max-width: 130px;
	appearance: none;
	-webkit-appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
	background-position: calc(100% - 12px) center, calc(100% - 8px) center;
	background-size: 4px 4px, 4px 4px;
	background-repeat: no-repeat;
	padding-right: 22px;
}
.ese-lang-select option {
	color: #1f2937;
	background: #fff;
}
.ese-lang-select:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Enhanced typing indicator (replaces the basic 3-dot loop) */
.ese-msg.thinking {
	background: linear-gradient(110deg, #f3f4f6 30%, #fef3c7 50%, #f3f4f6 70%);
	background-size: 200% 100%;
	animation: eseShimmer 1.6s ease-in-out infinite;
}
.ese-dots span {
	width: 7px;
	height: 7px;
	background: linear-gradient(135deg, var(--ese-primary), var(--ese-secondary));
	margin: 0 2px;
}
@keyframes eseShimmer {
	0%   { background-position: -100% 0; }
	100% { background-position:  100% 0; }
}

/* Genie lamp SVG icon inside the toggle button + header avatar */
.ese-toggle svg {
	width: 56px;
	height: 56px;
	display: block;
	background: #fff;
	border-radius: 50%;
	padding: 4px;
	box-sizing: border-box;
}
.ese-avatar svg {
	width: 30px;
	height: 30px;
	display: block;
	background: #fff;
	border-radius: 50%;
	padding: 2px;
	box-sizing: border-box;
}
.ese-toggle.open-state {
	font-size: 32px;
}

/* Caos City brand logo inside button and header avatar */
.ese-toggle .ese-logo {
	width: 42px;
	height: 42px;
	object-fit: contain;
	display: block;
	background: #fff;
	border-radius: 50%;
	padding: 3px;
}
.ese-avatar .ese-logo {
	width: 28px;
	height: 28px;
	object-fit: contain;
	display: block;
	background: #fff;
	border-radius: 50%;
}

/* ===== Persona picker (multi-character edition) ===== */
.ese-persona { margin-left: auto; }
.ese-persona-select {
	background: rgba(255,255,255,.18);
	color: #fff;
	border: 1px solid rgba(255,255,255,.35);
	border-radius: 6px;
	padding: 4px 6px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	max-width: 150px;
	appearance: none;
	-webkit-appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
	background-position: calc(100% - 12px) center, calc(100% - 8px) center;
	background-size: 4px 4px, 4px 4px;
	background-repeat: no-repeat;
	padding-right: 22px;
}
.ese-persona-select option { color: #1f2937; background: #fff; }
.ese-persona-select:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Persona photos: circular crop inside the toggle button and the header avatar. */
.ese-toggle .ese-logo,
.ese-avatar .ese-logo {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
	display: block;
}
.ese-avatar { overflow: hidden; }
.ese-toggle { overflow: hidden; }
