/* 
 * RESPONSIVE BREAKPOINT CONFIGURATION
 * Mobile/Tablet: < 1350px
 * Desktop: >= 1350px
 */

/* === Layout & Container === */
html, body {
	height: 100%;
	margin: 0;
	overflow: hidden;
	background-color: #f8f9fa;
}

.main-container {
	display: flex;
	flex-direction: column;
	height: 100vh;
}

.content-container {
	flex: 1;
	display: flex;
	overflow: hidden;
	min-height: 0;
}

/* === Navbar === */
.navbar {
	flex-shrink: 0;
	height: 56px;
}

.custom-nav {
	padding-left: 1rem !important;
	padding-right: 1rem !important;
	position: relative;
}

.page-title {
	font-size: var(--bs-navbar-brand-font-size, 1.25rem);
	font-weight: var(--bs-navbar-brand-font-weight, 500);
	line-height: var(--bs-navbar-brand-line-height, 1.2);
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	left: calc(25% + 1rem);
}

/* === Alert === */
.alert-custom-spacing {
	padding-top: 6px;
	padding-bottom: 6px;
	margin-top: 0;
}

.alert.fade {
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.alert.hiding {
	opacity: 0;
	transform: translateY(-4px);
}

/* === Form === */
#filterForm {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}

/* === Sidebar === */
.sidebar {
	width: 25%;
	flex-shrink: 0;
	padding: 1rem;
	padding-top: 0;
	background: #f8f9fa;
	overflow-y: auto;
}

.sidebar .card-body {
	padding: 0.5rem !important;
}

.sidebar .mb-3 {
	margin-bottom: 0.5rem !important;
}

.sidebar .form-label {
	font-size: 0.85rem;
	margin-bottom: 0.25rem;
}

.sidebar .form-control {
	font-size: 0.9rem;
	padding: 0.25rem 0.5rem;
}

.card-header.bg-light {
	background-color: #e9ecef !important;
}

.card-body-standard {
	padding: 0.5rem 0.75rem;
}

/* === Badge === */
.badge-custom-height {
	padding-top: 9px;
	padding-bottom: 5px;
}

#stichworte-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	justify-content: flex-start !important;
	text-align: left;
}

#stichworte-badges .badge {
	margin: 0 !important;
	white-space: normal !important;
	overflow-wrap: break-word;
	word-wrap: break-word;
	max-width: 100%;
}

#stichworte-badges .badge > span:first-child {
	display: block;
	width: 100%;
	text-align: left;
}

#stichworte-badges:has(.badge) {
	margin-top: 0.5rem;
}

/* === Bereich Filter (hierarchisch) === */
#bereichLevel2Wrapper {
	margin-top: 0.5rem;
	padding-left: 1.5rem;
	position: relative;
}

#bereichLevel2Wrapper.has-content::before {
	content: "└─";
	position: absolute;
	left: 0;
	top: 0.35rem;
	color: #6c757d;
	font-size: 0.9rem;
	line-height: 1;
}

#bereichLevel2Wrapper .form-label {
	display: none;
}

#bereichLevel2Wrapper .form-select {
	width: 100%;
}

/* === Gesetzesverweise (hierarchisch) === */
datalist#gesetzesverweiseList option {
	font-family: monospace;
	font-size: 0.9rem;
}

.verweis-indent-0 {
	padding-left: 0;
	font-weight: 600;
}

.verweis-indent-1 {
	padding-left: 1.5rem;
	font-weight: normal;
}

.verweis-indent-2 {
	padding-left: 3rem;
	font-weight: normal;
	font-size: 0.9em;
}

/* === Input Groups === */
.input-group .form-control:focus,
.input-group .btn:focus {
	outline: none !important;
	box-shadow: none !important;
}

.input-group:focus-within {
	box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
	border-radius: 0.375rem;
}

/* === Buttons === */
.btn {
	font-size: 0.9rem;
	padding: 0.3rem 0.5rem;
}

/* === Help Icon Styling === */
.help-icon {
	display: inline-block;
	width: auto;
	height: auto;
	margin-left: 6px;
	color: #6c757d;
	cursor: pointer;
	font-size: 18px;
	line-height: 0;
	transition: color 0.2s ease, transform 0.2s ease;
	position: relative;
	vertical-align: baseline;
	transform: translateY(1px);
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.help-icon:hover {
	color: #0d6efd;
	transform: scale(1.15);
}

.help-icon:active {
	transform: scale(0.95);
}

/* Focus bei Keyboard-Navigation: Icon blau + Ring */
.help-icon:focus {
	outline: none;
}

.help-icon:focus-visible {
	color: #0d6efd;
	
}

/* Touch-Target für Mobile */
.help-icon::before {
	content: '';
	position: absolute;
	top: -13px;
	left: -13px;
	right: -13px;
	bottom: -13px;
	border-radius: 50%;
	pointer-events: none; /* KRITISCH: Verhindert Flackern durch Mouse-Events */
}

/* Popover Custom Styling */
.popover {
	max-width: 320px;
	font-size: 0.9rem;
}

.popover-body {
	padding: 0.75rem 1rem;
	line-height: 1.5;
}

.popover-body ul {
	margin: 0.5rem 0 0 0;
	padding-left: 1.2rem;
}

.popover-body li {
	margin-bottom: 0.3rem;
}

.popover-body code {
	background: #f8f9fa;
	padding: 0.15rem 0.4rem;
	border-radius: 0.25rem;
	font-size: 0.85em;
	color: #d63384;
}

/* === Results Container === */
.results-container {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	min-width: 0;
	min-height: 0;
}

.results-scroll {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	padding-top: 0;
	padding-left: 0;
	min-height: 0;
}

/* === Results Table - Desktop Styling === */
#resultContainer .table {
	table-layout: fixed;
	width: 100%;
	border: 1px solid #D2D2D2; /* ✅ Umlaufender Rahmen */
	border-radius: 0.375rem; /* Abgerundete Ecken */
	border-collapse: separate; /* ✅ KRITISCH: Damit border-radius funktioniert */
	border-spacing: 0; /* Kein Abstand zwischen Zellen */
}

/* ✅ Header-Hintergrund auf Card-Header-Farbe setzen */
#resultContainer .table thead {
	background-color: #E9ECEF;
}

#resultContainer .table thead th {
	background-color: #E9ECEF; /* Explizit für alle TH-Elemente */
	border-bottom: 1px solid #D2D2D2; /* Trennlinie zwischen Header und Body */
	padding-bottom: 0.55rem;
	font-weight: normal;
}

#resultContainer {
	display: block;
	width: 100%;
}

#resultContainer .table th:nth-child(1) {
	width: 80px;
	padding-left: 16px;
	padding-top: 1px;
}

#resultContainer .table th:nth-child(2) {
	width: 200px;
	padding-top: 1px;
}

#resultContainer .table th:nth-child(3) {
	width: 120px;
	padding-top: 1px;
}

#resultContainer .table th:nth-child(4) {
	width: auto;
	padding-top: 1px;
}

#resultContainer .table td {
	word-wrap: break-word;
	overflow-wrap: break-word;
}

#resultContainer .table td:first-child a {
	padding-left: 9px;
}

#resultContainer .table thead tr:first-child th:first-child {
	border-top-left-radius: 0.375rem;
}

#resultContainer .table thead tr:first-child th:last-child {
	border-top-right-radius: 0.375rem;
}

#resultContainer .table tbody tr:last-child td:first-child {
	border-bottom-left-radius: 0.375rem;
}

#resultContainer .table tbody tr:last-child td:last-child {
	border-bottom-right-radius: 0.375rem;
}

#resultContainer .table tbody tr:last-child td {
	border-bottom: none;
}

/* === Sort Indicator === */
.sort-indicator {
	display: inline-block;
	transform: translateY(4px);
}

.sort-indicator i {
	font-size: 1.2rem;
	color: #6C757D;
	vertical-align: text-bottom;
}

/* ============================================
 * RESPONSIVE STYLES - BREAKPOINT: 1349px
 * Mobile optimizations with larger fonts
 * ============================================ */
@media (max-width: 1349px) {
	/* === Intelligente Schriftgrößen-Skalierung === */
	html {
		font-size: clamp(16px, 4vw, 18px);
	}
	
	/* Layout & Container */
	html, body {
		overflow: visible;
		height: auto;
		min-height: 100%;
	}
	
	.main-container {
		height: auto;
		min-height: 100vh;
	}
	
	.content-container {
		flex-direction: column;
		overflow: visible;
		flex: 1 1 auto;
	}
	
	/* Navbar */
	.navbar {
		position: sticky;
		top: 0;
		z-index: 1000;
		height: auto;
		padding: 0.75rem 0;
	}
	
	.navbar-brand {
		font-size: 1.3rem;
	}
	
	.page-title {
		left: 50%;
		transform: translate(-50%, -50%);
		font-size: 1.1rem;
	}
	
	/* Alert - Bessere Lesbarkeit */
	.alert-custom-spacing {
		padding: 0.75rem 1rem;
		font-size: 1rem;
	}
	
	/* Sidebar */
	.sidebar {
		width: 100%;
		max-height: none;
		flex: 0 0 auto;
		overflow-y: visible;
		overflow-x: hidden;
		font-size: 1rem;
		padding: 1rem;
	}
	
	.sidebar .card-body {
		padding: 1rem !important;
	}
	
	.sidebar .mb-3 {
		margin-bottom: 1rem !important;
	}
	
	.sidebar .form-label {
		font-size: 1rem;
		margin-bottom: 0.5rem;
		font-weight: 500;
	}
	
	.sidebar .form-control,
	.sidebar .form-select {
		font-size: 1rem;
		padding: 0.6rem 0.75rem;
		min-height: 44px; /* Touch-Target-Größe */
	}
	
	.sidebar .input-group-text {
		font-size: 1.1rem;
		padding: 0.6rem 0.75rem;
	}
	
	/* Card Header größer */
	.card-header {
		font-size: 1.1rem;
		font-weight: 600;
		padding: 0.75rem 1rem;
	}
	
	/* Buttons - Touch-optimiert */
	.btn {
		font-size: 1rem;
		padding: 0.6rem 1rem;
		min-height: 44px;
	}
	
	#resetFilters,
	#goToDocument {
		font-size: 1rem;
		padding: 0.75rem;
	}
	
	/* Badge */
	.badge-custom-height {
		font-size: 1rem;
		padding: 0.6rem 0.75rem 0.36rem;
	}
	
	.badge .btn-close {
		width: 1.2em;
		height: 1.2em;
		padding: 0.4rem;
	}
	
	/* Help Icon Mobile */
	.help-icon {
		display: inline-block;
		width: auto;
		height: auto;
		margin-left: 8px;
		color: #6c757d;
		cursor: pointer;
		font-size: 22px;
		line-height: 0;
		transition: color 0.2s ease, transform 0.2s ease;
		position: relative;
		vertical-align: baseline;
		transform: translateY(1px);
		user-select: none;
		-webkit-tap-highlight-color: transparent;
	}
	
	/* Popover Mobile */
	.popover {
		max-width: calc(100vw - 2rem);
		font-size: 1rem;
	}
	
	.popover-body {
		padding: 1rem;
	}
	
	/* Bereich Filter */
	#bereichLevel2Wrapper {
		padding-left: 1.5rem;
		margin-top: 0.75rem;
	}
	
	/* Results Container */
	.results-container {
		flex: 0 0 auto;
		min-height: 0;
		overflow: visible;
		display: block;
	}
	
	.results-scroll {
		padding: 1rem;
		padding-left: 1rem;
		overflow-y: visible;
		overflow-x: visible;
		flex: none;
		min-height: 0;
		height: auto;
		padding-bottom: 3rem;
	}
	
	/* === TABELLE → CARD-LAYOUT auf Mobile === */
	#resultContainer .table {
		display: block;
		border: none;
	}
	
	#resultContainer .table thead {
		display: none;
	}
	
	#resultContainer .table tbody {
		display: block;
	}
	
	#resultContainer .table tbody tr {
	    display: block;
	    background: white;
	    border: 1px solid #dee2e6;
	    border-radius: 0.5rem;
	    padding: 1rem;
	    margin-bottom: 1rem;
	    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
	    cursor: pointer;
	    transition: all 0.2s ease-in-out;
	    position: relative;
	    -webkit-tap-highlight-color: transparent;
	    user-select: none;
	}
	
	#resultContainer .table tbody tr:hover {
		box-shadow: 0 6px 16px rgba(0,0,0,0.12);
		transform: translateY(-3px);
		border-color: #0d6efd;
		background: #f8f9fa;
	}
	
	#resultContainer .table tbody tr:active {
		transform: translateY(-1px);
		box-shadow: 0 3px 8px rgba(0,0,0,0.08);
		background: #e9ecef;
	}
	
	#resultContainer .table tbody tr:not(:hover):not(:active) {
		transition: all 0.3s ease-out;
	}
	
	#resultContainer .table td {
		display: block;
		border: none;
		padding: 0.4rem 0;
		text-align: left;
		background: transparent;
	}
	
	#resultContainer .table td:nth-child(1) {
		display: inline;
		font-size: 1rem;
		font-weight: 600;
		color: #212529;
		margin-right: 0;
		padding-right: 0;
	}
	
	#resultContainer .table td:nth-child(1) a {
		padding: 0;
		background: transparent;
		text-decoration: none;
		color: inherit;
		pointer-events: none;
	}
	
	#resultContainer .table td:nth-child(1)::before {
		content: "#";
		margin-right: 0;
	}
	
	#resultContainer .table td:nth-child(1)::after {
		content: "- ";
		margin-left: 0;
	}
	
	#resultContainer .table td:nth-child(2) {
		display: inline;
		font-weight: 600;
		font-size: 1rem;
		margin-bottom: 0;
		padding-left: 0;
	}
	
	#resultContainer .table td:nth-child(2)::after {
		content: "";
		display: block;
		height: 0.5rem;
	}
	
	#resultContainer .table td:nth-child(3) {
		color: #6c757d;
		font-size: 0.95rem;
		margin-bottom: 0.5rem;
		display: block;
	}
	
	#resultContainer .table td:nth-child(3)::before {
		content: "🗓️ ";
		margin-right: 0.25rem;
	}
	
	#resultContainer .table td:nth-child(4) {
		font-size: 0.95rem;
		line-height: 1.5;
		color: #495057;
		border-top: 1px solid #e9ecef;
		padding-top: 0.75rem;
		margin-top: 0.5rem;
		display: block;
	}
	
	#resultContainer .table tbody tr:focus {
		outline: 2px solid #0d6efd;
		outline-offset: 2px;
	}
	
	/* Pagination */
	#resultContainer nav.pagination {
		display: block;
		margin-top: 1.5rem;
	}
	
	.pagination {
		justify-content: center;
	}
	
	.pagination .page-link {
		font-size: 1rem;
		padding: 0.6rem 0.9rem;
		min-width: 44px;
		min-height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
	}
}

/* === Noch kleinere Geräte (< 400px) === */
@media (max-width: 399px) {
	html {
		font-size: 17px;
	}
	
	.sidebar {
		padding: 0.75rem;
	}
	
	.sidebar .card-body {
		padding: 0.75rem !important;
	}
}