/**
 * Consent Manager - Frontend-Styling.
 * Nutzt CSS-Variablen, die aus der Admin-Konfiguration (Banner & Design)
 * inline gesetzt werden, damit keine Markenfarben im Plugin hardcodiert sind.
 */

:root {
	--cm-color-primary: #1a1a1a;
	--cm-color-background: #ffffff;
	--cm-color-text: #1a1a1a;
	--cm-border-radius: 8px;
	--cm-spacing-unit: 16px;
}

.cm-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 999998;
}

.cm-floating-button {
	position: fixed;
	bottom: 20px;
	z-index: 999997;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	border: none;
	background: var(--cm-color-primary);
	color: var(--cm-color-background);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0,0,0,0.25);
	padding: 0;
}

.cm-floating-button--bottom-left {
	left: 20px;
}

.cm-floating-button--bottom-right {
	right: 20px;
}

.cm-floating-button:hover,
.cm-floating-button:focus-visible {
	transform: scale(1.06);
	outline: none;
}

@media (max-width: 480px) {
	.cm-floating-button {
		width: 44px;
		height: 44px;
		bottom: 12px;
	}
	.cm-floating-button--bottom-left {
		left: 12px;
	}
	.cm-floating-button--bottom-right {
		right: 12px;
	}
}

.cm-banner {
	position: fixed;
	left: 0;
	right: 0;
	z-index: 999999;
	background: var(--cm-color-background);
	color: var(--cm-color-text);
	border-radius: var(--cm-border-radius);
	box-shadow: 0 2px 20px rgba(0,0,0,0.2);
	padding: var(--cm-spacing-unit);
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

.cm-banner--bottom {
	bottom: 16px;
	max-width: 640px;
	margin: 0 16px;
}

.cm-banner--top {
	top: 16px;
	max-width: 640px;
	margin: 0 16px;
}

.cm-banner--center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	max-width: 520px;
	right: auto;
}

/*
 * Layout "bar" (volle Breite) hebt Randabstand und Max-Breite von
 * Position "top"/"bottom" wieder auf, da eine echte Leiste randlos an
 * die Bildschirmkante stoßen soll statt als schwebende Box mit Lücke.
 * Die Reihenfolge im Stylesheet stellt sicher, dass diese Regel nach
 * .cm-banner--bottom/--top ausgewertet wird und deren margin/max-width
 * überschreibt (beide Klassen liegen gemeinsam auf dem Element).
 */
.cm-banner--bar.cm-banner--bottom,
.cm-banner--bar.cm-banner--top {
	margin: 0;
	max-width: none;
}
.cm-banner--bar.cm-banner--bottom {
	bottom: 0;
}
.cm-banner--bar.cm-banner--top {
	top: 0;
}

.cm-banner--bar {
	max-width: none;
	margin: 0;
	border-radius: 0;
}

/*
 * Bei Layout "bar" nimmt der Banner die volle Breite ein (siehe oben),
 * aber der Inhalt (Titel/Text/Buttons) soll nicht am linken Rand kleben,
 * sondern auf eine lesbare Breite begrenzt und zentriert werden.
 * Bewusst klassisches "max-width + margin: 0 auto" statt CSS Grid/
 * Flexbox-Zentrierung: in mehreren getesteten WebKit-Versionen wird
 * max-width auf Grid-/Flex-Items nicht zuverlässig respektiert, während
 * dieser Ansatz seit CSS2.1 universell unterstützt wird.
 */
.cm-banner--bar .cm-banner__inner {
	max-width: 1100px;
	margin: 0 auto;
}

.cm-banner__logo {
	max-height: 32px;
	margin-bottom: 8px;
}

.cm-banner__title {
	font-weight: 700;
	font-size: 16px;
	margin: 0 0 8px;
}

.cm-banner__description {
	margin: 0 0 16px;
}

.cm-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.cm-banner__legal-links {
	margin-top: 12px;
	font-size: 12px;
	opacity: 0.75;
}

.cm-banner__legal-links a {
	color: inherit;
	text-decoration: underline;
}

.cm-banner__legal-links a:hover,
.cm-banner__legal-links a:focus-visible {
	opacity: 1;
}

.cm-btn {
	appearance: none;
	border: 1px solid var(--cm-color-primary);
	border-radius: calc(var(--cm-border-radius) / 2);
	padding: 8px 16px;
	font-size: 14px;
	cursor: pointer;
	background: transparent;
	color: var(--cm-color-primary);
}

.cm-btn--primary {
	background: var(--cm-color-primary);
	color: var(--cm-color-background);
}

.cm-btn:focus-visible {
	outline: 2px solid var(--cm-color-primary);
	outline-offset: 2px;
}

.cm-settings-panel {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0,0,0,0.45);
}

.cm-settings-panel__inner {
	background: var(--cm-color-background);
	color: var(--cm-color-text);
	border-radius: var(--cm-border-radius);
	max-width: 640px;
	width: calc(100% - 32px);
	max-height: 85vh;
	overflow-y: auto;
	padding: 24px;
	position: relative;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.cm-settings-panel__close {
	position: absolute;
	top: 12px;
	right: 12px;
	appearance: none;
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: var(--cm-color-text);
	padding: 4px 8px;
	border-radius: 4px;
}

.cm-settings-panel__close:hover,
.cm-settings-panel__close:focus-visible {
	background: rgba(0,0,0,0.08);
	outline: none;
}

.cm-category {
	border-top: 1px solid rgba(0,0,0,0.1);
	padding: 12px 0;
}

.cm-category:first-of-type {
	border-top: none;
}

.cm-category__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
}

.cm-category__title {
	font-weight: 600;
}

.cm-category__services {
	margin: 8px 0 0;
	padding-left: 0;
	list-style: none;
	font-size: 13px;
	opacity: 0.85;
}

.cm-switch {
	position: relative;
	display: inline-block;
	width: 40px;
	height: 22px;
	flex-shrink: 0;
}

.cm-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.cm-switch__slider {
	position: absolute;
	inset: 0;
	background: #ccc;
	border-radius: 22px;
	transition: 0.15s;
}

.cm-switch__slider::before {
	content: "";
	position: absolute;
	height: 16px;
	width: 16px;
	left: 3px;
	top: 3px;
	background: #fff;
	border-radius: 50%;
	transition: 0.15s;
}

.cm-switch input:checked + .cm-switch__slider {
	background: var(--cm-color-primary);
}

.cm-switch input:checked + .cm-switch__slider::before {
	transform: translateX(18px);
}

.cm-switch input:disabled + .cm-switch__slider {
	opacity: 0.5;
	cursor: not-allowed;
}

.cm-settings-panel__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 20px;
}

.cm-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
}

@media (max-width: 480px) {
	.cm-banner {
		left: 8px;
		right: 8px;
		margin: 0;
	}
}
