/*
 * AI Document Chatbot — front-end widget styles.
 * --aidc-color is injected as a <style> block in chatbot-widget.php
 * so it is available even in browsers with limited CSS-variable support.
 */

:root {
	--aidc-color: #1e3a8a;
}

#aidc-root {
	/* intentionally unstyled container — fixed children escape it */
	position: static !important;
	display: block;
}

/* ── Launcher bubble ──────────────────────────────────────────── */
.aidc-launcher {
	position: fixed !important;
	bottom: 24px;
	z-index: 2147483000 !important;  /* near max int — above virtually any theme */
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--aidc-color, #1e3a8a);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(0,0,0,0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	/* Ensure transform-parent can't trap fixed positioning */
	-webkit-transform: translateZ(0);
	transform: translateZ(0);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.aidc-launcher:hover, .aidc-launcher:focus {
	transform: scale(1.08) translateZ(0);
	box-shadow: 0 6px 24px rgba(0,0,0,0.32);
	outline: 2px solid rgba(255,255,255,0.5);
	outline-offset: 2px;
}
.aidc-pos-br .aidc-launcher { right: 24px; }
.aidc-pos-bl .aidc-launcher { left: 24px; }

.aidc-launcher svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: #fff;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex-shrink: 0;
}
/* Chat icon path uses fill not stroke */
.aidc-icon-chat { fill: #fff; stroke: none; }

.aidc-launcher-label {
	display: none; /* hidden — label exists only for a11y / screen readers */
}

/* ── Chat panel ───────────────────────────────────────────────── */
.aidc-panel {
	position: fixed !important;
	bottom: 96px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	background: #fff;
	color: #111827;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0,0,0,0.18);
	z-index: 2147482999 !important;
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.aidc-panel[hidden] { display: none !important; }
.aidc-panel.aidc-open { display: flex; }
.aidc-pos-br .aidc-panel { right: 24px; }
.aidc-pos-bl .aidc-panel { left: 24px; }

/* ── Header ───────────────────────────────────────────────────── */
.aidc-header {
	background: var(--aidc-color, #1e3a8a);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}
.aidc-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba(255,255,255,0.2);
	flex-shrink: 0;
}
.aidc-header-text { flex: 1; min-width: 0; }
.aidc-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.aidc-status { font-size: 12px; opacity: 0.8; line-height: 1.2; }
.aidc-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
	border-radius: 50%;
	flex-shrink: 0;
}
.aidc-close:hover { background: rgba(255,255,255,0.15); }

/* ── Messages ─────────────────────────────────────────────────── */
.aidc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f8f9fb;
	min-height: 0;
}
.aidc-msg {
	max-width: 84%;
	padding: 9px 13px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	white-space: pre-wrap;
}
.aidc-msg.bot {
	background: #fff;
	color: #111827;
	align-self: flex-start;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.aidc-msg.user {
	background: var(--aidc-color, #1e3a8a);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

/* ── Typing indicator ─────────────────────────────────────────── */
.aidc-typing {
	align-self: flex-start;
	padding: 11px 16px;
	background: #fff;
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
	display: flex;
	gap: 4px;
	align-items: center;
}
.aidc-typing span {
	display: block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: aidc-blink 1.1s infinite ease-in-out both;
}
.aidc-typing span:nth-child(2) { animation-delay: 0.18s; }
.aidc-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aidc-blink {
	0%, 80%, 100% { opacity: 0.2; transform: scale(0.9); }
	40% { opacity: 1; transform: scale(1); }
}

/* ── Chips ────────────────────────────────────────────────────── */
.aidc-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 2px;
}
.aidc-chip {
	background: #fff;
	border: 1.5px solid var(--aidc-color, #1e3a8a);
	color: var(--aidc-color, #1e3a8a);
	border-radius: 20px;
	padding: 6px 14px;
	font-size: 13px;
	font-family: inherit;
	cursor: pointer;
	line-height: 1.3;
	transition: background 0.12s, color 0.12s;
}
.aidc-chip:hover, .aidc-chip:focus {
	background: var(--aidc-color, #1e3a8a);
	color: #fff;
	outline: none;
}

/* ── Feedback ─────────────────────────────────────────────────── */
.aidc-feedback {
	display: flex;
	gap: 6px;
	align-items: center;
	font-size: 12px;
	color: #6b7280;
	margin-top: 2px;
}
.aidc-feedback-label { margin-right: 2px; }
.aidc-feedback button {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	padding: 3px 10px;
	cursor: pointer;
	font-size: 13px;
	font-family: inherit;
	line-height: 1.4;
	transition: background 0.1s, border-color 0.1s;
}
.aidc-feedback button:hover { border-color: var(--aidc-color, #1e3a8a); }
.aidc-feedback button.aidc-voted {
	background: var(--aidc-color, #1e3a8a);
	color: #fff;
	border-color: var(--aidc-color, #1e3a8a);
}
.aidc-feedback-thankyou { font-style: italic; }

/* ── Suggested label ──────────────────────────────────────────── */
.aidc-suggested-label {
	font-size: 12px;
	color: #6b7280;
	margin-top: 4px;
}

/* ── Composer ─────────────────────────────────────────────────── */
.aidc-composer {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
	flex-shrink: 0;
	align-items: flex-end;
}
.aidc-composer textarea {
	flex: 1;
	resize: none;
	border: 1.5px solid #e5e7eb;
	border-radius: 20px;
	padding: 9px 14px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	max-height: 120px;
	min-height: 38px;
	background: #fff;
	color: #111827;
	outline: none;
	transition: border-color 0.15s;
}
.aidc-composer textarea:focus { border-color: var(--aidc-color, #1e3a8a); }
.aidc-composer button[type="submit"] {
	background: var(--aidc-color, #1e3a8a);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 38px;
	height: 38px;
	flex-shrink: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.15s;
}
.aidc-composer button[type="submit"]:disabled { opacity: 0.45; cursor: not-allowed; }
.aidc-composer button[type="submit"] svg {
	width: 18px;
	height: 18px;
	fill: #fff;
	stroke: none;
}

/* ── Mobile (<= 480px) ────────────────────────────────────────── */
@media screen and (max-width: 480px) {
	.aidc-panel {
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
		top: 0;
		bottom: 0;
	}
	.aidc-pos-br .aidc-panel,
	.aidc-pos-bl .aidc-panel { right: 0; left: 0; }
}
