/*
 * UI-Feinschliff: dezente Modernisierung von Typografie, Farben, Formularen, Tabs und Tabellen.
 * Wird als letztes Stylesheet geladen (siehe controller.class.php). Zum Zuruecknehmen genuegt es,
 * die Zeilen mit setHeadLoadFile("ui.css") und setHeadLoadFile("ui.js") dort zu entfernen.
 */

:root {
	--brand: #2B6E96;          /* Kontrast auf Weiss 5,6:1 (vorher #5295BB mit 3,4:1) */
	--brand-dark: #1D5578;
	--brand-soft: #EAF3F9;
	--text: #1F2D36;
	--muted: #5B6B75;
	--line: #D8E1E7;
	--line-soft: #EEF2F5;
	--radius: 6px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Grundlayout und Typografie */
body, html {
	font-family: var(--font);
	font-size: 13px;
	color: var(--text);
	-webkit-font-smoothing: antialiased;
}

td, th, input, select, textarea, button {
	font-family: var(--font);
}

#page {
	box-shadow: 0 1px 8px rgba(20, 40, 60, 0.12);
}

#main {
	padding: 16px 18px 20px 18px;
}

h1, h2 {
	color: var(--brand);
	font-weight: 600;
}

h1 {
	font-size: 17px;
	margin-bottom: 4px;
}

h2 {
	font-size: 13px;
}

a {
	color: var(--brand);
	font-size: inherit;
	transition: color 0.15s;
}

a:hover {
	color: var(--brand-dark);
}

#footer {
	color: var(--muted);
	font-size: 11px;
}

/* Tastaturfokus sichtbar machen (der globale outline:none nimmt ihn sonst komplett weg) */
a:focus-visible,
.button:focus-visible,
.btn-sm:focus-visible,
.button2:focus-visible,
input[type=submit]:focus-visible,
input[type=checkbox]:focus-visible,
input[type=radio]:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* Hauptnavigation: flach, mit Aktiv-Markierung, bleibt beim Scrollen sichtbar */
#topMenu {
	background-color: var(--brand);
	height: 38px;
	margin-top: 6px;
	position: sticky;
	top: 0;
	z-index: 200;
	box-shadow: 0 1px 3px rgba(20, 40, 60, 0.18);
}

#topMenu > div {
	height: 38px !important;
}

#topMenu li a {
	padding: 0 11px;
	height: 38px;
	line-height: 38px;
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	box-sizing: border-box;
	border-bottom: 3px solid transparent;
	transition: background-color 0.15s, border-color 0.15s;
}

#topMenu li a:hover {
	background-color: rgba(255, 255, 255, 0.14);
	color: #fff;
}

#topMenu li a.active {
	background-color: rgba(255, 255, 255, 0.16);
	border-bottom-color: #fff;
}

#topMenu li ul {
	background-color: var(--brand-dark);
	border-radius: 0 0 8px 8px;
	box-shadow: 0 8px 20px rgba(20, 40, 60, 0.22);
	overflow: hidden;
	min-width: 190px;
	width: auto;
}

#topMenu li ul li a {
	height: auto;
	line-height: 1.4;
	padding: 9px 16px;
	text-align: left;
	border-bottom: 0;
	white-space: nowrap;
}

#topMenu li ul li {
	text-align: left;
}

/* Formularfelder */
input[type=text],
input[type=password],
input[type=search],
input[type=number],
textarea,
select {
	font-size: 13px;
	color: var(--text);
	border: 1px solid #B5C2CB;
	border-radius: var(--radius);
	transition: border-color 0.15s, box-shadow 0.15s;
}

input[type=text]:hover,
input[type=password]:hover,
input[type=search]:hover,
input[type=number]:hover,
textarea:hover,
select:hover {
	border-color: #8EA3B0;
}

input[type=text]:focus,
input[type=password]:focus,
input[type=search]:focus,
input[type=number]:focus,
textarea:focus,
select:focus {
	border-color: var(--brand);
	box-shadow: 0 0 0 3px rgba(43, 110, 150, 0.2);
}

::placeholder {
	color: #8896A0;
}

input[type=checkbox],
input[type=radio] {
	accent-color: var(--brand);
	cursor: pointer;
}

label[for] {
	cursor: pointer;
}

/* Dropdowns: eigener Pfeil mit Abstand zum rechten Rand */
select:not([multiple]):not([size]) {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	padding: 6px 32px 6px 10px;
	background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%232B6E96' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 12px center;
	cursor: pointer;
}

select:not([multiple]):not([size]):disabled {
	background-color: #F0F3F5;
	cursor: default;
}

select[multiple],
select[size] {
	padding: 4px;
}

/* Moderne Browser (Chrome/Edge): auch die aufklappende Liste stylen statt der System-Liste */
@supports (appearance: base-select) {
	select:not([multiple]):not([size]),
	select:not([multiple]):not([size])::picker(select) {
		appearance: base-select;
	}

	select:not([multiple]):not([size]) {
		background: #fff;
		padding: 6px 10px 6px 10px;
		align-items: center;
		justify-content: space-between;
	}

	select:not([multiple]):not([size])::picker-icon {
		content: "";
		width: 10px;
		height: 6px;
		margin-left: auto;
		flex: none;
		background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%232B6E96' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
		transition: rotate 0.2s;
	}

	select:not([multiple]):not([size]):open::picker-icon {
		rotate: 180deg;
	}

	select:not([multiple]):not([size])::picker(select) {
		border: 1px solid var(--line);
		border-radius: 8px;
		padding: 4px;
		margin-top: 4px;
		background: #fff;
		box-shadow: 0 10px 28px rgba(20, 40, 60, 0.18);
		max-height: 320px;
	}

	select:not([multiple]):not([size]) option {
		padding: 6px 10px;
		border-radius: 5px;
		cursor: pointer;
		font-size: 13px;
	}

	select:not([multiple]):not([size]) option:hover,
	select:not([multiple]):not([size]) option:focus {
		background: var(--brand-soft);
	}

	select:not([multiple]):not([size]) option:checked {
		background: #DCEBF5;
		font-weight: 600;
	}

	select:not([multiple]):not([size]) option::checkmark {
		display: none;
	}
}

/* Schaltflaechen: flach mit feiner Kontur, Speichern als Hauptaktion hervorgehoben */
.button,
.btn-sm,
.button2 {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background-color: #fff;
	border: 1px solid #C5D2DA;
	border-radius: var(--radius);
	color: var(--text);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	box-shadow: 0 1px 2px rgba(20, 40, 60, 0.06);
	transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.btn-sm {
	padding: 5px 10px;
}

.button img,
.button2 img,
.btn-sm img {
	margin: 0;
}

.button:hover,
.btn-sm:hover,
.button2:hover {
	background-color: #F3F8FB;
	border-color: #94B0C2;
	box-shadow: 0 2px 6px rgba(20, 40, 60, 0.1);
}

.button:active,
.btn-sm:active,
.button2:active {
	transform: translateY(1px);
	box-shadow: none;
}

a.button,
a.button2 {
	color: var(--text);
}

#save,
input[type=submit].button2 {
	background-color: var(--brand);
	border-color: var(--brand);
	color: #fff;
}

#save:hover,
input[type=submit].button2:hover {
	background-color: var(--brand-dark);
	border-color: var(--brand-dark);
	color: #fff;
}

/* Tabs (jQuery UI): flach statt Glanz-Verlauf, mit Akzentlinie am aktiven Reiter */
.ui-tabs.ui-widget-content {
	border: 0;
	background: none;
	padding: 0;
}

.ui-tabs .ui-tabs-nav.ui-widget-header {
	background: none;
	border: 0;
	border-bottom: 1px solid var(--line);
	border-radius: 0;
	padding: 0;
}

.ui-tabs .ui-tabs-nav li.ui-state-default {
	background: none;
	border: 1px solid transparent;
	border-bottom: 0;
	border-radius: 8px 8px 0 0;
	margin: 0 3px -1px 0;
	transition: background-color 0.15s;
}

.ui-tabs .ui-tabs-nav li.ui-state-default a {
	padding: 10px 15px;
	color: var(--muted);
	font-weight: 500;
	transition: color 0.15s;
}

.ui-tabs .ui-tabs-nav li.ui-state-hover,
.ui-tabs .ui-tabs-nav li.ui-state-focus {
	background: #F1F6F9;
	border-color: transparent;
}

.ui-tabs .ui-tabs-nav li.ui-state-hover a {
	color: var(--brand);
}

.ui-tabs .ui-tabs-nav li.ui-tabs-active {
	background: #fff;
	border-color: var(--line);
	border-bottom: 1px solid #fff;
	box-shadow: inset 0 3px 0 var(--brand);
}

.ui-tabs .ui-tabs-nav li.ui-tabs-active a {
	color: var(--brand-dark);
}

.ui-tabs .ui-tabs-panel {
	padding: 16px 2px 4px 2px;
}

/* Reiter: kein Fokusrahmen um den Link (der Reiter selbst zeigt Hover/Aktiv-Zustand) */
.ui-tabs .ui-tabs-nav li a,
.ui-tabs .ui-tabs-nav li a:focus,
.ui-tabs .ui-tabs-nav li a:focus-visible {
	outline: none;
	box-shadow: none;
}

/* Ladeanzeige beim Nachladen eines Reiters: im Inhaltsbereich, erst nach 300 ms,
   damit schnelle Ladevorgaenge nichts einblenden und nichts springt */
.ui-tabs .ui-tabs-panel[aria-busy=true] {
	position: relative;
	animation: ui-reserve 0s linear 0.3s forwards;
}

.ui-tabs .ui-tabs-panel[aria-busy=true]::after {
	content: "";
	position: absolute;
	top: 30px;
	left: calc(50% - 14px);
	width: 28px;
	height: 28px;
	box-sizing: border-box;
	border: 3px solid #D3E3EE;
	border-top-color: var(--brand);
	border-radius: 50%;
	opacity: 0;
	animation: ui-spin 0.75s linear infinite, ui-fadein 0.2s ease 0.3s forwards;
}

@keyframes ui-reserve {
	to {
		min-height: 110px;
	}
}

@keyframes ui-fadein {
	to {
		opacity: 1;
	}
}

@keyframes ui-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Globale Ladeleiste am oberen Rand (siehe ui.js) */
#uiProgress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 9999;
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s;
}

#uiProgress.active {
	opacity: 1;
}

#uiProgress::before {
	content: "";
	display: block;
	width: 40%;
	height: 100%;
	background: linear-gradient(90deg, transparent, var(--brand), transparent);
	animation: ui-slide 1.1s ease-in-out infinite;
}

@keyframes ui-slide {
	from {
		transform: translateX(-100%);
	}
	to {
		transform: translateX(250%);
	}
}

body.ui-busy,
body.ui-busy * {
	cursor: progress;
}

/* Tabellen: ruhiger, abgerundet, ohne Behoerden-Optik */
.defaulttable {
	border: 1px solid var(--line);
	border-radius: 8px;
	border-collapse: separate;
	border-spacing: 0;
}

.defaulttable > tbody > tr > td,
.defaulttable > tr > td {
	padding: 7px 10px;
}

.defaulttable > tbody > tr:first-child > td:first-child {
	border-top-left-radius: 7px;
}

.defaulttable > tbody > tr:first-child > td:last-child {
	border-top-right-radius: 7px;
}

.defaulttable > tbody > tr:last-child > td:first-child {
	border-bottom-left-radius: 7px;
}

.defaulttable > tbody > tr:last-child > td:last-child {
	border-bottom-right-radius: 7px;
}

.defaulttable .headline,
.defaulttable .headline td {
	background-color: #F3F6F8;
	color: var(--muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.4px;
	text-transform: uppercase;
}

.defaulttable .subheadline,
.defaulttable .subheadline td {
	background-color: #F8FAFB;
	color: var(--brand);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0.3px;
}

.defaulttable > tbody > tr:not(.headline):not(.subheadline) > td {
	border-bottom: 1px solid var(--line-soft);
}

.defaulttable > tbody > tr:last-child > td {
	border-bottom: 0;
}

.defaulttable > tbody > tr:not(.headline):not(.subheadline):hover > td {
	background-color: #F4F9FC;
}

/* Beschriftung auf die Hoehe des Eingabefeldes ruecken */
.defaulttable > tbody > tr:has(> td > select, > td > input[type=text], > td > input[type=number]) > td:first-child {
	padding-top: 13px;
}

/* Gleiches fuer einfache Formulartabellen ohne defaulttable (z.B. Revierauswahl) */
table:not(.defaulttable) > tbody > tr:has(> td > select) > td:first-child {
	padding-top: 9px;
}

/* Alte Inline-Farbe aus den Templates (#5295BB, zu kontrastarm) zentral auf die neue Markenfarbe heben */
[style*=" color:#5295BB" i],
[style^="color:#5295BB" i] {
	color: var(--brand) !important;
}

td[style*="background-color:#F2F2F2"][style*="5295BB"] {
	background-color: #F8FAFB !important;
	font-weight: 600;
	letter-spacing: 0.3px;
	line-height: 1.3 !important;
}

/* Tabellen mit mehreren Dropdowns: Felder fuellen ihre Spalte, damit sie buendig untereinander stehen */
tr:has(> td:nth-child(3) > select) > td > select {
	width: 100%;
	min-width: max-content;
	box-sizing: border-box;
	text-align: left;
	white-space: nowrap;
}

/* Folgezeile desselben Baus (Fuchs-/Dachsbau): Nummer blass, Zeile leicht eingerueckt markiert */
tr.sameBau > td:first-child input.baunr {
	color: #9AA9B4;
	background: #F4F7F9;
}

tr.sameBau > td:first-child {
	position: relative;
}

tr.sameBau > td:first-child::before {
	content: "\21B3";
	position: absolute;
	left: 2px;
	top: 50%;
	transform: translateY(-50%);
	color: #9AA9B4;
	font-size: 14px;
}

/* Erfassungstabellen mit vielen Spalten: engere Zellen, damit sie in die Seitenbreite passen */
.defaulttable > tbody > tr.dataRow > td,
.defaulttable > tbody > tr.newRow > td {
	padding-left: 6px;
	padding-right: 6px;
}

.defaulttable > tbody > tr.dataRow textarea,
.defaulttable > tbody > tr.newRow textarea {
	width: 130px !important;
}
