/* Google Font - Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* Variables */
:root {
	--wca-primary: #4F46E5;
	/* Indigo 600 */
	--wca-primary-dark: #4338CA;
	/* Indigo 700 */
	--wca-secondary: #EC4899;
	/* Pink 500 */
	--wca-bg-light: #F3F4F6;
	--wca-card-bg: #ffffff;
	--wca-text-main: #111827;
	--wca-text-sub: #6B7280;
	--wca-shadow-lg: 0 12px 48px -12px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.02);
	--wca-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
	--wca-radius: 16px;
	--wca-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
	--wca-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Base Reset & Mobile Safe */
#wca-widget-container {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999999;
	font-family: var(--wca-font);
	display: flex;
	flex-direction: column-reverse;
	/* Bottom-up: Toggle then Window */
	align-items: flex-end;
	gap: 16px;
	line-height: normal;
	padding: 0;
	margin: 0;
	pointer-events: none !important;
}

#wca-widget-container,
#wca-widget-container * {
	box-sizing: border-box;
}

#wca-widget-container button,
#wca-widget-container input,
#wca-widget-container textarea {
	font-family: inherit;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
	#wca-widget-container {
		bottom: 16px;
		right: 16px;
		left: auto !important;
		/* Never stretch by default */
		width: auto !important;
		padding: 0 !important;
		margin: 0 !important;
		pointer-events: none !important;
	}

	#wca-widget-container.wca-chat-active {
		left: 16px !important;
		right: 16px !important;
		width: auto !important;
		align-items: stretch !important;
	}

	#wca-chat-toggle {
		align-self: flex-end;
		/* Keep toggle on right */
	}

	#wca-chat-window {
		width: 100% !important;
		height: 70vh !important;
		bottom: 90px;
	}
}

/* Toggle Button with Pulse */
.wca-toggle-wrapper {
	position: relative;
	width: 64px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: center;
}

#wca-chat-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--wca-primary), var(--wca-secondary));
	border: none;
	color: white;
	cursor: pointer;
	position: relative;
	z-index: 2;
	box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
	transition: var(--wca-transition);
	margin-right: 0px;
	pointer-events: auto !important;
	/* ALWAYS clickable */
	visibility: visible !important;
	/* ALWAYS visible even if container is hidden */
}

#wca-chat-toggle:hover {
	transform: scale(1.05) translateY(-2px);
	box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
}

.wca-pulse-ring {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: rgba(79, 70, 229, 0.3);
	animation: wca-pulse 2s infinite;
	z-index: 1;
	pointer-events: none;
}

@keyframes wca-pulse {
	0% {
		transform: translate(-50%, -50%) scale(1);
		opacity: 0.8;
	}

	100% {
		transform: translate(-50%, -50%) scale(1.6);
		opacity: 0;
	}
}

/* Icon Switching */
.wca-toggle-icon-open,
.wca-toggle-icon-close {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transition: var(--wca-transition);
}

.wca-toggle-icon-close {
	opacity: 0;
	transform: translate(-50%, -50%) rotate(-90deg);
}

/* Active State for Toggle */
#wca-chat-toggle.active .wca-toggle-icon-open {
	opacity: 0;
	transform: translate(-50%, -50%) rotate(90deg);
}

#wca-chat-toggle.active .wca-toggle-icon-close {
	opacity: 1;
	transform: translate(-50%, -50%) rotate(0deg);
}


/* Chat Window Card */
#wca-chat-window {
	width: 380px;
	height: 600px;
	max-height: 80vh;
	background: var(--wca-card-bg);
	border-radius: var(--wca-radius);
	box-shadow: var(--wca-shadow-lg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	transition: var(--wca-transition);
	border: 1px solid rgba(0, 0, 0, 0.04);
	pointer-events: auto;
	/* Restore clickable */
}

#wca-chat-window.hidden {
	display: none !important;
	opacity: 0;
	transform: scale(0.95) translateY(20px);
	pointer-events: none;
	visibility: hidden;
}

/* Header */
.wca-chat-header {
	padding: 20px !important;
	background: #ffffff;
	border-bottom: 1px solid #f0f0f0;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.wca-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.wca-avatar-bot {
	width: 40px;
	height: 40px;
	background: linear-gradient(135deg, var(--wca-primary), var(--wca-secondary));
	color: white;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	flex-shrink: 0;
}

.wca-header-text h3 {
	font-size: 16px;
	font-weight: 600;
	color: var(--wca-text-main);
	margin-bottom: 2px;
}

.wca-status-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: #10B981;
	/* Green */
	border-radius: 50%;
}

.wca-status-text {
	font-size: 12px;
	color: var(--wca-text-sub);
}

.wca-header-actions button {
	background: none;
	border: none;
	color: var(--wca-text-sub);
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	transition: 0.2s;
}

.wca-header-actions button:hover {
	background: #f3f4f6;
	color: var(--wca-text-main);
}

/* Messages Area */
#wca-messages-area {
	flex: 1;
	padding: 20px !important;
	overflow-y: auto;
	background: #ffffff;
	/* Clean white bg for modern feel */
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* Scrollbar Style */
#wca-messages-area::-webkit-scrollbar {
	width: 6px;
}

#wca-messages-area::-webkit-scrollbar-thumb {
	background-color: rgba(0, 0, 0, 0.1);
	border-radius: 10px;
}

.wca-date-divider {
	text-align: center;
	margin: 10px 0;
}

.wca-date-divider span {
	font-size: 11px;
	color: #9CA3AF;
	background: #f9fafb;
	padding: 4px 12px;
	border-radius: 12px;
}

/* Message Bubbles */
.wca-message {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 85%;
	animation: wca-slide-up 0.3s ease-out forwards;
	opacity: 0;
	transform: translateY(10px);
}

@keyframes wca-slide-up {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.wca-message.wca-user {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.wca-avatar-small {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--wca-bg-light);
	color: var(--wca-text-sub);
	font-size: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.wca-user .wca-avatar-small {
	display: none;
	/* Hide for user self */
}

#wca-widget-container .wca-bubble {
	padding: 12px 18px !important;
	border-radius: 18px;
	font-size: 14px !important;
	line-height: 1.6 !important;
	position: relative;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	text-align: left;
	word-break: break-word;
	white-space: pre-line;
	min-height: auto;
	margin: 0 !important;
	text-indent: 0 !important;
	/* Ensure no external margin affects it */
}

/* Bot Bubble Style */
.wca-bot .wca-bubble {
	background: #F3F4F6;
	color: var(--wca-text-main);
	border-bottom-left-radius: 4px;
}

/* User Bubble Style */
.wca-user .wca-bubble {
	background: var(--wca-primary);
	color: white;
	border-bottom-right-radius: 4px;
}

.wca-bubble a {
	color: inherit;
	text-decoration: underline;
}

/* Input Area */
.wca-chat-header {
	padding: 20px !important;
	background: #ffffff;
	border-bottom: 1px solid #f0f0f0;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

/* ... (skip middle content) ... */

.wca-input-wrapper {
	padding: 16px !important;
	background: white;
	border-top: 1px solid #f0f0f0;
}

.wca-input-area {
	display: flex;
	align-items: center;
	gap: 12px;
	background: #F9FAFB;
	border-radius: 24px;
	padding: 10px 16px !important;
	border: 1px solid transparent;
	transition: 0.2s;
	min-height: 48px;
}

.wca-input-area:focus-within {
	border-color: var(--wca-primary);
	background: white;
	box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

#wca-chat-input {
	flex: 1;
	border: none;
	background: transparent;
	outline: none;
	font-size: 14px !important;
	color: var(--wca-text-main);
	padding: 12px !important;
	/* Increased padding */
	margin: 0 !important;
	height: 100%;
	line-height: normal;
}

#wca-send-btn {
	background: var(--wca-primary);
	color: white;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: 0.2s;
}

#wca-send-btn:hover {
	transform: scale(1.1);
	background: var(--wca-primary-dark);
}

#wca-send-btn svg,
#wca-send-btn svg * {
	stroke: white !important;
	fill: none !important;
	width: 20px;
	height: 20px;
	display: block;
	pointer-events: none;
}

.wca-branding {
	text-align: center;
	font-size: 10px;
	color: #9CA3AF;
	margin-top: 8px;
}

/* Typography Helpers inside Messages */
.wca-bubble p {
	margin-bottom: 8px;
}

.wca-bubble p:last-child {
	margin-bottom: 0;
}

.wca-bubble ul {
	padding-left: 20px;
	margin-bottom: 8px;
}

.wca-bubble strong {
	font-weight: 600;
}

/* Typing Indicator */
.wca-typing span {
	background: #9CA3AF;
	width: 4px;
	height: 4px;
	margin: 0 2px;
}

/* Starter Actions */
.wca-starter-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 20px 10px 48px;
	/* Indent to align with bot bubble roughly */
}

.wca-starter-btn {
	background: white;
	border: 1px solid var(--wca-primary);
	color: var(--wca-primary);
	padding: 8px 14px;
	border-radius: 20px;
	font-size: 13px;
	cursor: pointer;
	transition: 0.2s;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	line-height: 1.2;
}

.wca-starter-btn:hover {
	background: var(--wca-primary);
	color: white;
	transform: translateY(-1px);
	box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.wca-starter-btn svg {
	width: 12px;
	height: 12px;
}