/* ── Root ── */
#ro-ai-chat-root {
	position: fixed;
	bottom: 20px;
	z-index: 9999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}
#ro-ai-chat-root.ro-ai-pos-right { right: 20px; }
#ro-ai-chat-root.ro-ai-pos-left  { left: 20px; }

/* ── Trigger pill ── */
.ro-ai-trigger-pill {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: #1a1a1a;
	color: #fff;
	border: none;
	border-radius: 28px;
	padding: 10px 20px 10px 10px;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0,0,0,0.25);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ro-ai-trigger-pill:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.ro-ai-trigger-pill:focus-visible {
	outline: 2px solid #4f9cf9;
	outline-offset: 2px;
}
.ro-ai-trigger-icon {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255,255,255,0.12);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.ro-ai-trigger-label {
	font-size: 14px;
	font-weight: 600;
}

/* Notification dot on trigger */
.ro-ai-notif-dot {
	position: absolute;
	top: -3px;
	right: -3px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #ef4444;
	border: 2px solid #fff;
	animation: ro-ai-notif-pulse 1.8s ease-in-out infinite;
}
@keyframes ro-ai-notif-pulse {
	0%, 100% { transform: scale(1);   opacity: 1; }
	50%       { transform: scale(1.3); opacity: 0.75; }
}

/* ── Panel ── */
.ro-ai-panel {
	position: absolute;
	bottom: 68px;
	width: 350px;
	background: #fff;
	border-radius: 18px;
	border: 1px solid rgba(0,0,0,0.1);
	box-shadow: 0 8px 30px rgba(0,0,0,0.18);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.ro-ai-pos-right .ro-ai-panel { right: 0; }
.ro-ai-pos-left  .ro-ai-panel { left: 0; }
.ro-ai-panel[hidden] { display: none; }

/* ── Header ── */
.ro-ai-panel-header {
	background: #111;
	padding: 12px 14px 10px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.ro-ai-header-top {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
}

.ro-ai-header-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #2a2a2a;
	border: 1px solid #3a3a3a;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: #fff;
}
.ro-ai-header-text {
	flex: 1;
	min-width: 0;
}
.ro-ai-header-name {
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	margin: 0;
}
.ro-ai-header-status {
	color: #6ee7b7;
	font-size: 10px;
	margin: 0;
	display: flex;
	align-items: center;
	gap: 4px;
}
.ro-ai-live-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #4ade80;
	flex-shrink: 0;
}
.ro-ai-close-btn {
	background: none;
	border: none;
	color: #666;
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	flex-shrink: 0;
}
.ro-ai-close-btn:hover { color: #fff; }
.ro-ai-close-btn:focus-visible { outline: 2px solid #4f9cf9; }

/* Header action buttons — full width row below name */
.ro-ai-header-actions {
	display: flex;
	gap: 8px;
	width: 100%;
}
.ro-ai-header-btn {
	flex: 1;
	background: #222;
	border: 1px solid #3a3a3a;
	border-radius: 8px;
	padding: 7px 10px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	color: #ccc;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.15s, border-color 0.15s;
	font-family: inherit;
}
.ro-ai-header-btn:hover { background: #2a2a2a; border-color: #555; color: #fff; }
.ro-ai-wa-header-btn {
	background: rgba(37,211,102,0.12) !important;
	border-color: #25D366 !important;
	color: #25D366 !important;
}
.ro-ai-wa-header-btn:hover {
	background: rgba(37,211,102,0.22) !important;
	color: #25D366 !important;
}

/* ── Messages ── */
.ro-ai-messages {
	flex: 1;
	padding: 14px 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	max-height: 300px;
	min-height: 160px;
	scroll-behavior: smooth;
}
.ro-ai-msg {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.ro-ai-msg-user { flex-direction: row-reverse; }
.ro-ai-msg-avatar {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: #f0f0f0;
	border: 1px solid #e0e0e0;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: #555;
}
.ro-ai-bubble {
	max-width: 82%;
	padding: 9px 12px;
	font-size: 13px;
	line-height: 1.55;
	border-radius: 14px;
	word-break: break-word;
}
.ro-ai-msg-ai   .ro-ai-bubble { background: #f4f4f5; color: #111; border-bottom-left-radius: 4px; }
.ro-ai-msg-user .ro-ai-bubble { background: #1a1a1a; color: #fff; border-bottom-right-radius: 4px; }

/* Typing indicator */
.ro-ai-typing-dots {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 9px 12px;
	background: #f4f4f5;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	width: fit-content;
}
.ro-ai-typing-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #aaa;
	display: block;
	animation: ro-ai-bop 1.2s infinite;
}
.ro-ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ro-ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ro-ai-bop {
	0%, 60%, 100% { transform: translateY(0); }
	30%            { transform: translateY(-5px); }
}

/* Error bubble */
.ro-ai-bubble-error { background: #fef2f2 !important; color: #b91c1c !important; }

/* Handoff card */
.ro-ai-handoff-card {
	margin: 4px 0 4px 34px;
	background: #f9f9f9;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 12px 14px;
}
.ro-ai-handoff-tag {
	font-size: 10px;
	color: #888;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin: 0 0 5px;
}
.ro-ai-handoff-title {
	font-size: 13px;
	font-weight: 600;
	color: #111;
	margin: 0 0 10px;
}
.ro-ai-handoff-btns {
	display: flex;
	gap: 8px;
}
.ro-ai-handoff-btn {
	flex: 1;
	padding: 10px 8px;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	text-decoration: none;
	transition: opacity 0.15s;
	box-sizing: border-box;
	line-height: 1.2;
	white-space: nowrap;
}
.ro-ai-handoff-btn:hover { opacity: 0.85; }
.ro-ai-handoff-btn-form { background: #1a1a1a; color: #fff; }
.ro-ai-handoff-btn-wa   { background: #25D366; color: #fff; }

/* ── Input row ── */
.ro-ai-input-row {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #f0f0f0;
	align-items: flex-end;
	flex-shrink: 0;
}
.ro-ai-input {
	flex: 1;
	font-size: 13px;
	padding: 9px 14px;
	border: 1px solid #ddd;
	border-radius: 22px;
	background: #fafafa;
	color: #111;
	outline: none;
	font-family: inherit;
	resize: none;
	max-height: 100px;
	overflow-y: auto;
	line-height: 1.4;
}
.ro-ai-input:focus { border-color: #aaa; background: #fff; }
.ro-ai-input:disabled { opacity: 0.5; }
.ro-ai-send-btn {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #1a1a1a;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	color: #fff;
	transition: opacity 0.15s;
}
.ro-ai-send-btn:hover   { opacity: 0.85; }
.ro-ai-send-btn:disabled { opacity: 0.4; cursor: default; }
.ro-ai-send-btn:focus-visible { outline: 2px solid #4f9cf9; outline-offset: 2px; }

/* ── Contact form ── */
.ro-ai-contact-form-wrap {
	padding: 14px 14px 12px;
	border-top: 1px solid #f0f0f0;
	flex-shrink: 0;
	background: #fafafa;
}
.ro-ai-contact-form-wrap[hidden] { display: none; }
.ro-ai-hp {
	position: absolute;
	left: -9999px;
	opacity: 0;
	height: 0;
	overflow: hidden;
}
.ro-ai-form-row {
	display: flex;
	flex-direction: column;
	gap: 3px;
	margin-bottom: 8px;
}
.ro-ai-form-row label {
	font-size: 11px;
	font-weight: 600;
	color: #555;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.ro-ai-optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: #aaa; }
.ro-ai-form-row input,
.ro-ai-form-row textarea {
	font-size: 13px;
	padding: 8px 10px;
	border: 1px solid #e0e0e0;
	border-radius: 7px;
	background: #fff;
	color: #111;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s;
}
.ro-ai-form-row input:focus,
.ro-ai-form-row textarea:focus  { border-color: #999; }
.ro-ai-form-row textarea        { resize: none; }
.ro-ai-field-error {
	font-size: 11px;
	color: #dc2626;
	min-height: 14px;
}

/* Form buttons — scoped under root ID to beat theme button reset (0,1,1 specificity) */
.ro-ai-form-actions {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}
#ro-ai-chat-root .ro-ai-submit-btn {
	flex: 1;
	background: #1a1a1a;
	color: #fff;
	border: none;
	border-radius: 9px;
	padding: 11px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s;
	letter-spacing: 0.01em;
}
#ro-ai-chat-root .ro-ai-submit-btn:hover    { background: #333; }
#ro-ai-chat-root .ro-ai-submit-btn:disabled { opacity: 0.45; cursor: default; background: #1a1a1a; }
#ro-ai-chat-root .ro-ai-cancel-btn {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 9px;
	padding: 11px 16px;
	font-size: 13px;
	font-weight: 500;
	color: #555;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#ro-ai-chat-root .ro-ai-cancel-btn:hover { background: #f0f0f0; border-color: #aaa; color: #111; }
.ro-ai-form-status {
	margin-top: 8px;
	font-size: 12px;
	color: #059669;
	min-height: 16px;
	text-align: center;
}

/* Link buttons inside AI messages */
.ro-ai-link-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #1a1a1a;
	color: #fff;
	padding: 4px 11px;
	border-radius: 20px;
	font-size: 11px;
	font-weight: 600;
	text-decoration: none;
	vertical-align: middle;
	margin: 3px 1px;
	transition: background 0.15s;
	white-space: nowrap;
}
.ro-ai-link-btn:hover { background: #333; color: #fff; }

/* ── Panel open animation ── */
@keyframes ro-ai-slide-up {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}
.ro-ai-panel:not([hidden]) {
	animation: ro-ai-slide-up 0.2s ease;
}

/* ── Responsive ── */
@media screen and (max-width: 768px) {
	.ro-ai-panel { width: 320px; }
}

@media screen and (max-width: 480px) {
	#ro-ai-chat-root { bottom: 16px; }
	#ro-ai-chat-root.ro-ai-pos-right { right: 12px; }
	#ro-ai-chat-root.ro-ai-pos-left  { left: 12px; }

	.ro-ai-panel {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		max-height: 88vh;
		border-radius: 20px 20px 0 0;
	}
	.ro-ai-pos-right .ro-ai-panel,
	.ro-ai-pos-left  .ro-ai-panel { left: 0; right: 0; }

	.ro-ai-messages { max-height: 46vh; }
}
