/* Floating Chat - uses site primary color (Reland theme: --unit-primary-color) */
.cfc-widget {
	--cfc-primary: var(--unit-primary-color, var(--tg-primary-color, #BD9A68));
	--cfc-primary-dark: #9a7b4d; /* fallback when color-mix not supported */
}

@supports (background: color-mix(in srgb, red, black)) {
	.cfc-widget {
		--cfc-primary-dark: color-mix(in srgb, var(--cfc-primary) 75%, black);
	}
}

.cfc-widget {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
	font-size: 16px;
	line-height: 1.5;
	box-sizing: border-box;
}

.cfc-widget *,
.cfc-widget *::before,
.cfc-widget *::after {
	box-sizing: border-box;
}

/* Toggle button */
.cfc-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border: none;
	border-radius: 28px;
	background: var(--cfc-primary);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.cfc-toggle:hover {
	background: var(--cfc-primary-dark);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	transform: scale(1.02);
}

.cfc-toggle:focus {
	outline: 2px solid var(--cfc-primary);
	outline-offset: 2px;
}

.cfc-toggle-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.cfc-toggle-icon svg {
	width: 1.25em;
	height: 1.25em;
}

.cfc-toggle-icon .cfc-icon-bubble {
	fill: #fff;
	stroke: rgba(0,0,0,0.12);
	stroke-width: 0.5;
}

.cfc-toggle-icon .cfc-icon-dot {
	fill: var(--cfc-primary);
}

.cfc-toggle-text {
	font-weight: 600;
}

/* Position variants */
.cfc-widget.cfc-bottom-right {
	bottom: 24px;
	right: 24px;
}

.cfc-widget.cfc-bottom-left {
	bottom: 24px;
	left: 24px;
}

/* Panel */
.cfc-panel {
	position: absolute;
	bottom: calc(100% + 12px);
	width: 360px;
	max-width: calc(100vw - 32px);
	max-height: 70vh;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: opacity 0.2s, transform 0.2s;
}

.cfc-widget.cfc-bottom-left .cfc-panel {
	left: 0;
}

.cfc-widget.cfc-bottom-right .cfc-panel {
	right: 0;
}

.cfc-panel[hidden] {
	display: none !important;
}

.cfc-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--cfc-primary);
	color: #fff;
}

.cfc-panel-title {
	font-weight: 600;
	font-size: 1.05em;
}

.cfc-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	padding: 0 4px;
	cursor: pointer;
	opacity: 0.9;
}

.cfc-close:hover {
	opacity: 1;
}

.cfc-close:focus {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.cfc-panel-body {
	padding: 16px;
	overflow-y: auto;
	flex: 1;
	min-height: 0;
}

/* --- Chat UI (AI mode) --- */
.cfc-chat-body {
	display: flex;
	flex-direction: column;
	padding: 0;
	min-height: 280px;
}

.cfc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px 16px;
	min-height: 200px;
	max-height: 50vh;
}

.cfc-msg {
	display: flex;
	margin-bottom: 12px;
	clear: both;
}

.cfc-msg--user {
	justify-content: flex-end;
}

.cfc-msg--assistant {
	justify-content: flex-start;
}

.cfc-msg-bubble {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	line-height: 1.45;
	font-size: 14px;
	word-wrap: break-word;
}

.cfc-msg--user .cfc-msg-bubble {
	background: var(--cfc-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.cfc-msg--assistant .cfc-msg-bubble {
	background: #e8e8e8;
	color: #333;
	border-bottom-left-radius: 4px;
}

.cfc-msg--loading .cfc-msg-bubble {
	padding: 12px 16px;
}

.cfc-typing {
	display: flex;
	align-items: center;
	gap: 4px;
}

.cfc-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #666;
	animation: cfc-bounce 0.6s ease-in-out infinite;
}

.cfc-typing span:nth-child(2) { animation-delay: 0.15s; }
.cfc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cfc-bounce {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-4px); }
}

.cfc-chat-input-wrap {
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid #e0e0e0;
	background: #fafafa;
}

.cfc-chat-input {
	flex: 1;
	padding: 10px 14px;
	border: 1px solid #ccc;
	border-radius: 20px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
}

.cfc-chat-input:focus {
	border-color: var(--cfc-primary);
}

.cfc-send-btn {
	padding: 10px 18px;
	border: none;
	border-radius: 20px;
	background: var(--cfc-primary);
	color: #fff;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.2s;
}

.cfc-send-btn:hover:not(:disabled) {
	background: var(--cfc-primary-dark);
}

.cfc-send-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

.cfc-greeting {
	margin: 0 0 12px;
	color: #333;
}

.cfc-contact {
	margin: 0 0 16px;
}

.cfc-contact-link {
	color: var(--cfc-primary);
	text-decoration: none;
	font-weight: 500;
}

.cfc-contact-link:hover {
	text-decoration: underline;
}

.cfc-form {
	margin-top: 12px;
}

.cfc-form .wpcf7-form-control-wrap {
	display: block;
	margin-bottom: 10px;
}

.cfc-form input[type="text"],
.cfc-form input[type="email"],
.cfc-form textarea {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #ccc;
	border-radius: 6px;
	font-size: 14px;
}

.cfc-form input[type="submit"] {
	padding: 10px 20px;
	background: var(--cfc-primary);
	color: #fff;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	font-weight: 500;
}

.cfc-form input[type="submit"]:hover {
	background: var(--cfc-primary-dark);
}

/* Responsive: stack on small screens */
@media (max-width: 480px) {
	.cfc-widget.cfc-bottom-right,
	.cfc-widget.cfc-bottom-left {
		bottom: 16px;
		right: 16px;
		left: 16px;
	}

	.cfc-panel {
		width: 100%;
		left: 0 !important;
		right: 0 !important;
	}
}
