/**
 * AI Assistant Widget - PinkDocs Style
 */

/* Floating Question Input - positioned in right sidebar area */
.wpchill-kb-ai-question {
	position: fixed;
	right: 0;
	bottom: 0;
	z-index: 9999;
	width: 20%;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.wpchill-kb-ai-open .wpchill-kb-ai-question {
	opacity: 0;
	pointer-events: none;
	transform: translateY(12px) scale(0.95);
}

.wpchill-kb-ai-question-input {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #fafbff;
	color: #111827;
	padding: 16px;
	border-radius: 0;
	border: none;
	border-top: 1px solid #e6e6e6;
	box-shadow: none;
	cursor: text;
}

.wpchill-kb-ai-question-input input {
	flex: 1;
	border: none;
	background: transparent;
	color: #111827;
	font-size: 14px;
	outline: none;
	min-width: 0;
	padding: 8px 0;
}

.wpchill-kb-ai-question-input input::placeholder {
	color: #9ca3af;
}

.wpchill-kb-ai-question-input input::placeholder {
	color: #9ca3af;
}

.wpchill-kb-ai-sparkles {
	width: 20px;
	height: 20px;
	color: #6b7280;
	flex-shrink: 0;
	margin-left: 4px;
}

.wpchill-kb-ai-voice-btn {
	width: 44px;
	height: 44px;
	border-radius: 12px;
	border: 1px solid #e5e7eb;
	background: #f3f4f6;
	color: #6b7280;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	flex-shrink: 0;
}

.wpchill-kb-ai-voice-btn:hover {
	background: #e5e7eb;
	border-color: #d1d5db;
	color: #374151;
}

.wpchill-kb-ai-voice-btn.is-listening {
	background: rgba(99, 91, 255, 0.25);
	color: #a5a0ff;
	box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.15);
	animation: wpchill-kb-pulse 1.2s infinite;
}

.wpchill-kb-ai-input-voice.is-listening {
	background: rgba(99, 91, 255, 0.15);
	color: #635bff;
	animation: wpchill-kb-pulse 1.2s infinite;
}

@keyframes wpchill-kb-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.06); }
}

.wpchill-kb-ai-voice-btn svg {
	width: 18px;
	height: 18px;
}

.wpchill-kb-ai-question-icon {
	width: 44px;
	height: 44px;
	border-radius: 12px; /* square-ish like PinkDocs */
	border: 1px solid #e5e7eb;
	background: #ffffff;
	color: #111827;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.wpchill-kb-ai-question-icon:hover {
	background: #f9fafb;
	border-color: #d1d5db;
	transform: translateY(-1px);
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.10);
}

.wpchill-kb-ai-question-icon svg {
	width: 18px;
	height: 18px;
}

/* Sidebar Panel */
.wpchill-kb-ai-sidebar {
	position: fixed;
	right: 0;
	top: 0;
	height: 100vh;
	width: 20%;
	max-width: 100%;
	background: #fafbff;
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	z-index: 10000;
	display: flex;
	flex-direction: column;
	box-shadow: -20px 0 60px rgba(0, 0, 0, 0.15);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Admin bar offset */
body.admin-bar .wpchill-kb-ai-sidebar {
	top: 32px;
	height: calc(100vh - 32px);
}

body.admin-bar .wpchill-kb-ai-overlay {
	top: 32px;
}

/* Sidebar should follow theme (light/dark) */
[data-theme="dark"] .wpchill-kb-ai-sidebar {
	background: #16161f;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-header {
	background: #16161f;
	border-bottom-color: rgba(255, 255, 255, 0.08);
	color: #f0f0f5;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-title svg {
	color: #a5a0ff;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-close {
	background: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.wpchill-kb-ai-sidebar.is-open {
	transform: translateX(0);
}

.wpchill-kb-ai-sidebar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 20px;
	border-bottom: 1px solid #e6e6e6;
	background: #fafbff;
	color: #1a1f36;
}

.wpchill-kb-ai-sidebar-title {
	font-weight: 600;
	font-size: 16px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.wpchill-kb-ai-sidebar-title svg {
	width: 20px;
	height: 20px;
	color: #635bff;
}

.wpchill-kb-ai-sidebar-close {
	width: 36px;
	height: 36px;
	border-radius: 8px;
	border: 1px solid #e6e6e6;
	background: #fff;
	color: #666;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}

.wpchill-kb-ai-sidebar-close:hover {
	background: #f3f4f6;
	color: #333;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-close:hover {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

/* Messages Area */
.wpchill-kb-ai-sidebar-messages {
	flex: 1;
	padding: 20px;
	overflow-y: auto;
	background: #f8fafc;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-messages {
	background: #16161f;
}

.wpchill-kb-ai-welcome {
	display: flex;
	align-items: center;
	gap: 12px;
	color: #111827;
	margin-bottom: 20px;
	padding: 16px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.wpchill-kb-ai-welcome svg {
	color: #635bff;
	width: 24px;
	height: 24px;
	flex-shrink: 0;
}

.wpchill-kb-ai-welcome p {
	margin: 0;
	font-size: 15px;
	color: #4b5563;
}

.wpchill-kb-ai-message {
	display: flex;
	margin-bottom: 16px;
	animation: wpchill-kb-ai-fadeIn 0.3s ease;
}

@keyframes wpchill-kb-ai-fadeIn {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.wpchill-kb-ai-message.is-user {
	justify-content: flex-end;
}

.wpchill-kb-ai-bubble {
	max-width: 85%;
	padding: 12px 16px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	background: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.wpchill-kb-ai-message.is-user .wpchill-kb-ai-bubble {
	background: linear-gradient(135deg, #1e1e2e 0%, #2d2d3f 100%);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.wpchill-kb-ai-message:not(.is-user) .wpchill-kb-ai-bubble {
	border-bottom-left-radius: 4px;
}

.wpchill-kb-ai-message.is-typing .wpchill-kb-ai-bubble {
	display: inline-flex;
	gap: 6px;
	padding: 16px 20px;
}

.wpchill-kb-ai-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #94a3b8;
	animation: wpchill-kb-ai-blink 1.2s infinite ease-in-out;
}

.wpchill-kb-ai-dot:nth-child(2) {
	animation-delay: 0.2s;
}

.wpchill-kb-ai-dot:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes wpchill-kb-ai-blink {
	0%, 80%, 100% {
		opacity: 0.3;
		transform: scale(0.8);
	}
	40% {
		opacity: 1;
		transform: scale(1);
	}
}

/* Docs/Sources Section */
.wpchill-kb-ai-docs {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid #e5e7eb;
}

.wpchill-kb-ai-docs-title {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #9ca3af;
	margin-bottom: 8px;
	font-weight: 600;
}

.wpchill-kb-ai-docs ul {
	margin: 0;
	padding-left: 0;
	list-style: none;
}

.wpchill-kb-ai-docs li {
	margin-bottom: 6px;
}

.wpchill-kb-ai-docs a {
	color: #635bff;
	text-decoration: none;
	font-size: 13px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.wpchill-kb-ai-docs a:hover {
	text-decoration: underline;
}

/* Suggestions Section */
.wpchill-kb-ai-suggestions {
	padding: 16px 20px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-suggestions {
	background: #1e1e2e;
	border-top-color: #2d2d3f;
}

.wpchill-kb-ai-suggestions-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}

.wpchill-kb-ai-suggestions-title {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #9ca3af;
	font-weight: 600;
}

.wpchill-kb-ai-suggestions-dismiss {
	width: 24px;
	height: 24px;
	border: none;
	background: transparent;
	color: #9ca3af;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: all 0.15s ease;
}

.wpchill-kb-ai-suggestions-dismiss:hover {
	background: #f3f4f6;
	color: #666;
}

[data-theme="dark"] .wpchill-kb-ai-suggestions-dismiss:hover {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.wpchill-kb-ai-suggestions.is-hidden {
	display: none;
}

.wpchill-kb-ai-suggestion {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	border: 1px solid #e5e7eb;
	background: #f9fafb;
	padding: 10px 14px;
	border-radius: 10px;
	margin-bottom: 8px;
	cursor: pointer;
	text-align: left;
	transition: all 0.15s ease;
}

.wpchill-kb-ai-suggestion:hover {
	background: #fff;
	border-color: #635bff;
	box-shadow: 0 2px 8px rgba(99, 91, 255, 0.1);
}

.wpchill-kb-ai-suggestion:last-child {
	margin-bottom: 0;
}

.wpchill-kb-ai-suggestion svg {
	width: 16px;
	height: 16px;
	color: #9ca3af;
	flex-shrink: 0;
}

.wpchill-kb-ai-suggestion span {
	font-size: 13px;
	color: #374151;
	line-height: 1.3;
}

/* Input Area */
.wpchill-kb-ai-sidebar-input {
	padding: 16px 20px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-input {
	background: #1e1e2e;
	border-top-color: #2d2d3f;
}

.wpchill-kb-ai-input-row {
	display: flex;
	gap: 12px;
	align-items: center;
}

.wpchill-kb-ai-input-field {
	flex: 1;
	position: relative;
}

.wpchill-kb-ai-input-field input {
	width: 100%;
	padding: 12px 48px 12px 16px;
	border-radius: 12px;
	border: 1px solid #e5e7eb;
	font-size: 14px;
	background: #f9fafb;
	transition: all 0.2s ease;
}

.wpchill-kb-ai-input-field input:focus {
	outline: none;
	border-color: #635bff;
	background: #fff;
	box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.1);
}

.wpchill-kb-ai-input-field input::placeholder {
	color: #9ca3af;
}

.wpchill-kb-ai-input-voice {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border-radius: 8px;
	border: none;
	background: transparent;
	color: #9ca3af;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s ease;
}

.wpchill-kb-ai-input-voice:hover {
	background: #f3f4f6;
	color: #374151;
}

.wpchill-kb-ai-input-voice svg {
	width: 18px;
	height: 18px;
}

.wpchill-kb-ai-sidebar-send {
	border: none;
	background: linear-gradient(135deg, #1e1e2e 0%, #2d2d3f 100%);
	color: #fff;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: all 0.2s ease;
}

.wpchill-kb-ai-sidebar-send:hover {
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(30, 30, 46, 0.3);
}

.wpchill-kb-ai-sidebar-send svg {
	width: 20px;
	height: 20px;
}

/* Overlay */
.wpchill-kb-ai-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.5);
	backdrop-filter: blur(4px);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
	z-index: 9998;
}

.wpchill-kb-ai-overlay.is-active {
	opacity: 1;
	pointer-events: auto;
}

/* Responsive */
@media (max-width: 768px) {
	.wpchill-kb-ai-question {
		right: 16px;
		bottom: 16px;
		max-width: calc(100% - 32px);
	}

	.wpchill-kb-ai-question-input {
		padding: 8px 8px 8px 14px;
	}

	.wpchill-kb-ai-sidebar {
		width: 100%;
	}

	.wpchill-kb-ai-voice-btn {
		display: none;
	}
}

/* Dark theme overrides for the floating pill */
[data-theme="dark"] .wpchill-kb-ai-question-input {
	background: #16161f;
	border-top-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .wpchill-kb-ai-question-input input {
	color: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-question-input input::placeholder {
	color: rgba(255, 255, 255, 0.55);
}

[data-theme="dark"] .wpchill-kb-ai-sparkles {
	color: #a5a0ff;
}

[data-theme="dark"] .wpchill-kb-ai-voice-btn {
	border: none;
	background: rgba(255, 255, 255, 0.08);
	color: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .wpchill-kb-ai-voice-btn:hover {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-question-icon {
	border: none;
	background: #635bff;
	color: #fff;
}

/* Dark mode - use [data-theme="dark"] selectors instead of prefers-color-scheme */
[data-theme="dark"] .wpchill-kb-ai-welcome {
	background: #2d2d3f;
	color: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-welcome p {
	color: #a0aec0;
}

[data-theme="dark"] .wpchill-kb-ai-bubble {
	background: #2d2d3f;
	color: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-suggestion {
	background: #2d2d3f;
	border-color: #3d3d4f;
}

[data-theme="dark"] .wpchill-kb-ai-suggestion:hover {
	background: #3d3d4f;
}

[data-theme="dark"] .wpchill-kb-ai-suggestion span {
	color: #e2e8f0;
}

[data-theme="dark"] .wpchill-kb-ai-sidebar-input {
	background: #16161f;
	border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .wpchill-kb-ai-input-field input {
	background: #2d2d3f;
	border-color: #3d3d4f;
	color: #fff;
}

[data-theme="dark"] .wpchill-kb-ai-input-field input:focus {
	background: #2d2d3f;
}

/* AI Response Feedback Buttons */
.wpchill-kb-ai-feedback {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
}

.wpchill-kb-ai-feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wpchill-kb-ai-feedback-btn:hover {
  background: #f3f4f6;
  color: #4b5563;
}

.wpchill-kb-ai-feedback-btn.is-positive:hover {
  border-color: #68d391;
  background: #f0fff4;
  color: #22543d;
}

.wpchill-kb-ai-feedback-btn.is-negative:hover {
  border-color: #fc8181;
  background: #fff5f5;
  color: #742a2a;
}

.wpchill-kb-ai-feedback-btn.is-selected {
  pointer-events: none;
}

.wpchill-kb-ai-feedback-btn.is-selected.is-positive {
  border-color: #68d391;
  background: #f0fff4;
  color: #22543d;
}

.wpchill-kb-ai-feedback-btn.is-selected.is-negative {
  border-color: #fc8181;
  background: #fff5f5;
  color: #742a2a;
}

.wpchill-kb-ai-feedback-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wpchill-kb-ai-feedback-thanks {
  font-size: 12px;
  color: #68d391;
  margin-left: 8px;
  align-self: center;
}

/* Dark mode feedback */
[data-theme="dark"] .wpchill-kb-ai-feedback-btn {
  border-color: #3d3d4f;
  color: #6b7280;
}

[data-theme="dark"] .wpchill-kb-ai-feedback-btn:hover {
  background: #2d2d3f;
  color: #a0aec0;
}

[data-theme="dark"] .wpchill-kb-ai-feedback-btn.is-positive:hover {
  border-color: #68d391;
  background: rgba(72, 187, 120, 0.15);
  color: #9ae6b4;
}

[data-theme="dark"] .wpchill-kb-ai-feedback-btn.is-negative:hover {
  border-color: #fc8181;
  background: rgba(245, 101, 101, 0.15);
  color: #feb2b2;
}

[data-theme="dark"] .wpchill-kb-ai-feedback-btn.is-selected.is-positive {
  border-color: #68d391;
  background: rgba(72, 187, 120, 0.15);
  color: #9ae6b4;
}

[data-theme="dark"] .wpchill-kb-ai-feedback-btn.is-selected.is-negative {
  border-color: #fc8181;
  background: rgba(245, 101, 101, 0.15);
  color: #feb2b2;
}

[data-theme="dark"] .wpchill-kb-ai-feedback-thanks {
  color: #68d391;
}
