/* AIS Chatbot widget — all selectors prefixed .aisc- */
#aisc-root {
	--aisc-surface: #ffffff;
	--aisc-bg: #f4f6fa;
	--aisc-text: #1c2430;
	--aisc-muted: #6b7686;
	--aisc-radius: 16px;
	--aisc-font: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
	font-family: var(--aisc-font);
	font-size: 15px;
	line-height: 1.45;
}
#aisc-root *, #aisc-root *::before, #aisc-root *::after { box-sizing: border-box; }

/* ---------- Launcher ---------- */
.aisc-launcher {
	position: fixed;
	bottom: 22px;
	z-index: var(--aisc-z, 999990);
	display: inline-flex;
	align-items: center;
	gap: 10px;
	border: 0;
	cursor: pointer;
	color: #fff;
	background: linear-gradient(135deg, var(--aisc-secondary), color-mix(in srgb, var(--aisc-secondary) 78%, #000));
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	font-family: var(--aisc-font);
	font-weight: 600;
	letter-spacing: 0.2px;
}
.aisc-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32); }
.aisc-launcher:focus-visible { outline: 3px solid var(--aisc-primary); outline-offset: 2px; }
.aisc-launcher.aisc-pos-right { right: 22px; }
.aisc-launcher.aisc-pos-left { left: 22px; }
.aisc-launcher.aisc-style-pill { padding: 14px 22px 14px 18px; border-radius: 999px; font-size: 15px; }
.aisc-launcher.aisc-style-icon { width: 62px; height: 62px; border-radius: 50%; justify-content: center; }
.aisc-launcher.aisc-style-icon .aisc-launcher-label { display: none; }
.aisc-launcher.aisc-style-icon svg { width: 28px; height: 28px; }
.aisc-launcher svg { width: 22px; height: 22px; flex: 0 0 auto; }
.aisc-launcher::before {
	content: '';
	position: absolute; inset: -5px;
	border-radius: inherit;
	border: 2px solid color-mix(in srgb, var(--aisc-secondary) 45%, transparent);
	opacity: 0;
	animation: aisc-ring 3.2s ease-out infinite;
	pointer-events: none;
}
@keyframes aisc-ring {
	0%, 55% { opacity: 0; transform: scale(0.9); }
	65% { opacity: 0.9; }
	100% { opacity: 0; transform: scale(1.22); }
}
.aisc-launcher .aisc-badge {
	position: absolute; top: -4px; right: -4px;
	min-width: 18px; height: 18px; padding: 0 5px;
	border-radius: 9px; background: var(--aisc-primary);
	color: #fff; font-size: 11px; font-weight: 700;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 0 0 2px #fff;
}
.aisc-hidden { display: none !important; }

/* ---------- Window ---------- */
.aisc-window {
	position: fixed;
	bottom: 92px;
	width: 380px;
	height: 560px;
	min-width: 300px;
	min-height: 380px;
	max-width: calc(100vw - 24px);
	max-height: calc(100vh - 24px);
	z-index: var(--aisc-z, 999990);
	display: flex;
	flex-direction: column;
	background: var(--aisc-bg);
	border-radius: var(--aisc-radius);
	box-shadow: 0 18px 60px rgba(10, 20, 40, 0.35);
	overflow: hidden;
	opacity: 0;
	transform: translateY(14px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease;
}
.aisc-window.aisc-open { opacity: 1; transform: none; pointer-events: auto; }
.aisc-window.aisc-pos-right { right: 22px; }
.aisc-window.aisc-pos-left { left: 22px; }
.aisc-window.aisc-dragging, .aisc-window.aisc-resizing { transition: none; user-select: none; }

/* ---------- Header ---------- */
.aisc-header {
	display: flex; align-items: center; gap: 12px;
	padding: 16px 14px 16px 18px;
	background: linear-gradient(150deg, var(--aisc-primary), color-mix(in srgb, var(--aisc-primary) 72%, #000));
	color: #fff;
	cursor: grab;
	flex: 0 0 auto;
	touch-action: none;
}
.aisc-header:active { cursor: grabbing; }
.aisc-avatar {
	width: 44px; height: 44px; border-radius: 50%;
	background: #fff; overflow: hidden; flex: 0 0 auto;
	padding: 6px;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.18);
}
.aisc-avatar img { width: 100%; height: 100%; object-fit: contain; }
.aisc-avatar .aisc-avatar-fallback { color: var(--aisc-primary); font-weight: 700; font-size: 17px; }
.aisc-head-text { flex: 1 1 auto; min-width: 0; }
.aisc-head-title { font-weight: 700; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aisc-head-sub { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aisc-dot { width: 7px; height: 7px; border-radius: 50%; background: #47d764; flex: 0 0 auto; box-shadow: 0 0 6px #47d764; }
.aisc-head-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.aisc-icon-btn {
	width: 32px; height: 32px; border-radius: 9px;
	border: 0;
	background: #ffffff; color: var(--aisc-primary, #002657); cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background 0.15s ease, transform 0.1s ease;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}
.aisc-icon-btn:hover { background: var(--aisc-secondary, #FA4616); color: #ffffff; }
.aisc-icon-btn:active { transform: scale(0.93); }
.aisc-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.aisc-icon-btn svg { width: 16px; height: 16px; }

/* ---------- Messages ---------- */
.aisc-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 20px 18px 12px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scroll-behavior: smooth;
}
.aisc-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.aisc-row.aisc-user { justify-content: flex-end; }
.aisc-msg-avatar {
	width: 30px; height: 30px; border-radius: 50%; overflow: hidden;
	background: #fff; flex: 0 0 auto; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
	padding: 4px;
	display: flex; align-items: center; justify-content: center;
	font-size: 12px; font-weight: 700; color: var(--aisc-primary);
}
.aisc-msg-avatar img { width: 100%; height: 100%; object-fit: contain; }
.aisc-bubble {
	max-width: 80%;
	padding: 12px 16px;
	border-radius: 18px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	box-shadow: 0 1px 3px rgba(15, 25, 45, 0.08);
	animation: aisc-pop 0.18s ease;
}
@keyframes aisc-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.aisc-bot .aisc-bubble { background: var(--aisc-surface); color: var(--aisc-text); border: 1px solid #e8ecf3; border-bottom-left-radius: 6px; }
.aisc-user .aisc-bubble {
	background: linear-gradient(135deg, var(--aisc-primary), color-mix(in srgb, var(--aisc-primary) 78%, #2a4d8f));
	color: #fff; border-bottom-right-radius: 5px;
}
.aisc-bubble a { color: var(--aisc-secondary); font-weight: 600; }
.aisc-user .aisc-bubble a { color: #ffd9cc; }
.aisc-time { font-size: 10.5px; color: var(--aisc-muted); margin: -4px 4px 0 38px; }
.aisc-user + .aisc-time, .aisc-row.aisc-user ~ .aisc-time.aisc-t-user { text-align: right; margin: -4px 6px 0 0; }

/* Typing indicator */
.aisc-typing { display: inline-flex; gap: 5px; padding: 15px 17px; }
.aisc-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--aisc-muted); opacity: 0.55;
	animation: aisc-blink 1.2s infinite;
}
.aisc-typing span:nth-child(2) { animation-delay: 0.18s; }
.aisc-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aisc-blink { 0%, 70%, 100% { transform: translateY(0); opacity: 0.45; } 35% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Composer ---------- */
.aisc-composer { flex: 0 0 auto; padding: 12px 16px 14px; background: var(--aisc-surface); border-top: 1px solid #e6eaf1; }
.aisc-input-row { display: flex; gap: 8px; align-items: flex-end; }
.aisc-input {
	flex: 1 1 auto;
	resize: none;
	border: 1.5px solid #dbe1ea;
	border-radius: 12px;
	padding: 10px 12px;
	font: inherit;
	color: var(--aisc-text);
	background: #fbfcfe;
	max-height: 110px;
	min-height: 42px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.aisc-input:focus { outline: none; border-color: var(--aisc-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--aisc-primary) 15%, transparent); }
.aisc-send {
	width: 42px; height: 42px; flex: 0 0 auto;
	border: 0; border-radius: 12px; cursor: pointer;
	background: var(--aisc-secondary); color: #fff;
	display: flex; align-items: center; justify-content: center;
	transition: filter 0.15s ease, transform 0.1s ease;
}
.aisc-send:hover { filter: brightness(1.08); }
.aisc-send:active { transform: scale(0.94); }
.aisc-send:disabled { opacity: 0.5; cursor: default; }
.aisc-send svg { width: 18px; height: 18px; }
.aisc-book {
	margin-top: 9px;
	display: flex; align-items: center; justify-content: center; gap: 8px;
	width: 100%;
	padding: 10px 14px;
	border: 0; border-radius: 12px;
	background: color-mix(in srgb, var(--aisc-secondary) 12%, #fff);
	color: var(--aisc-secondary);
	font-family: var(--aisc-font); font-weight: 700; font-size: 13.5px;
	letter-spacing: 0.3px; text-transform: uppercase;
	text-decoration: none; cursor: pointer;
	transition: background 0.15s ease;
}
.aisc-book:hover { background: color-mix(in srgb, var(--aisc-secondary) 20%, #fff); }
.aisc-book svg { width: 15px; height: 15px; }
.aisc-footer-note { text-align: center; font-size: 10px; color: var(--aisc-muted); padding-top: 7px; }

/* ---------- Resize handle ---------- */
.aisc-resize {
	position: absolute; top: 0; width: 22px; height: 22px;
	cursor: nwse-resize; z-index: 3; touch-action: none;
}
.aisc-window.aisc-pos-right .aisc-resize { left: 0; cursor: nwse-resize; }
.aisc-window.aisc-pos-left .aisc-resize { right: 0; cursor: nesw-resize; }
.aisc-resize::after {
	content: ''; position: absolute; inset: 5px;
	border-top: 2px solid rgba(255, 255, 255, 0.55);
	border-radius: 2px;
}
.aisc-window.aisc-pos-right .aisc-resize::after { border-left: 2px solid rgba(255, 255, 255, 0.55); }
.aisc-window.aisc-pos-left .aisc-resize::after { border-right: 2px solid rgba(255, 255, 255, 0.55); }

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
	.aisc-window {
		right: 8px !important; left: 8px !important;
		width: auto !important; height: 78vh !important;
		bottom: 84px !important; top: auto !important;
	}
	.aisc-resize { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.aisc-window, .aisc-launcher, .aisc-bubble { transition: none; animation: none; }
	.aisc-typing span { animation: none; }
}

/* ---------- Inline embed ([ais_chatbot] shortcode / Elementor) ---------- */
.aisc-inline { display: block; }
.aisc-embed {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 380px;
	background: var(--aisc-bg, #f4f6fa);
	border-radius: var(--aisc-radius, 16px);
	box-shadow: 0 8px 32px rgba(10, 20, 40, 0.14);
	overflow: hidden;
	font-family: var(--aisc-font, 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif);
	font-size: 15px;
	line-height: 1.45;
}
.aisc-embed *, .aisc-embed *::before, .aisc-embed *::after { box-sizing: border-box; }
.aisc-embed .aisc-header { cursor: default; }
.aisc-embed .aisc-header:active { cursor: default; }


/* ---------- Specificity hardening against theme resets ---------- */
#aisc-root .aisc-header, .aisc-embed .aisc-header { padding: 16px 14px 16px 18px; margin: 0; }
#aisc-root .aisc-messages, .aisc-embed .aisc-messages { padding: 20px 18px 12px; margin: 0; }
#aisc-root .aisc-bubble, .aisc-embed .aisc-bubble { padding: 12px 16px; margin: 0; }
#aisc-root .aisc-typing, .aisc-embed .aisc-typing { padding: 15px 17px; }
#aisc-root .aisc-composer, .aisc-embed .aisc-composer { padding: 12px 16px 14px; margin: 0; }
#aisc-root .aisc-avatar, .aisc-embed .aisc-avatar { padding: 6px; }
#aisc-root .aisc-msg-avatar, .aisc-embed .aisc-msg-avatar { padding: 4px; }
#aisc-root .aisc-input, .aisc-embed .aisc-input { padding: 10px 12px; margin: 0; }
#aisc-root .aisc-book, .aisc-embed .aisc-book { padding: 10px 14px; margin: 9px 0 0 0; }
#aisc-root .aisc-icon-btn, .aisc-embed .aisc-icon-btn,
#aisc-root .aisc-send, .aisc-embed .aisc-send { margin: 0; padding: 0; }
#aisc-root .aisc-launcher.aisc-style-pill { padding: 14px 22px 14px 18px; }
#aisc-root .aisc-launcher { margin: 0; }
#aisc-root .aisc-row, .aisc-embed .aisc-row { margin: 0; padding: 0; }
#aisc-root .aisc-head-title, .aisc-embed .aisc-head-title,
#aisc-root .aisc-head-sub, .aisc-embed .aisc-head-sub,
#aisc-root .aisc-footer-note, .aisc-embed .aisc-footer-note { margin: 0; padding: 7px 0 0 0; }


/* ---------- Button hardening (beats theme `button` element styles) ---------- */
#aisc-root .aisc-icon-btn, .aisc-embed .aisc-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	text-align: center;
	vertical-align: middle;
	background: #ffffff;
	color: var(--aisc-primary, #002657);
	border: 0;
	border-radius: 9px;
	width: 32px; height: 32px;
	min-width: 32px; min-height: 32px;
	line-height: 1;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
	text-shadow: none;
	outline: none;
}
#aisc-root .aisc-icon-btn:hover, .aisc-embed .aisc-icon-btn:hover {
	background: var(--aisc-secondary, #FA4616);
	color: #ffffff;
	border: 0;
}
#aisc-root .aisc-icon-btn svg, .aisc-embed .aisc-icon-btn svg {
	width: 16px; height: 16px; display: block; margin: 0 auto; flex: 0 0 auto;
}
#aisc-root .aisc-send, .aisc-embed .aisc-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: var(--aisc-secondary, #FA4616);
	color: #ffffff;
	border: 0;
	border-radius: 12px;
	width: 42px; height: 42px;
	min-width: 42px; min-height: 42px;
	box-shadow: none;
	text-shadow: none;
}
#aisc-root .aisc-send:hover, .aisc-embed .aisc-send:hover {
	background: var(--aisc-secondary, #FA4616);
	filter: brightness(1.08);
	border: 0;
}
#aisc-root .aisc-book, .aisc-embed .aisc-book {
	background: color-mix(in srgb, var(--aisc-secondary, #FA4616) 12%, #fff);
	color: var(--aisc-secondary, #FA4616);
	border: 0;
	border-radius: 12px;
	box-shadow: none;
	text-shadow: none;
}
#aisc-root .aisc-book:hover, .aisc-embed .aisc-book:hover {
	background: color-mix(in srgb, var(--aisc-secondary, #FA4616) 20%, #fff);
	color: var(--aisc-secondary, #FA4616);
}
#aisc-root .aisc-launcher {
	background: linear-gradient(135deg, var(--aisc-secondary, #FA4616), color-mix(in srgb, var(--aisc-secondary, #FA4616) 78%, #000));
	color: #ffffff;
	border: 0;
	text-shadow: none;
}
