/* ==========================================================================
   Einheitenliste [einheiten_tabelle]
   Grundstil der Tabelle (.unitlist th/td) steht in style.css, weil ältere
   Projektseiten noch statische Tabellen mit derselben Klasse verwenden.
   ========================================================================== */

.einheiten-wrapper {
	margin: 0 0 1rem;
}

.einheiten-wrapper .unitlist {
	position: relative;
	overflow-x: auto;
}

.einheiten-wrapper .unitlist table {
	width: 100%;
}

.einheiten-wrapper tr[hidden],
.einheiten-wrapper [hidden] {
	display: none !important;
}

.einheiten-wrapper .unitlist-row {
	opacity: 0;
	transition: opacity 180ms ease;
}

.einheiten-wrapper .unitlist-row.is-sichtbar {
	opacity: 1;
}

/* Ohne JavaScript alle Zeilen zeigen */
.einheiten-wrapper:not(.js) .unitlist-row {
	opacity: 1;
}

/* --- Einheit: Early Bird & Kapitalanlage ---------------------------------- */

.unitlist-aktion-icon {
	height: 1em;
	margin-right: 6px;
	vertical-align: middle;
}

.unitlist-legend .unitlist-aktion-icon {
	width: 20px;
	height: auto;
	margin-right: 0;
}

.unitlist-kapitalanlage {
	display: inline-block;
	margin-left: 6px;
	color: #ef5555;
	font-weight: 700;
}

td.aktion-highlight {
	min-width: 120px;
}

td.aktion-highlight > span:not(.unitlist-kapitalanlage) {
	padding: 6px 10px;
	border-radius: 4px;
	background-color: #e32528;
	color: #fff;
}

/* --- Filter --------------------------------------------------------------- */

.unitlist-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 1em;
}

.unitlist-filter__check {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	margin-left: 0.5rem;
}

.unitlist-reset {
	display: inline-flex;
	align-items: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: #ef5555;
	font-weight: 600;
	cursor: pointer;
}

.unitlist-reset::before {
	content: "✕";
	margin-right: 0.35rem;
}

.unitlist-filter .unitlist-reset {
	margin-left: auto;
}

/* --- Keine Treffer / Mehr laden / Legende --------------------------------- */

.unitlist-empty {
	padding: 1rem 0;
	text-align: center;
}

.unitlist-empty p {
	margin-bottom: 0.5rem;
	padding-bottom: 0;
	font-style: italic;
}

.unitlist-more {
	padding: 0.75rem 0;
	text-align: center;
}

.unitlist-more-btn {
	padding: 8px 12px;
	border: 0;
	border-radius: 6px;
	background: #e32528;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.7em;
	cursor: pointer;
}

.unitlist-legend {
	margin-top: 0.5em;
	color: #666;
	font-size: 14px;
}

.unitlist-legend ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 25px;
	padding: 0;
	list-style: none;
}

/* --- Skeleton beim Filtern ------------------------------------------------ */

.unitlist-skeleton {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 5;
	pointer-events: none;
}

.unitlist.is-skeleton tbody td {
	border-bottom-color: transparent !important;
}

.unitlist .skeleton-row {
	display: grid;
	grid-template-columns: var(--unitlist-skeleton-cols, repeat(6, 1fr));
	gap: 10px;
	align-items: center;
	height: 65px;
	padding: 0 10px;
	border-bottom: 3px solid #f2f2f2;
}

.unitlist .skeleton-cell {
	height: 20px;
	border-radius: 4px;
	background: linear-gradient(90deg, #f2f2f2 0%, #e9e9e9 50%, #f2f2f2 100%);
	background-size: 200% 100%;
	animation: unitlist-shimmer 1.2s infinite;
}

@keyframes unitlist-shimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* --- Smartphone: jede Einheit als Karte ----------------------------------- */

@media (max-width: 767px) {
	.einheiten-wrapper .unitlist {
		overflow: visible;
	}

	.einheiten-wrapper .unitlist table,
	.einheiten-wrapper .unitlist tbody {
		display: block;
		border: 0 !important;
		font-size: 14px;
		line-height: 1.4;
	}

	/* Kopfzeile nur für Screenreader */
	.einheiten-wrapper .unitlist thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	.einheiten-wrapper .unitlist tr {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 12px 0;
		margin-bottom: 12px;
		padding: 16px;
		border: 2px solid #ededed;
		border-radius: 6px;
	}

	.einheiten-wrapper .unitlist tr td {
		display: block;
		padding: 0 12px 0 0 !important;
		border: 0;
		color: #666;
		text-align: left;
		font-weight: 600;
	}

	.einheiten-wrapper .unitlist td.is-leer {
		display: none;
	}

	.einheiten-wrapper .unitlist td::before {
		content: attr(data-label);
		display: block;
		margin-bottom: 2px;
		color: #999;
		font-size: 11px;
		font-weight: 600;
		letter-spacing: 0.03em;
		text-transform: uppercase;
	}

	/* Kopf der Karte: Einheit links, Status rechts */
	.einheiten-wrapper .unitlist td.ul-einheit {
		grid-row: 1;
		grid-column: 1;
		color: #333;
		font-size: 16px;
		font-weight: 700;
	}

	.einheiten-wrapper .unitlist td.ul-status {
		grid-row: 1;
		grid-column: 2;
	}

	.einheiten-wrapper .unitlist td.ul-einheit::before,
	.einheiten-wrapper .unitlist td.ul-status::before,
	.einheiten-wrapper .unitlist td.ul-details::before {
		display: none;
	}

	.einheiten-wrapper .unitlist td.ul-einheit,
	.einheiten-wrapper .unitlist td.ul-status {
		padding-bottom: 12px !important;
		border-bottom: 2px solid #f2f2f2;
	}

	.einheiten-wrapper .unitlist td.ul-status,
	.einheiten-wrapper .unitlist td.ul-details {
		padding-right: 0 !important;
	}

	.einheiten-wrapper .unitlist td.ul-details {
		grid-column: 1 / -1;
	}

	.einheiten-wrapper .table-icon {
		justify-content: flex-end;
		font-size: 12px;
	}

	.einheiten-wrapper .table-icon::before {
		font-size: 14px;
	}

	.einheiten-wrapper .table-button {
		display: block;
		padding: 10px 12px;
		font-size: 14px;
		text-align: center;
	}

	/* Verkaufte/reservierte Einheiten etwas zurücknehmen */
	.einheiten-wrapper .unitlist tr.ist-verkauft,
	.einheiten-wrapper .unitlist tr.ist-reserviert {
		background: #fafafa;
	}

	.einheiten-wrapper .unitlist .skeleton-row {
		grid-template-columns: 1fr 1fr;
		height: 110px;
	}

	.unitlist-filter select,
	.unitlist-filter__check {
		flex: 1 1 100%;
		margin-left: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.einheiten-wrapper .unitlist-row,
	.unitlist .skeleton-cell {
		transition: none;
		animation: none;
	}
}
