/**
 * XKMCM AI Gateway Bridge public widget styles.
 * All selectors are plugin-prefixed to avoid Zibll/ZibPay conflicts.
 */

.xkmcm-ai-gateway-widget,
.xkmcm-ai-gateway-entry {
	box-sizing: border-box;
	font-size: 14px;
	line-height: 1.6;
}

.xkmcm-ai-gateway-widget *,
.xkmcm-ai-gateway-entry * {
	box-sizing: border-box;
}

.xkmcm-ai-gateway-widget--floating {
	position: fixed;
	right: 22px;
	bottom: 24px;
	z-index: 9998;
	font-family: inherit;
}

.xkmcm-ai-gateway-widget__launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: #0d3869;
	color: #fff;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 12px 30px rgba(13, 56, 105, 0.26);
}

.xkmcm-ai-gateway-widget__launcher:hover,
.xkmcm-ai-gateway-widget__launcher:focus {
	background: #164b85;
	color: #fff;
}

.xkmcm-ai-gateway-widget__launcher-mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	font-size: 12px;
	letter-spacing: 0.02em;
}

.xkmcm-ai-gateway-widget--floating .xkmcm-ai-gateway-widget__panel {
	position: absolute;
	right: 0;
	bottom: 58px;
	width: min(380px, calc(100vw - 32px));
	max-height: min(620px, calc(100vh - 120px));
}

.xkmcm-ai-gateway-widget--embedded .xkmcm-ai-gateway-widget__panel {
	width: 100%;
	max-width: 760px;
	margin: 16px 0 0;
}

.xkmcm-ai-gateway-widget.is-closed .xkmcm-ai-gateway-widget__panel {
	display: none;
}

.xkmcm-ai-gateway-widget__panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid rgba(13, 56, 105, 0.12);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.96);
	box-shadow: 0 18px 60px rgba(10, 31, 68, 0.18);
	backdrop-filter: blur(16px);
}

.xkmcm-ai-gateway-widget__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	padding: 16px 18px;
	border-bottom: 1px solid rgba(13, 56, 105, 0.08);
	background: linear-gradient(135deg, rgba(13, 56, 105, 0.08), rgba(255, 255, 255, 0.72));
}

.xkmcm-ai-gateway-widget__header h3 {
	margin: 0 0 4px;
	color: #0d3869;
	font-size: 16px;
	font-weight: 800;
	line-height: 1.35;
}

.xkmcm-ai-gateway-widget__header p {
	margin: 0;
	color: #64748b;
	font-size: 12px;
}

.xkmcm-ai-gateway-widget__close {
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	border: 0;
	border-radius: 50%;
	background: rgba(13, 56, 105, 0.08);
	color: #0d3869;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.xkmcm-ai-gateway-widget--embedded .xkmcm-ai-gateway-widget__close {
	display: none;
}

.xkmcm-ai-gateway-widget__messages {
	display: flex;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	min-height: 180px;
	max-height: 340px;
	padding: 16px;
	background: #f8fafc;
}

.xkmcm-ai-gateway-widget__message {
	max-width: 88%;
	padding: 10px 12px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-break: break-word;
}

.xkmcm-ai-gateway-widget__message--assistant {
	align-self: flex-start;
	background: #fff;
	color: #1f2937;
	border: 1px solid rgba(13, 56, 105, 0.08);
}

.xkmcm-ai-gateway-widget__message--user {
	align-self: flex-end;
	background: #0d3869;
	color: #fff;
}

.xkmcm-ai-gateway-widget__message--error {
	align-self: stretch;
	max-width: 100%;
	background: #fff1f2;
	color: #be123c;
	border: 1px solid #fecdd3;
}

.xkmcm-ai-gateway-widget__form {
	padding: 14px;
	background: #fff;
	border-top: 1px solid rgba(13, 56, 105, 0.08);
}

.xkmcm-ai-gateway-widget__input {
	display: block;
	width: 100%;
	min-height: 82px;
	padding: 10px 12px;
	resize: vertical;
	border: 1px solid rgba(13, 56, 105, 0.16);
	border-radius: 14px;
	outline: none;
	box-shadow: none;
	font: inherit;
	color: #0f172a;
	background: #fff;
}

.xkmcm-ai-gateway-widget__input:focus {
	border-color: #0d3869;
	box-shadow: 0 0 0 3px rgba(13, 56, 105, 0.1);
}

.xkmcm-ai-gateway-widget__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 10px;
}

.xkmcm-ai-gateway-widget__status {
	min-height: 20px;
	color: #64748b;
	font-size: 12px;
}

.xkmcm-ai-gateway-widget__send,
.xkmcm-ai-gateway-entry__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 38px;
	padding: 8px 16px;
	border: 0;
	border-radius: 999px;
	background: #0d3869;
	color: #fff;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
}

.xkmcm-ai-gateway-widget__send:hover,
.xkmcm-ai-gateway-entry__button:hover {
	background: #164b85;
	color: #fff;
}

.xkmcm-ai-gateway-widget__send:disabled {
	cursor: not-allowed;
	opacity: 0.68;
}

.xkmcm-ai-gateway-entry {
	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	padding: 18px;
	border: 1px solid rgba(13, 56, 105, 0.12);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.96);
	box-shadow: 0 14px 36px rgba(10, 31, 68, 0.08);
}

.xkmcm-ai-gateway-entry__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 48px;
	height: 48px;
	border-radius: 16px;
	background: #0d3869;
	color: #fff;
	font-weight: 900;
	letter-spacing: 0.04em;
}

.xkmcm-ai-gateway-entry__body {
	flex: 1 1 auto;
	min-width: 0;
}

.xkmcm-ai-gateway-entry__body h3 {
	margin: 0 0 4px;
	color: #0d3869;
	font-size: 17px;
	font-weight: 800;
}

.xkmcm-ai-gateway-entry__body p {
	margin: 0;
	color: #64748b;
	font-size: 13px;
}

@media screen and (max-width: 640px) {
	.xkmcm-ai-gateway-widget--floating {
		right: 14px;
		bottom: 14px;
	}

	.xkmcm-ai-gateway-widget--floating .xkmcm-ai-gateway-widget__panel {
		width: calc(100vw - 28px);
		bottom: 56px;
	}

	.xkmcm-ai-gateway-entry {
		align-items: flex-start;
		flex-direction: column;
	}
}

/* Step 9 frontend experience enhancements. */
.xkmcm-ai-gateway-widget__toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	border-bottom: 1px solid rgba(13, 56, 105, 0.08);
	background: #fff;
}

.xkmcm-ai-gateway-widget__model {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	font-size: 12px;
	color: #475569;
}

.xkmcm-ai-gateway-widget__model span {
	flex: 0 0 auto;
	font-weight: 700;
	color: #0d3869;
}

.xkmcm-ai-gateway-widget__model select {
	max-width: 180px;
	min-height: 32px;
	border: 1px solid rgba(13, 56, 105, 0.16);
	border-radius: 10px;
	background: #fff;
	color: #0f172a;
	font-size: 12px;
}

.xkmcm-ai-gateway-widget__clear {
	flex: 0 0 auto;
	min-height: 32px;
	padding: 5px 12px;
	border: 1px solid rgba(13, 56, 105, 0.14);
	border-radius: 999px;
	background: #f8fafc;
	color: #0d3869;
	font-weight: 700;
	font-size: 12px;
	cursor: pointer;
}

.xkmcm-ai-gateway-widget__clear:hover,
.xkmcm-ai-gateway-widget__clear:focus {
	background: #eef6ff;
	color: #0d3869;
}

.xkmcm-ai-gateway-widget__usage {
	padding: 8px 14px;
	border-bottom: 1px solid rgba(13, 56, 105, 0.08);
	background: #f8fafc;
	color: #64748b;
	font-size: 12px;
}

.xkmcm-ai-gateway-widget.is-loading .xkmcm-ai-gateway-widget__input {
	background: #f8fafc;
}

.xkmcm-ai-gateway-widget__message--typing {
	color: #64748b;
	letter-spacing: 0.08em;
}

.xkmcm-ai-gateway-widget__message--typing::after {
	content: '';
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-left: 6px;
	border-radius: 50%;
	background: currentColor;
	animation: xkmcm-ai-gateway-pulse 1s infinite ease-in-out;
	vertical-align: middle;
}

@keyframes xkmcm-ai-gateway-pulse {
	0%, 100% {
		opacity: 0.25;
		transform: scale(0.85);
	}
	50% {
		opacity: 1;
		transform: scale(1);
	}
}

@media screen and (max-width: 640px) {
	.xkmcm-ai-gateway-widget--floating .xkmcm-ai-gateway-widget__panel {
		max-height: calc(100vh - 92px);
	}

	.xkmcm-ai-gateway-widget__toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.xkmcm-ai-gateway-widget__model {
		align-items: stretch;
		flex-direction: column;
		gap: 5px;
	}

	.xkmcm-ai-gateway-widget__model select {
		max-width: 100%;
		width: 100%;
	}

	.xkmcm-ai-gateway-widget__clear {
		width: max-content;
	}

	.xkmcm-ai-gateway-widget__messages {
		max-height: 300px;
	}
}
