/**
 * mod_whatsappbutton
 * (C) 2026 cover72 - GNU General Public License version 2 or later
 */

.wab {
	--wab-size: 60px;
	--wab-bg: #25d366;
	--wab-fg: #ffffff;
	--wab-offset-x: 24px;
	--wab-offset-y: 24px;
	--wab-z: 9990;
	--wab-panel-bg: #ffffff;
	--wab-panel-fg: #1f2937;
	--wab-panel-muted: #6b7280;
	--wab-panel-shadow: 0 10px 30px rgba(0, 0, 0, .18);
	font-size: 15px;
	line-height: 1.45;
}

.wab *,
.wab *::before,
.wab *::after {
	box-sizing: border-box;
}

.wab[hidden] {
	display: none !important;
}

/* ---------- Layout ---------- */

/*
 * Der schwebende Rahmen selbst nimmt keine Klicks an - nur Button und Panels tun das.
 * Sonst legt sich seine unsichtbare Flaeche (Abstaende zwischen den Elementen, und bei
 * eingeblendetem Hinweis dessen ganze Breite) ueber darunterliegende Links.
 */
.wab--floating {
	position: fixed;
	z-index: var(--wab-z);
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: min(320px, calc(100vw - 24px));
	pointer-events: none;
}

.wab--floating > * {
	pointer-events: auto;
}

.wab--inline {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	gap: 10px;
	align-items: flex-start;
	max-width: 320px;
}

.wab--bottom-right {
	right: var(--wab-offset-x);
	bottom: var(--wab-offset-y);
	align-items: flex-end;
}

.wab--bottom-left {
	left: var(--wab-offset-x);
	bottom: var(--wab-offset-y);
	align-items: flex-start;
}

.wab--top-right {
	top: var(--wab-offset-y);
	right: var(--wab-offset-x);
	align-items: flex-end;
	flex-direction: column-reverse;
}

.wab--top-left {
	top: var(--wab-offset-y);
	left: var(--wab-offset-x);
	align-items: flex-start;
	flex-direction: column-reverse;
}

.wab--middle-right {
	top: 50%;
	right: var(--wab-offset-x);
	transform: translateY(-50%);
	align-items: flex-end;
}

.wab--middle-left {
	top: 50%;
	left: var(--wab-offset-x);
	transform: translateY(-50%);
	align-items: flex-start;
}

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

.wab__button {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	gap: .55em;
	min-width: var(--wab-size);
	height: var(--wab-size);
	border-radius: 999px;
	background-color: var(--wab-bg);
	color: var(--wab-fg);
	text-decoration: none;
	transition: transform .2s ease, filter .2s ease;
}

.wab--has-label .wab__button {
	padding: 0 calc(var(--wab-size) / 3.2);
}

.wab--shadow .wab__button {
	box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}

.wab__button:hover,
.wab__button:focus-visible {
	color: var(--wab-fg);
	text-decoration: none;
	transform: scale(1.06);
	filter: brightness(1.06);
}

.wab__button:focus-visible {
	outline: 3px solid var(--wab-fg);
	outline-offset: 3px;
}

.wab__icon {
	display: inline-flex;
	pointer-events: none;
}

/*
 * Icon und Beschriftung bekommen ihre Farbe direkt statt ueber currentColor:
 * Templates setzen Linkfarben oft per ID-Selektor (z. B. "#sp-footer a"), was jede
 * Klassenregel schlaegt - geerbte Farben verlieren dagegen gegen jede eigene Angabe.
 */
.wab__icon svg {
	display: block;
	width: calc(var(--wab-size) * .56);
	height: calc(var(--wab-size) * .56);
	fill: var(--wab-fg);
}

.wab__label {
	color: var(--wab-fg);
	font-weight: 600;
	white-space: nowrap;
	pointer-events: none;
}

/* ---------- Pulse ---------- */

/*
 * Der Puls-Ring waechst auf das 1,55-fache des Buttons. Ohne pointer-events: none faengt
 * er Klicks bis zu 17 px neben dem sichtbaren Button ab - und weil er animiert ist,
 * mal ja und mal nein. Genau das laesst benachbarte Menuelinks tot wirken.
 */
.wab--pulse .wab__button::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background-color: var(--wab-bg);
	z-index: -1;
	pointer-events: none;
	animation: wab-pulse 2.4s ease-out infinite;
}

@keyframes wab-pulse {
	0% {
		transform: scale(1);
		opacity: .6;
	}

	70% {
		transform: scale(1.55);
		opacity: 0;
	}

	100% {
		transform: scale(1.55);
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wab--pulse .wab__button::before {
		animation: none;
	}

	.wab__button {
		transition: none;
	}

	.wab__button:hover,
	.wab__button:focus-visible {
		transform: none;
	}
}

/* ---------- Bubble & offline notice ---------- */

.wab__bubble,
.wab__offline {
	position: relative;
	max-width: 260px;
	overflow-wrap: anywhere;
	padding: 12px 16px;
	border-radius: 14px;
	background-color: var(--wab-panel-bg);
	color: var(--wab-panel-fg);
	box-shadow: var(--wab-panel-shadow);
	font-size: .9em;
}

.wab__bubble,
.wab__offline {
	padding-right: 32px;
}

.wab__bubble-title {
	display: block;
	font-weight: 700;
}

.wab__bubble-text {
	display: block;
}

.wab__offline {
	background-color: #fff4d6;
	color: #6b4e00;
}

/*
 * Die Schliessen-Knoepfe werden vollstaendig zurueckgesetzt und ueber ".wab" adressiert:
 * Templates geben <button> gern einen Rahmen, eine Flaeche und eine eigene Schrift mit,
 * und ein blanker Klassenselektor verliert gegen deren Regeln.
 */
.wab .wab__bubble-close,
.wab .wab__offline-close,
.wab .wab__consent-close {
	position: absolute;
	top: 5px;
	right: 5px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	background-color: transparent;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	color: var(--wab-panel-muted);
	font: inherit;
	font-size: 15px;
	font-weight: 400;
	line-height: 1;
	text-shadow: none;
	text-transform: none;
	opacity: .65;
	cursor: pointer;
	transition: opacity .15s ease, background-color .15s ease;
}

.wab .wab__bubble-close svg,
.wab .wab__offline-close svg,
.wab .wab__consent-close svg {
	display: block;
	width: 11px;
	height: 11px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	pointer-events: none;
}

.wab .wab__bubble-close:hover,
.wab .wab__offline-close:hover,
.wab .wab__consent-close:hover,
.wab .wab__bubble-close:focus-visible,
.wab .wab__offline-close:focus-visible,
.wab .wab__consent-close:focus-visible {
	background-color: rgba(0, 0, 0, .09);
	opacity: 1;
}

.wab .wab__offline-close {
	color: #6b4e00;
}

/* ---------- Message window ---------- */

.wab__composer {
	position: absolute;
	width: min(330px, calc(100vw - 32px));
	overflow: hidden;
	border-radius: 16px;
	background-color: var(--wab-panel-bg);
	color: var(--wab-panel-fg);
	box-shadow: var(--wab-panel-shadow);
	text-align: left;
}

.wab__composer-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	background-color: var(--wab-bg);
	color: var(--wab-fg);
}

.wab__composer-avatar {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 999px;
	background-color: rgba(255, 255, 255, .22);
}

.wab__composer-avatar svg {
	display: block;
	width: 22px;
	height: 22px;
	fill: var(--wab-fg);
}

/* Eigenes Logo oder Foto statt des WhatsApp-Symbols */
.wab__composer-avatar--image {
	width: auto;
	height: auto;
	background: none;
}

.wab__composer-avatar--image img {
	display: block;
	max-width: none;
}

.wab__composer-avatar--circle img {
	width: 40px;
	height: 40px;
	border-radius: 999px;
	background-color: #fff;
	object-fit: cover;
}

.wab__composer-avatar--square img {
	width: auto;
	max-width: 92px;
	height: 32px;
	border-radius: 6px;
	object-fit: contain;
}

.wab__composer-heading {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
}

.wab__composer-title {
	color: var(--wab-fg);
	font-weight: 700;
	line-height: 1.25;
}

.wab__composer-status {
	color: var(--wab-fg);
	font-size: .82em;
	opacity: .85;
}

.wab .wab__composer-close {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	background-color: transparent;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	color: var(--wab-fg);
	font: inherit;
	line-height: 1;
	opacity: .85;
	cursor: pointer;
	transition: opacity .15s ease, background-color .15s ease;
}

.wab .wab__composer-close svg {
	display: block;
	width: 12px;
	height: 12px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	pointer-events: none;
}

.wab .wab__composer-close:hover,
.wab .wab__composer-close:focus-visible {
	background-color: rgba(255, 255, 255, .22);
	opacity: 1;
}

.wab__composer-body {
	padding: 14px;
}

.wab__composer-greeting {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-radius: 4px 12px 12px 12px;
	background-color: #f1f3f4;
	color: var(--wab-panel-fg);
	font-size: .92em;
}

.wab__composer-input {
	display: block;
	width: 100%;
	margin-bottom: 10px;
	padding: 10px 12px;
	border: 1px solid #d6d9dc;
	border-radius: 10px;
	background-color: #fff;
	color: var(--wab-panel-fg);
	font: inherit;
	font-size: .92em;
	line-height: 1.4;
	resize: vertical;
}

.wab__composer-input:focus {
	border-color: var(--wab-bg);
	outline: 2px solid var(--wab-bg);
	outline-offset: 1px;
}

.wab__composer-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .5em;
	width: 100%;
	padding: 10px 14px;
	border: 0;
	border-radius: 10px;
	background-color: var(--wab-bg);
	color: var(--wab-fg);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.wab__composer-send:hover {
	filter: brightness(1.06);
}

.wab__composer-send-icon svg {
	display: block;
	width: 18px;
	height: 18px;
	fill: var(--wab-fg);
}

.wab__sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	white-space: nowrap;
	border: 0;
	clip-path: inset(50%);
}

/* ---------- Consent ---------- */

.wab__consent {
	position: absolute;
	width: min(320px, calc(100vw - 32px));
	padding: 16px 18px;
	border-radius: 14px;
	background-color: var(--wab-panel-bg);
	color: var(--wab-panel-fg);
	box-shadow: var(--wab-panel-shadow);
	font-size: .9em;
	text-align: left;
}

/* Beide Panels haengen an derselben Ecke wie der Button. */
.wab--bottom-right .wab__consent,
.wab--middle-right .wab__consent,
.wab--bottom-right .wab__composer,
.wab--middle-right .wab__composer {
	right: 0;
	bottom: calc(100% + 10px);
}

.wab--bottom-left .wab__consent,
.wab--middle-left .wab__consent,
.wab--bottom-left .wab__composer,
.wab--middle-left .wab__composer {
	left: 0;
	bottom: calc(100% + 10px);
}

.wab--top-right .wab__consent,
.wab--top-right .wab__composer {
	right: 0;
	top: calc(100% + 10px);
}

.wab--top-left .wab__consent,
.wab--top-left .wab__composer {
	left: 0;
	top: calc(100% + 10px);
}

.wab--inline .wab__consent,
.wab--inline .wab__composer {
	left: 0;
	top: calc(100% + 10px);
	z-index: 20;
}

.wab__consent-title {
	margin: 0 0 .4em;
	padding-right: 24px;
	font-weight: 700;
}

.wab__consent-text {
	margin: 0 0 .6em;
}

.wab__consent-text p:last-child {
	margin-bottom: 0;
}

.wab__consent-link {
	margin: 0 0 .8em;
	font-size: .95em;
}

.wab__consent-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.wab__consent-btn {
	padding: 8px 14px;
	border: 1px solid transparent;
	border-radius: 8px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.wab__consent-btn--accept {
	background-color: var(--wab-bg);
	color: var(--wab-fg);
}

.wab__consent-btn--cancel {
	background-color: transparent;
	border-color: currentColor;
	color: var(--wab-panel-muted);
}

/* ---------- Opening hours states ---------- */

.wab--closed.wab--closed-hide {
	display: none !important;
}

.wab--closed.wab--closed-disabled .wab__button {
	pointer-events: none;
	opacity: .55;
	filter: grayscale(.85);
}

@media print {
	.wab--floating {
		display: none !important;
	}
}
