/**
 * WitFlow AI Assistant - Frontend Chat Styles
 * Modern AI-Powered Interface with Glassmorphism & Gradient Accents
 * 
 * @package WitFlow_AI_Assistant
 * @since 2.0.0
 * @author WitFlow AI Technologies
 */

:root {
	--witflow-primary: #6366f1;
	--witflow-primary-dark: #4f46e5;
	--witflow-secondary: #8b5cf6;
	--witflow-accent: #ec4899;
	--witflow-success: #10b981;
	--witflow-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	--witflow-gradient-alt: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
	--witflow-ai-glow: 0 0 20px rgba(99, 102, 241, 0.3);
	--witflow-glass-bg: rgba(255, 255, 255, 0.95);
	--witflow-glass-border: rgba(255, 255, 255, 0.3);
	--witflow-shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.08);
	--witflow-shadow-strong: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* ========== EMBEDDED CHAT ========== */

#witflow-chat-container {
	max-width: 700px;
	margin: 30px auto;
	padding: 0;
	border: none;
	border-radius: 24px;
	background: var(--witflow-glass-bg);
	backdrop-filter: blur(20px);
	box-shadow: var(--witflow-shadow-strong);
	overflow: hidden;
	position: relative;
}

#witflow-chat-container::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: var(--witflow-gradient);
	animation: shimmer 3s infinite linear;
}

@keyframes shimmer {
	0% { opacity: 0.6; transform: translateX(-100%); }
	50% { opacity: 1; }
	100% { opacity: 0.6; transform: translateX(100%); }
}

#witflow-chat-log {
	height: 450px;
	overflow-y: auto;
	border: none;
	padding: 25px;
	margin: 0;
	background: linear-gradient(to bottom, #fafbff 0%, #f3f4ff 100%);
	scrollbar-width: thin;
	scrollbar-color: var(--witflow-primary) transparent;
}

#witflow-chat-log::-webkit-scrollbar {
	width: 6px;
}

#witflow-chat-log::-webkit-scrollbar-track {
	background: transparent;
}

#witflow-chat-log::-webkit-scrollbar-thumb {
	background: var(--witflow-gradient);
	border-radius: 10px;
}

#witflow-chat-form {
	display: flex;
	gap: 12px;
	padding: 20px 25px;
	background: #fff;
	border-top: 1px solid rgba(99, 102, 241, 0.1);
	position: relative;
}

#witflow-chat-form::before {
	content: '';
	position: absolute;
	top: 0;
	left: 25px;
	right: 25px;
	height: 1px;
	background: var(--witflow-gradient);
	opacity: 0.3;
}

#witflow-chat-form input[type="text"] {
	flex: 1;
	padding: 14px 20px;
	border: 2px solid rgba(99, 102, 241, 0.2);
	border-radius: 16px;
	font-size: 15px;
	transition: all 0.3s ease;
	background: #fafbff;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#witflow-chat-form input[type="text"]:focus {
	outline: none;
	border-color: var(--witflow-primary);
	background: #fff;
	box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

#witflow-chat-form button {
	padding: 14px 28px;
	border: none;
	background: var(--witflow-gradient);
	color: #fff;
	cursor: pointer;
	border-radius: 16px;
	font-weight: 600;
	font-size: 15px;
	transition: all 0.3s ease;
	box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
	position: relative;
	overflow: hidden;
}

#witflow-chat-form button::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
	transition: left 0.5s;
}

#witflow-chat-form button:hover::before {
	left: 100%;
}

#witflow-chat-form button:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

#witflow-chat-form button:active {
	transform: translateY(0);
}

/* Message Styles - AI-Powered Design */
.witflow-user-msg {
	margin-bottom: 16px;
	padding: 14px 18px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #fff;
	border-radius: 20px;
	border-bottom-right-radius: 4px;
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
	max-width: 75%;
	margin-left: auto;
	font-size: 15px;
	line-height: 1.5;
	animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
	from {
		opacity: 0;
		transform: translateX(20px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

@keyframes slideInLeft {
	from {
		opacity: 0;
		transform: translateX(-20px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

.witflow-bot-msg,
.witflow-system-msg,
.witflow-agent-msg {
	margin-bottom: 16px;
	padding: 14px 18px;
	border-radius: 20px;
	max-width: 75%;
	font-size: 15px;
	line-height: 1.6;
	position: relative;
}

.witflow-bot-msg {
	background: #fff;
	border: 2px solid rgba(99, 102, 241, 0.15);
	border-bottom-left-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	animation: slideInLeft 0.3s ease-out;
	color: #1e293b;
}

.witflow-bot-msg::before {
	content: '🤖';
	position: absolute;
	left: -35px;
	top: 12px;
	font-size: 24px;
	filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.3));
}

.witflow-agent-msg {
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: #fff;
	border-bottom-left-radius: 4px;
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
	animation: slideInLeft 0.3s ease-out;
}

.witflow-agent-msg::before {
	content: '👤';
	position: absolute;
	left: -35px;
	top: 12px;
	font-size: 24px;
	filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.3));
}

.witflow-system-msg {
	background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
	color: #fff;
	font-style: italic;
	text-align: center;
	border-radius: 12px;
	font-size: 13px;
	padding: 10px 16px;
	box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
	margin: 20px auto;
	max-width: 85%;
	animation: pulse 0.5s ease-out;
}

@keyframes pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.03); }
}

.witflow-spinner {
	text-align: left;
	padding: 14px 18px;
	color: #6366f1;
	font-weight: 500;
	display: flex;
	align-items: center;
	gap: 10px;
	animation: slideInLeft 0.3s ease-out;
}

.witflow-spinner::before {
	content: '';
	width: 8px;
	height: 8px;
	background: var(--witflow-primary);
	border-radius: 50%;
	animation: typing 1.4s infinite;
}

.witflow-spinner::after {
	content: '';
	width: 8px;
	height: 8px;
	background: var(--witflow-primary);
	border-radius: 50%;
	animation: typing 1.4s infinite 0.2s;
	margin-left: -6px;
}

@keyframes typing {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.7;
	}
	30% {
		transform: translateY(-10px);
		opacity: 1;
	}
}

/* ========== FLOATING CHAT ========== */

#witflow-floating-container {
	position: fixed;
	bottom: 30px;
	right: 30px;
	z-index: 9999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Chat Bubble - AI Powered Design */
#witflow-bubble {
	width: 70px;
	height: 70px;
	background: var(--witflow-gradient);
	border-radius: 50%;
	box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4), 0 0 0 0 rgba(99, 102, 241, 0.4);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
	position: relative;
	animation: float 3s ease-in-out infinite, pulse-ring 2s infinite;
}

@keyframes float {
	0%, 100% {
		transform: translateY(0px);
	}
	50% {
		transform: translateY(-8px);
	}
}

@keyframes pulse-ring {
	0% {
		box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4), 0 0 0 0 rgba(99, 102, 241, 0.4);
	}
	50% {
		box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4), 0 0 0 15px rgba(99, 102, 241, 0);
	}
	100% {
		box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4), 0 0 0 0 rgba(99, 102, 241, 0);
	}
}

#witflow-bubble::before {
	content: '';
	position: absolute;
	inset: -3px;
	background: linear-gradient(45deg, #667eea, #764ba2, #f093fb, #667eea);
	border-radius: 50%;
	z-index: -1;
	opacity: 0;
	transition: opacity 0.3s;
	background-size: 300% 300%;
	animation: gradient-rotate 4s ease infinite;
}

@keyframes gradient-rotate {
	0% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
	100% { background-position: 0% 50%; }
}

#witflow-bubble:hover {
	transform: scale(1.1) translateY(-5px);
	box-shadow: 0 12px 48px rgba(99, 102, 241, 0.6), 0 0 0 0 rgba(99, 102, 241, 0.4);
}

#witflow-bubble:hover::before {
	opacity: 1;
}

#witflow-bubble img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	filter: brightness(0) invert(1);
}

#witflow-notification-dot {
	position: absolute;
	top: 5px;
	right: 5px;
	width: 12px;
	height: 12px;
	background: #f44336;
	border-radius: 50%;
	display: none;
	animation: pulse 2s infinite;
}

@keyframes pulse {
	0%, 100% {
		opacity: 1;
		transform: scale(1);
	}
	50% {
		opacity: 0.7;
		transform: scale(1.1);
	}
}

/* Chat Window - Modern Glassmorphism */
#witflow-chat-window {
	width: 400px;
	max-width: 100%;
	background: var(--witflow-glass-bg);
	backdrop-filter: blur(40px) saturate(180%);
	border: 1px solid rgba(99, 102, 241, 0.2);
	border-radius: 24px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
	overflow: hidden;
	display: none;
	animation: slideUpScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
	position: relative;
}

#witflow-chat-window::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: var(--witflow-gradient);
	z-index: 10;
}

@keyframes slideUpScale {
	from {
		opacity: 0;
		transform: translateY(30px) scale(0.9);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Chat Header - Gradient with AI Badge */
#witflow-chat-header {
	background: var(--witflow-gradient);
	color: #fff;
	padding: 18px 20px;
	text-align: center;
	position: relative;
	font-weight: 700;
	font-size: 17px;
	letter-spacing: 0.3px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

#witflow-chat-header::before {
	content: '✨';
	font-size: 20px;
	animation: sparkle 2s ease-in-out infinite;
}

#witflow-chat-header::after {
	content: 'AI';
	position: absolute;
	right: 50px;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.25);
	backdrop-filter: blur(10px);
	padding: 4px 10px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 1px;
	border: 1px solid rgba(255, 255, 255, 0.3);
}

@keyframes sparkle {
	0%, 100% {
		transform: scale(1) rotate(0deg);
		opacity: 1;
	}
	50% {
		transform: scale(1.2) rotate(180deg);
		opacity: 0.8;
	}
}

#witflow-close-chat {
	position: absolute;
	right: 15px;
	top: 50%;
	transform: translateY(-50%);
	color: #fff;
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: all 0.3s ease;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
}

#witflow-close-chat:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: translateY(-50%) rotate(90deg);
}

/* Floating Chat Log - Enhanced */
#witflow-floating-log {
	max-height: 450px;
	overflow-y: auto;
	padding: 20px;
	background: linear-gradient(to bottom, #fafbff 0%, #f3f4ff 100%);
	scrollbar-width: thin;
	scrollbar-color: var(--witflow-primary) transparent;
	min-height: 300px;
}

#witflow-floating-log::-webkit-scrollbar {
	width: 5px;
}

#witflow-floating-log::-webkit-scrollbar-track {
	background: transparent;
}

#witflow-floating-log::-webkit-scrollbar-thumb {
	background: var(--witflow-gradient);
	border-radius: 10px;
}

#witflow-floating-log::-webkit-scrollbar-thumb:hover {
	background: var(--witflow-gradient-alt);
}

/* Floating Chat Form - Modern Input */
#witflow-floating-form {
	display: flex;
	gap: 10px;
	padding: 15px;
	background: #fff;
	border-top: 1px solid rgba(99, 102, 241, 0.1);
	border-bottom-left-radius: 24px;
	border-bottom-right-radius: 24px;
}

#witflow-floating-form input[type="text"] {
	flex: 1;
	padding: 12px 18px;
	border: 2px solid rgba(99, 102, 241, 0.2);
	outline: none;
	font-size: 14px;
	border-radius: 14px;
	background: #fafbff;
	transition: all 0.3s ease;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#witflow-floating-form input[type="text"]:focus {
	border-color: var(--witflow-primary);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#witflow-floating-form button {
	padding: 12px 20px;
	background: var(--witflow-gradient);
	border: none;
	color: #fff;
	border-radius: 14px;
	cursor: pointer;
	font-weight: 600;
	font-size: 14px;
	transition: all 0.3s ease;
	box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
	position: relative;
	overflow: hidden;
}

#witflow-floating-form button::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
	transition: left 0.5s;
}

#witflow-floating-form button:hover::before {
	left: 100%;
}

#witflow-floating-form button:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

#witflow-floating-form button:active {
	transform: translateY(0);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
	#witflow-chat-container {
		max-width: 100%;
		margin: 10px;
	}

	#witflow-chat-window {
		width: 100%;
		max-width: calc(100vw - 40px);
	}

	#witflow-floating-container {
		right: 10px;
		bottom: 10px;
	}
}

/* ========== FRONTEND PAGE OVERRIDES ========== */

.page #grve-content #witflow-conversations-table button,
.page #grve-content #witflow-conversations-table .grve-btn {
	padding: 8px 20px;
	display: inline-block;
	background: #0073aa;
	color: #fff;
	border-radius: 4px;
	text-decoration: none;
}

.page #grve-content #witflow-conversations-table button:hover,
.page #grve-content #witflow-conversations-table .grve-btn:hover {
	background: #005177;
}

.page #grve-content #wp-agent_reply-wrap button {
	background: initial;
	padding: 2px;
	color: #333;
	border: 1px solid #ddd;
}
