/* ── AI Chat Widget ─────────────────────────────────────────────────────── */

#alms-chat-widget {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

/* ── Toggle bubble ─────────────────────────────────────────────────────── */

#alms-chat-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: #1a5c7a;
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
	transition: background .2s, transform .15s;
	margin-left: auto;
}

#alms-chat-toggle:hover {
	background: #154d68;
	transform: scale(1.06);
}

#alms-chat-toggle:focus-visible {
	outline: 3px solid #1a5c7a;
	outline-offset: 3px;
}

/* ── Chat pane ─────────────────────────────────────────────────────────── */

#alms-chat-pane {
	display: flex;
	flex-direction: column;
	width: 340px;
	max-height: 480px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
	overflow: hidden;
	margin-bottom: 12px;
	border: 1px solid rgba(0, 0, 0, .08);
}

#alms-chat-pane[hidden] {
	display: none;
}

/* ── Header ────────────────────────────────────────────────────────────── */

#alms-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	background: #1a5c7a;
	color: #fff;
	flex-shrink: 0;
}

#alms-chat-title {
	font-weight: 600;
	font-size: 14px;
	letter-spacing: .01em;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

#alms-chat-user {
	font-size: 10px;
	font-weight: 400;
	opacity: .8;
	letter-spacing: .02em;
}

#alms-chat-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	border-radius: 4px;
	opacity: .8;
	transition: opacity .15s;
	padding: 0;
}

#alms-chat-close:hover {
	opacity: 1;
}

#alms-chat-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 1px;
}

/* ── Messages area ─────────────────────────────────────────────────────── */

#alms-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f7f8fa;
}

.alms-chat-bubble {
	max-width: 82%;
	padding: 9px 12px;
	border-radius: 14px;
	word-wrap: break-word;
	font-size: 13.5px;
	line-height: 1.45;
}

.alms-chat-user {
	align-self: flex-end;
	background: #1a5c7a;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.alms-chat-assistant {
	align-self: flex-start;
	background: #fff;
	color: #1a1a1a;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}

/* Typing indicator */
.alms-chat-typing {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 10px 14px;
}

.alms-chat-typing span {
	display: inline-block;
	width: 7px;
	height: 7px;
	background: #9ca3af;
	border-radius: 50%;
	animation: alms-chat-dot .9s infinite ease-in-out;
}

.alms-chat-typing span:nth-child(2) { animation-delay: .15s; }
.alms-chat-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes alms-chat-dot {
	0%, 80%, 100% { transform: scale(.7); opacity: .5; }
	40%            { transform: scale(1);  opacity: 1;   }
}

/* ── Escalated banner ──────────────────────────────────────────────────── */

#alms-chat-escalated {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background: #edfaef;
	border-top: 1px solid #b8dfc0;
	color: #1a5c2a;
	font-size: 12.5px;
	font-weight: 500;
	flex-shrink: 0;
}

#alms-chat-escalated[hidden] {
	display: none;
}

/* ── Input area ────────────────────────────────────────────────────────── */

#alms-chat-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	background: #fff;
	border-top: 1px solid #e5e7eb;
	flex-shrink: 0;
}

#alms-chat-input {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 8px 10px;
	font-family: inherit;
	font-size: 13.5px;
	line-height: 1.4;
	color: #1a1a1a;
	background: #fff;
	outline: none;
	transition: border-color .15s;
	max-height: 100px;
	overflow-y: auto;
}

#alms-chat-input:focus {
	border-color: #1a5c7a;
	box-shadow: 0 0 0 2px rgba(26, 92, 122, .15);
}

#alms-chat-input:disabled {
	background: #f3f4f6;
	color: #9ca3af;
	cursor: not-allowed;
}

#alms-chat-send {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	flex-shrink: 0;
	background: #1a5c7a;
	color: #fff;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background .15s;
	padding: 0;
}

#alms-chat-send:hover {
	background: #154d68;
}

#alms-chat-send:disabled {
	background: #9ca3af;
	cursor: not-allowed;
}

#alms-chat-send:focus-visible {
	outline: 3px solid #1a5c7a;
	outline-offset: 2px;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media ( max-width: 400px ) {
	#alms-chat-widget {
		right: 12px;
		bottom: 12px;
	}
	#alms-chat-pane {
		width: calc( 100vw - 24px );
		max-height: 60vh;
	}
}
