/* AI Sales Agent - Chat Widget Styles
   Vanilla CSS, no framework dependency. Uses CSS custom properties so the
   admin's branding settings (and auto-detected Elementor colours) can
   theme the whole widget without touching this file. */

:root {
	--asa-primary: #6C5CE7;
	--asa-primary-dark: #5849c2;
	--asa-accent: #00D9C0;
	--asa-radius: 20px;
	--asa-radius-sm: 12px;
	--asa-shadow: 0 20px 60px rgba(20, 20, 43, 0.35), 0 2px 8px rgba(20,20,43,0.12);
	--asa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	--asa-bg-light: rgba(255, 255, 255, 0.72);
	--asa-bg-dark: rgba(24, 24, 38, 0.72);
	--asa-text-light: #17172b;
	--asa-text-dark: #f2f2f8;
	--asa-border-light: rgba(255, 255, 255, 0.5);
	--asa-border-dark: rgba(255, 255, 255, 0.08);
}

#asa-chat-root, #asa-chat-root * {
	box-sizing: border-box;
	font-family: var(--asa-font);
}

/* ---------- Launcher ---------- */
.asa-launcher {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999998;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 20px 14px 16px;
	border-radius: 999px;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, var(--asa-primary), var(--asa-primary-dark));
	color: #fff;
	box-shadow: var(--asa-shadow);
	transition: transform .25s ease, box-shadow .25s ease;
	font-weight: 600;
	font-size: 14px;
}
.asa-launcher.asa-pos-left { right: auto; left: 24px; }
.asa-launcher:hover { transform: translateY(-2px) scale(1.02); }
.asa-launcher:focus-visible { outline: 3px solid var(--asa-accent); outline-offset: 3px; }
.asa-launcher-icon {
	width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
}
.asa-launcher-icon svg { width: 22px; height: 22px; }
.asa-unread-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	background: #ff4d6d;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	border: 2px solid #fff;
}
.asa-launcher-online-dot {
	position: absolute;
	bottom: -2px;
	right: 14px;
	width: 12px;
	height: 12px;
	border-radius: 999px;
	background: #2ecc71;
	border: 2px solid #fff;
}

/* ---------- Panel ---------- */
.asa-panel {
	position: fixed;
	bottom: 100px;
	right: 24px;
	z-index: 999999;
	width: 392px;
	max-width: calc(100vw - 32px);
	height: 640px;
	max-height: calc(100vh - 140px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: var(--asa-radius);
	background: var(--asa-bg-light);
	backdrop-filter: blur(24px) saturate(160%);
	-webkit-backdrop-filter: blur(24px) saturate(160%);
	border: 1px solid var(--asa-border-light);
	box-shadow: var(--asa-shadow);
	color: var(--asa-text-light);
	opacity: 0;
	transform: translateY(16px) scale(.98);
	pointer-events: none;
	transition: opacity .28s ease, transform .28s ease;
}
.asa-panel.asa-pos-left { right: auto; left: 24px; }
.asa-panel.asa-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}
.asa-theme-dark .asa-panel {
	background: var(--asa-bg-dark);
	border-color: var(--asa-border-dark);
	color: var(--asa-text-dark);
}

@media (max-width: 480px) {
	.asa-panel {
		right: 8px;
		left: 8px;
		bottom: 84px;
		width: auto;
		max-height: calc(100vh - 100px);
	}
	.asa-launcher { right: 16px; bottom: 16px; }
}

/* ---------- Header ---------- */
.asa-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px;
	background: linear-gradient(135deg, var(--asa-primary), var(--asa-primary-dark));
	color: #fff;
	flex-shrink: 0;
}
.asa-avatar {
	width: 40px; height: 40px; border-radius: 999px;
	background: rgba(255,255,255,0.18);
	display: flex; align-items: center; justify-content: center;
	font-weight: 700; font-size: 16px;
	overflow: hidden;
	flex-shrink: 0;
}
.asa-avatar img { width: 100%; height: 100%; object-fit: cover; }
.asa-header-info { flex: 1; min-width: 0; }
.asa-header-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.asa-header-status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.asa-status-dot { width: 7px; height: 7px; border-radius: 999px; background: #2ecc71; display: inline-block; }
.asa-header-actions { display: flex; gap: 4px; }
.asa-icon-btn {
	background: rgba(255,255,255,0.14);
	border: none;
	width: 32px; height: 32px;
	border-radius: 999px;
	color: #fff;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background .2s ease;
}
.asa-icon-btn:hover { background: rgba(255,255,255,0.28); }
.asa-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.asa-icon-btn svg { width: 16px; height: 16px; }

/* ---------- Search bar ---------- */
.asa-search-bar {
	display: none;
	padding: 10px 14px;
	border-bottom: 1px solid var(--asa-border-light);
	flex-shrink: 0;
}
.asa-theme-dark .asa-search-bar { border-color: var(--asa-border-dark); }
.asa-search-bar.asa-visible { display: block; }
.asa-search-input {
	width: 100%;
	padding: 8px 12px;
	border-radius: var(--asa-radius-sm);
	border: 1px solid rgba(0,0,0,0.1);
	background: rgba(255,255,255,0.6);
	font-size: 13px;
	color: inherit;
}
.asa-theme-dark .asa-search-input { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }

/* ---------- Messages ---------- */
.asa-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}
.asa-messages::-webkit-scrollbar { width: 6px; }
.asa-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 999px; }
.asa-theme-dark .asa-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

.asa-msg-row { display: flex; gap: 8px; max-width: 92%; }
.asa-msg-row.asa-from-agent { align-self: flex-start; }
.asa-msg-row.asa-from-visitor { align-self: flex-end; flex-direction: row-reverse; }

.asa-bubble {
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-wrap: break-word;
	box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.asa-from-agent .asa-bubble {
	background: rgba(255,255,255,0.85);
	border-bottom-left-radius: 4px;
	color: var(--asa-text-light);
}
.asa-theme-dark .asa-from-agent .asa-bubble {
	background: rgba(255,255,255,0.08);
	color: var(--asa-text-dark);
}
.asa-from-visitor .asa-bubble {
	background: linear-gradient(135deg, var(--asa-primary), var(--asa-primary-dark));
	color: #fff;
	border-bottom-right-radius: 4px;
}
.asa-bubble a { color: inherit; text-decoration: underline; }
.asa-bubble code { background: rgba(0,0,0,0.08); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.asa-bubble ul { margin: 6px 0; padding-left: 18px; }

.asa-msg-time { font-size: 10px; opacity: .55; margin-top: 3px; }

/* Feedback (thumbs) */
.asa-feedback { display: flex; gap: 6px; margin-top: 4px; }
.asa-feedback button {
	background: transparent; border: none; cursor: pointer; opacity: .5; padding: 2px;
	transition: opacity .15s ease, transform .15s ease;
}
.asa-feedback button:hover { opacity: 1; transform: scale(1.1); }
.asa-feedback button.asa-active { opacity: 1; }
.asa-feedback svg { width: 14px; height: 14px; }

/* Typing indicator */
.asa-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	border-radius: 16px;
	background: rgba(255,255,255,0.85);
	width: fit-content;
}
.asa-theme-dark .asa-typing { background: rgba(255,255,255,0.08); }
.asa-typing span {
	width: 6px; height: 6px; border-radius: 999px;
	background: currentColor; opacity: .5;
	animation: asa-bounce 1.2s infinite ease-in-out;
}
.asa-typing span:nth-child(2) { animation-delay: .15s; }
.asa-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes asa-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .4; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Quick action buttons (persistent, distinct from AI suggestions) ---------- */
.asa-quick-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 8px;
	flex-shrink: 0;
}
.asa-quick-btn {
	font-weight: 600;
	border-color: var(--asa-primary);
	color: var(--asa-primary);
}
.asa-theme-dark .asa-quick-btn { color: var(--asa-accent); border-color: var(--asa-accent); }
.asa-quick-btn:hover { color: #fff; }

/* ---------- Suggested replies / quick buttons ---------- */
.asa-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 10px;
	flex-shrink: 0;
}
.asa-chip {
	border: 1px solid rgba(0,0,0,0.12);
	background: rgba(255,255,255,0.6);
	color: inherit;
	padding: 7px 12px;
	border-radius: 999px;
	font-size: 12.5px;
	cursor: pointer;
	transition: background .2s ease, transform .15s ease;
	white-space: nowrap;
}
.asa-theme-dark .asa-chip { border-color: rgba(255,255,255,0.14); background: rgba(255,255,255,0.06); }
.asa-chip:hover { background: var(--asa-primary); color: #fff; border-color: transparent; transform: translateY(-1px); }

/* ---------- Lead capture card ---------- */
.asa-lead-card {
	margin: 0 16px 10px;
	padding: 14px;
	border-radius: var(--asa-radius-sm);
	background: rgba(255,255,255,0.7);
	border: 1px solid rgba(0,0,0,0.06);
}
.asa-theme-dark .asa-lead-card { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
.asa-lead-card h4 { margin: 0 0 10px; font-size: 13.5px; font-weight: 700; }
.asa-lead-field { margin-bottom: 8px; }
.asa-lead-field input, .asa-lead-field textarea {
	width: 100%;
	padding: 8px 10px;
	border-radius: 10px;
	border: 1px solid rgba(0,0,0,0.12);
	background: rgba(255,255,255,0.8);
	font-size: 13px;
	color: inherit;
}
.asa-theme-dark .asa-lead-field input, .asa-theme-dark .asa-lead-field textarea {
	background: rgba(0,0,0,0.2); border-color: rgba(255,255,255,0.14);
}
.asa-lead-actions { display: flex; gap: 8px; margin-top: 4px; }
.asa-btn-primary, .asa-btn-secondary {
	flex: 1;
	padding: 9px 12px;
	border-radius: 10px;
	border: none;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
.asa-btn-primary { background: linear-gradient(135deg, var(--asa-primary), var(--asa-primary-dark)); color: #fff; }
.asa-btn-secondary { background: rgba(0,0,0,0.06); color: inherit; }
.asa-theme-dark .asa-btn-secondary { background: rgba(255,255,255,0.08); }

/* ---------- Composer ---------- */
.asa-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--asa-border-light);
	flex-shrink: 0;
}
.asa-theme-dark .asa-composer { border-color: var(--asa-border-dark); }
.asa-composer textarea {
	flex: 1;
	resize: none;
	max-height: 100px;
	border: 1px solid rgba(0,0,0,0.12);
	border-radius: 16px;
	padding: 10px 14px;
	font-size: 14px;
	background: rgba(255,255,255,0.7);
	color: inherit;
	line-height: 1.4;
}
.asa-theme-dark .asa-composer textarea { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14); }
.asa-composer textarea:focus, .asa-search-input:focus, .asa-lead-field input:focus, .asa-lead-field textarea:focus {
	outline: none;
	border-color: var(--asa-primary);
	box-shadow: 0 0 0 3px rgba(108,92,231,0.18);
}
.asa-send-btn {
	width: 40px; height: 40px; flex-shrink: 0;
	border-radius: 999px; border: none; cursor: pointer;
	background: linear-gradient(135deg, var(--asa-primary), var(--asa-primary-dark));
	color: #fff;
	display: flex; align-items: center; justify-content: center;
	transition: transform .15s ease, opacity .15s ease;
}
.asa-send-btn:disabled { opacity: .4; cursor: not-allowed; }
.asa-send-btn:not(:disabled):hover { transform: scale(1.06); }
.asa-send-btn svg { width: 17px; height: 17px; }

.asa-powered-by {
	text-align: center;
	font-size: 10.5px;
	opacity: .5;
	padding: 4px 0 10px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.asa-panel, .asa-launcher, .asa-typing span { transition: none !important; animation: none !important; }
}

/* Screen-reader only helper */
.asa-sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Inline (Elementor widget / shortcode) mode ---------- */
.asa-inline-host {
	position: static;
	width: 100%;
	max-width: 100%;
	display: block;
}
.asa-panel.asa-inline {
	position: static;
	width: 100%;
	max-width: 100%;
	height: 600px;
	max-height: 80vh;
	opacity: 1;
	transform: none;
	pointer-events: auto;
	box-shadow: 0 10px 40px rgba(20,20,43,0.18);
	margin: 0 auto;
}
@media (max-width: 480px) {
	.asa-panel.asa-inline { height: 520px; }
}
