/* Changes for Hope Chat. Everything is scoped under #cfh-chat-root to avoid theme conflicts. */

#cfh-chat-root,
#cfh-chat-root * {
	box-sizing: border-box;
}

#cfh-chat-root {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: #1f2933;
}

#cfh-chat-root.cfh-pos-left {
	right: auto;
	left: 36px;
}

#cfh-chat-root [hidden] {
	display: none !important;
}

/* ---------- Launcher ---------- */

#cfh-chat-root .cfh-launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--cfh-color, #3d9a4d);
	box-shadow: 0 0 0 4px #fff, 0 8px 20px rgba(0, 0, 0, 0.3);
	cursor: pointer;
	overflow: visible;
	-webkit-appearance: none;
	appearance: none;
	transition: transform 0.18s ease;
}

#cfh-chat-root .cfh-launcher:hover {
	transform: scale(1.06);
	background: var(--cfh-color, #3d9a4d);
}

#cfh-chat-root .cfh-launcher:focus-visible,
#cfh-chat-root .cfh-close:focus-visible,
#cfh-chat-root .cfh-send:focus-visible,
#cfh-chat-root .cfh-chip:focus-visible {
	outline: 3px solid #1b6fd6;
	outline-offset: 3px;
}

#cfh-chat-root .cfh-icon {
	display: flex;
	pointer-events: none;
}

#cfh-chat-root .cfh-icon svg {
	display: block;
}

#cfh-chat-root .cfh-icon-bubble {
	fill: #fff;
}

#cfh-chat-root .cfh-icon-smile {
	fill: none;
	stroke: var(--cfh-color, #3d9a4d);
	stroke-width: 2.2;
	stroke-linecap: round;
}

/* Notification badge */
#cfh-chat-root .cfh-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #c62828;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	border: 2px solid #fff;
	pointer-events: none;
}

/* Curved "Chat with us" message */
#cfh-chat-root .cfh-arc {
	position: absolute;
	left: -48px;
	top: -38px;
	width: 160px;
	height: 90px;
	overflow: visible;
	pointer-events: none;
	opacity: 0;
	animation: cfh-pop 0.5s ease 0.6s forwards, cfh-bob 3.4s ease-in-out 1.2s infinite;
}

#cfh-chat-root .cfh-arc-text {
	fill: var(--cfh-label, #1b6fd6);
	stroke: #fff;
	stroke-width: 5px;
	stroke-linejoin: round;
	paint-order: stroke fill;
	font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
	font-weight: 800;
	letter-spacing: 0.4px;
}

/* Waving hand */
#cfh-chat-root .cfh-hand {
	position: absolute;
	left: -46px;
	top: 6px;
	font-size: 28px;
	line-height: 1;
	pointer-events: none;
	transform-origin: 70% 70%;
	opacity: 0;
	animation: cfh-pop 0.5s ease 0.6s forwards, cfh-wave 2.4s ease-in-out 1.2s infinite;
}

#cfh-chat-root.cfh-pos-left .cfh-hand {
	left: auto;
	right: -46px;
	animation: cfh-pop 0.5s ease 0.6s forwards, cfh-wave-l 2.4s ease-in-out 1.2s infinite;
}

#cfh-chat-root.cfh-seen .cfh-arc,
#cfh-chat-root.cfh-seen .cfh-hand,
#cfh-chat-root.cfh-seen .cfh-badge,
#cfh-chat-root.cfh-open .cfh-arc,
#cfh-chat-root.cfh-open .cfh-hand,
#cfh-chat-root.cfh-open .cfh-badge {
	display: none;
}

@keyframes cfh-pop {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes cfh-bob {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-3px); }
}

@keyframes cfh-wave {
	0%, 60%, 100% { transform: rotate(0deg); }
	10% { transform: rotate(16deg); }
	20% { transform: rotate(-8deg); }
	30% { transform: rotate(16deg); }
	40% { transform: rotate(-4deg); }
	50% { transform: rotate(10deg); }
}

@keyframes cfh-wave-l {
	0%, 60%, 100% { transform: scaleX(-1) rotate(0deg); }
	10% { transform: scaleX(-1) rotate(16deg); }
	20% { transform: scaleX(-1) rotate(-8deg); }
	30% { transform: scaleX(-1) rotate(16deg); }
	40% { transform: scaleX(-1) rotate(-4deg); }
	50% { transform: scaleX(-1) rotate(10deg); }
}

/* ---------- Panel ---------- */

#cfh-chat-root .cfh-panel {
	position: absolute;
	bottom: 84px;
	right: 0;
	display: flex;
	flex-direction: column;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 130px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
	overflow: hidden;
}

#cfh-chat-root.cfh-pos-left .cfh-panel {
	right: auto;
	left: -12px;
}

#cfh-chat-root .cfh-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	background: var(--cfh-color, #3d9a4d);
	color: #fff;
}

#cfh-chat-root .cfh-head-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

#cfh-chat-root .cfh-title {
	font-size: 16px;
	font-weight: 700;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#cfh-chat-root .cfh-sub {
	font-size: 12px;
	opacity: 0.92;
	color: #fff;
}

#cfh-chat-root .cfh-close {
	flex: none;
	width: 34px;
	height: 34px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

#cfh-chat-root .cfh-close:hover {
	background: rgba(255, 255, 255, 0.32);
}

/* ---------- Messages ---------- */

#cfh-chat-root .cfh-msgs {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	overflow-y: auto;
	background: #f4f6f7;
	overscroll-behavior: contain;
}

#cfh-chat-root .cfh-msg {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14.5px;
	line-height: 1.45;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

#cfh-chat-root .cfh-msg p {
	margin: 0 0 6px;
}

#cfh-chat-root .cfh-msg p:last-child {
	margin-bottom: 0;
}

#cfh-chat-root .cfh-bot {
	align-self: flex-start;
	background: #fff;
	color: #1f2933;
	border: 1px solid #e1e6ea;
	border-bottom-left-radius: 4px;
}

#cfh-chat-root .cfh-bot a {
	color: #0b5cad;
	text-decoration: underline;
}

#cfh-chat-root .cfh-user {
	align-self: flex-end;
	background: var(--cfh-color, #3d9a4d);
	color: #fff;
	border-bottom-right-radius: 4px;
}

#cfh-chat-root .cfh-typing {
	display: flex;
	gap: 5px;
	padding: 14px 16px;
}

#cfh-chat-root .cfh-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #8a96a0;
	animation: cfh-dot 1.2s infinite ease-in-out;
}

#cfh-chat-root .cfh-dot:nth-child(2) { animation-delay: 0.15s; }
#cfh-chat-root .cfh-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes cfh-dot {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

#cfh-chat-root .cfh-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 2px;
}

#cfh-chat-root .cfh-chip {
	margin: 0;
	padding: 8px 12px;
	border: 1.5px solid var(--cfh-color, #3d9a4d);
	border-radius: 999px;
	background: #fff;
	color: #1f2933;
	font-size: 13.5px;
	line-height: 1.2;
	text-align: left;
	cursor: pointer;
}

#cfh-chat-root .cfh-chip:hover {
	background: var(--cfh-color, #3d9a4d);
	color: #fff;
}

/* ---------- Form ---------- */

#cfh-chat-root .cfh-form {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
	background: #fff;
	border-top: 1px solid #e1e6ea;
}

#cfh-chat-root .cfh-input {
	flex: 1;
	min-width: 0;
	height: 42px;
	margin: 0;
	padding: 0 14px;
	border: 1.5px solid #cfd6dc;
	border-radius: 999px;
	background: #fff;
	color: #1f2933;
	font-size: 16px;
	box-shadow: none;
}

#cfh-chat-root .cfh-input:focus {
	outline: none;
	border-color: var(--cfh-color, #3d9a4d);
}

#cfh-chat-root .cfh-send {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--cfh-color, #3d9a4d);
	cursor: pointer;
}

#cfh-chat-root .cfh-send svg {
	fill: #fff;
}

#cfh-chat-root .cfh-send:disabled,
#cfh-chat-root .cfh-input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

#cfh-chat-root .cfh-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

#cfh-chat-root .cfh-note {
	margin: 0;
	padding: 0 12px 10px;
	background: #fff;
	color: #5f6b76;
	font-size: 11.5px;
	text-align: center;
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
	#cfh-chat-root {
		bottom: 16px;
		right: 16px;
	}

	#cfh-chat-root.cfh-pos-left {
		left: 30px;
	}

	#cfh-chat-root .cfh-panel {
		position: fixed;
		left: 8px;
		right: 8px;
		bottom: 92px;
		width: auto;
		max-width: none;
		height: calc(100vh - 110px);
		max-height: 600px;
	}

	#cfh-chat-root.cfh-pos-left .cfh-panel {
		left: 8px;
		right: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	#cfh-chat-root .cfh-arc,
	#cfh-chat-root .cfh-hand,
	#cfh-chat-root .cfh-dot {
		animation: none;
		opacity: 1;
	}

	#cfh-chat-root .cfh-launcher {
		transition: none;
	}
}
