/**
 * CIX Connect AI — Stable widget (ol3 architecture, enterprise skin).
 * No all:initial · no contain · opacity-only visibility.
 */

#cix-chat-root {
	position: fixed;
	bottom: 24px;
	z-index: 2147483647 !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	box-sizing: border-box;
	pointer-events: none;
	isolation: isolate;
}

#cix-chat-root[data-position="left"] {
	left: 24px;
	right: auto;
}

#cix-chat-root[data-position="right"] {
	right: 24px;
	left: auto;
}

#cix-chat-root *,
#cix-chat-root *::before,
#cix-chat-root *::after {
	box-sizing: border-box;
}

#cix-chat-launcher {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
	pointer-events: auto;
	touch-action: manipulation;
	transition: opacity 0.2s ease, transform 0.2s ease;
	z-index: 2147483647 !important;
}

#cix-chat-launcher svg {
	width: 28px;
	height: 28px;
	pointer-events: none;
}

#cix-chat-panel {
	position: fixed;
	bottom: 24px;
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 680px;
	max-height: calc(100vh - 100px);
	background: var(--cix-panel-bg, #111318);
	color: var(--cix-label, #f3f4f6);
	border-radius: 16px;
	border: 1px solid var(--cix-widget-accent, rgba(255, 198, 92, 0.22));
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
	transform: translateY(10px) scale(0.98);
	transition: opacity 0.22s ease, transform 0.22s ease;
	visibility: visible;
	z-index: 2147483647 !important;
}

#cix-chat-root[data-position="left"] #cix-chat-panel {
	left: 24px;
	right: auto;
}

#cix-chat-root[data-position="right"] #cix-chat-panel {
	right: 24px;
	left: auto;
}

#cix-chat-root.is-open #cix-chat-panel {
	opacity: 1;
	pointer-events: auto;
	transform: none;
}

#cix-chat-root.is-open #cix-chat-launcher {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.92);
}

.cix-chat-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--cix-card-bg, #1a1a1f) 0%, color-mix(in srgb, var(--cix-card-bg, #252530) 70%, #000) 100%);
	border-bottom: 1px solid var(--cix-widget-accent, rgba(255, 198, 92, 0.15));
	flex-shrink: 0;
}

.cix-chat-head .cix-chat-av {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 198, 92, 0.15);
	border: 1px solid rgba(255, 198, 92, 0.35);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	color: #ffc65c;
	flex-shrink: 0;
}

.cix-chat-head-meta {
	flex: 1;
	min-width: 0;
}

.cix-chat-head .cix-chat-nm {
	font-weight: 700;
	font-size: 15px;
	color: #ffffff;
	margin: 0;
}

.cix-entity-status {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 4px 0 0;
	font-size: 11px;
	color: #9ca3af;
}

.cix-entity-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
	animation: cix-entity-pulse 2s ease infinite;
}

.cix-entity-pulse {
	position: relative;
}

#cix-entity-status[data-state="researching"] .cix-entity-dot,
#cix-entity-status[data-state="learning"] .cix-entity-dot {
	background: #60a5fa;
	box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.45);
}

#cix-entity-status[data-state="escalation"] .cix-entity-dot {
	background: #f59e0b;
}

@keyframes cix-entity-pulse {
	0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
	70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
	100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.cix-chat-msg.bot.cix-cognition::after {
	content: '';
	display: inline-block;
	width: 4px;
	height: 4px;
	margin-left: 4px;
	border-radius: 50%;
	background: #ffc65c;
	animation: cix-entity-pulse 1.2s ease infinite;
	vertical-align: middle;
}

.cix-chat-head .cix-chat-bz {
	font-size: 12px;
	color: #9ca3af;
	margin: 2px 0 0;
}

.cix-chat-close {
	margin-left: auto;
	background: transparent;
	border: none;
	color: #d1d5db;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
	touch-action: manipulation;
}

.cix-chat-body {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: var(--cix-panel-bg, #0f1014);
	-webkit-overflow-scrolling: touch;
}

.cix-chat-msg {
	max-width: 88%;
	padding: 10px 12px;
	border-radius: 12px;
	margin-bottom: 10px;
	font-size: 14px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.cix-chat-msg.bot {
	background: var(--cix-card-bg, #1f2937);
	border: 1px solid var(--cix-border, #374151);
	color: var(--cix-label, #e5e7eb);
}

.cix-chat-msg.me {
	background: var(--cix-primary, var(--cix-brand, #ff6b00));
	color: #ffffff;
	margin-left: auto;
	border: 1px solid rgba(255, 198, 92, 0.4);
}

.cix-chat-foot {
	padding: 12px;
	background: var(--cix-widget-foot, #16181e);
	border-top: 1px solid var(--cix-border, #2d323c);
	flex-shrink: 0;
}

.cix-chat-foot input,
.cix-chat-foot select {
	width: 100%;
	padding: 10px 12px;
	margin-bottom: 8px;
	border: 1px solid #374151;
	border-radius: 8px;
	font-size: 14px;
	background: #0f1014;
	color: #f3f4f6;
}

.cix-chat-foot input.bad,
.cix-chat-foot select.bad {
	border-color: #ef4444;
}

.cix-chat-err {
	color: #f87171;
	font-size: 12px;
	margin: -4px 0 8px;
}

.cix-chat-send {
	background: var(--cix-button-bg, var(--cix-brand, #ff6b00));
	color: #fff;
	font-weight: 700;
	border: none;
	border-radius: 8px;
	padding: 11px;
	cursor: pointer;
	width: 100%;
	font-size: 14px;
	touch-action: manipulation;
}

.cix-chat-send:disabled {
	opacity: 0.55;
	cursor: default;
}

.cix-chat-bar {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	background: var(--cix-widget-foot, #16181e);
	border-top: 1px solid var(--cix-border, #2d323c);
	flex-shrink: 0;
}

.cix-chat-bar input {
	flex: 1;
	padding: 10px 14px;
	border: 1px solid #374151;
	border-radius: 20px;
	font-size: 14px;
	background: #0f1014;
	color: #f3f4f6;
}

.cix-chat-bar button {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--cix-button-bg, var(--cix-brand, #ff6b00));
	color: #fff;
	border: none;
	cursor: pointer;
	flex-shrink: 0;
	touch-action: manipulation;
}

.cix-chat-credit {
	text-align: center;
	font-size: 11px;
	color: var(--cix-muted, #6b7280);
	padding: 6px;
	background: var(--cix-widget-foot, #16181e);
	flex-shrink: 0;
}

@media (max-width: 1024px) {
	#cix-chat-root {
		bottom: 18px;
	}

	#cix-chat-root[data-position="left"] {
		left: 18px;
	}

	#cix-chat-root[data-position="right"] {
		right: 18px;
	}

	#cix-chat-panel {
		width: calc(100vw - 24px);
		height: min(92vh, 720px);
		max-height: calc(100vh - 48px);
		bottom: 18px;
		border-radius: 14px;
	}

	#cix-chat-root[data-position="left"] #cix-chat-panel {
		left: 12px;
	}

	#cix-chat-root[data-position="right"] #cix-chat-panel {
		right: 12px;
	}
}
