/**
 * This file is part of Cnvrse Lite .
 *
 * Copyright (C) 2010-2025, Renzo Johnson (email: hello at cnvrse.com)
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code, or visit:
 * https://www.gnu.org/licenses/gpl-2.0.html
*/


/* ========================================
	Variables & Resets
	======================================== */
:root {
	/* Color customization - these can be overridden via wp_add_inline_style() */
	--cnvrse-primary: #64c306;
	--cnvrse-primary-hover: #4fa005;
	--cnvrse-green-start: #7dd81f;
	--cnvrse-green-end: #54b400;
	--cnvrse-bubble-visitor: rgba(100, 195, 6, 0.03);

	/* Static colors */
	--cnvrse-bg-light: #ffffff;
	--cnvrse-bg-dark: #f5f7fa;
	--cnvrse-text-dark: #2c3e50;
	--cnvrse-text-light: #6b7280;
	--cnvrse-border: #e5e7eb;
	--cnvrse-shadow-sm: rgba(0, 0, 0, 0.05);
	--cnvrse-shadow: rgba(0, 0, 0, 0.08);
	--cnvrse-shadow-lg: rgba(0, 0, 0, 0.12);
	--cnvrse-bubble-admin: #f0f2f5;
	--cnvrse-z-index: 999999;
}

/* Use dark text for light background visitor bubbles */
.cnvrse-message-visitor .cnvrse-message-bubble {
	color: #2c3e50 !important;
}

/* ========================================
	Utility Classes
	======================================== */
.cnvrse-hidden {
	display: none !important;
}

/* ========================================
	Chat Widget Container
	======================================== */
#cnvrse-chat-widget {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: var(--cnvrse-z-index);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

#cnvrse-chat-widget * {
	box-sizing: border-box;
}

/* ========================================
	Chat Button
	======================================== */
.cnvrse-launcher {
	position: relative;
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background: linear-gradient(to bottom, var(--cnvrse-green-start) 0%, var(--cnvrse-green-end) 100%);
	color: #ffffff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 12px var(--cnvrse-shadow-lg);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	align-items: center;
	justify-content: center;
	outline: none;
}

.cnvrse-launcher:hover {
	background: linear-gradient(to bottom, var(--cnvrse-green-end) 0%, var(--cnvrse-green-start) 100%);
	transform: scale(1.05);
	box-shadow: 0 6px 16px var(--cnvrse-shadow-lg);
}

.cnvrse-launcher:active {
	transform: scale(0.95);
}

.cnvrse-launcher svg {
	width: 24px;
	height: 24px;
	transition: opacity 0.2s;
}

/* Unread Badge */
.cnvrse-unread-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	background: #e74c3c;
	color: #ffffff;
	border-radius: 12px;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	font-size: 12px;
	font-weight: 600;
	display: none;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
	Proactive Teaser Card
	======================================== */
.cnvrse-teaser {
	position: absolute;
	bottom: 90px;
	right: 0;
	width: 340px;
	max-width: calc(100vw - 40px);
	background: transparent;
	padding: 0;
	display: none;
	opacity: 0;
	transform: translateY(20px);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	pointer-events: none;
}

.cnvrse-teaser.cnvrse-teaser-visible {
	display: block;
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

/* Close Button */
.cnvrse-teaser-close {
	position: absolute;
	top: 12px;
	right: 12px;
	background: transparent;
	border: none;
	color: var(--cnvrse-text-light);
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	opacity: 0;
	outline: none;
}

.cnvrse-teaser:hover .cnvrse-teaser-close {
	opacity: 1;
}

.cnvrse-teaser-close:hover {
	background: rgba(0, 0, 0, 0.05);
	color: var(--cnvrse-text-dark);
}

/* Header with Icon */
.cnvrse-teaser-header {
	display: flex;
	gap: 12px;
	margin-bottom: 16px;
	background: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	padding: 16px;
	border-radius: 8px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.cnvrse-teaser-icon {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.cnvrse-teaser-text {
	flex: 1;
	min-width: 0;
}

.cnvrse-teaser-greeting {
	margin: 0 0 6px 0;
	font-size: 16px;
	font-weight: 600;
	color: var(--cnvrse-text-dark);
	line-height: 1.3;
}

.cnvrse-teaser-message {
	margin: 0;
	font-size: 14px;
	color: var(--cnvrse-text-light);
	line-height: 1.5;
}

/* Buttons */
.cnvrse-teaser-buttons {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 0;
}

.cnvrse-teaser-btn {
	width: 100%;
	padding: 12px 20px;
	border: none;
	border-radius: 100px;
	font-size: 14px;
	font-weight: 500;
	font-family: inherit;
	cursor: pointer;
	transition: all 0.2s ease;
	text-align: center;
	outline: none;
	background: #ffffff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cnvrse-teaser-btn-primary {
	color: #9b2c2c;
}

.cnvrse-teaser-btn-primary:hover {
	background: #f7fafc;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.cnvrse-teaser-btn-secondary {
	color: #2b6cb0;
}

.cnvrse-teaser-btn-secondary:hover {
	background: #f7fafc;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.cnvrse-teaser-btn:active {
	transform: translateY(0);
}

/* ========================================
	Chat Window
	======================================== */
.cnvrse-window {
	position: absolute;
	bottom: 80px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 600px;
	max-height: calc(100vh - 120px);
	background: var(--cnvrse-bg-light);
	border-radius: 8px;
	box-shadow: 0 4px 20px var(--cnvrse-shadow-lg), 0 2px 8px var(--cnvrse-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(20px) scale(0.95);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cnvrse-window:not(.cnvrse-hidden) {
	display: flex;
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* ========================================
	Chat Header
	======================================== */
.cnvrse-header {
	background: linear-gradient(to bottom, var(--cnvrse-green-start) 0%, var(--cnvrse-green-end) 100%);
	color: #ffffff;
	height: 55px;
	padding: 0 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

.cnvrse-header-icon {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.cnvrse-header-content {
	flex: 1;
	min-width: 0;
}

.cnvrse-title {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
}

.cnvrse-subtitle {
	margin: 2px 0 0;
	font-size: 12px;
	opacity: 0.9;
	line-height: 1.2;
}

.cnvrse-close-btn {
	background: transparent;
	border: none;
	color: #ffffff;
	cursor: pointer;
	padding: 4px;
	margin: 0 0 0 12px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	flex-shrink: 0;
	outline: none;
}

.cnvrse-close-btn:hover {
	background: rgba(255, 255, 255, 0.2);
}

.cnvrse-close-btn svg {
	width: 20px;
	height: 20px;
}

/* ========================================
	Messages Container
	======================================== */
.cnvrse-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 20px;
	background: var(--cnvrse-bg-dark);
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.cnvrse-messages::-webkit-scrollbar {
	width: 6px;
}

.cnvrse-messages::-webkit-scrollbar-track {
	background: transparent;
}

.cnvrse-messages::-webkit-scrollbar-thumb {
	background: var(--cnvrse-border);
	border-radius: 3px;
}

.cnvrse-messages::-webkit-scrollbar-thumb:hover {
	background: #bdc3c7;
}

/* ========================================
	Message Bubbles
	======================================== */
.cnvrse-message {
	display: flex;
	flex-direction: column;
	max-width: 80%;
	width: fit-content;
	animation: cnvrse-message-in 0.3s ease-out;
}

@keyframes cnvrse-message-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.cnvrse-message-visitor {
	align-self: flex-end;
}

.cnvrse-message-admin {
	align-self: flex-start;
}

.cnvrse-message-bubble {
	padding: 12px 16px;
	border-radius: 8px;
	word-wrap: break-word;
	word-break: break-word;
	/* white-space: pre-wrap; */
	line-height: 1.5;
	text-align: left;
}

.cnvrse-message-visitor .cnvrse-message-bubble {
	background: var(--cnvrse-bubble-visitor) !important;
	color: #ffffff !important;
	border-bottom-right-radius: 3px;
	box-shadow: 0 1px 2px var(--cnvrse-shadow-sm);
}

.cnvrse-message-admin .cnvrse-message-bubble {
	background: var(--cnvrse-bubble-admin) !important;
	color: var(--cnvrse-text-dark) !important;
	border-bottom-left-radius: 3px;
	box-shadow: 0 1px 2px var(--cnvrse-shadow-sm);
}

.cnvrse-message-time {
	font-size: 11px;
	color: var(--cnvrse-text-light);
	margin-top: 4px;
	padding: 0 4px;
}

/* ========================================
	Typing Indicator
	======================================== */
.cnvrse-typing {
	display: flex;
	gap: 4px;
	padding: 12px 16px;
	background: var(--cnvrse-bubble-admin);
	border-radius: 8px;
	width: fit-content;
	align-self: flex-start;
	margin: 0 20px 12px;
	box-shadow: 0 1px 2px var(--cnvrse-shadow-sm);
}

.cnvrse-typing-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--cnvrse-text-light);
	animation: cnvrse-typing 1.4s infinite;
}

.cnvrse-typing-dot:nth-child(2) {
	animation-delay: 0.2s;
}

.cnvrse-typing-dot:nth-child(3) {
	animation-delay: 0.4s;
}

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

/* ========================================
	Input Area
	======================================== */
.cnvrse-input-container {
	padding: 16px 20px;
	background: var(--cnvrse-bg-light);
	border-top: 1px solid var(--cnvrse-border);
	flex-shrink: 0;
}

/* Name Prompt */
.cnvrse-name-prompt {
	display: flex;
	gap: 8px;
}

.cnvrse-input {
	flex: 1;
	padding: 12px 16px;
	border: 1px solid var(--cnvrse-border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	outline: none;
	transition: all 0.2s ease;
	background: var(--cnvrse-bg-light);
}

.cnvrse-input:focus {
	border-color: var(--cnvrse-border);
	box-shadow: 0 0 0 3px rgba(100, 195, 6, 0.15);
}

.cnvrse-button {
	padding: 12px 20px;
	background: var(--cnvrse-primary);
	color: #ffffff;
	border: none;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 500;
	font-family: inherit;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
	outline: none;
}

.cnvrse-button:hover {
	background: var(--cnvrse-primary-hover);
	transform: translateY(-1px);
	box-shadow: 0 2px 8px var(--cnvrse-shadow);
}

.cnvrse-button:active {
	transform: translateY(0);
}

/* Message Input */
.cnvrse-form {
	display: flex;
	gap: 10px;
	align-items: flex-end;
}

.cnvrse-input {
	flex: 1;
	padding: 12px 16px;
	border: 1px solid var(--cnvrse-border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	outline: none;
	transition: all 0.2s ease;
	max-height: 120px;
	overflow-y: auto;
	background: var(--cnvrse-bg-light);
}

.cnvrse-input:focus {
	border-color: var(--cnvrse-border);
	box-shadow: 0 0 0 3px rgba(100, 195, 6, 0.15);
}

.cnvrse-input::-webkit-scrollbar {
	width: 4px;
}

.cnvrse-input::-webkit-scrollbar-thumb {
	background: var(--cnvrse-border);
	border-radius: 2px;
}

.cnvrse-send-btn {
	width: 44px;
	height: 44px;
	background: var(--cnvrse-primary);
	color: #ffffff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
	outline: none;
	box-shadow: 0 2px 4px var(--cnvrse-shadow-sm);
}

.cnvrse-send-btn:hover {
	background: var(--cnvrse-primary-hover);
	transform: translateY(-1px);
	box-shadow: 0 3px 8px var(--cnvrse-shadow);
}

.cnvrse-send-btn:active {
	transform: translateY(0);
	box-shadow: 0 1px 2px var(--cnvrse-shadow-sm);
}

.cnvrse-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	box-shadow: 0 1px 2px var(--cnvrse-shadow-sm);
}

.cnvrse-send-btn svg {
	width: 20px;
	height: 20px;
}

/* ========================================
	Customer Support Form
	======================================== */
.cnvrse-customer-form-container {
	display: none;
	padding: 16px 20px;
	animation: cnvrse-message-in 0.3s ease-out;
}

.cnvrse-customer-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 0 20px 20px;
}

.cnvrse-form-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.cnvrse-form-field label {
	font-size: 13px;
	font-weight: 500;
	color: var(--cnvrse-text-dark);
}

.cnvrse-form-field input {
	padding: 12px 16px;
	border: 1.5px solid var(--cnvrse-border);
	border-radius: 8px;
	font-size: 15px;
	font-family: inherit;
	outline: none;
	transition: all 0.2s ease;
	background: var(--cnvrse-bg-light);
}

.cnvrse-form-field input:focus {
	border-color: var(--cnvrse-primary);
	box-shadow: 0 0 0 3px rgba(0, 120, 185, 0.08);
}

.cnvrse-customer-submit {
	padding: 12px 20px;
	background: var(--cnvrse-primary);
	color: #ffffff;
	border: none;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 500;
	font-family: inherit;
	cursor: pointer;
	transition: all 0.2s ease;
	margin-top: 6px;
	outline: none;
	box-shadow: 0 2px 4px var(--cnvrse-shadow-sm);
}

.cnvrse-customer-submit:hover {
	background: var(--cnvrse-primary-hover);
	transform: translateY(-1px);
	box-shadow: 0 3px 8px var(--cnvrse-shadow);
}

.cnvrse-customer-submit:active {
	transform: translateY(0);
	box-shadow: 0 1px 2px var(--cnvrse-shadow-sm);
}

.cnvrse-customer-submit:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

/* ========================================
	Footer
	======================================== */
.cnvrse-footer {
	padding: 8px 16px;
	text-align: center;
	background: var(--cnvrse-bg-light);
	border-top: 1px solid var(--cnvrse-border);
	flex-shrink: 0;
}

.cnvrse-footer a {
	font-size: 11px;
	color: var(--cnvrse-text-light);
	text-decoration: none;
	transition: color 0.2s ease;
}

.cnvrse-footer a:hover {
	color: var(--cnvrse-text-dark);
}

.cnvrse-footer-branding {
	font-size: 10px;
	color: #9ca3af;
}

/* ========================================
	Mobile Responsive
	======================================== */
@media (max-width: 480px) {
	#cnvrse-chat-widget {
		bottom: 10px;
		right: 10px;
		left: 10px;
	}

	.cnvrse-window {
		width: 100%;
		max-width: 100%;
		height: calc(100vh - 80px);
		max-height: calc(100vh - 80px);
		bottom: 70px;
		right: 0;
		left: 0;
		border-radius: 8px 8px 0 0;
	}

	.cnvrse-message {
		max-width: 90%;
	}

	.cnvrse-input-container {
		padding: 12px 16px;
	}
}

/* ========================================
	Print Styles
	======================================== */
@media print {
	#cnvrse-chat-widget {
		display: none !important;
	}
}

/* ========================================
	Accessibility
	======================================== */
.cnvrse-chat-button:focus-visible,
.cnvrse-close-button:focus-visible,
.cnvrse-input:focus-visible,
.cnvrse-textarea:focus-visible,
.cnvrse-button:focus-visible,
.cnvrse-send-btn:focus-visible {
	outline: 2px solid var(--cnvrse-primary);
	outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
	.cnvrse-chat-button,
	.cnvrse-chat-window,
	.cnvrse-message,
	.cnvrse-typing-dot {
		animation: none;
		transition: none;
	}
}
