/* RO AI Chat — Frontend Styles
   ALL selectors scoped under .ro-chat- prefix
   Mobile-first: base = 320px, enhanced at 768px and 1024px */

:root {
	--ro-chat-primary: #141414;
	--ro-chat-accent: #ffffff;
	--ro-chat-radius: 16px;
	--ro-chat-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--ro-chat-shadow: 0 8px 32px rgba(0,0,0,0.18);
	--ro-chat-z: 9999;
	--ro-chat-offset-bottom: 24px;
	--ro-chat-offset-side: 24px;
	--ro-chat-w: 360px;
	--ro-chat-h: 520px;
	--ro-chat-wa-green: #25D366;
}

/* ── Bubble ── */
.ro-chat-bubble {
	position: fixed;
	bottom: var(--ro-chat-offset-bottom);
	right: var(--ro-chat-offset-side);
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	padding: 12px 20px 12px 14px;
	border-radius: 50px;
	cursor: pointer;
	z-index: var(--ro-chat-z);
	box-shadow: var(--ro-chat-shadow);
	transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease;
	font-family: var(--ro-chat-font);
	min-height: 56px;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}
.ro-chat-bubble.ro-chat-position-left {
	right: auto;
	left: var(--ro-chat-offset-side);
}
.ro-chat-bubble:hover,
.ro-chat-bubble:focus-visible {
	transform: scale(1.04);
	box-shadow: 0 12px 40px rgba(0,0,0,0.24);
	outline: 2px solid var(--ro-chat-accent);
	outline-offset: 2px;
}
.ro-chat-bubble.ro-chat-open .ro-chat-bubble__text { display: none; }
.ro-chat-bubble.ro-chat-open .ro-chat-bubble__close { display: flex; }
.ro-chat-bubble.ro-chat-open .ro-chat-bubble__avatar { display: none; }
.ro-chat-bubble__avatar { font-size: 22px; line-height: 1; }
.ro-chat-bubble__text { display: flex; flex-direction: column; }
.ro-chat-bubble__label { font-weight: 700; font-size: 14px; }
.ro-chat-bubble__sublabel { font-size: 11px; opacity: 0.75; }
.ro-chat-bubble__close {
	display: none;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	width: 36px;
	height: 36px;
}
.ro-chat-bubble__badge {
	position: absolute;
	top: -6px;
	right: -6px;
	background: #e53e3e;
	color: #fff;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* ── Window ── */
.ro-chat-window {
	position: fixed;
	bottom: calc(var(--ro-chat-offset-bottom) + 72px);
	right: var(--ro-chat-offset-side);
	width: 100%;
	max-width: var(--ro-chat-w);
	height: var(--ro-chat-h);
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: var(--ro-chat-radius);
	box-shadow: var(--ro-chat-shadow);
	display: flex;
	flex-direction: column;
	z-index: calc(var(--ro-chat-z) - 1);
	font-family: var(--ro-chat-font);
	overflow: hidden;
	transform: translateY(20px) scale(0.97);
	opacity: 0;
	pointer-events: none;
	transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
.ro-chat-window.ro-chat-position-left {
	right: auto;
	left: var(--ro-chat-offset-side);
}
.ro-chat-window.ro-chat-window--open {
	transform: translateY(0) scale(1);
	opacity: 1;
	pointer-events: all;
}

/* ── Header ── */
.ro-chat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	flex-shrink: 0;
}
.ro-chat-header__avatar { font-size: 26px; line-height: 1; }
.ro-chat-header__info { flex: 1; min-width: 0; }
.ro-chat-header__name { display: block; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ro-chat-header__status { display: flex; align-items: center; gap: 5px; font-size: 11px; opacity: 0.8; }
.ro-chat-status-dot {
	width: 7px;
	height: 7px;
	background: #48bb78;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
}
.ro-chat-header__actions { display: flex; align-items: center; gap: 6px; }
.ro-chat-sound-toggle,
.ro-chat-close-btn {
	background: none;
	border: none;
	color: var(--ro-chat-accent);
	cursor: pointer;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	font-size: 16px;
	opacity: 0.85;
	transition: opacity 0.15s, background 0.15s;
	min-width: 44px;
	min-height: 44px;
}
.ro-chat-sound-toggle:hover,
.ro-chat-close-btn:hover,
.ro-chat-sound-toggle:focus-visible,
.ro-chat-close-btn:focus-visible {
	opacity: 1;
	background: rgba(255,255,255,0.15);
	outline: 2px solid var(--ro-chat-accent);
}

/* ── Messages ── */
.ro-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 12px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}
.ro-chat-messages::-webkit-scrollbar { width: 4px; }
.ro-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ro-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.ro-chat-msg {
	display: flex;
	flex-direction: column;
	max-width: 82%;
	gap: 2px;
}
.ro-chat-msg--user {
	align-self: flex-end;
	align-items: flex-end;
}
.ro-chat-msg--ai,
.ro-chat-msg--agent {
	align-self: flex-start;
	align-items: flex-start;
}
.ro-chat-msg__bubble {
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	white-space: pre-wrap;
}
.ro-chat-msg--user .ro-chat-msg__bubble {
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	border-bottom-right-radius: 4px;
}
.ro-chat-msg--ai .ro-chat-msg__bubble {
	background: #f2f2f7;
	color: #1a1a1a;
	border-bottom-left-radius: 4px;
}
.ro-chat-msg--agent .ro-chat-msg__bubble {
	background: #e8f5e9;
	color: #1a1a1a;
	border-bottom-left-radius: 4px;
	border-left: 3px solid #48bb78;
}
.ro-chat-msg__time {
	font-size: 10px;
	color: #999;
	padding: 0 4px;
}

/* ── Typing Indicator ── */
.ro-chat-typing {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 10px 16px;
	flex-shrink: 0;
}
.ro-chat-typing__dot {
	width: 7px;
	height: 7px;
	background: #aaa;
	border-radius: 50%;
	animation: ro-chat-bounce 1.2s infinite ease-in-out;
}
.ro-chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.ro-chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ro-chat-bounce {
	0%, 80%, 100% { transform: translateY(0); }
	40% { transform: translateY(-7px); }
}
.ro-chat-typing__label { font-size: 11px; color: #999; margin-left: 4px; }

/* ── Quick Replies ── */
.ro-chat-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 6px 12px;
	flex-shrink: 0;
}
.ro-chat-chip {
	background: #fff;
	border: 1px solid var(--ro-chat-primary);
	color: var(--ro-chat-primary);
	padding: 6px 14px;
	border-radius: 20px;
	font-size: 12px;
	font-family: var(--ro-chat-font);
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	min-height: 32px;
	white-space: nowrap;
}
.ro-chat-chip:hover,
.ro-chat-chip:focus-visible {
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	outline: 2px solid var(--ro-chat-primary);
}

/* ── WhatsApp Button ── */
.ro-chat-whatsapp-wrap {
	padding: 8px 12px;
	flex-shrink: 0;
}
.ro-chat-whatsapp-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	background: var(--ro-chat-wa-green);
	color: #fff;
	padding: 11px 16px;
	border-radius: 8px;
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	font-family: var(--ro-chat-font);
	transition: opacity 0.15s;
	min-height: 44px;
}
.ro-chat-whatsapp-btn:hover,
.ro-chat-whatsapp-btn:focus-visible {
	opacity: 0.9;
	outline: 2px solid var(--ro-chat-wa-green);
	outline-offset: 2px;
}

/* ── Lead Form ── */
.ro-chat-lead-form {
	background: #f9f9f9;
	padding: 16px 14px;
	border-top: 1px solid #eee;
	flex-shrink: 0;
}
.ro-chat-lead-form__title {
	font-size: 14px;
	font-weight: 700;
	color: var(--ro-chat-primary);
	margin: 0 0 12px;
}
.ro-chat-field { margin-bottom: 8px; }
.ro-chat-field label {
	display: block;
	font-size: 11px;
	font-weight: 600;
	color: #555;
	margin-bottom: 3px;
}
.ro-chat-field input,
.ro-chat-field textarea {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #ddd;
	border-radius: 6px;
	font-size: 13px;
	font-family: var(--ro-chat-font);
	box-sizing: border-box;
	background: #fff;
	color: #1a1a1a;
	transition: border-color 0.15s;
	min-height: 36px;
}
.ro-chat-field input:focus,
.ro-chat-field textarea:focus {
	outline: none;
	border-color: var(--ro-chat-primary);
	box-shadow: 0 0 0 2px rgba(20,20,20,0.08);
}
.ro-chat-field textarea { resize: none; }
.ro-chat-lead-submit {
	width: 100%;
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	border: none;
	padding: 11px 16px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	font-family: var(--ro-chat-font);
	cursor: pointer;
	margin-top: 4px;
	transition: opacity 0.15s;
	min-height: 44px;
}
.ro-chat-lead-submit:hover { opacity: 0.88; }
.ro-chat-lead-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Rating ── */
.ro-chat-rating {
	padding: 12px 14px;
	border-top: 1px solid #eee;
	background: #fafafa;
	flex-shrink: 0;
	text-align: center;
}
.ro-chat-rating__question { font-size: 13px; font-weight: 600; color: #333; margin: 0 0 8px; }
.ro-chat-rating__buttons { display: flex; gap: 10px; justify-content: center; }
.ro-chat-rate-btn {
	background: #fff;
	border: 1px solid #ddd;
	padding: 8px 20px;
	border-radius: 20px;
	font-size: 14px;
	cursor: pointer;
	font-family: var(--ro-chat-font);
	min-height: 44px;
	transition: border-color 0.15s, background 0.15s;
}
.ro-chat-rate-btn:hover { border-color: var(--ro-chat-primary); background: #f5f5f5; }

/* ── Transcript ── */
.ro-chat-transcript {
	padding: 10px 14px;
	border-top: 1px solid #eee;
	flex-shrink: 0;
	background: #fafafa;
}
.ro-chat-transcript p { font-size: 12px; color: #555; margin: 0 0 6px; }
.ro-chat-transcript__form { display: flex; gap: 6px; }
#ro-chat-transcript-email {
	flex: 1;
	padding: 8px 10px;
	border: 1px solid #ddd;
	border-radius: 6px;
	font-size: 12px;
	font-family: var(--ro-chat-font);
	min-height: 36px;
}
#ro-chat-transcript-send {
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	border: none;
	padding: 8px 14px;
	border-radius: 6px;
	font-size: 12px;
	font-family: var(--ro-chat-font);
	cursor: pointer;
	white-space: nowrap;
	min-height: 36px;
}

/* ── Input Area ── */
.ro-chat-input-area {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	padding: 10px 12px;
	border-top: 1px solid #eee;
	background: #fff;
	flex-shrink: 0;
}
.ro-chat-file-btn {
	cursor: pointer;
	font-size: 18px;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	flex-shrink: 0;
	transition: background 0.15s;
	position: relative;
}
.ro-chat-file-btn:hover { background: #f0f0f0; }
.ro-chat-file-input { display: none; }
.ro-chat-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 10px 14px;
	font-size: 14px;
	font-family: var(--ro-chat-font);
	resize: none;
	outline: none;
	line-height: 1.4;
	max-height: 100px;
	overflow-y: auto;
	background: #f9f9f9;
	color: #1a1a1a;
	transition: border-color 0.15s;
	min-height: 44px;
}
.ro-chat-input:focus {
	border-color: var(--ro-chat-primary);
	background: #fff;
	box-shadow: 0 0 0 2px rgba(20,20,20,0.06);
}
.ro-chat-send-btn {
	width: 44px;
	height: 44px;
	min-width: 44px;
	background: var(--ro-chat-primary);
	color: var(--ro-chat-accent);
	border: none;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: transform 0.15s, opacity 0.15s;
}
.ro-chat-send-btn:hover { transform: scale(1.08); }
.ro-chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Footer / GDPR ── */
.ro-chat-footer { padding: 6px 14px 10px; flex-shrink: 0; }
.ro-chat-gdpr { font-size: 10px; color: #aaa; margin: 0; text-align: center; }
.ro-chat-gdpr a { color: #888; text-decoration: underline; }

/* ── Mobile: full-screen bottom-sheet ── */
@media (max-width: 767px) {
	.ro-chat-window {
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		max-height: 92vh;
		border-radius: var(--ro-chat-radius) var(--ro-chat-radius) 0 0;
		transform: translateY(100%);
	}
	.ro-chat-window.ro-chat-window--open { transform: translateY(0); }
	.ro-chat-bubble.ro-chat-position-left { left: var(--ro-chat-offset-side); right: auto; }
}

/* ── Tablet ── */
@media (min-width: 768px) and (max-width: 1023px) {
	:root { --ro-chat-w: 380px; }
}

/* ── Desktop ── */
@media (min-width: 1024px) {
	:root { --ro-chat-w: 400px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
	.ro-chat-bubble,
	.ro-chat-window,
	.ro-chat-typing__dot { transition: none; animation: none; }
}
