/**
 * UCDREAMS Tools Floating AI Assistant Styles
 * Full Dark & Light Mode Support with zero visual glitches
 *
 * @package ucdreams-tools
 */

:root {
	--ucd-primary: #C5453E;
	--ucd-primary-hover: #D6524B;
	--ucd-primary-rgb: 197, 69, 62;
	
	/* Default Light Mode Variables */
	--ucd-bot-bg: #FFFFFF;
	--ucd-bot-card-bg: #F8FAFC;
	--ucd-bot-input-bg: #FFFFFF;
	--ucd-bot-border: #E2E8F0;
	--ucd-bot-text: #0F172A;
	--ucd-bot-text-muted: #64748B;
	--ucd-bot-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
	--ucd-bot-chip-bg: #F1F5F9;
	--ucd-bot-chip-border: #E2E8F0;
	--ucd-bot-chip-text: #334155;
	--ucd-bot-avatar-bg: #F1F5F9;
	--ucd-bot-strong: #0F172A;
	--ucd-bot-tool-card-bg: #FFFFFF;
	--ucd-bot-tool-card-border: rgba(197, 69, 62, 0.25);
	--ucd-bot-tool-card-title: #0F172A;
}

[data-theme="light"],
html:not([data-theme="dark"]):not(.dark) {
	--ucd-bot-bg: #FFFFFF;
	--ucd-bot-card-bg: #F8FAFC;
	--ucd-bot-input-bg: #FFFFFF;
	--ucd-bot-border: #E2E8F0;
	--ucd-bot-text: #0F172A;
	--ucd-bot-text-muted: #64748B;
	--ucd-bot-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
	--ucd-bot-chip-bg: #F1F5F9;
	--ucd-bot-chip-border: #E2E8F0;
	--ucd-bot-chip-text: #334155;
	--ucd-bot-avatar-bg: #F1F5F9;
	--ucd-bot-strong: #0F172A;
	--ucd-bot-tool-card-bg: #FFFFFF;
	--ucd-bot-tool-card-border: rgba(197, 69, 62, 0.25);
	--ucd-bot-tool-card-title: #0F172A;
}

html[data-theme="dark"],
html.dark {
	--ucd-bot-bg: #0F1117;
	--ucd-bot-card-bg: #181B22;
	--ucd-bot-input-bg: #12151C;
	--ucd-bot-border: rgba(255, 255, 255, 0.1);
	--ucd-bot-text: #F1F5F9;
	--ucd-bot-text-muted: #94A3B8;
	--ucd-bot-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
	--ucd-bot-chip-bg: rgba(255, 255, 255, 0.06);
	--ucd-bot-chip-border: rgba(255, 255, 255, 0.1);
	--ucd-bot-chip-text: #F1F5F9;
	--ucd-bot-avatar-bg: #181B22;
	--ucd-bot-strong: #FFFFFF;
	--ucd-bot-tool-card-bg: rgba(255, 255, 255, 0.04);
	--ucd-bot-tool-card-border: rgba(197, 69, 62, 0.3);
	--ucd-bot-tool-card-title: #FFFFFF;
}

/* ==================== ROOT CONTAINER ==================== */
.ucd-assistant-wrap {
	position: fixed;
	bottom: 26px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	pointer-events: none;
}

.ucd-assistant-wrap * {
	box-sizing: border-box;
}

.ucd-assistant-wrap.ucd-pos-bottom-right {
	right: 26px;
	align-items: flex-end;
}

.ucd-assistant-wrap.ucd-pos-bottom-left {
	left: 26px;
	align-items: flex-start;
}

/* Ensure What's New pill adapts smoothly if assistant is placed on bottom left */
body:has(.ucd-pos-bottom-left) .ucd-wn-floating-pill {
	right: 24px !important;
}

/* ==================== GREETING CALLOUT BUBBLE ==================== */
.ucd-assistant-greeting-bubble {
	pointer-events: auto;
	margin-bottom: 12px;
	background: var(--ucd-bot-card-bg);
	color: var(--ucd-bot-text);
	padding: 10px 14px;
	border-radius: 24px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	border: 1px solid var(--ucd-bot-border);
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	max-width: 320px;
	animation: ucdBubbleFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

html[data-theme="dark"] .ucd-assistant-greeting-bubble,
html.dark .ucd-assistant-greeting-bubble {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.ucd-assistant-greeting-bubble:hover {
	transform: translateY(-2px);
	border-color: rgba(var(--ucd-primary-rgb), 0.5);
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.ucd-greeting-content {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
}

.ucd-greeting-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--ucd-primary);
	line-height: 1;
}

.ucd-greeting-close {
	background: transparent;
	border: none;
	color: var(--ucd-bot-text-muted);
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 4px;
	border-radius: 50%;
	transition: color 0.15s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ucd-greeting-close:hover {
	color: var(--ucd-bot-text);
}

/* ==================== FLOATING ACTION BUTTON (FAB) ==================== */
.ucd-assistant-fab {
	pointer-events: auto;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--ucd-primary) 0%, #A53630 100%);
	color: #FFFFFF;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 26px rgba(var(--ucd-primary-rgb), 0.45);
	position: relative;
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background 0.2s ease;
	outline: none;
}

.ucd-assistant-fab:hover {
	transform: scale(1.08) translateY(-2px);
	box-shadow: 0 14px 34px rgba(var(--ucd-primary-rgb), 0.6);
	background: linear-gradient(135deg, var(--ucd-primary-hover) 0%, var(--ucd-primary) 100%);
}

.ucd-assistant-fab:active {
	transform: scale(0.96);
}

.ucd-fab-pulse {
	position: absolute;
	top: -4px;
	left: -4px;
	right: -4px;
	bottom: -4px;
	border-radius: 50%;
	border: 2px solid rgba(var(--ucd-primary-rgb), 0.6);
	animation: ucdFabPulse 2.4s infinite cubic-bezier(0.25, 1, 0.5, 1);
	pointer-events: none;
}

.ucd-fab-icon-sparkle,
.ucd-fab-icon-close {
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease;
}

.ucd-assistant-fab.is-open .ucd-fab-icon-sparkle {
	display: none !important;
}

.ucd-assistant-fab.is-open .ucd-fab-icon-close {
	display: flex !important;
}

.ucd-assistant-fab.is-open .ucd-fab-pulse {
	display: none;
}

/* ==================== CHAT DIALOG WINDOW ==================== */
.ucd-assistant-dialog {
	pointer-events: auto;
	position: absolute;
	bottom: 74px;
	width: 390px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 120px);
	background: var(--ucd-bot-bg);
	border: 1px solid var(--ucd-bot-border);
	border-radius: 18px;
	box-shadow: var(--ucd-bot-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: scale(0.94) translateY(12px);
	transform-origin: bottom right;
	transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
	z-index: 99995;
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
}

.ucd-assistant-wrap.ucd-pos-bottom-left .ucd-assistant-dialog {
	transform-origin: bottom left;
}

.ucd-assistant-dialog.is-active {
	opacity: 1;
	visibility: visible;
	transform: scale(1) translateY(0);
}

/* ==================== DIALOG HEADER ==================== */
.ucd-assistant-header {
	padding: 14px 18px;
	background: var(--ucd-bot-card-bg);
	border-bottom: 1px solid var(--ucd-bot-border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.ucd-assistant-header-left {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ucd-assistant-avatar-wrap {
	position: relative;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--ucd-bot-avatar-bg);
	border: 1px solid var(--ucd-bot-border);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: visible;
}

.ucd-assistant-avatar-img {
	width: 26px;
	height: auto;
	max-height: 26px;
	object-fit: contain;
}

.ucd-assistant-status-dot {
	position: absolute;
	bottom: -2px;
	right: -2px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #22C55E;
	border: 2px solid var(--ucd-bot-card-bg);
	box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.ucd-assistant-header-info {
	display: flex;
	flex-direction: column;
}

.ucd-assistant-title {
	font-size: 15px;
	font-weight: 700;
	color: var(--ucd-bot-text);
	margin: 0;
	line-height: 1.2;
}

.ucd-assistant-subtitle {
	font-size: 11px;
	color: var(--ucd-bot-text-muted);
	margin-top: 2px;
}

.ucd-assistant-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.ucd-assistant-action-btn {
	background: transparent;
	border: none;
	color: var(--ucd-bot-text-muted);
	padding: 6px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}

.ucd-assistant-action-btn:hover {
	background: var(--ucd-bot-chip-bg);
	color: var(--ucd-bot-text);
}

/* ==================== QUICK PROMPTS CAROUSEL ==================== */
.ucd-assistant-quick-prompts {
	padding: 8px 14px;
	background: rgba(var(--ucd-primary-rgb), 0.04);
	border-bottom: 1px solid var(--ucd-bot-border);
	display: flex;
	gap: 6px;
	overflow-x: auto;
	white-space: nowrap;
	flex-shrink: 0;
	scrollbar-width: none;
}

.ucd-assistant-quick-prompts::-webkit-scrollbar {
	display: none;
}

.ucd-quick-chip {
	background: var(--ucd-bot-chip-bg);
	border: 1px solid var(--ucd-bot-chip-border);
	color: var(--ucd-bot-chip-text);
	padding: 5px 11px;
	border-radius: 14px;
	font-size: 11.5px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
	flex-shrink: 0;
}

.ucd-quick-chip:hover {
	background: rgba(var(--ucd-primary-rgb), 0.15);
	border-color: rgba(var(--ucd-primary-rgb), 0.4);
	color: var(--ucd-primary);
	transform: translateY(-1px);
}

html[data-theme="dark"] .ucd-quick-chip:hover,
html.dark .ucd-quick-chip:hover {
	background: rgba(var(--ucd-primary-rgb), 0.2);
	color: #FFFFFF;
}

/* ==================== MESSAGES FEED ==================== */
.ucd-assistant-messages {
	flex: 1;
	padding: 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scroll-behavior: smooth;
	background: transparent;
}

.ucd-assistant-messages::-webkit-scrollbar {
	width: 5px;
}

.ucd-assistant-messages::-webkit-scrollbar-thumb {
	background: var(--ucd-bot-border);
	border-radius: 4px;
}

/* Single Message Rows */
.ucd-msg-row {
	display: flex;
	gap: 10px;
	max-width: 92%;
	animation: ucdMsgSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ucd-msg-incoming {
	align-self: flex-start;
}

.ucd-msg-outgoing {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.ucd-msg-avatar {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: var(--ucd-bot-avatar-bg);
	border: 1px solid var(--ucd-bot-border);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-top: 2px;
}

.ucd-msg-avatar img {
	width: 18px;
	height: auto;
	object-fit: contain;
}

.ucd-msg-bubble {
	padding: 11px 14px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.5;
	position: relative;
	word-break: break-word;
}

.ucd-msg-incoming .ucd-msg-bubble {
	background: var(--ucd-bot-card-bg);
	border: 1px solid var(--ucd-bot-border);
	color: var(--ucd-bot-text);
	border-top-left-radius: 4px;
}

.ucd-msg-outgoing .ucd-msg-bubble {
	background: linear-gradient(135deg, var(--ucd-primary) 0%, #B03B35 100%);
	color: #FFFFFF;
	border-top-right-radius: 4px;
	box-shadow: 0 4px 12px rgba(var(--ucd-primary-rgb), 0.25);
}

.ucd-msg-bubble p {
	margin: 0 0 8px 0;
}

.ucd-msg-bubble p:last-child {
	margin-bottom: 0;
}

.ucd-msg-bubble ul,
.ucd-msg-bubble ol {
	margin: 6px 0;
	padding-left: 18px;
}

.ucd-msg-bubble li {
	margin-bottom: 4px;
}

.ucd-msg-incoming .ucd-msg-bubble strong {
	color: var(--ucd-bot-strong);
	font-weight: 700;
}

.ucd-msg-outgoing .ucd-msg-bubble strong {
	color: #FFFFFF;
	font-weight: 700;
}

.ucd-msg-incoming .ucd-msg-bubble a {
	color: var(--ucd-primary);
	text-decoration: underline;
	font-weight: 600;
	text-underline-offset: 2px;
	transition: opacity 0.15s ease;
}

.ucd-msg-incoming .ucd-msg-bubble a:hover {
	opacity: 0.85;
}

.ucd-msg-outgoing .ucd-msg-bubble a {
	color: #FFFFFF;
	text-decoration: underline;
}

/* Tool Recommendation Cards inside Chat */
.ucd-chat-tool-cards {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 10px;
}

.ucd-chat-tool-card {
	background: var(--ucd-bot-tool-card-bg);
	border: 1px solid var(--ucd-bot-tool-card-border);
	border-radius: 10px;
	padding: 10px 12px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.ucd-chat-tool-card:hover {
	background: rgba(var(--ucd-primary-rgb), 0.08);
	border-color: var(--ucd-primary);
	transform: translateY(-1px);
}

.ucd-tool-card-main {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ucd-tool-card-title {
	font-size: 13px;
	font-weight: 700;
	color: var(--ucd-bot-tool-card-title);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ucd-tool-card-desc {
	font-size: 11px;
	color: var(--ucd-bot-text-muted);
	margin-top: 2px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	line-height: 1.35;
}

.ucd-tool-card-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--ucd-primary);
	color: #FFFFFF !important;
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 11.5px;
	font-weight: 700;
	text-decoration: none !important;
	flex-shrink: 0;
	transition: background 0.15s ease, transform 0.15s ease;
}

.ucd-tool-card-btn:hover {
	background: var(--ucd-primary-hover);
	transform: scale(1.03);
}

/* Copy text button */
.ucd-msg-copy-btn {
	opacity: 0;
	position: absolute;
	top: 6px;
	right: 6px;
	background: var(--ucd-bot-chip-bg);
	border: 1px solid var(--ucd-bot-border);
	color: var(--ucd-bot-text-muted);
	padding: 3px 6px;
	border-radius: 4px;
	font-size: 10px;
	cursor: pointer;
	transition: opacity 0.15s ease, color 0.15s ease;
}

.ucd-msg-incoming .ucd-msg-bubble:hover .ucd-msg-copy-btn {
	opacity: 1;
}

.ucd-msg-copy-btn:hover {
	color: var(--ucd-bot-text);
}

/* ==================== TYPING INDICATOR ==================== */
.ucd-assistant-typing-indicator {
	padding: 8px 18px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.ucd-typing-bubble {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--ucd-bot-card-bg);
	border: 1px solid var(--ucd-bot-border);
	padding: 8px 12px;
	border-radius: 14px;
}

.ucd-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--ucd-primary);
	animation: ucdDotBlink 1.4s infinite ease-in-out both;
}

.ucd-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ucd-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.ucd-typing-dot:nth-child(3) { animation-delay: 0s; }

.ucd-typing-label {
	font-size: 11.5px;
	color: var(--ucd-bot-text-muted);
	font-style: italic;
}

/* ==================== FOOTER & INPUT ==================== */
.ucd-assistant-footer {
	padding: 12px 16px 14px 16px;
	background: var(--ucd-bot-card-bg);
	border-top: 1px solid var(--ucd-bot-border);
	flex-shrink: 0;
}

.ucd-input-wrap {
	position: relative;
	display: flex;
	align-items: center;
	background: var(--ucd-bot-input-bg);
	border: 1.5px solid var(--ucd-bot-border);
	border-radius: 12px;
	padding: 4px 6px 4px 12px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ucd-input-wrap:focus-within {
	border-color: var(--ucd-primary);
	box-shadow: 0 0 0 3px rgba(var(--ucd-primary-rgb), 0.15);
}

.ucd-assistant-input {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--ucd-bot-text);
	font-size: 13.5px;
	line-height: 1.4;
	resize: none;
	outline: none;
	padding: 6px 0;
	max-height: 100px;
	font-family: inherit;
}

.ucd-assistant-input::placeholder {
	color: var(--ucd-bot-text-muted);
}

.ucd-assistant-send-btn {
	width: 34px;
	height: 34px;
	border-radius: 8px;
	background: var(--ucd-primary);
	color: #FFFFFF;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.ucd-assistant-send-btn:hover:not(:disabled) {
	background: var(--ucd-primary-hover);
	transform: scale(1.05);
}

.ucd-assistant-send-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
	background: var(--ucd-bot-border);
	color: var(--ucd-bot-text-muted);
}

.ucd-assistant-badge-bar {
	margin-top: 8px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 11px;
	color: var(--ucd-bot-text-muted);
}

.ucd-browse-all-link {
	color: var(--ucd-primary);
	text-decoration: none;
	font-weight: 600;
	transition: opacity 0.15s ease;
}

.ucd-browse-all-link:hover {
	text-decoration: underline;
	opacity: 0.9;
}

/* ==================== ANIMATIONS ==================== */
@keyframes ucdBubbleFadeIn {
	from { opacity: 0; transform: translateY(8px) scale(0.96); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ucdFabPulse {
	0% { transform: scale(1); opacity: 0.8; }
	70% { transform: scale(1.35); opacity: 0; }
	100% { transform: scale(1.35); opacity: 0; }
}

@keyframes ucdMsgSlideIn {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes ucdDotBlink {
	0%, 80%, 100% { transform: scale(0); }
	40% { transform: scale(1); }
}

/* ==================== MOBILE RESPONSIVENESS ==================== */
@media (max-width: 600px) {
	.ucd-assistant-wrap {
		bottom: 16px;
	}
	.ucd-assistant-wrap.ucd-pos-bottom-right {
		right: 14px;
	}
	.ucd-assistant-wrap.ucd-pos-bottom-left {
		left: 14px;
	}

	.ucd-assistant-fab {
		width: 52px;
		height: 52px;
	}

	.ucd-assistant-dialog {
		position: fixed;
		bottom: 14px !important;
		left: 14px !important;
		right: 14px !important;
		width: calc(100vw - 28px) !important;
		max-width: calc(100vw - 28px) !important;
		height: min(580px, calc(100dvh - 28px)) !important;
		max-height: calc(100dvh - 28px) !important;
		border-radius: 18px !important;
		border: 1px solid var(--ucd-bot-border) !important;
		box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4) !important;
		transform-origin: bottom center;
	}

	.ucd-assistant-greeting-bubble {
		max-width: calc(100vw - 36px);
	}

	.ucd-assistant-header {
		padding: 12px 14px;
	}

	.ucd-assistant-messages {
		padding: 12px 14px;
		gap: 12px;
	}

	.ucd-assistant-footer {
		padding: 10px 12px 12px 12px;
	}
}
