/**
 * Motorica: zentrierte Aktions-Buttons oben (Tab-Optik, ohne Layout-Überlappung).
 */

:root {
	--motorica-topbar-height: 4.375rem;
	/* Negativer Zug: Tab unter Topbar andocken, ohne in die Navbar zu schneiden */
	--motorica-toolbar-pull-up: 14px;
}

#content > nav.topbar {
	position: sticky !important;
	top: 0;
	z-index: 1025;
}

/* Standard-Abstand oben (ehemals pt-3 in layout.php) – ohne Toolbar */
.tableBackground.pl-3 {
	padding-top: 1rem;
}

.tableBackground:has(.motorica-toolbar-row) {
	padding-top: 0 !important;
}

body.app-matrix-bg .tableBackground:has(.motorica-toolbar-row) {
	margin-top: 1px;
	/* Primary-Rahmen wie Dashboard (layout.php) – nicht durch Toolbar ersetzen */
	border-top-left-radius: 20px;
	border-top: 3px solid var(--motorica-primary);
}

/* Toolbar-Tabs hängen unter dem tableBackground-Rahmen; kein doppelter Top-Border */
body.app-matrix-bg .tableBackground:has(.motorica-toolbar-row) .motorica-toolbar-row .sticky-tab-btn {
	border-top: none;
}

body.app-matrix-bg .tableBackground:has(.motorica-toolbar-row) .motorica-toolbar-row .sticky-tab-btn::before {
	display: none;
}

/* Matrix-Layout: Panel-Rand statt Button-Border – weniger nach oben ziehen */
body.app-matrix-bg .tableBackground:has(.motorica-toolbar-row) .motorica-toolbar-row.sticky-toolbar-row,
body.app-matrix-bg .tableBackground .motorica-admin-partners-page > .motorica-toolbar-row.sticky-toolbar-row {
	margin-top: -10px;
}

/* Volle Breite: Verlauf-Button bündig rechts (gleicht pl-3/pr-3 aus) */
.tableBackground [class*="motorica-"][class*="-page"] > .motorica-toolbar-row.sticky-toolbar-row,
.tableBackground .motorica-admin-partners-page > .motorica-toolbar-row.sticky-toolbar-row {
	margin-left: -1rem;
	margin-right: -1rem;
	width: calc(100% + 2rem);
	max-width: calc(100% + 2rem);
}

.tableBackground .motorica-toolbar-row.sticky-toolbar-row,
.tableBackground .motorica-admin-partners-page > .motorica-toolbar-row.sticky-toolbar-row {
	display: flex;
	justify-content: center;
	margin: calc(-1 * var(--motorica-toolbar-pull-up)) 0 0.75rem;
	padding: 0;
	position: sticky;
	top: var(--motorica-topbar-height);
	z-index: 1015;
	background: transparent;
}

.tableBackground .motorica-toolbar-row .sticky-toolbar-actions {
	display: flex;
	justify-content: center;
	align-items: flex-end;
	flex-wrap: wrap;
	gap: 0.5rem;
	width: 100%;
}

/* Bootstrap-Cols in der Toolbar: kein vertikales Padding (sonst hängt der Tab unter dem Panel-Rand) */
.tableBackground .motorica-toolbar-row > [class*="col-"],
.tableBackground .motorica-toolbar-row > .col {
	padding-top: 0;
	padding-bottom: 0;
}

.tableBackground .motorica-toolbar-row .sticky-toolbar-actions .sticky-tab-btn,
.tableBackground .motorica-toolbar-row .sticky-tab-btn {
	/* Legacy -28px aus motorica-toolbar-buttons.css hier neutralisieren */
	margin-top: 0 !important;
	border-radius: 0 0 14px 14px;
	border: none;
	border-top: 3px solid var(--motorica-primary);
	padding: 10px 20px;
	font-weight: 600;
	box-shadow: 0 4px 12px rgba(13, 35, 75, 0.12);
	position: relative;
}

.tableBackground .motorica-toolbar-row .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-toolbar-row .sticky-tab-btn.motorica-btn-toolbar--primary,
.tableBackground .motorica-toolbar-row .sticky-tab-btn.btn-primary {
	background: var(--motorica-primary);
	color: #fff;
}

.tableBackground .motorica-toolbar-row .sticky-tab-btn.motorica-btn-toolbar--primary:hover,
.tableBackground .motorica-toolbar-row .sticky-tab-btn.btn-primary:hover {
	background: var(--motorica-primary-hover);
	color: #fff;
}

.tableBackground .motorica-page-body,
.tableBackground .content-card-below-toolbar {
	position: relative;
}

/* Kein zusätzlicher Abstand zwischen Tab-Button und Listeninhalt */
.tableBackground:has(.motorica-toolbar-row) .content-card-below-toolbar {
	margin-top: 0;
}

.motorica-invoices-page .bgc-white.bd,
.motorica-customers-page .bgc-white.bd,
.motorica-items-page .bgc-white.bd,
.motorica-offers-page .bgc-white.bd,
.motorica-employees-page .bgc-white.bd {
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 12px;
	padding: 1.25rem;
}

@media (max-width: 767px) {
	.tableBackground [class*="motorica-"][class*="-page"] > .motorica-toolbar-row.sticky-toolbar-row {
		margin-left: 0;
		margin-right: 0;
		width: 100%;
		max-width: 100%;
	}

	.tableBackground .motorica-toolbar-row .sticky-tab-btn {
		min-height: var(--motorica-touch-min, 44px);
		padding: 10px 16px;
	}

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