/**
 * Frontend Style sheet for DS WP WhatsApp Chat widget
 */

/* Scope everything inside the portal wrapper to avoid conflicts */
#ds-chat-portal.ds-wa-wrapper {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	display: block;
	box-sizing: border-box;
}

#ds-chat-portal.ds-wa-wrapper *,
#ds-chat-portal.ds-wa-wrapper *::before,
#ds-chat-portal.ds-wa-wrapper *::after {
	box-sizing: border-box;
}

/* Position Configurations */
#ds-chat-portal.ds-wa-pos-right {
	right: 24px;
}

#ds-chat-portal.ds-wa-pos-left {
	left: 24px;
}

/* Floating WhatsApp Bubble Pill */
.ds-wa-bubble {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 24px 12px 18px;
	background-color: var(--ds-wa-bubble-bg, #25D366);
	color: var(--ds-wa-bubble-text, #ffffff);
	border: none;
	border-radius: 50px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	position: relative;
	transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
	            background-color 0.2s ease, 
	            box-shadow 0.2s ease;
	outline: none;
}

.ds-wa-bubble:hover {
	transform: scale(1.06);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.ds-wa-bubble:active {
	transform: scale(0.98);
}

.ds-wa-bubble-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	color: inherit;
}

.ds-wa-bubble-icon svg {
	width: 100%;
	height: 100%;
}

.ds-wa-bubble-text {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
}

/* Unread Badge */
.ds-wa-badge {
	position: absolute;
	top: -4px;
	right: 2px;
	background-color: #ff3b30;
	color: #ffffff;
	font-size: 10px;
	font-weight: 700;
	border-radius: 50%;
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #ffffff;
	animation: ds-pulse-badge 2s infinite ease-in-out;
	line-height: 1;
}

/* Chat Card (Window) */
.ds-wa-card {
	position: absolute;
	width: 360px;
	border-radius: 16px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background-color: var(--ds-wa-body-bg, #091E28);
	color: var(--ds-wa-body-text, #ffffff);
	bottom: 78px;
	opacity: 0;
	visibility: hidden;
	transform: scale(0.85) translateY(24px);
	pointer-events: none;
	transition: opacity 0.25s cubic-bezier(0.165, 0.84, 0.44, 1), 
	            transform 0.25s cubic-bezier(0.165, 0.84, 0.44, 1),
	            visibility 0.25s;
}

/* Alignments of open card */
.ds-wa-pos-right .ds-wa-card {
	right: 0;
	transform-origin: bottom right;
}

.ds-wa-pos-left .ds-wa-card {
	left: 0;
	transform-origin: bottom left;
}

/* Open Card State */
.ds-wa-card.ds-wa-open {
	opacity: 1;
	visibility: visible;
	transform: scale(1) translateY(0);
	pointer-events: auto;
}

/* Chat Card Header */
.ds-wa-card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background-color: var(--ds-wa-header-bg, #1C2B35);
	padding: 16px 20px;
	color: var(--ds-wa-header-text, #ffffff);
}

.ds-wa-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ds-wa-avatar-container {
	position: relative;
	width: 42px;
	height: 42px;
	background-color: rgba(255, 255, 255, 0.08);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: inherit;
}

.ds-wa-avatar-svg {
	width: 22px;
	height: 22px;
}

.ds-wa-avatar-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.ds-wa-online-dot {
	position: absolute;
	bottom: 1px;
	right: 1px;
	width: 10px;
	height: 10px;
	background-color: #4AD954;
	border-radius: 50%;
	border: 2px solid var(--ds-wa-header-bg, #1C2B35);
	animation: ds-pulse-dot 2s infinite;
}

.ds-wa-header-text-container {
	display: flex;
	flex-direction: column;
	text-align: left;
}

.ds-wa-header-title {
	font-weight: 700;
	font-size: 16px;
	line-height: 1.2;
}

.ds-wa-header-subtitle {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.65);
	margin-top: 3px;
	line-height: 1;
}

.ds-wa-close {
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.5);
	cursor: pointer;
	padding: 4px;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.ds-wa-close:hover {
	color: var(--ds-wa-header-text, #ffffff);
	background-color: rgba(255, 255, 255, 0.08);
}

.ds-wa-close svg {
	width: 14px;
	height: 14px;
}

/* Chat Card Body */
.ds-wa-card-body {
	position: relative;
	padding: 24px 20px;
	height: 210px;
	overflow-y: auto;
	background-color: var(--ds-wa-body-bg, #091E28);
	scrollbar-width: thin;
}

.ds-wa-chat-pattern {
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
	background-size: 16px 16px;
	pointer-events: none;
	z-index: 1;
}

.ds-wa-message-container {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.ds-wa-message-bubble {
	background-color: #202C33;
	color: #ffffff;
	padding: 10px 14px;
	border-radius: 0px 12px 12px 12px;
	max-width: 85%;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
	position: relative;
	word-wrap: break-word;
	line-height: 1.4;
	font-size: 14px;
	text-align: left;
}

/* Tail/triangle for left message */
.ds-wa-message-bubble::before {
	content: "";
	position: absolute;
	top: 0;
	left: -8px;
	width: 8px;
	height: 10px;
	background-color: #202C33;
	clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.ds-wa-message-text {
	margin-bottom: 4px;
	white-space: pre-line;
}

.ds-wa-message-time {
	color: rgba(255, 255, 255, 0.45);
	font-size: 10px;
	text-align: right;
	margin-top: 2px;
}

/* Chat Card Footer (Action Bar) */
.ds-wa-card-footer {
	background-color: var(--ds-wa-header-bg, #1C2B35);
	padding: 12px 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ds-wa-input-wrapper {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
}

.ds-wa-input {
	flex: 1;
	background-color: #2a3942;
	border: none;
	border-radius: 24px;
	padding: 10px 16px;
	color: #ffffff;
	font-size: 14px;
	outline: none;
	transition: background-color 0.2s ease;
}

.ds-wa-input::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

.ds-wa-input:focus {
	background-color: #32444f;
}

.ds-wa-send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background-color: var(--ds-wa-send-bg, #25D366);
	color: #ffffff;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
	            background-color 0.2s ease;
	padding: 0;
	flex-shrink: 0;
}

.ds-wa-send:hover {
	transform: scale(1.08);
}

.ds-wa-send:active {
	transform: scale(0.95);
}

.ds-wa-send svg {
	width: 15px;
	height: 15px;
	margin-left: 2px; /* visual alignment offset */
}

/* Branding footer */
.ds-wa-branding {
	text-align: center;
	font-size: 10px;
}

.ds-wa-branding a {
	color: rgba(255, 255, 255, 0.35);
	text-decoration: none;
	font-family: inherit;
	transition: color 0.2s ease;
}

.ds-wa-branding a:hover {
	color: rgba(255, 255, 255, 0.6);
	text-decoration: underline;
}

/* Animations */
@keyframes ds-pulse-dot {
	0% { box-shadow: 0 0 0 0 rgba(74, 217, 84, 0.5); }
	70% { box-shadow: 0 0 0 7px rgba(74, 217, 84, 0); }
	100% { box-shadow: 0 0 0 0 rgba(74, 217, 84, 0); }
}

@keyframes ds-pulse-badge {
	0% { transform: scale(1); }
	50% { transform: scale(1.12); }
	100% { transform: scale(1); }
}

/* Responsive Scaling for Mobile viewports */
@media (max-width: 480px) {
	#ds-chat-portal.ds-wa-wrapper {
		bottom: 16px;
	}
	#ds-chat-portal.ds-wa-pos-right {
		right: 16px;
	}
	#ds-chat-portal.ds-wa-pos-left {
		left: 16px;
	}
	.ds-wa-card {
		width: calc(100vw - 32px);
		bottom: 72px;
	}
}
