/**
 * Frontend Chat Widget Stylesheet.
 * Supports Glassmorphism, animations, and dark/light modes.
 */

.docsai-chatbot-chat-wrapper {
	position: fixed;
	bottom: 30px;
	right: 30px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Floating Launcher Bubble */
.docsai-chatbot-chat-bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
	color: #ffffff;
	box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: absolute;
	bottom: 0;
	right: 0;
	animation: wpRagBubblePulse 2.5s infinite;
}

@keyframes wpRagBubblePulse {
	0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
	70% { box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
	100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.docsai-chatbot-chat-bubble:hover {
	transform: scale(1.08) rotate(5deg);
	box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
	animation: none;
}

.docsai-chatbot-chat-bubble span.dashicons {
	font-size: 28px;
	width: 28px;
	height: 28px;
}

/* Chat Panel Container */
.docsai-chatbot-chat-box {
	position: absolute;
	bottom: 80px;
	right: 0;
	width: 100%;
	min-width: 320px;
	max-width: 420px;
	background: #ffffff;
	border: 1px solid rgba(15, 23, 42, 0.05);
	border-radius: 16px;
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: wpRagWidgetSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
	transform-origin: bottom right;
}

@keyframes wpRagWidgetSlideIn {
	from { transform: scale(0.85) translateY(20px); opacity: 0; }
	to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Header styling */
.docsai-chatbot-chat-header {
	padding: 15px 20px;
	background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.docsai-chatbot-chat-header-identity {
	display: flex;
	align-items: center;
	gap: 10px;
}

.docsai-chatbot-chat-avatar {
	font-size: 20px;
}

.docsai-chatbot-chat-header h4 {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: #ffffff;
}

.docsai-chatbot-chat-header-controls {
	display: flex;
	gap: 8px;
}

.docsai-chatbot-chat-header-controls button {
	background: transparent;
	border: none;
	color: rgba(255, 255, 255, 0.8);
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	transition: all 0.2s;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.docsai-chatbot-chat-header-controls button:hover {
	color: #ffffff;
	background-color: rgba(255, 255, 255, 0.15);
}

.docsai-chatbot-chat-header-controls button span.dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/* Chat Body (Conversation Thread) */
.docsai-chatbot-chat-body {
	flex-grow: 1;
	padding: 20px;
	overflow-y: auto;
	background: #fcfcfd;
	display: flex;
	flex-direction: column;
	gap: 15px;
}

/* Message Bubbles */
.docsai-chatbot-msg {
	display: flex;
	flex-direction: column;
	max-width: 85%;
	animation: wpRagMsgFade 0.25s ease;
}

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

.docsai-chatbot-msg-user {
	align-self: flex-end;
}

.docsai-chatbot-msg-bot {
	align-self: flex-start;
}

.docsai-chatbot-msg-content {
	padding: 12px 16px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.5;
	position: relative;
}

.docsai-chatbot-msg-user .docsai-chatbot-msg-content {
	background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
	color: #ffffff;
	border-radius: 12px 12px 4px 12px;
	box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.docsai-chatbot-msg-bot .docsai-chatbot-msg-content {
	background-color: #ffffff;
	color: #1e293b;
	border-radius: 12px 12px 12px 4px;
	border: 1px solid rgba(15, 23, 42, 0.05);
	box-shadow: 0 2px 4px rgba(15, 23, 42, 0.02);
}

.docsai-chatbot-msg-content p {
	margin: 0 0 10px 0;
}

.docsai-chatbot-msg-content p:last-child {
	margin-bottom: 0;
}

/* Code block styles */
.docsai-chatbot-msg-content pre {
	background: #1e293b;
	color: #f8fafc;
	padding: 12px;
	border-radius: 6px;
	overflow-x: auto;
	margin: 10px 0;
	font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
	font-size: 12px;
}

.docsai-chatbot-msg-content code {
	font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
	font-size: 12px;
	background: rgba(0, 0, 0, 0.05);
	padding: 2px 4px;
	border-radius: 3px;
}

.docsai-chatbot-msg-user code {
	background: rgba(255, 255, 255, 0.2);
}

/* Citation source list */
.docsai-chatbot-citations {
	font-size: 11px;
	color: #64748b;
	margin-top: 6px;
	padding: 4px 8px;
	background: #f8fafc;
	border-left: 2px solid #cbd5e1;
	border-radius: 0 4px 4px 0;
}

.docsai-chatbot-citations h5 {
	margin: 0 0 3px 0;
	font-weight: 600;
	color: #475569;
}

.docsai-chatbot-citations ul {
	margin: 0;
	padding-left: 14px;
}

.docsai-chatbot-citations li {
	margin-bottom: 2px;
}

/* Copy Action Button */
.docsai-chatbot-copy-btn {
	background: transparent;
	border: none;
	color: #94a3b8;
	cursor: pointer;
	padding: 2px;
	margin-top: 5px;
	align-self: flex-end;
	font-size: 11px;
	display: flex;
	align-items: center;
	gap: 4px;
	opacity: 0.7;
	transition: opacity 0.2s;
}

.docsai-chatbot-copy-btn:hover {
	opacity: 1;
	color: #6366f1;
}

/* Input Area styling */
.docsai-chatbot-chat-footer {
	padding: 15px 20px;
	background: #ffffff;
	border-top: 1px solid #e2e8f0;
	display: flex;
	align-items: flex-end;
	gap: 12px;
}

.docsai-chatbot-chat-footer textarea {
	flex-grow: 1;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	padding: 10px 14px;
	font-size: 13.5px;
	resize: none;
	outline: none;
	max-height: 100px;
	height: 38px;
	box-sizing: border-box;
	line-height: 1.4;
	overflow-y: hidden;
}

.docsai-chatbot-chat-footer textarea:focus {
	border-color: #6366f1;
	box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.docsai-chatbot-chat-footer button {
	background-color: #6366f1;
	color: #ffffff;
	border: none;
	width: 38px;
	height: 38px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
	box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.docsai-chatbot-chat-footer button:hover {
	background-color: #4f46e5;
	transform: scale(1.05);
	box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
}

.docsai-chatbot-chat-footer button:active {
	transform: scale(0.95);
}

.docsai-chatbot-send-icon {
	width: 18px;
	height: 18px;
	color: #ffffff;
	display: block;
	transition: transform 0.2s ease;
}

.docsai-chatbot-chat-footer button:hover .docsai-chatbot-send-icon {
	transform: translate(1px, -1px);
}

/* Typing Indicator */
.docsai-chatbot-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 5px 0;
}

.docsai-chatbot-typing-dot {
	width: 6px;
	height: 6px;
	background-color: #94a3b8;
	border-radius: 50%;
	animation: wpRagBounce 1.4s infinite ease-in-out both;
}

.docsai-chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.docsai-chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Theme overrides */
/* Dark Mode Theme */
.docsai-chatbot-theme-dark .docsai-chatbot-chat-box {
	background-color: #0f172a;
	border-color: rgba(255, 255, 255, 0.08);
	color: #f8fafc;
}

.docsai-chatbot-theme-dark .docsai-chatbot-chat-body {
	background-color: #1e293b;
}

.docsai-chatbot-theme-dark .docsai-chatbot-msg-bot .docsai-chatbot-msg-content {
	background-color: #334155;
	color: #f8fafc;
	border-color: #475569;
}

.docsai-chatbot-theme-dark .docsai-chatbot-chat-footer {
	background-color: #0f172a;
	border-top-color: #334155;
}

.docsai-chatbot-theme-dark .docsai-chatbot-chat-footer textarea {
	background-color: #1e293b;
	color: #f8fafc;
	border-color: #475569;
}

.docsai-chatbot-theme-dark .docsai-chatbot-citations {
	background-color: #334155;
	border-left-color: #6366f1;
	color: #cbd5e1;
}

.docsai-chatbot-theme-dark .docsai-chatbot-citations h5 {
	color: #e2e8f0;
}

/* Glassmorphism Theme */
.docsai-chatbot-theme-glass .docsai-chatbot-chat-box {
	background: rgba(255, 255, 255, 0.7);
	backdrop-filter: blur(16px) saturate(180%);
	-webkit-backdrop-filter: blur(16px) saturate(180%);
	border: 1px solid rgba(255, 255, 255, 0.4);
	box-shadow: 0 12px 32px rgba(31, 38, 135, 0.15);
}

.docsai-chatbot-theme-glass .docsai-chatbot-chat-body {
	background: transparent;
}

.docsai-chatbot-theme-glass .docsai-chatbot-msg-bot .docsai-chatbot-msg-content {
	background: rgba(255, 255, 255, 0.45);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(255, 255, 255, 0.25);
}

.docsai-chatbot-theme-glass .docsai-chatbot-chat-footer {
	background: rgba(255, 255, 255, 0.5);
	backdrop-filter: blur(8px);
	border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.docsai-chatbot-theme-glass .docsai-chatbot-chat-footer textarea {
	background: rgba(255, 255, 255, 0.7);
	border-color: rgba(0, 0, 0, 0.12);
}
