/*
 * AppleInCookie – Frontend Styles
 *
 * Alle Styles sind unter `.applein-cookie-*` gescoped, um Konflikte mit
 * Theme-Styles zu vermeiden. Wir nutzen CSS Custom Properties, damit
 * Themes Farben einfach überschreiben können – ohne `!important`-Schlachten.
 */

.applein-cookie-root {
	--ac-color-bg: #ffffff;
	--ac-color-text: #1a1a1a;
	--ac-color-text-light: #555;
	--ac-color-border: #d8e0e8;
	--ac-color-primary: #1a5276;
	--ac-color-primary-hover: #154360;
	--ac-color-ghost-bg: #f4f8fb;
	--ac-color-ghost-hover: #e6eef5;
	--ac-radius: 6px;
	--ac-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
	--ac-z: 999990;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--ac-color-text);
}

.applein-cookie-root[hidden] {
	display: none !important;
}

/* ---------- Banner ---------- */

.applein-cookie-banner {
	position: fixed;
	right: 24px;
	left: auto;
	bottom: 24px;
	width: calc(100% - 48px);
	max-width: 540px;
	background: var(--ac-color-bg);
	border: 1px solid var(--ac-color-border);
	border-radius: var(--ac-radius);
	box-shadow: var(--ac-shadow);
	z-index: var(--ac-z);
	animation: applein-cookie-slide-up 0.25s ease-out;
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 80px);
}

.applein-cookie-banner.is-expanded {
	max-width: 600px;
}

.applein-cookie-banner[hidden] {
	display: none;
}

.applein-cookie-banner__head {
	padding: 20px 24px 10px;
	flex: 0 0 auto;
}

.applein-cookie-banner__title {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 600;
}

.applein-cookie-banner__message {
	margin: 0;
	color: var(--ac-color-text-light);
	font-size: 13px;
	line-height: 1.5;
}

/* ----- Expand-Bereich (slide down animation) ----- */

.applein-cookie-banner__expand {
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	transition: max-height 0.32s ease, opacity 0.22s ease 0.04s, padding 0.32s ease;
	padding: 0 24px;
	flex: 1 1 auto;
	min-height: 0;
}

.applein-cookie-banner.is-expanded .applein-cookie-banner__expand {
	max-height: 60vh;
	overflow-y: auto;
	opacity: 1;
	padding: 16px 24px 4px;
}

.applein-cookie-banner__foot {
	padding: 14px 24px 18px;
	border-top: 1px solid transparent;
	flex: 0 0 auto;
	transition: border-color 0.2s ease;
}

.applein-cookie-banner.is-expanded .applein-cookie-banner__foot {
	border-top-color: var(--ac-color-border);
}

.applein-cookie-banner__legal {
	margin: 12px 0 0;
	font-size: 12px;
	color: var(--ac-color-text-light);
	text-align: center;
}

.applein-cookie-banner__legal a {
	color: var(--ac-color-primary);
	text-decoration: underline;
	margin: 0 4px;
}

.applein-cookie-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.applein-cookie-banner__actions .applein-cookie-button {
	flex: 1 1 auto;
	min-width: 0;
	white-space: nowrap;
}

/* Compact/expanded Toggle: nur jeweils der passende Button sichtbar. */
.applein-cookie-banner[data-state="compact"] [data-applein-cookie-only-when="expanded"],
.applein-cookie-banner[data-state="expanded"] [data-applein-cookie-only-when="compact"] {
	display: none;
}

@keyframes applein-cookie-slide-up {
	from { transform: translateY(20px); opacity: 0; }
	to   { transform: translateY(0); opacity: 1; }
}

/* ---------- Buttons ---------- */

.applein-cookie-button {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 9px 16px;
	font: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	border-radius: 4px;
	border: 1px solid transparent;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	min-height: 36px;
}

.applein-cookie-button:focus-visible {
	outline: 2px solid var(--ac-color-primary);
	outline-offset: 2px;
}

.applein-cookie-button--primary {
	background: var(--ac-color-primary);
	color: #fff;
}

.applein-cookie-button--primary:hover {
	background: var(--ac-color-primary-hover);
}

.applein-cookie-button--ghost {
	background: var(--ac-color-ghost-bg);
	color: var(--ac-color-text);
	border-color: var(--ac-color-border);
}

.applein-cookie-button--ghost:hover {
	background: var(--ac-color-ghost-hover);
}

/* ---------- Categories ---------- */

.applein-cookie-categories {
	list-style: none;
	margin: 0 0 18px;
	padding: 0;
	border: 1px solid var(--ac-color-border);
	border-radius: var(--ac-radius);
	overflow: hidden;
}

.applein-cookie-category {
	padding: 14px 16px;
	background: var(--ac-color-bg);
	border-bottom: 1px solid var(--ac-color-border);
}

.applein-cookie-category:last-child {
	border-bottom: 0;
}

.applein-cookie-category__header {
	display: flex;
	align-items: center;
	gap: 12px;
}

.applein-cookie-category__name {
	flex: 1;
	font-weight: 600;
	font-size: 15px;
}

.applein-cookie-category__badge {
	font-size: 12px;
	font-weight: 500;
	color: #2e7d32;
}

.applein-cookie-category__description {
	margin: 8px 0 0;
	font-size: 13px;
	line-height: 1.5;
	color: var(--ac-color-text-light);
}

/* iOS-style Toggle */

.applein-cookie-toggle {
	position: relative;
	display: inline-block;
	width: 40px;
	height: 22px;
	flex-shrink: 0;
	cursor: pointer;
}

.applein-cookie-toggle input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.applein-cookie-toggle__slider {
	position: absolute;
	inset: 0;
	background: #cdd6df;
	border-radius: 999px;
	transition: background 0.18s ease;
}

.applein-cookie-toggle__slider::before {
	content: "";
	position: absolute;
	left: 2px;
	top: 2px;
	width: 18px;
	height: 18px;
	background: #ffffff;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	transition: transform 0.18s ease;
}

.applein-cookie-toggle input[type="checkbox"]:checked + .applein-cookie-toggle__slider {
	background: var(--ac-color-primary);
}

.applein-cookie-toggle input[type="checkbox"]:checked + .applein-cookie-toggle__slider::before {
	transform: translateX(18px);
}

.applein-cookie-toggle input[type="checkbox"]:focus-visible + .applein-cookie-toggle__slider {
	outline: 2px solid var(--ac-color-primary);
	outline-offset: 2px;
}

/* Accessible-text helper (gescoped, kein Konflikt mit Theme-Klassen). */
.applein-cookie-screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Dienste verwalten (Akkordeon) ---------- */

.applein-cookie-services {
	margin: 0 0 4px;
	border-top: 1px solid var(--ac-color-border);
	padding-top: 12px;
}

.applein-cookie-services__summary {
	cursor: pointer;
	font-size: 14px;
	color: var(--ac-color-primary);
	text-decoration: underline;
	list-style: none;
	display: inline-block;
}

.applein-cookie-services__summary::-webkit-details-marker {
	display: none;
}

.applein-cookie-services__summary::before {
	content: "▸ ";
	display: inline-block;
	transition: transform 0.18s ease;
}

.applein-cookie-services[open] .applein-cookie-services__summary::before {
	transform: rotate(90deg);
}

.applein-cookie-services__body {
	margin-top: 12px;
	font-size: 13px;
}

.applein-cookie-services__body .applein-cookie-table {
	margin: 0;
	font-size: 12px;
}


/* ---------- Hover-Tab (schmaler Streifen unten rechts) ---------- */

.applein-cookie-tab {
	position: fixed;
	bottom: 0;
	right: 24px;
	height: 28px;
	padding: 0 14px;
	border: 0;
	border-radius: 6px 6px 0 0;
	background: var(--ac-color-primary);
	color: #ffffff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font: inherit;
	font-size: 13px;
	font-weight: 500;
	box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.18);
	z-index: calc(var(--ac-z) - 1);
	transition: height 0.22s ease, padding 0.22s ease, background 0.15s ease;
	overflow: hidden;
}

.applein-cookie-tab__icon {
	flex: 0 0 auto;
}

.applein-cookie-tab__label {
	max-width: 0;
	overflow: hidden;
	white-space: nowrap;
	opacity: 0;
	transition: max-width 0.22s ease, opacity 0.18s ease 0.04s;
}

.applein-cookie-tab:hover,
.applein-cookie-tab:focus-visible {
	height: 36px;
	padding: 0 18px;
	background: var(--ac-color-primary-hover);
}

.applein-cookie-tab:hover .applein-cookie-tab__label,
.applein-cookie-tab:focus-visible .applein-cookie-tab__label {
	max-width: 220px;
	opacity: 1;
}

.applein-cookie-tab:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: -2px;
}

/* ---------- Service Placeholder (Click-to-Consent) ---------- */

.applein-cookie-placeholder {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 320px;
	padding: 32px 24px;
	background-color: #eae5d4; /* Karten-Farbe als Fallback */
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	border-radius: var(--ac-radius, 6px);
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	color: #1a1a1a;
}

.applein-cookie-placeholder__overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.85) 100%);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
}

.applein-cookie-placeholder__inner {
	position: relative;
	max-width: 460px;
	text-align: center;
	background: #ffffff;
	border-radius: 8px;
	padding: 22px 26px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.applein-cookie-placeholder__title {
	margin: 0 0 10px;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
}

.applein-cookie-placeholder__text {
	margin: 0 0 18px;
	font-size: 14px;
	color: #555;
	line-height: 1.55;
}

.applein-cookie-placeholder__button {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 11px 22px;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	background: #1a5276;
	color: #fff;
	border: 0;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.15s ease;
}

.applein-cookie-placeholder__button:hover,
.applein-cookie-placeholder__button:focus-visible {
	background: #154360;
	outline: none;
}

.applein-cookie-placeholder__legal {
	margin: 14px 0 0;
	font-size: 12px;
}

.applein-cookie-placeholder__legal a {
	color: #555;
	text-decoration: underline;
}

/* ---------- Cookie-Tabelle (Shortcode) ---------- */

/* Wrapper sorgt dafür, dass die Tabelle auf Mobil horizontal gescrollt
 * werden kann, ohne dass der Body-Container über den Viewport hinausragt.
 * Sonst würde der fixed-positioned Hover-Tab unsichtbar werden und das
 * Mobile-Banner-Layout (max-width: 540px Media-Query) nicht greifen.
 */
.applein-cookie-table-wrap {
	width: 100%;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: 16px 0;
}

.applein-cookie-table {
	width: 100%;
	min-width: 540px;
	border-collapse: collapse;
	margin: 0;
	font-size: 14px;
}

.applein-cookie-table th,
.applein-cookie-table td {
	padding: 10px 12px;
	border: 1px solid var(--ac-color-border, #d8e0e8);
	text-align: left;
	vertical-align: top;
}

.applein-cookie-table th {
	background: var(--ac-color-ghost-bg, #f4f8fb);
	font-weight: 600;
}

/* ---------- Mobile ---------- */

/* Drucken: Banner und Floating-Tab nicht auf Papier ausgeben. */
@media print {
	.applein-cookie-root,
	.applein-cookie-tab {
		display: none !important;
	}
}

@media (max-width: 540px) {
	.applein-cookie-banner {
		left: 12px;
		right: 12px;
		bottom: 12px;
		max-width: none;
	}

	.applein-cookie-banner.is-expanded {
		max-width: none;
	}

	.applein-cookie-banner__head,
	.applein-cookie-banner__foot {
		padding-left: 18px;
		padding-right: 18px;
	}

	.applein-cookie-banner__expand {
		padding-left: 18px;
		padding-right: 18px;
	}

	.applein-cookie-banner.is-expanded .applein-cookie-banner__expand {
		padding-left: 18px;
		padding-right: 18px;
	}

	.applein-cookie-banner__actions {
		flex-direction: column;
	}

	.applein-cookie-banner__actions .applein-cookie-button {
		width: 100%;
	}
}
