/**
 * Frontend Styles for Interactive Sticky WhatsApp & Call Widget
 * Zero-dependency, lightweight, mobile responsive CSS.
 */

:root {
	--wpsc-wa-color: #25D366;
	--wpsc-call-color: #0284C7;
	--wpsc-header-bg: #075E54;
	--wpsc-header-text: #FFFFFF;
}

/* Root Widget Container */
.wpsc-widget-container {
	position: fixed;
	bottom: max(20px, env(safe-area-inset-bottom, 20px));
	z-index: 999999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
	pointer-events: none; /* Container ignores clicks; children re-enable pointer-events */
}

.wpsc-widget-container * {
	box-sizing: border-box;
}

/* Positioning */
.wpsc-widget-container.wpsc-pos-right {
	right: max(20px, env(safe-area-inset-right, 20px));
	align-items: flex-end;
}

.wpsc-widget-container.wpsc-pos-left {
	left: max(20px, env(safe-area-inset-left, 20px));
	align-items: flex-start;
}

/* Floating Actions Stack */
.wpsc-actions-stack {
	display: flex;
	flex-direction: column;
	gap: 12px;
	pointer-events: auto;
	margin-top: 12px;
}

/* Base Floating Button */
.wpsc-btn {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	outline: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	text-decoration: none;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.12);
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background-color 0.2s ease;
	position: relative;
	-webkit-tap-highlight-color: transparent;
}

.wpsc-btn:hover {
	transform: scale(1.08) translateY(-2px);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28), 0 4px 10px rgba(0, 0, 0, 0.15);
	color: #ffffff;
}

.wpsc-btn:active {
	transform: scale(0.94);
}

/* Direct Call Button Styling */
.wpsc-btn-call {
	background-color: var(--wpsc-call-color);
}

/* WhatsApp Trigger Button Styling */
.wpsc-btn-wa {
	background-color: var(--wpsc-wa-color);
}

.wpsc-btn-wa .wpsc-icon-close {
	display: none;
}

.wpsc-btn-wa.wpsc-active .wpsc-icon-wa {
	display: none;
}

.wpsc-btn-wa.wpsc-active .wpsc-icon-close {
	display: block;
}

/* Unread Badge */
.wpsc-notification-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	background: #ef4444;
	color: #ffffff;
	font-size: 11px;
	font-weight: 700;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #ffffff;
	box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
	animation: wpscBadgeBounce 2s ease infinite;
}

@keyframes wpscBadgeBounce {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.15); }
}

/* Radar Pulse Ring */
.wpsc-pulse::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background-color: inherit;
	opacity: 0.6;
	z-index: -1;
	animation: wpscRadarPulse 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes wpscRadarPulse {
	0% {
		transform: scale(1);
		opacity: 0.7;
	}
	70%, 100% {
		transform: scale(1.65);
		opacity: 0;
	}
}

/* ==========================================================================
   WhatsApp Interactive Chat Window
   ========================================================================== */
.wpsc-chat-window {
	width: 360px;
	max-width: calc(100vw - 32px);
	background: #ffffff;
	border-radius: 18px;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
	overflow: hidden;
	pointer-events: auto;
	transform: translateY(24px) scale(0.92);
	opacity: 0;
	visibility: hidden;
	transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease, visibility 0.25s ease;
	transform-origin: bottom right;
	border: 1px solid rgba(0, 0, 0, 0.06);
}

.wpsc-pos-left .wpsc-chat-window {
	transform-origin: bottom left;
}

.wpsc-chat-window.wpsc-active {
	transform: translateY(0) scale(1);
	opacity: 1;
	visibility: visible;
}

/* Chat Header */
.wpsc-chat-header {
	background-color: var(--wpsc-header-bg);
	color: var(--wpsc-header-text);
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.wpsc-chat-agent {
	display: flex;
	align-items: center;
	gap: 12px;
}

.wpsc-chat-avatar-wrap {
	position: relative;
	width: 44px;
	height: 44px;
	flex-shrink: 0;
}

.wpsc-chat-avatar {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.4);
}

.wpsc-online-indicator {
	position: absolute;
	bottom: 2px;
	right: 2px;
	width: 11px;
	height: 11px;
	background: #22c55e;
	border: 2px solid #ffffff;
	border-radius: 50%;
	box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.wpsc-chat-agent-details {
	display: flex;
	flex-direction: column;
}

.wpsc-chat-agent-name {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: inherit;
	line-height: 1.25;
}

.wpsc-chat-agent-status {
	margin: 2px 0 0 0;
	font-size: 12px;
	opacity: 0.88;
	line-height: 1.2;
}

.wpsc-chat-close-btn {
	background: transparent;
	border: none;
	color: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 50%;
	opacity: 0.8;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.wpsc-chat-close-btn:hover {
	opacity: 1;
	background-color: rgba(255, 255, 255, 0.15);
}

/* Chat Body */
.wpsc-chat-body {
	background-color: #efeae2;
	background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
	background-size: 14px 14px;
	padding: 20px 16px;
	min-height: 140px;
	max-height: 260px;
	overflow-y: auto;
}

.wpsc-chat-date-badge {
	text-align: center;
	font-size: 11px;
	font-weight: 500;
	background: rgba(255, 255, 255, 0.88);
	color: #64748b;
	padding: 3px 10px;
	border-radius: 12px;
	width: max-content;
	margin: 0 auto 16px auto;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	backdrop-filter: blur(4px);
}

.wpsc-chat-bubble {
	background: #ffffff;
	padding: 12px 14px;
	border-radius: 0 14px 14px 14px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
	max-width: 88%;
	position: relative;
	animation: wpscBubbleEntrance 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wpsc-chat-bubble::before {
	content: '';
	position: absolute;
	top: 0;
	left: -8px;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 0 8px 10px 0;
	border-color: transparent #ffffff transparent transparent;
}

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

.wpsc-chat-bubble-sender {
	font-size: 12px;
	font-weight: 700;
	color: var(--wpsc-header-bg);
	margin-bottom: 4px;
}

.wpsc-chat-bubble-msg {
	font-size: 13.5px;
	color: #0f172a;
	line-height: 1.45;
	word-wrap: break-word;
}

.wpsc-chat-bubble-meta {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 4px;
	font-size: 10px;
	color: #94a3b8;
	margin-top: 6px;
}

.wpsc-double-check {
	flex-shrink: 0;
}

/* Chat Footer / CTA */
.wpsc-chat-footer {
	padding: 14px 16px;
	background: #f8fafc;
	border-top: 1px solid #f1f5f9;
}

.wpsc-chat-start-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	background-color: var(--wpsc-wa-color);
	color: #ffffff;
	text-decoration: none;
	padding: 12px 18px;
	border-radius: 24px;
	font-size: 14px;
	font-weight: 600;
	box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
	transition: all 0.25s ease;
	text-align: center;
}

.wpsc-chat-start-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
	color: #ffffff;
	opacity: 0.95;
}

.wpsc-chat-start-btn:active {
	transform: translateY(0);
}

/* Responsive adjustments for Mobile */
@media (max-width: 480px) {
	.wpsc-widget-container {
		bottom: max(16px, env(safe-area-inset-bottom, 16px));
	}

	.wpsc-widget-container.wpsc-pos-right {
		right: max(16px, env(safe-area-inset-right, 16px));
	}

	.wpsc-widget-container.wpsc-pos-left {
		left: max(16px, env(safe-area-inset-left, 16px));
	}

	.wpsc-chat-window {
		width: calc(100vw - 32px);
		bottom: 76px;
	}

	.wpsc-btn {
		width: 52px;
		height: 52px;
	}
}
