/**
 * AI Website Assistant Pro — front-end widget styles.
 * Colors are themed at runtime via the --aiwa-primary CSS variable set on #aiwa-root.
 */

#aiwa-root {
	--aiwa-primary: #2563eb;
	--aiwa-bg: #ffffff;
	--aiwa-fg: #1f2430;
	--aiwa-muted: #6b7280;
	--aiwa-surface: #f3f4f6;
	--aiwa-border: #e5e7eb;
	--aiwa-on-primary: #ffffff;
	--aiwa-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	position: fixed;
	z-index: 999999;
	bottom: 22px;
}

#aiwa-root.aiwa-pos-bottom-right { right: 22px; }
#aiwa-root.aiwa-pos-bottom-left  { left: 22px; }

#aiwa-root.aiwa-theme-dark {
	--aiwa-bg: #1b1f27;
	--aiwa-fg: #e8eaed;
	--aiwa-muted: #9aa0aa;
	--aiwa-surface: #262b34;
	--aiwa-border: #333a45;
}

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

/* Launcher button */
.aiwa-launcher {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background: var(--aiwa-primary);
	color: var(--aiwa-on-primary);
	cursor: pointer;
	box-shadow: var(--aiwa-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, opacity 0.15s ease;
	padding: 0;
}
.aiwa-launcher:hover { transform: scale(1.06); }
.aiwa-launcher svg { width: 28px; height: 28px; fill: currentColor; }
.aiwa-launcher img { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; }

/* Panel */
.aiwa-panel {
	position: absolute;
	bottom: 76px;
	width: 370px;
	max-width: calc(100vw - 40px);
	height: 540px;
	max-height: calc(100vh - 120px);
	background: var(--aiwa-bg);
	color: var(--aiwa-fg);
	border: 1px solid var(--aiwa-border);
	border-radius: 16px;
	box-shadow: var(--aiwa-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-size: 14px;
	line-height: 1.5;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#aiwa-root.aiwa-pos-bottom-right .aiwa-panel { right: 0; }
#aiwa-root.aiwa-pos-bottom-left  .aiwa-panel { left: 0; }
#aiwa-root.aiwa-open .aiwa-panel { display: flex; }

.aiwa-header {
	background: var(--aiwa-primary);
	color: var(--aiwa-on-primary);
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 10px;
}
.aiwa-header .aiwa-avatar {
	width: 34px; height: 34px; border-radius: 50%;
	background: rgba(255, 255, 255, 0.25);
	display: flex; align-items: center; justify-content: center;
	overflow: hidden; flex: none;
}
.aiwa-header .aiwa-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aiwa-header .aiwa-title { font-weight: 600; flex: 1; }
.aiwa-header .aiwa-close {
	background: transparent; border: none; color: inherit;
	cursor: pointer; font-size: 20px; line-height: 1; padding: 4px;
	opacity: 0.85;
}
.aiwa-header .aiwa-close:hover { opacity: 1; }

.aiwa-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--aiwa-bg);
}

.aiwa-msg { max-width: 84%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.aiwa-msg-bot  { background: var(--aiwa-surface); color: var(--aiwa-fg); align-self: flex-start; border-bottom-left-radius: 4px; }
.aiwa-msg-user { background: var(--aiwa-primary); color: var(--aiwa-on-primary); align-self: flex-end; border-bottom-right-radius: 4px; }

.aiwa-sources { margin-top: 6px; font-size: 12px; align-self: flex-start; max-width: 84%; }
.aiwa-sources a { color: var(--aiwa-primary); text-decoration: none; display: block; margin-top: 2px; }
.aiwa-sources a:hover { text-decoration: underline; }
.aiwa-sources .aiwa-sources-label { color: var(--aiwa-muted); }

.aiwa-suggested { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.aiwa-chip {
	background: transparent;
	border: 1px solid var(--aiwa-primary);
	color: var(--aiwa-primary);
	border-radius: 16px;
	padding: 5px 11px;
	font-size: 12.5px;
	cursor: pointer;
}
.aiwa-chip:hover { background: var(--aiwa-primary); color: var(--aiwa-on-primary); }

.aiwa-typing { display: inline-flex; gap: 4px; align-items: center; padding: 11px 13px; }
.aiwa-typing span {
	width: 7px; height: 7px; border-radius: 50%; background: var(--aiwa-muted);
	animation: aiwa-bounce 1.2s infinite ease-in-out;
}
.aiwa-typing span:nth-child(2) { animation-delay: 0.15s; }
.aiwa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiwa-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
	30% { transform: translateY(-5px); opacity: 1; }
}

.aiwa-input {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--aiwa-border);
	background: var(--aiwa-bg);
}
.aiwa-input textarea {
	flex: 1;
	resize: none;
	border: 1px solid var(--aiwa-border);
	border-radius: 10px;
	padding: 9px 11px;
	font-family: inherit;
	font-size: 14px;
	background: var(--aiwa-bg);
	color: var(--aiwa-fg);
	max-height: 96px;
	line-height: 1.4;
}
.aiwa-input textarea:focus { outline: 2px solid var(--aiwa-primary); outline-offset: -1px; }
.aiwa-send {
	border: none;
	background: var(--aiwa-primary);
	color: var(--aiwa-on-primary);
	border-radius: 10px;
	width: 42px;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	flex: none;
}
.aiwa-send:disabled { opacity: 0.5; cursor: default; }
.aiwa-send svg { width: 20px; height: 20px; fill: currentColor; }

.aiwa-footer {
	text-align: center;
	font-size: 11px;
	color: var(--aiwa-muted);
	padding: 0 0 8px;
	background: var(--aiwa-bg);
}

@media (max-width: 480px) {
	.aiwa-panel {
		width: calc(100vw - 24px);
		height: calc(100vh - 100px);
	}
}
