:root {
	--agc-brand: #0256fc;
	--agc-brand-dark: #0256fc;
}

#agc-chatbot-root, .agc-inline-mount {
	all: initial;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
}
#agc-chatbot-root *, .agc-inline-mount * {
	box-sizing: border-box;
	font-family: inherit;
}

/* ---------- Floating bubble ---------- */
.agc-bubble {
	position: fixed;
	bottom: 24px;
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--agc-brand);
	box-shadow: 0 6px 24px rgba(0,0,0,.22);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 999999;
	transition: transform .15s ease;
	animation: agc-pulse 2.4s infinite;
}
.agc-bubble:hover { transform: scale(1.06); }
.agc-bubble.agc-pos-right { right: 24px; }
.agc-bubble.agc-pos-left { left: 24px; }
.agc-bubble svg { width: 28px; height: 28px; fill: #fff; }
.agc-bubble-icon { width: 38px; height: 38px; object-fit: contain; border-radius: 50%; pointer-events: none; }
.agc-bubble-badge {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 13px;
	height: 13px;
	background: #ef4444;
	border: 2px solid #fff;
	border-radius: 50%;
	animation: agc-dot-pulse 1.8s ease-in-out infinite;
}
.agc-bubble.agc-seen .agc-bubble-badge { display: none; }

@keyframes agc-dot-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.35); }
}

@keyframes agc-pulse {
	0% { box-shadow: 0 6px 24px rgba(0,0,0,.22), 0 0 0 0 rgba(79,70,229,.4); }
	70% { box-shadow: 0 6px 24px rgba(0,0,0,.22), 0 0 0 14px rgba(79,70,229,0); }
	100% { box-shadow: 0 6px 24px rgba(0,0,0,.22), 0 0 0 0 rgba(79,70,229,0); }
}

/* ---------- Greeting tooltip ---------- */
.agc-greeting-tooltip {
	position: fixed;
	bottom: 100px;
	max-width: 260px;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 8px 28px rgba(0,0,0,.18);
	padding: 14px 30px 14px 14px;
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	z-index: 999998;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity .25s ease, transform .25s ease;
}
.agc-greeting-tooltip.agc-visible { opacity: 1; transform: translateY(0); }
.agc-greeting-tooltip.agc-pos-right { right: 24px; }
.agc-greeting-tooltip.agc-pos-left { left: 24px; }
.agc-greeting-tooltip::after {
	content: '';
	position: absolute;
	bottom: -7px;
	width: 14px;
	height: 14px;
	background: #fff;
	transform: rotate(45deg);
}
.agc-greeting-tooltip.agc-pos-right::after { right: 28px; }
.agc-greeting-tooltip.agc-pos-left::after { left: 28px; }
.agc-greeting-avatar { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: #f0f0fb; }
.agc-greeting-avatar img { width: 100%; height: 100%; object-fit: cover; }
.agc-greeting-text { font-size: 13px; color: #1f2937; line-height: 1.4; }
.agc-greeting-close {
	position: absolute;
	top: 6px;
	right: 8px;
	background: none;
	border: none;
	font-size: 15px;
	line-height: 1;
	color: #9ca3af;
	cursor: pointer;
	padding: 2px;
}
.agc-greeting-close:hover { color: #4b5563; }

@media (max-width: 480px) {
	.agc-greeting-tooltip { max-width: calc(100vw - 100px); bottom: 96px; }
}

/* ---------- Chat window ---------- */
.agc-window {
	position: fixed;
	bottom: 100px;
	width: 380px;
	height: 560px;
	max-height: 80vh;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0,0,0,.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 999999;
	opacity: 0;
	transform: translateY(16px) scale(.98);
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease;
}
.agc-window.agc-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.agc-window.agc-pos-right { right: 24px; }
.agc-window.agc-pos-left { left: 24px; }

.agc-inline-mount .agc-window {
	position: static;
	width: 100%;
	height: 100%;
	max-height: none;
	opacity: 1;
	transform: none;
	pointer-events: all;
	box-shadow: 0 1px 4px rgba(0,0,0,.12);
	border: 1px solid #e5e7eb;
}

@media (max-width: 480px) {
	.agc-window { width: calc(100vw - 20px); height: 80vh; right: 10px !important; left: 10px !important; bottom: 90px; }
}

/* Header */
.agc-header {
	background: var(--agc-brand);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}
.agc-header-avatar {
	width: 36px; height: 36px; border-radius: 50%;
	background: rgba(255,255,255,.2);
	display: flex; align-items: center; justify-content: center;
	overflow: hidden; flex-shrink: 0;
}
.agc-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.agc-header-info { flex: 1; min-width: 0; }
.agc-header-name { font-weight: 600; font-size: 14px; }
.agc-header-status { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 4px; }
.agc-header-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; display: inline-block; }
.agc-close-btn { background: none; border: none; color: #fff; cursor: pointer; font-size: 20px; opacity: .85; line-height: 1; padding: 4px; }
.agc-close-btn:hover { opacity: 1; }

/* Messages */
.agc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f7f7f9;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.agc-msg-row { display: flex; flex-direction: column; max-width: 85%; }
.agc-msg-row.agc-from-user { align-self: flex-end; align-items: flex-end; }
.agc-msg-row.agc-from-bot, .agc-msg-row.agc-from-human { align-self: flex-start; align-items: flex-start; }

.agc-bubble-text {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.agc-from-user .agc-bubble-text { background: var(--agc-brand); color: #fff; border-bottom-right-radius: 4px; }
.agc-from-bot .agc-bubble-text { background: #fff; color: #1f2937; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }
.agc-from-human .agc-bubble-text { background: #fff; color: #1f2937; border: 1px solid #bbf7d0; border-bottom-left-radius: 4px; }

.agc-bubble-text p { margin: 0 0 8px; }
.agc-bubble-text p:last-child { margin-bottom: 0; }
.agc-bubble-text ul, .agc-bubble-text ol { margin: 4px 0 8px; padding-left: 20px; }
.agc-bubble-text li { margin-bottom: 4px; }
.agc-bubble-text strong { font-weight: 700; }
.agc-bubble-text em { font-style: italic; }

.agc-human-label {
	font-size: 10px;
	font-weight: 600;
	color: #059669;
	margin-bottom: 3px;
	padding: 0 2px;
}

.agc-contact-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.agc-contact-btn {
	display: inline-flex; align-items: center; gap: 5px;
	background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0;
	border-radius: 16px; padding: 6px 12px; font-size: 12px; font-weight: 600;
	text-decoration: none;
}
.agc-contact-btn:hover { background: #dcfce7; }

.agc-msg-meta { font-size: 10px; color: #9ca3af; margin-top: 4px; padding: 0 4px; display: flex; gap: 8px; align-items: center; }
.agc-msg-actions { display: flex; gap: 6px; }
.agc-msg-actions button {
	background: none; border: none; cursor: pointer; color: #9ca3af; font-size: 10px;
	padding: 2px 4px; display: inline-flex; align-items: center; gap: 3px;
}
.agc-msg-actions button:hover { color: var(--agc-brand); }

.agc-typing { display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; border-bottom-left-radius: 4px; width: fit-content; }
.agc-typing span { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; animation: agc-blink 1.2s infinite; }
.agc-typing span:nth-child(2) { animation-delay: .2s; }
.agc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes agc-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* Quick replies */
.agc-quick-replies { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; flex-shrink: 0; min-width: 0; background: #fff; border-top: 1px solid #f0f0f0; scroll-behavior: smooth; cursor: grab; }
.agc-quick-replies.agc-dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
.agc-quick-replies::-webkit-scrollbar { height: 5px; }
.agc-quick-replies::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.agc-quick-replies::-webkit-scrollbar-track { background: transparent; }
.agc-qr-btn {
	white-space: nowrap;
	background: #f0f0fb;
	color: var(--agc-brand);
	border: 1px solid #e0e0f8;
	border-radius: 16px;
	padding: 7px 14px;
	font-size: 12px;
	cursor: pointer;
	flex-shrink: 0;
}
.agc-qr-btn:hover { background: var(--agc-brand); color: #fff; }

/* Input area */
.agc-input-area { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #eee; background: #fff; flex-shrink: 0; align-items: flex-end; }
.agc-input-area textarea {
	flex: 1; resize: none; border: 1px solid #e5e7eb; border-radius: 20px; padding: 10px 16px;
	font-size: 13.5px; max-height: 90px; outline: none; font-family: inherit;
}
.agc-input-area textarea:focus { border-color: var(--agc-brand); }
.agc-send-btn {
	width: 38px; height: 38px; border-radius: 50%; background: var(--agc-brand); border: none;
	cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.agc-send-btn svg { width: 16px; height: 16px; fill: #fff; }
.agc-send-btn:disabled { opacity: .5; cursor: not-allowed; }
.agc-stop-btn { background: #ef4444; }

.agc-footer { text-align: center; font-size: 10px; color: #9ca3af; padding: 6px 0; flex-shrink: 0; background: #fff; }

/* Lead / pre-chat form */
.agc-lead-form { padding: 20px 16px; background: #fff; display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; }
.agc-lead-form h4 { margin: 0 0 2px; font-size: 15px; }
.agc-lead-form p.agc-subtitle { margin: 0 0 10px; font-size: 12px; color: #6b7280; }
.agc-lead-form input {
	border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; font-size: 13px; outline: none;
}
.agc-lead-form input:focus { border-color: var(--agc-brand); }
.agc-lead-form-actions { display: flex; gap: 8px; margin-top: 6px; }
.agc-btn-primary {
	background: var(--agc-brand); color: #fff; border: none; border-radius: 8px; padding: 10px 16px;
	font-size: 13px; cursor: pointer; flex: 1; font-weight: 600;
}
.agc-btn-primary:hover { background: var(--agc-brand-dark); }
.agc-btn-secondary { background: none; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 16px; font-size: 13px; cursor: pointer; color: #6b7280; }

.agc-handoff-banner {
	background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 12px;
	padding: 8px 12px; margin: 0 16px 10px; border-radius: 8px;
}

.agc-error-banner {
	background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: 12px;
	padding: 8px 12px; margin: 0 16px 10px; border-radius: 8px;
}
