/* Restoration AI Chat Widget — front-end styles.
   Branding is driven by CSS variables set inline from admin settings:
   --rchat-primary, --rchat-secondary, --rchat-bg, --rchat-text, --rchat-radius, --rchat-font */

#rchat-root {
	position: fixed;
	bottom: 20px;
	z-index: 2147483000;
	font-family: var(--rchat-font, inherit);
	font-size: 15px;
	line-height: 1.45;
	box-sizing: border-box;
}
#rchat-root *,
#rchat-root *::before,
#rchat-root *::after {
	box-sizing: border-box;
}

/* Launcher */
.rchat-launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	border: 0;
	cursor: pointer;
	color: #fff;
	background: var(--rchat-primary, #0b5cab);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	font-family: inherit;
}
.rchat-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}
.rchat-launcher:focus-visible {
	outline: 3px solid var(--rchat-secondary, #08407a);
	outline-offset: 2px;
}
.rchat-launcher--bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	justify-content: center;
	padding: 0;
}
.rchat-launcher--pill {
	height: 54px;
	border-radius: 27px;
	padding: 0 22px 0 18px;
	font-weight: 600;
	font-size: 16px;
}
.rchat-launcher-icon {
	display: inline-flex;
}
.rchat-root[data-state="open"] .rchat-launcher {
	display: none;
}

/* Panel */
.rchat-panel {
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 90px);
	background: var(--rchat-bg, #fff);
	color: var(--rchat-text, #1f2933);
	border-radius: var(--rchat-radius, 16px);
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
	/* Hidden by default; the launcher maximizes it. Visibility is driven by
	   the data-state on #rchat-root so it cannot be overridden by the panel's
	   own display rule (which is why the old [hidden] approach failed). */
	display: none;
	flex-direction: column;
	overflow: hidden;
}
.rchat-root[data-state="open"] .rchat-panel {
	display: flex;
	animation: rchat-pop 0.18s ease;
}
@keyframes rchat-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.rchat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--rchat-primary, #0b5cab);
	color: #fff;
}
.rchat-header-avatar {
	display: inline-flex;
	width: 30px;
	height: 30px;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.18);
	border-radius: 50%;
}
.rchat-header-title {
	font-weight: 600;
	font-size: 16px;
	flex: 1;
}
.rchat-min {
	background: transparent;
	border: 0;
	color: #fff;
	line-height: 0;
	cursor: pointer;
	opacity: 0.85;
	padding: 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
}
.rchat-min:hover { opacity: 1; background: rgba(255, 255, 255, 0.16); }
.rchat-min:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 1px; }

.rchat-end-link {
	background: transparent;
	border: 0;
	color: #fff;
	opacity: 0.85;
	cursor: pointer;
	font-size: 12px;
	font-family: inherit;
	text-decoration: underline;
	padding: 4px 6px;
	white-space: nowrap;
}
.rchat-end-link:hover { opacity: 1; }
.rchat-end-link:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 1px; }

/* Post-end "start new chat" state (replaces the input row) */
.rchat-newchat {
	padding: 12px;
	border-top: 1px solid #e4e7eb;
	background: var(--rchat-bg, #fff);
	text-align: center;
}
.rchat-newchat-btn {
	border: 0;
	border-radius: 12px;
	padding: 10px 16px;
	background: var(--rchat-primary, #0b5cab);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
}
.rchat-newchat-btn:hover { background: var(--rchat-secondary, #08407a); }

/* Emergency bar */
.rchat-emergency-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	background: #b91c1c;
	color: #fff;
	font-weight: 600;
	font-size: 14px;
}
.rchat-call-btn {
	background: #fff;
	color: #b91c1c !important;
	text-decoration: none;
	padding: 7px 14px;
	border-radius: 999px;
	font-weight: 700;
	white-space: nowrap;
}
.rchat-call-btn:hover { background: #ffe8e8; }

/* Messages */
.rchat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--rchat-bg, #fff);
}
.rchat-msg {
	max-width: 85%;
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
	font-size: 14.5px;
}
.rchat-msg--bot {
	align-self: flex-start;
	background: #eef2f7;
	color: var(--rchat-text, #1f2933);
	border-bottom-left-radius: 4px;
}
.rchat-msg--user {
	align-self: flex-end;
	background: var(--rchat-primary, #0b5cab);
	color: #fff;
	border-bottom-right-radius: 4px;
}

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

/* Lead form card */
.rchat-lead-card {
	align-self: stretch;
	background: #f7f9fc;
	border: 1px solid #e1e8f0;
	border-radius: 12px;
	padding: 14px;
}
.rchat-lead-card h4 {
	margin: 0 0 10px;
	font-size: 14px;
	color: var(--rchat-text, #1f2933);
}
.rchat-lead-card label {
	display: block;
	font-size: 12px;
	color: #52606d;
	margin: 8px 0 3px;
}
.rchat-lead-card input,
.rchat-lead-card textarea {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #cdd6e0;
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	color: var(--rchat-text, #1f2933);
	background: #fff;
}
.rchat-lead-card textarea { resize: vertical; min-height: 56px; }
.rchat-lead-actions {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}
.rchat-lead-actions button {
	border: 0;
	border-radius: 8px;
	padding: 9px 14px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
}
.rchat-lead-submit { background: var(--rchat-primary, #0b5cab); color: #fff; flex: 1; }
.rchat-lead-skip { background: #e4e7eb; color: #52606d; }

/* Input */
.rchat-input-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e4e7eb;
	background: var(--rchat-bg, #fff);
}
.rchat-input {
	flex: 1;
	resize: none;
	max-height: 110px;
	border: 1px solid #cdd6e0;
	border-radius: 12px;
	padding: 10px 12px;
	font-size: 14.5px;
	font-family: inherit;
	color: var(--rchat-text, #1f2933);
	background: #fff;
	line-height: 1.4;
}
.rchat-input:focus {
	outline: none;
	border-color: var(--rchat-primary, #0b5cab);
	box-shadow: 0 0 0 3px rgba(11, 92, 171, 0.15);
}
.rchat-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: var(--rchat-primary, #0b5cab);
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.rchat-send:disabled { opacity: 0.5; cursor: default; }
.rchat-send:hover:not(:disabled) { background: var(--rchat-secondary, #08407a); }

.rchat-sr,
.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* Mobile */
@media (max-width: 480px) {
	.rchat-panel {
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		max-width: 100vw;
		border-radius: 0;
		position: fixed;
		inset: 0;
	}
	#rchat-root { bottom: 16px; }
}
.rchat-hide-mobile {
	display: block;
}
@media (max-width: 600px) {
	.rchat-hide-mobile { display: none !important; }
}
