/* Premium WhatsApp Chat – Frontend */

#pwc-widget {
	--pwc-size: 64px;
	--pwc-x: 24px;
	--pwc-y: 24px;
	--pwc-c1: #25d366;
	--pwc-c2: #128c7e;
	position: fixed;
	bottom: var(--pwc-y);
	z-index: 99999;
	display: flex;
	flex-direction: column;
	gap: 14px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	opacity: 0;
	visibility: hidden;
	transform: translateY(14px) scale(0.92);
	/* Der Container bleibt dauerhaft klick-durchlässig – nur Button und
	   geöffnetes Popup fangen Klicks, sonst blockiert die unsichtbare
	   Popup-Fläche darunterliegende Links. */
	pointer-events: none;
	transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.5s;
}

#pwc-widget,
#pwc-widget * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

#pwc-widget.pwc-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
}

#pwc-widget.pwc-visible .pwc-button {
	pointer-events: auto;
}

.pwc-pos-left {
	left: var(--pwc-x);
	align-items: flex-start;
}

.pwc-pos-right {
	right: var(--pwc-x);
	align-items: flex-end;
}

/* ---------- Button ---------- */

.pwc-button {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--pwc-size);
	height: var(--pwc-size);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	background: linear-gradient(135deg, var(--pwc-c1), var(--pwc-c2));
	box-shadow: 0 6px 18px rgba(18, 140, 126, 0.35), 0 2px 6px rgba(0, 0, 0, 0.15);
	color: #fff;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.pwc-button:hover,
.pwc-button:focus-visible {
	transform: scale(1.08) translateY(-2px);
	box-shadow: 0 10px 26px rgba(18, 140, 126, 0.45), 0 3px 8px rgba(0, 0, 0, 0.18);
	color: #fff;
}

.pwc-button:focus-visible {
	outline: 3px solid rgba(37, 211, 102, 0.55);
	outline-offset: 3px;
}

.pwc-icon-box {
	position: relative;
	width: calc(var(--pwc-size) * 0.55);
	height: calc(var(--pwc-size) * 0.55);
	flex-shrink: 0;
}

.pwc-button .pwc-icon {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transform: scale(1) rotate(0deg);
	transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.pwc-button .pwc-icon-close {
	opacity: 0;
	transform: scale(0.4) rotate(-90deg);
}

.pwc-open .pwc-icon-whatsapp {
	opacity: 0;
	transform: scale(0.4) rotate(90deg);
}

.pwc-open .pwc-icon-close {
	opacity: 1;
	transform: scale(0.78) rotate(0deg);
}

/* Länglicher Button mit Beschriftung.
   Abstands-Regeln tragen das #pwc-widget-Präfix, damit sie den
   ID-basierten Reset oben schlagen. */

#pwc-widget.pwc-style-pill .pwc-button {
	width: auto;
	min-width: var(--pwc-size);
	padding: 0 22px 0 16px;
	border-radius: 999px;
	gap: 10px;
}

.pwc-style-pill .pwc-button:hover,
.pwc-style-pill .pwc-button:focus-visible {
	transform: scale(1.04) translateY(-2px);
}

.pwc-style-pill .pwc-icon-box {
	width: calc(var(--pwc-size) * 0.5);
	height: calc(var(--pwc-size) * 0.5);
}

.pwc-label {
	font-size: clamp(14px, calc(var(--pwc-size) * 0.28), 20px);
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1;
	white-space: nowrap;
}

/* Puls-Ring */

.pwc-pulse {
	position: absolute;
	inset: -4px;
	border-radius: inherit;
	border: 3px solid var(--pwc-c1);
	opacity: 0;
	animation: pwc-pulse 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
	pointer-events: none;
}

@keyframes pwc-pulse {
	0% {
		transform: scale(0.9);
		opacity: 0.7;
	}
	70% {
		transform: scale(1.55);
		opacity: 0;
	}
	100% {
		transform: scale(1.55);
		opacity: 0;
	}
}

/* Tooltip */

#pwc-widget .pwc-tooltip {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	white-space: nowrap;
	background: #fff;
	color: #111b21;
	padding: 9px 16px;
	border-radius: 999px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.pwc-pos-left .pwc-tooltip {
	left: calc(100% + 14px);
}

.pwc-pos-right .pwc-tooltip {
	right: calc(100% + 14px);
}

#pwc-widget .pwc-button:hover .pwc-tooltip,
#pwc-widget .pwc-button:focus-visible .pwc-tooltip {
	opacity: 1;
}

.pwc-open .pwc-tooltip {
	display: none;
}

@media (hover: none) {
	.pwc-tooltip {
		display: none;
	}
}

/* ---------- Chat-Popup ---------- */

.pwc-popup {
	width: min(360px, calc(100vw - 2 * var(--pwc-x)));
	background: #efeae2;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 12px 44px rgba(0, 0, 0, 0.24), 0 3px 10px rgba(0, 0, 0, 0.1);
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(0.96);
	transform-origin: bottom left;
	pointer-events: none;
	transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1), transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.3s;
}

.pwc-pos-right .pwc-popup {
	transform-origin: bottom right;
}

.pwc-open .pwc-popup {
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
}

/* Kopfbereich */

#pwc-widget .pwc-popup-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--pwc-c2), #075e54);
	color: #fff;
}

.pwc-avatar {
	position: relative;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.pwc-avatar img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	display: block;
}

.pwc-avatar .pwc-avatar-icon {
	width: 24px;
	height: 24px;
	color: #fff;
}

.pwc-status-dot {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #4ad504;
	border: 2px solid #0b6e60;
}

.pwc-popup-heading {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.pwc-agent-name {
	font-weight: 600;
	font-size: 15px;
	line-height: 1.25;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pwc-agent-status {
	font-size: 12.5px;
	line-height: 1.3;
	opacity: 0.85;
}

#pwc-widget .pwc-popup-close {
	margin-left: auto;
	background: transparent;
	border: 0;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.8;
	padding: 2px 8px;
	border-radius: 8px;
	flex-shrink: 0;
	transition: opacity 0.15s ease, background 0.15s ease;
}

#pwc-widget .pwc-popup-close:hover,
#pwc-widget .pwc-popup-close:focus-visible {
	opacity: 1;
	background: rgba(255, 255, 255, 0.15);
}

/* Nachrichtenbereich */

#pwc-widget .pwc-popup-body {
	padding: 18px 16px;
	min-height: 112px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	background:
		radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.4) 0, transparent 42%),
		radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.3) 0, transparent 38%),
		#efeae2;
}

#pwc-widget .pwc-bubble {
	max-width: 85%;
	background: #fff;
	border-radius: 0 12px 12px 12px;
	padding: 10px 12px;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
	font-size: 14px;
	line-height: 1.45;
	color: #111b21;
}

#pwc-widget .pwc-bubble-author {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: #1fa855;
	margin-bottom: 3px;
}

#pwc-widget .pwc-bubble-time {
	display: block;
	font-size: 11px;
	color: #667781;
	text-align: right;
	margin-top: 4px;
}

/* Tipp-Animation */

#pwc-widget .pwc-typing {
	display: inline-flex;
	gap: 4px;
	padding: 5px 2px;
}

.pwc-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9aa0a6;
	animation: pwc-blink 1.2s ease-in-out infinite;
}

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

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

@keyframes pwc-blink {
	0%,
	80%,
	100% {
		opacity: 0.25;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

.pwc-typing-bubble.pwc-hidden {
	display: none;
}

.pwc-message-bubble {
	display: none;
}

.pwc-message-bubble.pwc-shown {
	display: block;
	animation: pwc-bubble-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pwc-bubble-in {
	from {
		opacity: 0;
		transform: translateY(6px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* Fußbereich */

#pwc-widget .pwc-popup-footer {
	padding: 12px 16px 14px;
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

#pwc-widget .pwc-cta {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	background: linear-gradient(135deg, var(--pwc-c1), var(--pwc-c2));
	color: #fff !important;
	text-decoration: none !important;
	font-weight: 600;
	font-size: 15px;
	line-height: 1;
	padding: 13px 18px;
	border-radius: 999px;
	box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#pwc-widget .pwc-cta:hover,
#pwc-widget .pwc-cta:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
}

.pwc-cta .pwc-cta-icon {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}

.pwc-privacy-hint {
	font-size: 11px;
	line-height: 1.4;
	color: #8696a0;
	text-align: center;
}

/* ---------- Sichtbarkeit ---------- */

@media (max-width: 782px) {
	.pwc-hide-mobile {
		display: none !important;
	}
}

@media (min-width: 783px) {
	.pwc-hide-desktop {
		display: none !important;
	}
}

/* ---------- Reduced Motion ---------- */

@media (prefers-reduced-motion: reduce) {
	#pwc-widget,
	.pwc-popup,
	.pwc-button,
	.pwc-button .pwc-icon {
		transition: none;
	}

	.pwc-pulse {
		display: none;
	}

	.pwc-typing i {
		animation: none;
		opacity: 0.6;
	}

	.pwc-message-bubble.pwc-shown {
		animation: none;
	}
}
