/* Chat Modal Base */
.branchout-chat-modal {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.5);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.branchout-chat-modal.hidden {
	display: none;
}

/* Chat Window */
.branchout-chat-window {
	width: 100%;
	max-width: 400px;
	height: 100%;
	background-color: white;
	display: flex;
	flex-direction: column;
	transition: transform 0.3s ease-in-out;
	box-shadow: -4px 0 15px rgba(0, 0, 0, 0.2);
}

.branchout-chat-window.translate-x-full {
	transform: translateX(100%);
}

.branchout-chat-window.translate-x-0 {
	transform: translateX(0);
}

/* Chat Header */
.branchout-chat-header {
	padding: 1.5rem;
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: white;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.branchout-chat-header h3 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

.branchout-chat-header-right {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.branchout-credits-display {
	font-size: 0.875rem;
	font-weight: 500;
	background: rgba(255, 255, 255, 0.2);
	padding: 0.375rem 0.75rem;
	border-radius: 1rem;
	backdrop-filter: blur(10px);
	min-width: 90px;
	text-align: center;
}

.credits-unlimited {
	color: #fff;
	font-weight: 600;
}

.credits-count {
	color: #fff;
	font-weight: 600;
}

.credits-count.credits-low {
	color: #fbbf24;
	animation: pulse-credits 2s infinite;
}

@keyframes pulse-credits {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.7;
	}
}

.branchout-close-chat {
	background: none;
	border: none;
	color: white;
	font-size: 2rem;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s;
}

.branchout-close-chat:hover {
	opacity: 0.8;
}

/* Chat Messages Area */
.branchout-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 1.5rem;
	background-color: #f9fafb;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

#welcomeMessage {
	text-align: center;
	color: #6b7280;
	padding: 2rem 1rem;
}

#welcomeMessage p {
	margin: 0.5rem 0;
}

/* Chat Message Bubbles */
.branchout-chat-message {
	display: flex;
	margin-bottom: 1rem;
}

.branchout-chat-message.user {
	justify-content: flex-end;
}

.branchout-chat-message.ai {
	justify-content: flex-start;
}

.branchout-chat-bubble {
	max-width: 80%;
	padding: 0.75rem 1rem;
	border-radius: 1rem;
	word-wrap: break-word;
}

.branchout-chat-message.user .branchout-chat-bubble {
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: white;
}

.branchout-chat-message.ai .branchout-chat-bubble {
	background-color: white;
	color: #1f2937;
	border: 1px solid #e5e7eb;
}

/* Markdown Content */
.markdown-content p {
	margin: 0.5rem 0;
}

.markdown-content p:first-child {
	margin-top: 0;
}

.markdown-content p:last-child {
	margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
	margin: 1rem 0 0.5rem 0;
	font-weight: 600;
}

.markdown-content h1 {
	font-size: 1.25rem;
}

.markdown-content h2 {
	font-size: 1.125rem;
}

.markdown-content h3 {
	font-size: 1rem;
}

.markdown-content strong {
	font-weight: 600;
}

.markdown-content a {
	color: #3b82f6;
	text-decoration: underline;
}

.markdown-content ul,
.markdown-content ol {
	margin: 0.5rem 0;
	padding-left: 1.5rem;
}

.markdown-content li {
	margin: 0.25rem 0;
}

/* Typing Indicator */
#typing-indicator {
	display: flex;
	margin-bottom: 1rem;
}

.typing-dots {
	display: inline-block;
	animation: typing 1.4s infinite;
}

@keyframes typing {
	0%, 60%, 100% {
		opacity: 0;
	}
	30% {
		opacity: 1;
	}
}

/* Chat Input Area */
.branchout-chat-input-area {
	padding: 1rem 1.5rem;
	border-top: 1px solid #e5e7eb;
	background: white;
	display: flex;
	gap: 0.75rem;
	align-items: flex-end;
}

.branchout-chat-input {
	flex: 1;
	padding: 0.75rem;
	border: 1px solid #d1d5db;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	resize: none;
	min-height: 48px;
	max-height: 120px;
	font-family: inherit;
	transition: border-color 0.2s;
}

.branchout-chat-input:focus {
	outline: none;
	border-color: #10b981;
	box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.branchout-send-button {
	padding: 0.75rem 1.25rem;
	background-color: #10b981;
	color: white;
	border: none;
	border-radius: 0.5rem;
	font-weight: 500;
	cursor: pointer;
	transition: background-color 0.2s;
	white-space: nowrap;
}

.branchout-send-button:hover {
	background-color: #059669;
}

.branchout-send-button:disabled {
	background-color: #d1d5db;
	cursor: not-allowed;
}

/* Floating Chat Button */
.branchout-floating-button {
	position: fixed;
	bottom: 30px;
	right: 30px;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: white;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	z-index: 9998;
}

.branchout-floating-button:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.branchout-floating-button svg {
	width: 28px;
	height: 28px;
}

.branchout-floating-button.hidden {
	display: none;
}

/* Shortcode Button */
.branchout-chat-button {
	display: inline-block;
	padding: 0.75rem 1.5rem;
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: white;
	border: none;
	border-radius: 0.5rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	text-decoration: none;
}

.branchout-chat-button:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
	color: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
	.branchout-chat-window {
		max-width: 100%;
	}
	
	.branchout-chat-header {
		padding: 1rem;
	}
	
	.branchout-chat-header h3 {
		font-size: 1.125rem;
	}
	
	.branchout-chat-header-right {
		gap: 0.5rem;
	}
	
	.branchout-credits-display {
		font-size: 0.75rem;
		padding: 0.25rem 0.5rem;
		min-width: 70px;
	}
	
	.branchout-floating-button {
		bottom: 20px;
		right: 20px;
		width: 56px;
		height: 56px;
	}
	
	.branchout-floating-button svg {
		width: 24px;
		height: 24px;
	}
}