/**
 * Conversions Bridge - chat widget styles.
 * All colors flow from the --cb-accent variable set at runtime from settings.
 */

#cb-chat-root {
	--cb-accent: #2563eb;
	--cb-accent-ink: #ffffff;
	--cb-surface: #ffffff;
	--cb-text: #1f2430;
	--cb-muted: #6b7280;
	--cb-bubble-bot: #f1f3f7;
	--cb-line: #e6e8ee;
	--cb-radius: 16px;
	--cb-shadow: 0 12px 40px rgba(17, 24, 39, 0.16);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.5;
}

/* Launcher button */
.cb-launcher {
	position: fixed;
	bottom: 24px;
	z-index: 999998;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 18px;
	border: none;
	border-radius: 999px;
	background: var(--cb-accent);
	color: var(--cb-accent-ink);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: var(--cb-shadow);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cb-launcher:hover { transform: translateY(-2px); }
.cb-launcher:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.4); outline-offset: 2px; }
.cb-launcher svg { width: 22px; height: 22px; flex: none; }

.cb-pos-right { right: 24px; }
.cb-pos-left { left: 24px; }

/* Chat panel */
.cb-panel {
	position: fixed;
	bottom: 92px;
	z-index: 999999;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	background: var(--cb-surface);
	border: 1px solid var(--cb-line);
	border-radius: var(--cb-radius);
	box-shadow: var(--cb-shadow);
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}
.cb-panel.is-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Header */
.cb-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--cb-accent);
	color: var(--cb-accent-ink);
}
.cb-header__avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.22);
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 16px;
	flex: none;
}
.cb-header__meta { flex: 1; min-width: 0; }
.cb-header__name { font-weight: 700; font-size: 15px; }
.cb-header__status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.cb-header__status::before {
	content: "";
	width: 8px; height: 8px; border-radius: 50%;
	background: #4ade80;
	display: inline-block;
}
.cb-close {
	background: transparent;
	border: none;
	color: var(--cb-accent-ink);
	cursor: pointer;
	padding: 6px;
	border-radius: 8px;
	line-height: 0;
}
.cb-close:hover { background: rgba(255, 255, 255, 0.18); }
.cb-close svg { width: 20px; height: 20px; }

/* Messages */
.cb-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #fafbfc;
}
.cb-msg {
	max-width: 82%;
	padding: 11px 14px;
	border-radius: 14px;
	font-size: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.cb-msg--bot {
	align-self: flex-start;
	background: var(--cb-bubble-bot);
	color: var(--cb-text);
	border-bottom-left-radius: 4px;
}
.cb-msg--user {
	align-self: flex-end;
	background: var(--cb-accent);
	color: var(--cb-accent-ink);
	border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cb-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 14px;
	background: var(--cb-bubble-bot);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}
.cb-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--cb-muted);
	animation: cb-bounce 1.2s infinite ease-in-out;
}
.cb-typing span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* Quick replies */
.cb-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 18px 12px;
	background: #fafbfc;
}
.cb-quick button {
	border: 1px solid var(--cb-accent);
	background: var(--cb-surface);
	color: var(--cb-accent);
	padding: 8px 12px;
	border-radius: 999px;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}
.cb-quick button:hover { background: var(--cb-accent); color: var(--cb-accent-ink); }

/* Composer */
.cb-composer {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--cb-line);
	background: var(--cb-surface);
}
.cb-composer textarea {
	flex: 1;
	resize: none;
	border: 1px solid var(--cb-line);
	border-radius: 12px;
	padding: 10px 12px;
	font-size: 14px;
	font-family: inherit;
	max-height: 110px;
	color: var(--cb-text);
	background: #fff;
}
.cb-composer textarea:focus {
	outline: none;
	border-color: var(--cb-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.cb-send {
	border: none;
	background: var(--cb-accent);
	color: var(--cb-accent-ink);
	width: 44px;
	border-radius: 12px;
	cursor: pointer;
	display: grid;
	place-items: center;
	flex: none;
}
.cb-send:disabled { opacity: 0.5; cursor: default; }
.cb-send svg { width: 20px; height: 20px; }

/* Footer credit */
.cb-footer {
	text-align: center;
	font-size: 11px;
	color: var(--cb-muted);
	padding: 0 12px 10px;
	background: var(--cb-surface);
}
.cb-footer a { color: var(--cb-muted); text-decoration: none; }

/* Action bar (book a meeting) */
.cb-actions {
	padding: 0 12px 10px;
	background: var(--cb-surface);
}
.cb-actions:empty { display: none; }
.cb-actionbtn {
	width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 14px;
	border: 1px solid var(--cb-accent);
	border-radius: 12px;
	background: var(--cb-surface);
	color: var(--cb-accent);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}
.cb-actionbtn:hover { background: var(--cb-accent); color: var(--cb-accent-ink); }
.cb-actionbtn svg { width: 18px; height: 18px; flex: none; }

/* Lead form card */
.cb-leadcard {
	align-self: stretch;
	background: var(--cb-surface);
	border: 1px solid var(--cb-line);
	border-radius: 14px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	box-shadow: 0 2px 10px rgba(17, 24, 39, 0.06);
}
.cb-leadcard__intro { font-size: 13.5px; color: var(--cb-text); }
.cb-lf { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--cb-muted); }
.cb-lf input, .cb-lf textarea {
	border: 1px solid var(--cb-line);
	border-radius: 10px;
	padding: 9px 11px;
	font-size: 14px;
	font-family: inherit;
	color: var(--cb-text);
	background: #fff;
	resize: none;
}
.cb-lf input:focus, .cb-lf textarea:focus {
	outline: none;
	border-color: var(--cb-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.cb-lf__err { color: #dc2626; font-size: 12.5px; }
.cb-lf__err:empty { display: none; }
.cb-lf__row { display: flex; gap: 8px; justify-content: flex-end; }
.cb-lf__cancel {
	border: 1px solid var(--cb-line);
	background: var(--cb-surface);
	color: var(--cb-muted);
	padding: 9px 14px;
	border-radius: 10px;
	font-size: 13px;
	cursor: pointer;
}
.cb-lf__submit {
	border: none;
	background: var(--cb-accent);
	color: var(--cb-accent-ink);
	padding: 9px 16px;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
.cb-lf__submit:disabled { opacity: 0.6; cursor: default; }

/* Booking prompt card */
.cb-bookcard { align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.cb-bookcard__intro { font-size: 13.5px; color: var(--cb-text); }
.cb-bookbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 14px;
	border: none;
	border-radius: 12px;
	background: var(--cb-accent);
	color: var(--cb-accent-ink);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}
.cb-bookbtn svg { width: 18px; height: 18px; flex: none; }

/* In-chat booking iframe overlay */
.cb-bookframe {
	position: absolute;
	inset: 0;
	background: var(--cb-surface);
	display: flex;
	flex-direction: column;
	z-index: 5;
}
.cb-bookframe__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	border-bottom: 1px solid var(--cb-line);
	background: var(--cb-surface);
}
.cb-bookframe__back {
	border: none;
	background: transparent;
	color: var(--cb-accent);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	padding: 4px 6px;
}
.cb-bookframe__ext { color: var(--cb-muted); font-size: 12.5px; text-decoration: none; }
.cb-bookframe iframe { flex: 1; width: 100%; border: 0; }

@media (max-width: 480px) {
	.cb-panel {
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}
}

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