/* ChatWidget.css
   Pairs with ChatWidget.jsx. Requires Bulma to be loaded globally
   (e.g. `import "bulma/css/bulma.min.css";` in your app entry point).
   These rules only handle the parts Bulma doesn't provide: floating
   position, bubbles, and motion. */

/* Hide chat widget while mobile drawer is open so it can't block menu links */
body.drawer-open .chat-widget-root {
	display: none;
}

.chat-widget-root {
	--cw-ink: #12162a;
	--cw-ink-soft: #1e2340;
	--cw-porcelain: #f7f8fb;
	--cw-paper: #ffffff;
	--cw-line: #e7e9f3;
	--cw-teal: #17bebb;
	--cw-teal-deep: #0fa3a0;
	--cw-amber: #ffb86b;
	--cw-text-muted: #8a8fa8;
	--cw-font-display: 'Sora', sans-serif;
	--cw-font-body: 'Inter', sans-serif;

	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	font-family: var(--cw-font-body);
	/* When closed, only the launcher button itself is interactive */
	pointer-events: none;
}

/* Re-enable pointer events on the always-visible launcher */
.chat-widget-root .chat-launcher {
	pointer-events: auto;
}

/* Re-enable pointer events on the open panel */
.chat-widget-root.is-open .chat-panel {
	pointer-events: auto;
}

/* ---------- Launcher ---------- */
.chat-launcher {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(155deg, var(--cw-teal) 0%, var(--cw-teal-deep) 100%);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow:
		0 10px 30px rgba(15, 163, 160, 0.35),
		0 2px 8px rgba(18, 22, 42, 0.15);
	position: relative;
	transition:
		transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
		box-shadow 0.25s ease;
}
.chat-launcher:hover {
	transform: scale(1.06);
	box-shadow:
		0 14px 36px rgba(15, 163, 160, 0.45),
		0 2px 8px rgba(18, 22, 42, 0.18);
}
.chat-launcher:active {
	transform: scale(0.96);
}

.chat-icon-wrap {
	position: relative;
	display: inline-block;
	width: 26px;
	height: 26px;
}
.chat-icon-wrap svg {
	position: absolute;
	top: 0;
	left: 0;
	width: 26px;
	height: 26px;
	transition:
		opacity 0.2s ease,
		transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-icon-chat {
	opacity: 1;
	transform: rotate(0deg) scale(1);
}
.chat-icon-close {
	opacity: 0;
	transform: rotate(-45deg) scale(0.6);
}
.chat-widget-root.is-open .chat-icon-chat {
	opacity: 0;
	transform: rotate(45deg) scale(0.6);
}
.chat-widget-root.is-open .chat-icon-close {
	opacity: 1;
	transform: rotate(0deg) scale(1);
}

.chat-pulse-dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 12px;
	height: 12px;
	background: var(--cw-amber);
	border-radius: 50%;
	border: 2px solid var(--cw-paper);
}
.chat-pulse-dot::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--cw-amber);
	animation: cw-pulse 2s ease-out infinite;
}
@keyframes cw-pulse {
	0% {
		transform: scale(1);
		opacity: 0.7;
	}
	100% {
		transform: scale(2.4);
		opacity: 0;
	}
}
.chat-widget-root.is-open .chat-pulse-dot {
	display: none;
}

/* ---------- Panel ---------- */
.chat-panel {
	width: 368px;
	max-width: calc(100vw - 32px);
	height: calc(100vh - 120px);
	max-height: 640px;
	border-radius: 20px !important;
	box-shadow:
		0 24px 60px rgba(18, 22, 42, 0.22),
		0 4px 16px rgba(18, 22, 42, 0.08) !important;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	margin-bottom: 16px;

	opacity: 0;
	transform: translateY(16px) scale(0.96);
	pointer-events: none;
	transform-origin: bottom right;
	transition:
		opacity 0.22s ease,
		transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.chat-widget-root.is-open .chat-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* ---------- Header ---------- */
.chat-header {
	background: linear-gradient(135deg, var(--cw-ink) 0%, var(--cw-ink-soft) 100%);
	padding: 18px 20px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}
.chat-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: linear-gradient(155deg, var(--cw-teal) 0%, var(--cw-teal-deep) 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.chat-avatar svg {
	width: 20px;
	height: 20px;
}
.chat-header-text {
	flex: 1;
	min-width: 0;
}
.chat-name {
	font-family: var(--cw-font-display);
	font-weight: 600;
	font-size: 14.5px;
	color: #fff;
	letter-spacing: 0.01em;
	margin: 0;
}
.chat-status {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.55);
	display: flex;
	align-items: center;
	gap: 5px;
	margin: 2px 0 0;
}
.chat-status-dot {
	width: 6px;
	height: 6px;
	background: var(--cw-teal);
	border-radius: 50%;
	box-shadow: 0 0 0 3px rgba(23, 190, 187, 0.18);
}
.chat-header-close {
	background: rgba(255, 255, 255, 0.08);
	border: none;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s ease;
}
.chat-header-close:hover {
	background: rgba(255, 255, 255, 0.16);
}
.chat-header-close svg {
	width: 13px;
	height: 13px;
}

/* ---------- Messages ---------- */
.chat-messages {
	height: 52vh;
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--cw-porcelain);
}
.chat-messages::-webkit-scrollbar {
	width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
	background: #d6d9e8;
	border-radius: 10px;
}

.chat-bubble-row {
	display: flex;
}
.chat-bubble-row.bot {
	justify-content: flex-start;
}
.chat-bubble-row.user {
	justify-content: flex-end;
}

.chat-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 13.5px;
	line-height: 1.45;
	animation: cw-rise 0.25s ease;
}
@keyframes cw-rise {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}
.chat-bubble-row.bot .chat-bubble {
	background: var(--cw-paper);
	color: var(--cw-ink);
	border: 1px solid var(--cw-line);
	border-bottom-left-radius: 5px;
}
.chat-bubble-row.user .chat-bubble {
	background: linear-gradient(135deg, var(--cw-teal) 0%, var(--cw-teal-deep) 100%);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.chat-typing-bubble {
	background: var(--cw-paper);
	border: 1px solid var(--cw-line);
	border-radius: 16px;
	border-bottom-left-radius: 5px;
	padding: 12px 16px;
	display: flex;
	gap: 4px;
}
.chat-typing-bubble span {
	width: 6px;
	height: 6px;
	background: var(--cw-text-muted);
	border-radius: 50%;
	animation: cw-bounce 1.2s infinite;
}
.chat-typing-bubble span:nth-child(2) {
	animation-delay: 0.15s;
}
.chat-typing-bubble span:nth-child(3) {
	animation-delay: 0.3s;
}
@keyframes cw-bounce {
	0%,
	60%,
	100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* ---------- Input ---------- */
/* ---------- Input (Uiverse messageBox) ---------- */
.chat-input-bar {
	padding: 10px 12px;
	background: var(--cw-paper);
	border-top: 1px solid var(--cw-line);
	flex-shrink: 0;
}

.cw-messageBox {
	width: 100%;
	height: 40px;
	display: flex;
	align-items: center;
	background-color: #2d2d2d;
	padding: 0 12px 0 4px;
	border-radius: 10px;
	border: 1px solid rgb(63, 63, 63);
	box-sizing: border-box;
	transition: border 0.2s ease;
}

.cw-messageBox:focus-within {
	border: 1px solid rgb(110, 110, 110);
}

.cw-messageInput {
	flex: 1;
	min-width: 0;
	height: 100%;
	background-color: transparent;
	outline: none;
	border: none;
	padding: 0 8px;
	color: white;
	font-family: var(--cw-font-body);
	font-size: 13.5px;
}

.cw-messageInput::placeholder {
	color: rgba(255, 255, 255, 0.35);
}

.cw-messageInput:focus ~ .cw-sendButton svg path,
.cw-messageInput:valid ~ .cw-sendButton svg path {
	fill: #3c3c3c;
	stroke: white;
}

.cw-sendButton {
	width: 28px;
	height: 28px;
	background-color: transparent;
	outline: none;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: all 0.3s;
}

.cw-sendButton svg {
	width: 18px;
	height: 18px;
	transition: all 0.3s;
}

.cw-sendButton svg path {
	transition: all 0.3s;
}

.cw-sendButton:hover svg path {
	fill: #3c3c3c;
	stroke: white;
}

.cw-sendButton:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.chat-footnote {
	font-size: 10.5px;
	color: var(--cw-text-muted);
	padding: 6px 0 10px;
	margin: 0;
	background: var(--cw-paper);
}

/* ---------- Small screens ---------- */
@media (max-width: 420px) {
	.chat-widget-root {
		right: 12px;
		bottom: 12px;
	}
	.chat-panel {
		width: calc(100vw - 24px);
	}
}

/* ---------- Markdown inside bot bubbles ---------- */
.chat-bubble-row.bot .chat-bubble p {
	margin: 0 0 6px;
}
.chat-bubble-row.bot .chat-bubble p:last-child {
	margin-bottom: 0;
}
.chat-bubble-row.bot .chat-bubble ul,
.chat-bubble-row.bot .chat-bubble ol {
	margin: 4px 0 6px 16px;
	padding: 0;
}
.chat-bubble-row.bot .chat-bubble li {
	margin-bottom: 3px;
}
.chat-bubble-row.bot .chat-bubble strong {
	font-weight: 600;
	color: var(--cw-ink);
}
.chat-bubble-row.bot .chat-bubble a {
	color: var(--cw-teal-deep);
	text-decoration: underline;
	word-break: break-all;
}
.chat-bubble-row.bot .chat-bubble a:hover {
	color: var(--cw-teal);
}
.chat-bubble-row.bot .chat-bubble code {
	background: var(--cw-line);
	border-radius: 4px;
	padding: 1px 5px;
	font-size: 12px;
}

/* ---------- Markdown tables in bot bubbles ---------- */
.chat-bubble-row.bot .chat-bubble table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12.5px;
	margin: 6px 0;
}
.chat-bubble-row.bot .chat-bubble th,
.chat-bubble-row.bot .chat-bubble td {
	border: 1px solid var(--cw-line);
	padding: 6px 10px;
	text-align: left;
	vertical-align: top;
}
.chat-bubble-row.bot .chat-bubble th {
	background: var(--cw-porcelain);
	font-weight: 600;
	color: var(--cw-ink);
}
.chat-bubble-row.bot .chat-bubble tr:nth-child(even) td {
	background: #f0f2f9;
}

/* ---------- Lead capture form ---------- */
.chat-lead-form {
	padding: 20px 18px 18px;
	display: flex;
	flex-direction: column;
	gap: 0;
	flex: 1;
	height: 65vh;
	overflow-y: auto;
	background: var(--cw-porcelain);
}

.chat-lead-intro {
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--cw-ink);
	margin-bottom: 18px;
}

.chat-lead-field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin-bottom: 14px;
}

.chat-lead-field label {
	font-size: 12px;
	font-weight: 600;
	color: var(--cw-ink);
	letter-spacing: 0.02em;
}

.chat-lead-field input {
	border: 1.5px solid var(--cw-line);
	border-radius: 10px;
	padding: 9px 13px;
	font-family: var(--cw-font-body);
	font-size: 13.5px;
	color: var(--cw-ink);
	background: var(--cw-paper);
	outline: none;
	transition: border-color 0.15s ease;
}

.chat-lead-field input:focus {
	border-color: var(--cw-teal);
}

.chat-lead-field input::placeholder {
	color: var(--cw-text-muted);
}

.chat-lead-error {
	font-size: 11.5px;
	color: #e05252;
}

.chat-lead-submit {
	margin-top: 6px;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 18px;
	background: linear-gradient(135deg, var(--cw-teal) 0%, var(--cw-teal-deep) 100%);
	color: #fff;
	border: none;
	border-radius: 12px;
	font-family: var(--cw-font-body);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition:
		opacity 0.2s ease,
		transform 0.15s ease;
}

.chat-lead-submit:hover {
	opacity: 0.92;
}

.chat-lead-submit:active {
	transform: scale(0.97);
}

.chat-lead-submit svg {
	width: 15px;
	height: 15px;
}
