/* AlyxWeb AI Chatbot — widget styles */

/*
 * SVG Isolation — protect chatbot icons from theme-global SVG resets
 * (Astra, GeneratePress, OceanWP etc. often zero-out or hide SVGs globally)
 * Scoped to .aw-panel only so it never interferes with the launcher icon transitions.
 */
#alyxweb-chatbot-root .aw-panel svg,
#alyxweb-chatbot-root .aw-panel svg * {
	visibility: visible !important;
	opacity: 1 !important;
	display: inline !important;
	max-width: none !important;
	max-height: none !important;
	overflow: visible !important;
	clip: auto !important;
	clip-path: none !important;
	-webkit-clip-path: none !important;
}

#alyxweb-chatbot-root {
	--aw-accent: #6366f1;
	--aw-accent-soft: rgba(99, 102, 241, 0.18);
	--aw-bg: #14141c;
	--aw-panel: #1b1b26;
	--aw-panel-2: #212230;
	--aw-border: rgba(255, 255, 255, 0.08);
	--aw-text: #e9e9f2;
	--aw-text-dim: #9797a8;
	--aw-radius: 18px;
	--aw-launcher-right: 24px;
	--aw-launcher-left: auto;
	--aw-launcher-bottom: 24px;
	--aw-panel-right: 24px;
	--aw-panel-left: auto;
	--aw-panel-bottom: 96px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	position: fixed;
	z-index: 999999;
	bottom: 0;
	right: 0;
}

/* Launcher button */
.aw-launcher {
	position: fixed;
	right: var(--aw-launcher-right);
	left: var(--aw-launcher-left);
	bottom: var(--aw-launcher-bottom);
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(145deg, var(--aw-accent), #4338ca);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(67, 56, 202, 0.45), 0 2px 6px rgba(0,0,0,0.3);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.aw-launcher:hover {
	transform: translateY(-2px) scale(1.04);
	box-shadow: 0 12px 30px rgba(67, 56, 202, 0.55), 0 2px 6px rgba(0,0,0,0.35);
}
/* Launcher icons — use display switching, not opacity, so theme SVG rules can't interfere */
#alyxweb-chatbot-root .aw-launcher svg {
	width: 26px;
	height: 26px;
	stroke: #fff;
	fill: none;
	position: absolute;
	transition: transform 0.2s ease, opacity 0.2s ease;
}
.aw-launcher .aw-icon-close {
	opacity: 0;
	transform: scale(0.5) rotate(-45deg);
}
.aw-launcher .aw-icon-chat {
	opacity: 1;
	transform: scale(1) rotate(0deg);
}
.aw-launcher.open .aw-icon-chat {
	opacity: 0;
	transform: scale(0.5) rotate(45deg);
}
.aw-launcher.open .aw-icon-close {
	opacity: 1;
	transform: scale(1) rotate(0deg);
}

.aw-launcher .aw-dot {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 10px;
	height: 10px;
	background: #34d399;
	border: 2px solid var(--aw-bg);
	border-radius: 50%;
}

/* Chat panel */
.aw-panel {
	position: fixed;
	right: var(--aw-panel-right);
	left: var(--aw-panel-left);
	bottom: var(--aw-panel-bottom);
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 140px);
	background: var(--aw-panel);
	border: 1px solid var(--aw-border);
	border-radius: var(--aw-radius);
	box-shadow: 0 20px 60px rgba(0,0,0,0.5);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease;
}
.aw-panel.open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.aw-header {
	padding: 16px 18px;
	background: linear-gradient(120deg, var(--aw-panel-2), var(--aw-panel));
	border-bottom: 1px solid var(--aw-border);
	display: flex;
	align-items: center;
	gap: 10px;
}
.aw-header-avatar {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	background: linear-gradient(145deg, var(--aw-accent), #4338ca);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	color: #fff;
	flex-shrink: 0;
	overflow: hidden;
}
.aw-header-logo {
	width: 100%;
	height: 100%;
	object-fit: contain;
	border-radius: 8px;
}
.aw-header-text {
	display: flex;
	flex-direction: column;
	line-height: 1.25;
	overflow: hidden;
}
.aw-header-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--aw-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.aw-header-status {
	font-size: 12px;
	color: #34d399;
	display: flex;
	align-items: center;
	gap: 5px;
}
.aw-header-status::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #34d399;
	display: inline-block;
}

/* Messages */
.aw-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.aw-messages::-webkit-scrollbar { width: 6px; }
.aw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.aw-msg {
	max-width: 84%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: aw-pop 0.18s ease;
}
.aw-msg p { margin: 0 0 6px; }
.aw-msg p:last-child { margin-bottom: 0; }
.aw-msg strong { font-weight: 700; }
.aw-msg em { font-style: italic; }
.aw-msg code.aw-code {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
	background: rgba(255,255,255,0.12);
	border-radius: 4px;
	padding: 1px 5px;
}
.aw-msg pre.aw-code-block {
	background: rgba(0,0,0,0.25);
	border-radius: 8px;
	padding: 10px 12px;
	margin: 6px 0;
	overflow-x: auto;
	white-space: pre;
}
.aw-msg pre.aw-code-block code {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
	background: transparent;
}
.aw-msg ul.aw-list {
	margin: 4px 0 4px 16px;
	padding: 0;
	list-style: disc;
}
.aw-msg ul.aw-list li { margin: 2px 0; }
@keyframes aw-pop {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}
.aw-msg.bot {
	align-self: flex-start;
	background: var(--aw-panel-2);
	color: var(--aw-text);
	border-bottom-left-radius: 4px;
}
.aw-msg.user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--aw-accent), #4338ca);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.aw-msg.error {
	align-self: flex-start;
	background: rgba(239, 68, 68, 0.12);
	color: #fca5a5;
	border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Typing indicator */
.aw-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--aw-panel-2);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}
.aw-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--aw-text-dim);
	animation: aw-blink 1.2s infinite ease-in-out;
}
.aw-typing span:nth-child(2) { animation-delay: 0.15s; }
.aw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aw-blink {
	0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
	40% { opacity: 1; transform: scale(1); }
}

/* Input area */
.aw-input-area {
	border-top: 1px solid var(--aw-border);
	background: var(--aw-panel);
	padding: 10px 12px 6px;
}
.aw-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
}
.aw-char-counter {
	font-size: 10.5px;
	color: var(--aw-text-dim);
	text-align: right;
	padding-top: 3px;
	transition: color 0.15s ease;
}
.aw-char-counter.aw-char-warn { color: #fbbf24; }
.aw-input {
	flex: 1;
	resize: none;
	max-height: 90px;
	background: var(--aw-panel-2);
	border: 1px solid var(--aw-border);
	border-radius: 12px;
	color: var(--aw-text);
	font-size: 13.5px;
	font-family: inherit;
	padding: 9px 12px;
	outline: none;
	transition: border-color 0.15s ease;
}
.aw-input:focus {
	border-color: var(--aw-accent);
}
.aw-input::placeholder { color: var(--aw-text-dim); }

.aw-send {
	width: 36px;
	height: 36px;
	border-radius: 10px;
	border: none;
	background: linear-gradient(145deg, var(--aw-accent), #4338ca);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: opacity 0.15s ease, transform 0.1s ease, filter 0.15s ease;
}
.aw-send:hover:not(:disabled) { filter: brightness(1.15); }
.aw-send:disabled { opacity: 0.45; cursor: default; }
.aw-send:not(:disabled):active { transform: scale(0.93); }
#alyxweb-chatbot-root .aw-send svg { width: 16px; height: 16px; fill: none !important; }
#alyxweb-chatbot-root .aw-send svg path { fill: #fff !important; stroke: none !important; }

/* Launcher keyboard focus ring */
.aw-launcher:focus-visible {
	outline: 3px solid rgba(255, 255, 255, 0.7);
	outline-offset: 3px;
}

/* Branding footer */
.aw-branding {
	text-align: center;
	padding: 5px 0 7px;
	background: var(--aw-panel);
}
.aw-branding a {
	font-size: 10.5px;
	color: var(--aw-text-dim);
	text-decoration: none;
	opacity: 0.6;
	transition: opacity 0.15s ease;
}
.aw-branding a:hover { opacity: 1; }
/* Mobile */
@media (max-width: 480px) {
	.aw-panel {
		right: var(--aw-panel-right, 12px);
		left: var(--aw-panel-left, 12px);
		bottom: var(--aw-panel-bottom, 88px);
		width: auto;
		height: calc(100vh - 120px);
	}
	.aw-launcher {
		right: var(--aw-launcher-right, 16px);
		left: var(--aw-launcher-left, auto);
		bottom: var(--aw-launcher-bottom, 16px);
	}
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.aw-panel, .aw-msg, .aw-launcher, .aw-launcher svg { transition: none; animation: none; }
}
