/*
 * Layout, sizing and behaviour fixes on top of Bootstrap, Ace and cnm.css.
 * No colour changes: every rule here only changes size, spacing, alignment or shape
 * (separators and focus rings use neutral, see-through lines).
 * Loaded last in common/header.html and on the sign-in pages.
 */

/* ------------------------------------------------------------------ equal-height middle / right panels */
@media (min-width: 768px) {
	body.no-skin .page-content > .row:has(> [class*="col-"] > .panel) {
		display: flex;
		flex-wrap: wrap;
		align-items: stretch;
	}
	body.no-skin .page-content > .row:has(> [class*="col-"] > .panel) > [class*="col-"] {
		display: flex;
		flex-direction: column;
		float: none;
	}
	body.no-skin .page-content > .row:has(> [class*="col-"] > .panel) > [class*="col-"] > .panel:last-child {
		flex: 1 1 auto;
	}
	/* panels sit in wrapper divs on some pages (#details_div, #function_grph_div...): stretch every wrapper */
	body.no-skin .page-content > .row > [class*="col-"] div:has(.panel):not(.panel):not(.panel *) {
		display: flex;
		flex-direction: column;
		flex: 1 1 auto;
	}
	body.no-skin .page-content > .row > [class*="col-"] .panel:not(.panel .panel):not(:has(~ .panel)) {
		flex: 1 1 auto;
		display: flex;
		flex-direction: column;
	}
	body.no-skin .page-content > .row > [class*="col-"] .panel:not(.panel .panel):not(:has(~ .panel)) > .panel-body {
		flex: 1 1 auto;
	}
}

/* middle list panel: the scrolling list fills the (stretched) panel instead of a fixed 600px */
@media (min-width: 768px) {
	body.no-skin #divMiddle > .panel > .panel-body,
	body.no-skin #divMiddle > .panel > .panel-body div:has(.my-custom-scrollbar, .my-custom-scrollbar-500, .table-wrapper-scroll-y, .cnm-scrollbar-end, .body-scrollbar) {
		display: flex;
		flex-direction: column;
		flex: 1 1 auto;
		min-height: 0;
	}
	body.no-skin #divMiddle > .panel > .panel-body div:has(.my-custom-scrollbar, .my-custom-scrollbar-500, .table-wrapper-scroll-y, .cnm-scrollbar-end, .body-scrollbar) > [class*="col-"] {
		width: 100%;
	}
	body.no-skin #divMiddle .my-custom-scrollbar,
	body.no-skin #divMiddle .my-custom-scrollbar-500,
	body.no-skin #divMiddle .table-wrapper-scroll-y,
	body.no-skin #divMiddle .cnm-scrollbar-end,
	body.no-skin #divMiddle .body-scrollbar {
		height: auto !important;
		max-height: none !important;
		flex: 1 1 600px;
		min-height: 300px;
	}
}

/* ------------------------------------------------------------------ left menu width / right panel width
   The left menu is narrower than Ace's 310px: 260px; German keeps 310px (its longest menu item,
   "Produkte & Dienstleistungen", needs it). The content starts next to the menu from the first paint
   (url_control_script.html sets the same margin once the page has loaded, so nothing jumps).
   The middle list keeps its 378px and the right panel takes all the rest. Panels can still be dragged. */
@media (min-width: 992px) {
	html body.no-skin .sidebar:not(.menu-min),
	html body.no-skin .sidebar:not(.menu-min):before {
		width: 260px;
	}
	html:has(#idCurrentLangIcon[data-lang="de"]) body.no-skin .sidebar:not(.menu-min),
	html:has(#idCurrentLangIcon[data-lang="de"]) body.no-skin .sidebar:not(.menu-min):before {
		width: 310px;
	}
	html body.no-skin .page-content > .row > #divMiddle.col-sm-4 {
		width: 378px;
	}
	html body.no-skin .page-content > .row > #divLeft.col-sm-8 {
		width: calc(100% - 378px);
	}
	html body.no-skin .sidebar:not(.menu-min) + .main-content {
		margin-left: 260px;
	}
	html:has(#idCurrentLangIcon[data-lang="de"]) body.no-skin .sidebar:not(.menu-min) + .main-content {
		margin-left: 310px;
	}
	/* the menu's full-height background follows the menu when it is dragged wider or narrower */
	html body.no-skin .sidebar:not(.menu-min):before,
	html:has(#idCurrentLangIcon[data-lang="de"]) body.no-skin .sidebar:not(.menu-min):before {
		width: inherit;
	}
	/* footer: starts where the menu ends (Ace starts it at 190px, its own menu width, so its top line ran into the menu);
	   url_control_script.html moves it with the content when the menu is dragged */
	html body.no-skin .sidebar:not(.menu-min) ~ .footer .footer-inner {
		left: 260px;
	}
	html:has(#idCurrentLangIcon[data-lang="de"]) body.no-skin .sidebar:not(.menu-min) ~ .footer .footer-inner {
		left: 310px;
	}
}

/* ------------------------------------------------------------------ icons */
/* small icon buttons: icon exactly centred (cnm.css padding + inherited line-height pushed it down) */
body.no-skin .btn.btn-sm,
body.no-skin a.btn-sm,
body.no-skin button.btn-sm {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	padding: 0 !important;
	line-height: 1 !important;
	vertical-align: middle;
	position: relative;
}
body.no-skin .btn.btn-sm > .fa,
body.no-skin .btn.btn-sm > .glyphicon,
body.no-skin .btn.btn-sm > .ace-icon,
body.no-skin a.btn-sm > .fa,
body.no-skin a.btn-sm > .glyphicon {
	line-height: 1 !important;
	margin: 0 !important;
	padding: 0 !important;
	top: 0 !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
body.no-skin .btn.btn-sm > .fa[class*="cnm-"]::before {
	display: block;
	line-height: 0;
}
/* icon-only small buttons: pin the icon to the exact centre (templates often add &nbsp; after the icon) */
body.no-skin .btn-sm > i:only-child,
body.no-skin .btn-sm > .fa:only-child,
body.no-skin .btn-sm > .glyphicon:only-child,
body.no-skin .btn-sm > .ace-icon:only-child {
	position: absolute !important;
	left: 50% !important;
	top: 50% !important;
	transform: translate(-50%, -50%);
	margin: 0 !important;
}

/* picture icons (cnm-* classes insert an image with ::before): centre the image in its box everywhere
   (not in tabs: there the icon stays above the label, as in the original) */
body.no-skin i.fa[class*="cnm-"]:not([class*="fa-"]):not(.nav-tabs *),
body.no-skin i.ace-icon[class*="cnm-"]:not([class*="fa-"]):not(.nav-tabs *),
body.no-skin .menu-icon[class*="cnm-"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	line-height: 0 !important;
}
body.no-skin i.fa[class*="cnm-"]:not([class*="fa-"]):not(.nav-tabs *)::before,
body.no-skin i.ace-icon[class*="cnm-"]:not([class*="fa-"]):not(.nav-tabs *)::before,
body.no-skin .menu-icon[class*="cnm-"]::before {
	display: block;
	height: auto;
	line-height: 0;
	font-size: 0;
}
body.no-skin .nav-list > li > a > .menu-icon[class*="cnm-"],
body.no-skin .nav-list > li .submenu > li > a > .fa[class*="cnm-"] {
	display: inline-flex !important;
}

/* mobile menu button: three bars exactly centred */
@media (max-width: 991px) {
	body.no-skin .navbar .navbar-toggle.menu-toggler {
		display: flex !important;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 4px;
		width: 40px;
		height: 36px;
		padding: 0 !important;
		box-sizing: border-box;
	}
	body.no-skin .navbar .navbar-toggle.menu-toggler .icon-bar {
		display: block;
		margin: 0 !important;
		position: static !important;
	}
	body.no-skin .navbar .navbar-toggle.menu-toggler .icon-bar + .icon-bar {
		margin-top: 0 !important;
	}
}

/* ------------------------------------------------------------------ table pagers: one line, inside the table */
html body.no-skin .pagination {
	white-space: nowrap;
	display: inline-flex !important;                   /* one row, even though the buttons are floated */
	flex-wrap: nowrap !important;
	align-items: stretch;
}
html body.no-skin .dataTables_paginate .pagination {
	margin-left: 0 !important;
	margin-right: 0 !important;
}
html body.no-skin .pagination > li {
	display: block;
	float: none;
}
html body.no-skin .pagination > li > a,
html body.no-skin .pagination > li > span {
	float: none !important;
	margin: 0 1px !important;
	padding-left: 10px !important;
	padding-right: 10px !important;
}
/* the pager's row: the pager takes the room it needs (the info text beside it shrinks), so a long pager
   (e.g. Previous 1 2 3 4 5 ... 10 Next) stays inside the table instead of running past its right edge */
html body.no-skin .row:has(> [class*="col-"] > .dataTables_paginate) {
	display: flex;
	align-items: center;
	flex-wrap: nowrap;
}
html body.no-skin .row:has(> [class*="col-"] > .dataTables_paginate) > [class*="col-"] {
	float: none;
	width: auto;
	flex: 1 1 0;
	min-width: 0;
}
html body.no-skin .row:has(> [class*="col-"] > .dataTables_paginate) > [class*="col-"]:has(> .dataTables_paginate) {
	flex: 0 0 auto;
	max-width: 100%;
}

/* ------------------------------------------------------------------ tables inside panels: small, even gap */
/* a tab whose content is itself a framed panel (e.g. Employees vs Roles): small inset instead of full padding */
html body.no-skin .page-content .tab-content:has(> .tab-pane.active .panel) {
	padding: 6px !important;
}
html body.no-skin .page-content .tab-content > .tab-pane .panel:last-child {
	margin-bottom: 0;
}
/* a table directly inside a panel (e.g. History tabs): the column wrapper's padding was added to the panel's */
html body.no-skin .page-content .panel-body > [class*="col-"]:has(> .table-responsive, > .dataTables_wrapper) {
	padding-left: 0;
	padding-right: 0;
}
html body.no-skin .page-content .panel > .panel-body:has(.dataTables_wrapper):not(:has(.panel .dataTables_wrapper)) {
	padding: 6px !important;
}
/* boxes grouped inside a tab (e.g. Requirements > Links): wrapper columns and margins added up */
html body.no-skin .page-content [class*="col-"]:has(> .panel-group),
html body.no-skin .page-content .panel-collapse > .row > [class*="col-"] {
	padding-left: 6px;
	padding-right: 6px;
}
html body.no-skin .page-content .link-margin {
	margin-left: 0;
	margin-right: 0;
}
html body.no-skin .page-content [class*="col-"]:has(> .scrollable-full-width) {
	padding-left: 0;
	padding-right: 0;
}

/* ------------------------------------------------------------------ top bar */
/* top-bar menus (display as, organisation, language): as wide as the longest item (160-360px), the list
   fills its box instead of running past the right edge, small even gap between the border and the rows */
body.no-skin .ace-nav > li > .dropdown-navbar {
	width: max-content !important;
	min-width: 160px !important;
	max-width: min(360px, calc(100vw - 24px)) !important;
}
body.no-skin .ace-nav > li > .dropdown-navbar > .dropdown-content .dropdown-menu {   /* Ace wraps it in .scroll-content */
	min-width: 0 !important;
	width: 100% !important;
}

/* ------------------------------------------------------------------ sign-in pages: the ALTCHA check has the same
   size everywhere (its container no longer shrinks to fit) */
body.login-layout div:has(> altcha-widget),
body.login-layout altcha-widget {
	display: block;
	width: 100%;
	max-width: 100%;
}
body.login-layout .input-group:has(altcha-widget) {
	display: block;
	width: 100%;
}
