/*
 * NVG Self Hosted Chatbot - Front-end widget styles.
 * All styles scoped under #nvg-cb-root to prevent Elementor / theme conflicts.
 * No layout shift: launcher uses position:fixed, panel is fixed and overlays content.
 */

#nvg-cb-root,
#nvg-cb-root *,
#nvg-cb-root *::before,
#nvg-cb-root *::after {
	box-sizing: border-box;
}

#nvg-cb-root {
	--nvg-primary: #0e4d8c;
	--nvg-accent: #f59e0b;
	--nvg-text-on-primary: #ffffff;
	--nvg-bg: #ffffff;
	--nvg-bg-soft: #f6f8fb;
	--nvg-text: #1e293b;
	--nvg-text-soft: #64748b;
	--nvg-border: #e2e8f0;
	--nvg-radius-md: 12px;
	--nvg-radius-lg: 18px;
	--nvg-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.18);
	--nvg-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.10);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: var(--nvg-text);
}

/* ---------- Floating Launcher ---------- */
#nvg-cb-root .nvg-cb-launcher {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 2147483600;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px 12px 14px;
	background: var(--nvg-primary);
	color: var(--nvg-text-on-primary);
	border: none;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: var(--nvg-shadow-lg);
	transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
	font-family: inherit;
	line-height: 1;
}
#nvg-cb-root .nvg-cb-launcher:hover {
	transform: translateY(-1px);
	box-shadow: 0 16px 38px rgba(15, 23, 42, 0.22);
}
#nvg-cb-root .nvg-cb-launcher:focus-visible {
	outline: 3px solid var(--nvg-accent);
	outline-offset: 2px;
}
#nvg-cb-root .nvg-cb-launcher-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
}
#nvg-cb-root .nvg-cb-launcher-dot {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 10px;
	height: 10px;
	background: var(--nvg-accent);
	border: 2px solid var(--nvg-bg);
	border-radius: 50%;
	display: none;
}
#nvg-cb-root[data-nvg-state="closed"] .nvg-cb-launcher-dot.is-visible {
	display: block;
}
#nvg-cb-root[data-nvg-state="open"] .nvg-cb-launcher {
	transform: scale(0.9);
	opacity: 0.85;
}

/* ---------- Chat Panel ---------- */
#nvg-cb-root .nvg-cb-panel {
	position: fixed;
	right: 22px;
	bottom: 84px;
	z-index: 2147483601;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 110px);
	background: var(--nvg-bg);
	border-radius: var(--nvg-radius-lg);
	box-shadow: var(--nvg-shadow-lg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: nvgCbFadeIn 0.22s ease;
}
#nvg-cb-root .nvg-cb-panel[hidden] {
	display: none;
}

@keyframes nvgCbFadeIn {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
#nvg-cb-root .nvg-cb-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	background: var(--nvg-primary);
	color: var(--nvg-text-on-primary);
	flex: 0 0 auto;
}
#nvg-cb-root .nvg-cb-header-content {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}
#nvg-cb-root .nvg-cb-header-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255,255,255,0.18);
	flex: 0 0 auto;
}
#nvg-cb-root .nvg-cb-header-text {
	min-width: 0;
}
#nvg-cb-root .nvg-cb-header-title {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
#nvg-cb-root .nvg-cb-header-subtitle {
	font-size: 12px;
	opacity: 0.85;
	margin-top: 2px;
}
#nvg-cb-root .nvg-cb-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: transparent;
	border: none;
	color: var(--nvg-text-on-primary);
	border-radius: 8px;
	cursor: pointer;
	opacity: 0.9;
	transition: background 0.15s ease, opacity 0.15s ease;
}
#nvg-cb-root .nvg-cb-close:hover { background: rgba(255,255,255,0.15); opacity: 1; }
#nvg-cb-root .nvg-cb-close:focus-visible { outline: 2px solid var(--nvg-accent); outline-offset: 1px; }

/* ---------- Messages ---------- */
#nvg-cb-root .nvg-cb-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	background: var(--nvg-bg-soft);
	display: flex;
	flex-direction: column;
	gap: 8px;
}
#nvg-cb-root .nvg-cb-messages::-webkit-scrollbar { width: 6px; }
#nvg-cb-root .nvg-cb-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

#nvg-cb-root .nvg-cb-msg {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: var(--nvg-radius-md);
	font-size: 14px;
	line-height: 1.45;
	word-wrap: break-word;
	animation: nvgCbMsgIn 0.18s ease;
	box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
@keyframes nvgCbMsgIn {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: translateY(0); }
}
#nvg-cb-root .nvg-cb-msg-bot {
	align-self: flex-start;
	background: var(--nvg-bg);
	color: var(--nvg-text);
	border: 1px solid var(--nvg-border);
	border-top-left-radius: 4px;
}
#nvg-cb-root .nvg-cb-msg-user {
	align-self: flex-end;
	background: var(--nvg-primary);
	color: var(--nvg-text-on-primary);
	border-top-right-radius: 4px;
}
#nvg-cb-root .nvg-cb-msg-system {
	align-self: center;
	background: transparent;
	color: var(--nvg-text-soft);
	font-size: 12px;
	font-style: italic;
	padding: 4px 8px;
	box-shadow: none;
}

/* ---------- Quick Replies ---------- */
#nvg-cb-root .nvg-cb-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 4px;
	animation: nvgCbMsgIn 0.22s ease;
}
#nvg-cb-root .nvg-cb-quick-reply {
	background: var(--nvg-bg);
	color: var(--nvg-primary);
	border: 1px solid var(--nvg-primary);
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 13px;
	cursor: pointer;
	font-family: inherit;
	font-weight: 500;
	transition: background 0.15s ease, color 0.15s ease;
	line-height: 1.2;
}
#nvg-cb-root .nvg-cb-quick-reply:hover {
	background: var(--nvg-primary);
	color: var(--nvg-text-on-primary);
}

/* ---------- Typing Indicator ---------- */
#nvg-cb-root .nvg-cb-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	padding: 10px 14px;
	background: var(--nvg-bg);
	border: 1px solid var(--nvg-border);
	border-radius: var(--nvg-radius-md);
	border-top-left-radius: 4px;
	align-self: flex-start;
}
#nvg-cb-root .nvg-cb-typing span {
	width: 6px;
	height: 6px;
	background: var(--nvg-text-soft);
	border-radius: 50%;
	animation: nvgCbBounce 1.2s infinite;
}
#nvg-cb-root .nvg-cb-typing span:nth-child(2) { animation-delay: 0.15s; }
#nvg-cb-root .nvg-cb-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes nvgCbBounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------- CTA Bar ---------- */
#nvg-cb-root .nvg-cb-cta-bar {
	flex: 0 0 auto;
	padding: 8px 16px;
	background: var(--nvg-bg);
	border-top: 1px solid var(--nvg-border);
}
#nvg-cb-root .nvg-cb-cta-bar[hidden] { display: none; }
#nvg-cb-root .nvg-cb-cta-btn {
	width: 100%;
	background: var(--nvg-accent);
	color: #1e293b;
	border: none;
	padding: 10px 16px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	font-family: inherit;
	transition: filter 0.15s ease;
	line-height: 1.2;
}
#nvg-cb-root .nvg-cb-cta-btn:hover { filter: brightness(0.95); }
#nvg-cb-root .nvg-cb-cta-btn:focus-visible { outline: 2px solid var(--nvg-primary); outline-offset: 2px; }

/* ---------- Composer ---------- */
#nvg-cb-root .nvg-cb-composer {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: var(--nvg-bg);
	border-top: 1px solid var(--nvg-border);
}
#nvg-cb-root .nvg-cb-input {
	flex: 1 1 auto;
	padding: 10px 14px;
	font-size: 14px;
	font-family: inherit;
	border: 1px solid var(--nvg-border);
	border-radius: 999px;
	background: var(--nvg-bg-soft);
	color: var(--nvg-text);
	outline: none;
	transition: border-color 0.15s ease, background 0.15s ease;
	line-height: 1.3;
}
#nvg-cb-root .nvg-cb-input:focus { border-color: var(--nvg-primary); background: var(--nvg-bg); }
#nvg-cb-root .nvg-cb-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	background: var(--nvg-primary);
	color: var(--nvg-text-on-primary);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	flex: 0 0 auto;
	transition: background 0.15s ease;
}
#nvg-cb-root .nvg-cb-send:hover { filter: brightness(1.08); }
#nvg-cb-root .nvg-cb-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Footer ---------- */
#nvg-cb-root .nvg-cb-footer {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 14px 8px;
	background: var(--nvg-bg);
	border-top: 1px solid var(--nvg-border);
	font-size: 11px;
	color: var(--nvg-text-soft);
}
#nvg-cb-root .nvg-cb-phone-link {
	color: var(--nvg-primary);
	text-decoration: none;
	font-weight: 600;
}
#nvg-cb-root .nvg-cb-phone-link:hover { text-decoration: underline; }

/* ---------- Lead Form (inline in conversation) ---------- */
#nvg-cb-root .nvg-cb-lead-form {
	background: var(--nvg-bg);
	border: 1px solid var(--nvg-border);
	border-radius: var(--nvg-radius-md);
	padding: 14px;
	width: 100%;
	max-width: 100%;
	margin: 4px 0;
	animation: nvgCbMsgIn 0.22s ease;
}
#nvg-cb-root .nvg-cb-lead-form-title {
	font-size: 15px;
	font-weight: 700;
	color: var(--nvg-primary);
	margin-bottom: 2px;
}
#nvg-cb-root .nvg-cb-lead-form-subtitle {
	font-size: 12px;
	color: var(--nvg-text-soft);
	margin-bottom: 12px;
}
#nvg-cb-root .nvg-cb-field {
	margin-bottom: 10px;
}
#nvg-cb-root .nvg-cb-field label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: var(--nvg-text);
	margin-bottom: 4px;
}
#nvg-cb-root .nvg-cb-req {
	color: #dc2626;
}
#nvg-cb-root .nvg-cb-field input[type="text"],
#nvg-cb-root .nvg-cb-field input[type="tel"],
#nvg-cb-root .nvg-cb-field input[type="email"],
#nvg-cb-root .nvg-cb-field select,
#nvg-cb-root .nvg-cb-field textarea {
	width: 100%;
	padding: 8px 10px;
	font-size: 13px;
	font-family: inherit;
	border: 1px solid var(--nvg-border);
	border-radius: 8px;
	background: var(--nvg-bg);
	color: var(--nvg-text);
	outline: none;
	transition: border-color 0.15s ease;
	line-height: 1.3;
}
#nvg-cb-root .nvg-cb-field input:focus,
#nvg-cb-root .nvg-cb-field select:focus,
#nvg-cb-root .nvg-cb-field textarea:focus {
	border-color: var(--nvg-primary);
}
#nvg-cb-root .nvg-cb-field textarea {
	resize: vertical;
	min-height: 50px;
}
#nvg-cb-root .nvg-cb-radio-row {
	display: flex;
	gap: 8px;
}
#nvg-cb-root .nvg-cb-radio {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 10px;
	border: 1px solid var(--nvg-border);
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
	transition: border-color 0.15s ease, background 0.15s ease;
}
#nvg-cb-root .nvg-cb-radio:has(input:checked) {
	border-color: var(--nvg-primary);
	background: rgba(14, 77, 140, 0.06);
}
#nvg-cb-root .nvg-cb-radio input { margin: 0; accent-color: var(--nvg-primary); }
#nvg-cb-root .nvg-cb-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}
#nvg-cb-root .nvg-cb-form-error {
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 12px;
	margin-bottom: 8px;
}
#nvg-cb-root .nvg-cb-form-actions {
	display: flex;
	gap: 8px;
	margin-top: 8px;
}
#nvg-cb-root .nvg-cb-form-submit {
	flex: 1;
	background: var(--nvg-primary);
	color: var(--nvg-text-on-primary);
	border: none;
	padding: 10px 14px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
	font-family: inherit;
	transition: filter 0.15s ease;
	line-height: 1.2;
}
#nvg-cb-root .nvg-cb-form-submit:hover { filter: brightness(1.08); }
#nvg-cb-root .nvg-cb-form-submit:disabled { opacity: 0.6; cursor: wait; }
#nvg-cb-root .nvg-cb-form-cancel {
	background: transparent;
	color: var(--nvg-text-soft);
	border: 1px solid var(--nvg-border);
	padding: 10px 14px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	font-family: inherit;
	line-height: 1.2;
}
#nvg-cb-root .nvg-cb-form-cancel:hover { background: var(--nvg-bg-soft); }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	#nvg-cb-root .nvg-cb-launcher {
		right: 16px;
		bottom: 16px;
		padding: 12px 16px 12px 12px;
	}
	#nvg-cb-root .nvg-cb-launcher-text {
		font-size: 13px;
	}
	#nvg-cb-root .nvg-cb-panel {
		right: 8px;
		left: 8px;
		bottom: 80px;
		width: auto;
		max-width: none;
		height: calc(100vh - 100px);
		max-height: calc(100vh - 100px);
	}
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	#nvg-cb-root .nvg-cb-panel,
	#nvg-cb-root .nvg-cb-msg,
	#nvg-cb-root .nvg-cb-quick-replies,
	#nvg-cb-root .nvg-cb-lead-form {
		animation: none;
	}
	#nvg-cb-root .nvg-cb-typing span { animation: none; }
}
