/* AI Site Chatbot. Colors, sizes and fonts come from CSS custom properties set on .aisc-root by the plugin settings. */

.aisc-root {
	--aisc-primary: #4f46e5;
	--aisc-on-primary: #fff;
	--aisc-bg: #fff;
	--aisc-text: #1f2937;
	--aisc-bot-bg: #f3f4f6;
	--aisc-bot-text: #1f2937;
	--aisc-font: inherit;
	--aisc-font-size: 15px;
	--aisc-radius: 16px;
	--aisc-width: 380px;
	--aisc-height: 600px;
	--aisc-offset-x: 24px;
	--aisc-offset-y: 24px;
	--aisc-shadow: 0 12px 40px rgba(0, 0, 0, .18);
	--aisc-inline-height: 520px;
	--aisc-image-shape: 8px;
	--aisc-bubble-radius: calc(var(--aisc-radius) * .75 + 4px);

	font-family: var(--aisc-font);
	font-size: var(--aisc-font-size);
	line-height: 1.5;
	color: var(--aisc-text);
	box-sizing: border-box;
}
.aisc-root *, .aisc-root *::before, .aisc-root *::after { box-sizing: inherit; }
.aisc-root button { font: inherit; }
.aisc-root svg { width: 100%; height: 100%; display: block; }

/* ---------- Floating mode ---------- */
.aisc-mode-floating, .aisc-mode-preview {
	position: fixed;
	bottom: var(--aisc-offset-y);
	z-index: 999999;
}
.aisc-mode-floating.aisc-pos-right, .aisc-mode-preview.aisc-pos-right { right: var(--aisc-offset-x); }
.aisc-mode-floating.aisc-pos-left, .aisc-mode-preview.aisc-pos-left { left: var(--aisc-offset-x); }

.aisc-launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 60px;
	min-width: 60px;
	padding: 0 18px;
	margin: 0;
	border: 0;
	border-radius: 999px;
	background: var(--aisc-primary);
	color: var(--aisc-on-primary);
	box-shadow: var(--aisc-shadow);
	cursor: pointer;
	transition: transform .2s ease, filter .2s ease;
	position: relative;
}
.aisc-pos-right .aisc-launcher { margin-left: auto; }
.aisc-launcher:not(.aisc-has-label) { width: 60px; padding: 0; justify-content: center; }
.aisc-launcher:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.06); }
.aisc-launcher:focus-visible { outline: 3px solid var(--aisc-primary); outline-offset: 3px; }
.aisc-launcher-icon, .aisc-launcher-close { width: 28px; height: 28px; flex: none; display: flex; align-items: center; justify-content: center; }
.aisc-launcher-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.aisc-launcher-close { display: none; width: 22px; height: 22px; }
.aisc-launcher-label { font-weight: 600; white-space: nowrap; }
.aisc-open .aisc-launcher-icon, .aisc-open .aisc-launcher-label { display: none; }
.aisc-open .aisc-launcher-close { display: flex; }
.aisc-open .aisc-launcher { width: 60px; padding: 0; justify-content: center; }

.aisc-mode-floating .aisc-panel, .aisc-mode-preview .aisc-panel {
	position: absolute;
	bottom: 76px;
	width: var(--aisc-width);
	height: var(--aisc-height);
	max-height: calc(100vh - var(--aisc-offset-y) - 100px);
	max-width: calc(100vw - 2 * var(--aisc-offset-x));
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(.98);
	transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.aisc-pos-right .aisc-panel { right: 0; transform-origin: bottom right; }
.aisc-pos-left .aisc-panel { left: 0; transform-origin: bottom left; }
.aisc-open .aisc-panel {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .2s ease, transform .2s ease;
}

/* ---------- Inline mode ---------- */
.aisc-mode-inline { margin: 1.5em 0; }
.aisc-mode-inline .aisc-panel { height: var(--aisc-inline-height); width: 100%; }

/* ---------- Panel ---------- */
.aisc-panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--aisc-bg);
	color: var(--aisc-text);
	border-radius: var(--aisc-radius);
	box-shadow: var(--aisc-shadow);
	border: 1px solid rgba(0, 0, 0, .06);
}

.aisc-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 12px 14px 16px;
	background: var(--aisc-primary);
	color: var(--aisc-on-primary);
	flex: none;
}
.aisc-header-image { width: 42px; height: 42px; border-radius: var(--aisc-image-shape); object-fit: cover; flex: none; background: rgba(255, 255, 255, .2); }
.aisc-titles { flex: 1; min-width: 0; }
.aisc-title { font-weight: 700; font-size: 1.05em; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aisc-subtitle { font-size: .85em; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aisc-icon-btn {
	width: 32px; height: 32px; padding: 7px; margin: 0;
	border: 0; border-radius: 8px;
	background: transparent; color: inherit;
	cursor: pointer; opacity: .85; flex: none;
}
.aisc-icon-btn:hover { background: rgba(255, 255, 255, .15); opacity: 1; }

.aisc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
}
.aisc-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.aisc-msg-avatar { width: 26px; height: 26px; border-radius: var(--aisc-image-shape); object-fit: cover; flex: none; }
.aisc-msg-image { display: block; max-width: 100%; max-height: 200px; border-radius: calc(var(--aisc-bubble-radius) - 4px); margin: 2px 0 4px; }
.aisc-msg-text { white-space: pre-wrap; }
.aisc-bubble {
	padding: 9px 13px;
	border-radius: var(--aisc-bubble-radius);
	max-width: 85%;
	overflow-wrap: anywhere;
}
.aisc-bot .aisc-bubble { background: var(--aisc-bot-bg); color: var(--aisc-bot-text); border-bottom-left-radius: 4px; }
.aisc-user { justify-content: flex-end; }
.aisc-user .aisc-bubble { background: var(--aisc-primary); color: var(--aisc-on-primary); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.aisc-error .aisc-bubble { background: #fef2f2; color: #991b1b; }

.aisc-bubble p { margin: 0 0 .6em; }
.aisc-bubble p:last-child, .aisc-bubble ul:last-child, .aisc-bubble ol:last-child { margin-bottom: 0; }
.aisc-bubble ul, .aisc-bubble ol { margin: 0 0 .6em; padding-left: 1.3em; }
.aisc-bubble li { margin: .15em 0; }
.aisc-bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.aisc-bot .aisc-bubble a { color: var(--aisc-primary); }
.aisc-bubble code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: rgba(0, 0, 0, .07); padding: .1em .35em; border-radius: 4px; }
.aisc-bubble pre { margin: 0 0 .6em; padding: 10px; background: rgba(0, 0, 0, .07); border-radius: 8px; overflow-x: auto; }
.aisc-bubble pre code { background: none; padding: 0; }
.aisc-sources { margin-top: .6em; padding-top: .5em; border-top: 1px solid rgba(0, 0, 0, .08); font-size: .82em; opacity: .9; }

.aisc-typing .aisc-bubble { display: flex; align-items: center; gap: 4px; padding: 13px 14px; }
.aisc-typing .aisc-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .4; animation: aisc-dot 1.2s infinite ease-in-out; flex: none; }
.aisc-typing .aisc-dot:nth-child(2) { animation-delay: .15s; }
.aisc-typing .aisc-dot:nth-child(3) { animation-delay: .3s; }
.aisc-typing .aisc-status { display: none; margin-left: 6px; font-size: .85em; opacity: .75; }
.aisc-typing.aisc-has-status .aisc-status { display: inline; }
.aisc-typing.aisc-has-status .aisc-bubble { padding: 9px 13px; }

/* Blinking caret at the end of a reply that is still streaming in. */
.aisc-cursor { display: inline-block; width: .5em; height: 1em; margin-left: 1px; vertical-align: -.15em; background: currentColor; opacity: .5; animation: aisc-blink 1s steps(2) infinite; }
@keyframes aisc-blink { 50% { opacity: 0; } }
@keyframes aisc-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-4px); opacity: .9; } }

.aisc-starters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; flex: none; }
.aisc-starters:not(:empty) { padding-bottom: 10px; }
.aisc-starter {
	padding: 6px 12px; margin: 0;
	border: 1px solid var(--aisc-primary);
	border-radius: 999px;
	background: transparent;
	color: var(--aisc-primary);
	font-size: .88em;
	cursor: pointer;
	text-align: left;
}
.aisc-starter:hover { background: var(--aisc-primary); color: var(--aisc-on-primary); }
/* Once the conversation has started, remaining suggestions sit in one scrollable row. */
.aisc-starters.aisc-compact { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.aisc-starters.aisc-compact .aisc-starter { white-space: nowrap; flex: none; font-size: .82em; padding: 4px 10px; }

.aisc-login {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 14px;
	font-size: .85em;
	background: color-mix(in srgb, var(--aisc-primary) 10%, var(--aisc-bg));
	border-bottom: 1px solid rgba(0, 0, 0, .06);
	flex: none;
}
.aisc-login[hidden] { display: none; }
.aisc-login svg { width: 18px; height: 18px; flex: none; color: var(--aisc-primary); }
.aisc-login span { flex: 1; }
.aisc-login-link { font-weight: 600; color: var(--aisc-primary); text-decoration: none; white-space: nowrap; }
.aisc-login-link:hover { text-decoration: underline; }

.aisc-attachment { position: relative; align-self: flex-start; margin: 0 16px 8px; flex: none; }
.aisc-attachment[hidden] { display: none; }
.aisc-attachment img { display: block; height: 64px; max-width: 120px; object-fit: cover; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .1); }
.aisc-attachment-remove {
	position: absolute; top: -7px; right: -7px;
	width: 20px; height: 20px; padding: 4px; margin: 0;
	border: 0; border-radius: 50%;
	background: #111; color: #fff; cursor: pointer;
}
.aisc-attach {
	width: 36px; height: 40px; padding: 8px 6px; margin: 0;
	border: 0; background: transparent; color: var(--aisc-text);
	opacity: .55; cursor: pointer; flex: none;
}
.aisc-attach:hover { opacity: 1; color: var(--aisc-primary); }

.aisc-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(0, 0, 0, .08);
	flex: none;
	margin: 0;
}
.aisc-input {
	flex: 1;
	resize: none;
	border: 1px solid rgba(0, 0, 0, .15);
	border-radius: calc(var(--aisc-bubble-radius));
	padding: 9px 12px;
	margin: 0;
	font: inherit;
	color: var(--aisc-text);
	background: var(--aisc-bg);
	max-height: 120px;
	min-height: 0;
	line-height: 1.4;
	box-shadow: none;
}
.aisc-input:focus { outline: none; border-color: var(--aisc-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--aisc-primary) 25%, transparent); }
.aisc-send {
	width: 40px; height: 40px; padding: 9px; margin: 0;
	border: 0; border-radius: 50%;
	background: var(--aisc-primary); color: var(--aisc-on-primary);
	cursor: pointer; flex: none;
}
.aisc-send:disabled { opacity: .5; cursor: default; }

/* ---------- Small screens: floating panel goes full screen ---------- */
@media (max-width: 600px) {
	.aisc-hide-mobile { display: none !important; }
	.aisc-mode-floating.aisc-open .aisc-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-width: none;
		max-height: none;
		border-radius: 0;
	}
	.aisc-mode-floating.aisc-open .aisc-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.aisc-root * { transition: none !important; animation: none !important; }
}

/* ---------- Lead form cards ---------- */
.aisc-form-card { width: 100%; max-width: 100%; background: var(--aisc-bg); color: var(--aisc-text); border: 1px solid rgba(0, 0, 0, .1); box-shadow: 0 1px 3px rgba(0, 0, 0, .05); }
.aisc-form-msg { padding-right: 0; }
.aisc-form-title { font-weight: 700; margin-bottom: 4px; }
.aisc-form-intro { margin: 0 0 10px; font-size: .92em; opacity: .85; }
.aisc-lead-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.aisc-field { display: flex; flex-direction: column; gap: 4px; }
.aisc-field > label { font-size: .88em; font-weight: 600; }
.aisc-req { color: #dc2626; }
.aisc-field input:not([type=checkbox]):not([type=radio]), .aisc-field select, .aisc-field textarea {
	width: 100%; margin: 0; padding: 8px 10px;
	font: inherit; font-size: .95em; color: var(--aisc-text); background: var(--aisc-bg);
	border: 1px solid rgba(0, 0, 0, .18); border-radius: calc(var(--aisc-bubble-radius) * .6);
	box-shadow: none; min-height: 0; line-height: 1.4;
}
.aisc-field input:focus, .aisc-field select:focus, .aisc-field textarea:focus { outline: none; border-color: var(--aisc-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--aisc-primary) 22%, transparent); }
.aisc-choices { display: flex; flex-direction: column; gap: 4px; }
.aisc-choice { display: flex; align-items: flex-start; gap: 6px; font-size: .92em; font-weight: 400; cursor: pointer; }
.aisc-choice input { margin: 3px 0 0; accent-color: var(--aisc-primary); }
.aisc-field-error { color: #b91c1c; font-size: .82em; }
.aisc-field-error:empty { display: none; }
.aisc-invalid input:not([type=checkbox]):not([type=radio]), .aisc-invalid select, .aisc-invalid textarea { border-color: #dc2626; }
.aisc-form-submit {
	align-self: flex-start; margin: 2px 0 0; padding: 8px 18px;
	border: 0; border-radius: 999px; cursor: pointer; font-weight: 600;
	background: var(--aisc-primary); color: var(--aisc-on-primary);
}
.aisc-form-submit:disabled { opacity: .6; cursor: default; }
.aisc-form-done { border-color: color-mix(in srgb, var(--aisc-primary) 35%, transparent); }
.aisc-form-success { margin: 0; }
.aisc-form-success::before { content: "✓ "; color: var(--aisc-primary); font-weight: 700; }
