/**
 * Skyra WhatsApp Chat — Frontend Design System
 * Scoped, theme-isolated, highly customizable stylesheet (< 14 KB).
 *
 * @package Skyra\WhatsAppChat\Frontend
 */

/* 1. Global Scoped Reset & CSS Variables */
.swc-widget-wrap,
.swc-widget-wrap *,
.swc-widget-wrap *::before,
.swc-widget-wrap *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.swc-widget-wrap {
	position: fixed !important;
	bottom: var(--swc-bottom-spacing, 24px) !important;
	z-index: 9999999 !important;
	display: block;
	pointer-events: none;
}

/* Positioning rules */
.swc-widget-wrap.swc-pos--right {
	right: var(--swc-side-spacing, 24px);
	left: auto;
}

.swc-widget-wrap.swc-pos--left {
	left: var(--swc-side-spacing, 24px);
	right: auto;
}

/* 2. Floating Trigger Button */
.swc-trigger-container {
	position: relative;
	pointer-events: auto;
}

.swc-btn-trigger {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: var(--swc-btn-size, 60px) !important;
	height: var(--swc-btn-size, 60px) !important;
	padding: 0 !important;
	background: var(--swc-btn-bg, #25D366) !important;
	background-color: var(--swc-btn-bg, #25D366) !important;
	color: var(--swc-btn-icon, #ffffff) !important;
	border: none !important;
	border-radius: var(--swc-btn-radius, 50%) !important;
	cursor: pointer !important;
	text-decoration: none !important;
	user-select: none !important;
	-webkit-tap-highlight-color: transparent !important;
	box-shadow: 0 4px 18px rgba(37, 211, 102, 0.45) !important;
	transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s !important;
	outline: none !important;
}

/* Icon-only mode */
.swc-btn-trigger.swc-btn-trigger--icon-only {
	width: var(--swc-btn-size, 60px) !important;
	padding: 0 !important;
	justify-content: center !important;
	border-radius: 50% !important;
}

.swc-btn-trigger:hover,
.swc-btn-trigger:focus-visible {
	transform: scale(1.05) !important;
	filter: brightness(1.03) !important;
	box-shadow: 0 6px 24px rgba(37, 211, 102, 0.55) !important;
	outline: none !important;
}

.swc-btn-trigger:active {
	transform: scale(0.97) !important;
}

.swc-trigger-icon {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 100% !important;
	height: 100% !important;
	flex-shrink: 0 !important;
}

.swc-trigger-icon svg {
	width: var(--swc-icon-size, 34px) !important;
	height: var(--swc-icon-size, 34px) !important;
	fill: currentColor !important;
}

.swc-trigger-pill {
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.2px;
	white-space: nowrap;
	color: currentColor;
	margin-left: 8px;
	margin-right: 12px;
}

/* 3. Modal Popup Chat Box */
.swc-chat-box {
	position: absolute;
	bottom: calc(var(--swc-btn-size, 60px) + 16px);
	width: var(--swc-popup-width, 350px);
	max-width: calc(100vw - 32px);
	background: var(--swc-card-bg, #ffffff);
	border-radius: var(--swc-popup-radius, 14px) !important;
	box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06) !important;
	overflow: hidden !important;
	opacity: 0;
	visibility: hidden;
	border: 1px solid #e2e8f0 !important;
	pointer-events: none;
}

.swc-pos--right .swc-chat-box {
	right: 0;
	left: auto;
	transform-origin: bottom right;
}

.swc-pos--left .swc-chat-box {
	left: 0;
	right: auto;
	transform-origin: bottom left;
}

/* Active open state */
.swc-chat-box.swc-chat-box--open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* Animation Styles */
.swc-anim--none .swc-chat-box {
	transition: none !important;
}

.swc-anim--fade .swc-chat-box {
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.swc-anim--slide .swc-chat-box {
	transform: translateY(18px);
	transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
}
.swc-anim--slide .swc-chat-box.swc-chat-box--open {
	transform: translateY(0);
}

.swc-anim--scale .swc-chat-box {
	transform: scale(0.85);
	transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.25s;
}
.swc-anim--scale .swc-chat-box.swc-chat-box--open {
	transform: scale(1);
}

/* 4. Chat Header */
.swc-chat-header {
	padding: 16px 18px 14px !important;
	background: var(--swc-header-bg, #075E54) !important;
	color: var(--swc-header-text, #ffffff) !important;
	border-radius: 14px 14px 0 0 !important;
}

.swc-chat-header-top {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between !important;
	gap: 12px !important;
	margin-bottom: 3px !important;
}

.swc-header-title {
	font-size: var(--swc-font-header, 18px) !important;
	font-weight: 700 !important;
	line-height: 1.25 !important;
	color: var(--swc-header-text, #ffffff) !important;
	margin: 0 !important;
	padding: 0 !important;
	letter-spacing: -0.2px !important;
	font-family: inherit !important;
}

.swc-header-subtitle {
	font-size: 13px !important;
	line-height: 1.35 !important;
	color: var(--swc-header-sub, #E9EDEF) !important;
	margin: 0 !important;
	padding: 0 !important;
	opacity: 0.92 !important;
	font-family: inherit !important;
}

.swc-close-btn {
	background: rgba(255, 255, 255, 0.2) !important;
	border: none !important;
	color: #ffffff !important;
	width: 28px !important;
	height: 28px !important;
	border-radius: 50% !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	cursor: pointer !important;
	transition: background 0.2s, transform 0.2s !important;
	flex-shrink: 0 !important;
	padding: 0 !important;
}

.swc-close-btn:hover,
.swc-close-btn:focus-visible {
	background: rgba(255, 255, 255, 0.35) !important;
	transform: scale(1.06) !important;
	outline: none !important;
}

/* 5. Chat Body & Agent Roster List */
.swc-chat-body {
	background: #f8fafc !important;
	padding: 14px 14px 10px !important;
	max-height: var(--swc-popup-max-height, 520px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Custom minimal scrollbar */
.swc-chat-body::-webkit-scrollbar {
	width: 5px;
}
.swc-chat-body::-webkit-scrollbar-track {
	background: transparent;
}
.swc-chat-body::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 10px;
}
.swc-chat-body::-webkit-scrollbar-thumb:hover {
	background: #94a3b8;
}

.swc-agents-list {
	list-style: none !important;
	display: flex !important;
	flex-direction: column !important;
	gap: 10px !important;
	margin: 0 !important;
	padding: 0 !important;
}

.swc-agent-item {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

/* 6. Individual Agent Card */
.swc-agent-card {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between !important;
	gap: 12px !important;
	background: #ffffff !important;
	border: 1px solid #e2e8f0 !important;
	border-radius: 12px !important;
	padding: 12px 14px !important;
	text-decoration: none !important;
	color: #111827 !important;
	transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, border-color 0.2s !important;
	position: relative !important;
	cursor: pointer !important;
	-webkit-tap-highlight-color: transparent !important;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02) !important;
}

.swc-agent-card:hover,
.swc-agent-card:focus-visible {
	transform: translateY(-2px) !important;
	border-color: #cbd5e1 !important;
	box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
	outline: none !important;
}

.swc-agent-card:active {
	transform: translateY(0) !important;
}

/* Avatar container with flag */
.swc-agent-avatar-wrap {
	position: relative !important;
	width: 44px !important;
	height: 44px !important;
	flex-shrink: 0 !important;
}

.swc-agent-avatar-inner {
	width: 44px !important;
	height: 44px !important;
	border-radius: 50% !important;
	background: #edf2f7 !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	overflow: hidden !important;
}

.swc-agent-avatar {
	width: 26px !important;
	height: 18px !important;
	object-fit: cover !important;
	border-radius: 2px !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12) !important;
	display: block !important;
}

/* Availability Status Indicator Dot */
.swc-status-indicator {
	position: absolute !important;
	bottom: 0px !important;
	right: 0px !important;
	width: 12px !important;
	height: 12px !important;
	border-radius: 50% !important;
	border: 2px solid #ffffff !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
}

.swc-status-indicator.swc-status--online {
	background-color: var(--swc-status-online, #25D366) !important;
}

.swc-status-indicator.swc-status--away {
	background-color: var(--swc-status-away, #F59E0B) !important;
}

.swc-status-indicator.swc-status--offline {
	background-color: var(--swc-status-offline, #9CA3AF) !important;
}

/* Agent Information Layout (2 lines: Name + Title/Role) */
.swc-agent-info {
	flex: 1 !important;
	min-width: 0 !important;
	display: flex !important;
	flex-direction: column !important;
	justify-content: center !important;
	gap: 2px !important;
}

.swc-agent-name {
	font-size: var(--swc-font-agent, 15px) !important;
	font-weight: 700 !important;
	color: #111827 !important;
	white-space: nowrap !important;
	overflow: hidden !important;
	text-overflow: ellipsis !important;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 1.3 !important;
	font-family: inherit !important;
}

.swc-agent-title {
	font-size: var(--swc-font-desc, 13px) !important;
	font-weight: 400 !important;
	color: #64748b !important;
	white-space: nowrap !important;
	overflow: hidden !important;
	text-overflow: ellipsis !important;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 1.3 !important;
	font-family: inherit !important;
}

/* Status badge column on the right */
.swc-agent-status-col {
	flex-shrink: 0 !important;
	display: flex !important;
	align-items: center !important;
}

.swc-agent-status-tag {
	font-size: 12px !important;
	font-weight: 600 !important;
	padding: 4px 10px !important;
	border-radius: 6px !important;
	white-space: nowrap !important;
	letter-spacing: 0.1px !important;
	font-family: inherit !important;
}

.swc-agent-status-tag.swc-status--online {
	background: #e8f8ee !important;
	color: #16a34a !important;
}

.swc-agent-status-tag.swc-status--away {
	background: #fef3c7 !important;
	color: #b45309 !important;
}

.swc-agent-status-tag.swc-status--offline {
	background: #f1f5f9 !important;
	color: #64748b !important;
}

/* 7. Mobile Responsive Breakpoints */
@media (max-width: 480px) {
	.swc-widget-wrap {
		bottom: 16px !important;
	}

	.swc-widget-wrap.swc-pos--right {
		right: 16px !important;
	}

	.swc-widget-wrap.swc-pos--left {
		left: 16px !important;
	}

	.swc-chat-box {
		bottom: calc(var(--swc-btn-size, 60px) + 12px);
		width: calc(100vw - 32px) !important;
		max-width: 100% !important;
	}

	.swc-btn-trigger {
		height: max(48px, calc(var(--swc-btn-size, 60px) - 6px));
		padding: 0 14px;
	}

	.swc-btn-trigger.swc-btn-trigger--icon-only {
		width: max(48px, calc(var(--swc-btn-size, 60px) - 6px));
		padding: 0;
	}

	.swc-trigger-pill {
		font-size: 13px;
	}

	.swc-chat-body {
		max-height: 340px;
		padding: 10px 8px;
	}

	.swc-agent-card {
		padding: 10px 12px;
	}

	.swc-agent-avatar-wrap,
	.swc-agent-avatar {
		width: 42px;
		height: 42px;
	}
}

/* 8. Accessibility: Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
	.swc-chat-box,
	.swc-btn-trigger,
	.swc-trigger-pulse,
	.swc-agent-card,
	.swc-close-btn {
		animation: none !important;
		transition: none !important;
	}
}

/* 7. Display Rules - Responsive Device Hiding */
@media (min-width: 1024px) {
	.swc-widget-wrap.swc-hide-desktop,
	.swc-embedded-wrap.swc-hide-desktop {
		display: none !important;
	}
}

@media (min-width: 768px) and (max-width: 1023px) {
	.swc-widget-wrap.swc-hide-tablet,
	.swc-embedded-wrap.swc-hide-tablet {
		display: none !important;
	}
}

@media (max-width: 767px) {
	.swc-widget-wrap.swc-hide-mobile,
	.swc-embedded-wrap.swc-hide-mobile {
		display: none !important;
	}
}

/* 9. Embedded Shortcode & Gutenberg Block Styles */
.swc-embedded-wrap,
.swc-embedded-wrap *,
.swc-embedded-wrap *::before,
.swc-embedded-wrap *::after {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
}

.swc-embedded-wrap {
	position: relative;
	display: block;
	max-width: var(--swc-popup-width, 380px);
	width: 100%;
	margin: 24px auto;
	box-sizing: border-box;
	clear: both;
}

.swc-embedded-wrap .swc-chat-box {
	position: relative !important;
	bottom: auto !important;
	right: auto !important;
	left: auto !important;
	opacity: 1 !important;
	visibility: visible !important;
	pointer-events: auto !important;
	transform: none !important;
	max-width: 100% !important;
	width: 100% !important;
	margin: 0 auto;
	display: block;
}

.swc-embedded-wrap .swc-close-btn {
	display: none !important;
}

.swc-embedded-wrap .swc-backdrop {
	display: none !important;
}

/* Standalone Inline Button Layout */
.swc-btn-inline {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: var(--swc-btn-size, 50px);
	padding: 0 22px 0 16px;
	background: var(--swc-btn-bg, #25D366);
	color: var(--swc-btn-icon, #ffffff) !important;
	border-radius: var(--swc-btn-radius, 25px);
	font-size: var(--swc-font-agent, 15px);
	font-weight: 600;
	text-decoration: none !important;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
	transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, filter 0.2s;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	margin: 12px 0;
	line-height: 1;
}

.swc-btn-inline:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
	filter: brightness(1.05);
	color: var(--swc-btn-icon, #ffffff) !important;
}

.swc-btn-inline:active {
	transform: translateY(0);
}

.swc-btn-inline .swc-btn-inline-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--swc-icon-size, 26px);
	height: var(--swc-icon-size, 26px);
	flex-shrink: 0;
}

.swc-btn-inline .swc-btn-inline-icon svg {
	width: 100%;
	height: 100%;
	fill: currentColor;
}

/* 7. Attention Animations & Advanced CTA Behavior */
@keyframes swc-bounce {
	0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
	40% { transform: translateY(-12px); }
	60% { transform: translateY(-6px); }
}

@keyframes swc-pulse-cta {
	0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
	70% { transform: scale(1.05); box-shadow: 0 0 0 14px rgba(37, 211, 102, 0); }
	100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

@keyframes swc-shake {
	0%, 100% { transform: rotate(0deg); }
	20%, 60% { transform: rotate(-8deg); }
	40%, 80% { transform: rotate(8deg); }
}

.swc-attention--bounce .swc-btn-trigger {
	animation: swc-bounce 2s infinite ease-in-out;
}

.swc-attention--pulse .swc-btn-trigger {
	animation: swc-pulse-cta 2.2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.swc-attention--shake .swc-btn-trigger {
	animation: swc-shake 2.5s infinite ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
	.swc-attention--bounce .swc-btn-trigger,
	.swc-attention--pulse .swc-btn-trigger,
	.swc-attention--shake .swc-btn-trigger {
		animation: none !important;
	}
}
