/**
 * Motorica global history (audit log) – bottom sheet + triggers
 */

/* Toolbar: Mitte = Aktion, rechts = Verlauf (Grid, gleiche Unterkante) */
.tableBackground .motorica-toolbar-row .sticky-toolbar-actions.sticky-toolbar-actions--split {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: end;
	width: 100%;
	min-height: 38px;
	padding: 0 0 10px;
}

.tableBackground .sticky-toolbar-actions--split .sticky-toolbar-actions-start {
	grid-column: 2;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.tableBackground .motorica-toolbar-row .sticky-toolbar-actions--split .sticky-tab-btn {
	margin-top: 0 !important;
}

.motorica-history-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

/* Modul-Verlauf: Light-Tab (Theming Light #fff), rechts, unter Topbar ohne Überlappung */
.tableBackground .motorica-history-trigger--sticky.sticky-tab-btn {
	grid-column: 3;
	justify-self: end;
	align-self: end;
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	margin-top: 0 !important;
	margin-left: 0;
	padding: 0;
	border: none;
	border-top: 3px solid #0d234b;
	border-radius: 0 0 0 14px;
	background: #fff;
	color: #0d234b;
	box-shadow: 0 4px 12px rgba(13, 35, 75, 0.12);
}

.tableBackground .motorica-history-trigger--sticky.sticky-tab-btn::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: -3px;
	height: 3px;
	background: linear-gradient(90deg, #0d234b 0%, #1a3a6e 100%);
	pointer-events: none;
}

.tableBackground .motorica-history-trigger--sticky.sticky-tab-btn:hover,
.tableBackground .motorica-history-trigger--sticky.sticky-tab-btn:focus {
	background: #f8f9fc;
	color: #0d234b;
	outline: none;
}

html[dir="rtl"] .tableBackground .motorica-history-trigger--sticky.sticky-tab-btn {
	grid-column: 1;
	justify-self: start;
	border-radius: 0 0 14px 0;
}

@media (max-width: 575px) {
	/* Gleiches 3-Spalten-Raster wie Desktop (1fr auto 1fr): Aktion bleibt mittig, Verlauf rechts */
	.tableBackground .motorica-toolbar-row .sticky-toolbar-actions--split {
		min-height: var(--motorica-touch-min, 44px);
	}

	.tableBackground .motorica-history-trigger--sticky.sticky-tab-btn {
		width: var(--motorica-touch-min, 44px);
		height: var(--motorica-touch-min, 44px);
	}
}

.motorica-history-trigger--floating {
	position: fixed;
	top: 72px;
	right: 1.25rem;
	z-index: 1020;
	margin-top: 0;
	border: none;
	border-radius: 50%;
	width: 44px;
	height: 44px;
	padding: 0;
	background: #0d234b;
	color: #fff;
	box-shadow: 0 4px 14px rgba(13, 35, 75, 0.25);
}

.motorica-history-trigger--floating:hover,
.motorica-history-trigger--floating:focus {
	background: #091a38;
	color: #fff;
	outline: none;
}

.motorica-history-trigger--sheet {
	width: 36px;
	height: 36px;
	margin-top: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.15);
	box-shadow: none;
	flex-shrink: 0;
}

.motorica-history-trigger--sheet:hover {
	background: rgba(255, 255, 255, 0.28);
}

.bottom-sheet-header .bottom-sheet-header-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-left: auto;
}

#motoricaHistorySheet.bottom-sheet {
	position: fixed;
	inset: 0;
	z-index: 1060;
	visibility: hidden;
	pointer-events: none;
}

#motoricaHistorySheet.bottom-sheet.bottom-sheet--open {
	visibility: visible;
	pointer-events: auto;
}

#motoricaHistorySheet .bottom-sheet-backdrop {
	position: absolute;
	inset: 0;
	z-index: 0;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

#motoricaHistorySheet.bottom-sheet--open .bottom-sheet-backdrop {
	opacity: 1;
	pointer-events: auto;
}

#motoricaHistorySheet .bottom-sheet-card {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
	height: 92vh;
	max-height: 92vh;
	background: #fff;
	border-radius: 20px 20px 0 0;
	box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
	transform: translateY(100%);
	transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

#motoricaHistorySheet.bottom-sheet--open .bottom-sheet-card {
	transform: translateY(0);
}

#motoricaHistorySheet .bottom-sheet-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

#motoricaHistorySheet .bottom-sheet-body {
	max-height: calc(92vh - 4.5rem);
	overflow-y: auto;
	padding: 1rem 1.25rem 1.5rem;
}

.motorica-history-loading,
.motorica-history-empty {
	text-align: center;
	padding: 2rem 1rem;
	color: #6c757d;
}

.motorica-history-group {
	border-left: 3px solid #0d234b;
	padding-left: 1rem;
	margin-bottom: 1.25rem;
}

.motorica-history-group-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem 0.75rem;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
}

.motorica-history-group-meta time {
	color: #6c757d;
}

.motorica-history-group-meta .motorica-history-user {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-weight: 600;
	color: #0d234b;
}

.motorica-history-user-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.motorica-history-user-avatar--initials {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #6c757d;
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
	line-height: 1;
}

.motorica-history-user-name {
	line-height: 1.2;
}

.motorica-history-entity {
	font-weight: 500;
}

.motorica-history-badge {
	display: inline-block;
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 0.15rem 0.5rem;
	border-radius: 4px;
}

.motorica-history-badge--created {
	background: #ff6600;
	color: #fff;
}

.motorica-history-badge--updated {
	background: #8eddf9;
	color: #0d234b;
}

.motorica-history-badge--deleted {
	background: #c62828;
	color: #fff;
}

.motorica-history-changes {
	list-style: none;
	margin: 0;
	padding: 0;
}

.motorica-history-change {
	padding: 0.5rem 0;
	border-bottom: 1px solid #e2e8f0;
	font-size: 0.875rem;
}

.motorica-history-change:last-child {
	border-bottom: none;
}

.motorica-history-field {
	font-weight: 600;
	color: #4a1f00;
}

.motorica-history-values {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.35rem;
	margin-top: 0.2rem;
}

.motorica-history-value-before {
	color: #6c757d;
	text-decoration: line-through;
	word-break: break-word;
}

.motorica-history-value-arrow {
	color: #adb5bd;
}

.motorica-history-value-after {
	color: #198754;
	font-weight: 500;
	word-break: break-word;
}

.motorica-history-value-empty {
	color: #adb5bd;
	font-style: italic;
}
