/*
 * The site's standard controls (plan Dokument\05 Development\ui-controls, Magnus 2026-10-28).
 * Loaded by mwlPageLayout after css_main and css_button, before the page's own CSS.
 *
 * Checkbox "B" (and the radio button further down): a 16px square with a 1px corner and a grey border. When checked the border turns green,
 * the box gets a faint green fill and a green tick shows inside. Same size in all places.
 *
 * The selector is kept at the weight of "input[type=checkbox]" (the :where part counts as nothing), so a page's
 * own rule such as ".x input" still wins. Pages that hide the checkbox (chips, toggles) keep doing so with
 * opacity:0; this file never sets opacity. A checkbox that draws itself (the switch on the Airports page)
 * carries the class mwl-own-box and is left alone.
 *
 * Colours: --border-check, --bg-check, --bg-check-on and --text-check-tick in css_main (light and dark).
 */

input[type="checkbox"]:where(:not(.mwl-own-box)) {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin: 3px 3px 3px 4px;
	padding: 0;
	display: inline-grid;
	place-content: center;
	vertical-align: middle;
	border: 1px solid var(--border-check);
	border-radius: 1px;
	background: var(--bg-check);
	cursor: pointer;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}

/* The tick: an SVG used as a mask, so its colour comes from the theme */
input[type="checkbox"]:where(:not(.mwl-own-box))::before {
	content: "";
	width: 14px;
	height: 14px;
	background: var(--text-check-tick);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.4l3 3 6.6-7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 8.4l3 3 6.6-7' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	transform: scale(0);
	transition: transform 0.12s;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}

input[type="checkbox"]:where(:not(.mwl-own-box)):checked {
	border-color: var(--text-check-tick);
	background: var(--bg-check-on);
}
input[type="checkbox"]:where(:not(.mwl-own-box)):checked::before {
	transform: scale(1);
}

input[type="checkbox"]:where(:not(.mwl-own-box)):focus-visible {
	outline: 2px solid var(--border-brand);
	outline-offset: 2px;
}

/* Disabled: greyed with colours, not opacity (opacity would show the checkboxes that pages hide) */
input[type="checkbox"]:where(:not(.mwl-own-box)):disabled {
	border-color: var(--border-neutral-4);
	background: var(--bg-neutral-8);
	cursor: not-allowed;
}
input[type="checkbox"]:where(:not(.mwl-own-box)):disabled::before {
	background: var(--text-neutral-6);
}

/*
 * Radio button: the same box made round. When chosen the border turns green, the box gets the faint
 * green fill and a green dot shows. Same rules as the checkbox: page rules win, opacity is never set.
 */
input[type="radio"]:where(:not(.mwl-own-box)) {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	width: 16px;
	height: 16px;
	margin: 3px 3px 3px 4px;
	padding: 0;
	display: inline-grid;
	place-content: center;
	vertical-align: middle;
	border: 1px solid var(--border-check);
	border-radius: 50%;
	background: var(--bg-check);
	cursor: pointer;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}
input[type="radio"]:where(:not(.mwl-own-box))::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--text-check-tick);
	transform: scale(0);
	transition: transform 0.12s;
	-webkit-print-color-adjust: exact;
	print-color-adjust: exact;
}
input[type="radio"]:where(:not(.mwl-own-box)):checked {
	border-color: var(--text-check-tick);
	background: var(--bg-check-on);
}
input[type="radio"]:where(:not(.mwl-own-box)):checked::before {
	transform: scale(1);
}
input[type="radio"]:where(:not(.mwl-own-box)):focus-visible {
	outline: 2px solid var(--border-brand);
	outline-offset: 2px;
}
input[type="radio"]:where(:not(.mwl-own-box)):disabled {
	border-color: var(--border-neutral-4);
	background: var(--bg-neutral-8);
	cursor: not-allowed;
}
input[type="radio"]:where(:not(.mwl-own-box)):disabled::before {
	background: var(--text-neutral-6);
}

@media (prefers-reduced-motion: reduce) {
	input[type="checkbox"]:where(:not(.mwl-own-box))::before,
	input[type="radio"]:where(:not(.mwl-own-box))::before { transition: none; }
}

/* Windows high contrast: the browser's own checkbox and radio, which follow the system colours */
@media (forced-colors: active) {
	input[type="checkbox"]:where(:not(.mwl-own-box)),
	input[type="radio"]:where(:not(.mwl-own-box)) { -webkit-appearance: auto; appearance: auto; }
	input[type="checkbox"]:where(:not(.mwl-own-box))::before,
	input[type="radio"]:where(:not(.mwl-own-box))::before { content: none; }
}

/*
 * The question before a delete (js/confirm-dialog, plan delete-edit-controls phase 2, Magnus 2026-11-17):
 * the question, Cancel and a red "Yes, delete" with the trash can. Same look as the pop-up on c_confirm_docs.
 */
.mwl-confirm-back {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(20, 28, 40, 0.55);
	padding: 16px;
}
/* On a zoomed page (phones) the backdrop is placed over the visible part by the script instead */
.mwl-confirm-back.mwl-confirm-zoomed { position: absolute; inset: auto; left: 0; align-items: flex-start; }
.mwl-confirm {
	width: 100%;
	max-width: 460px;
	background: var(--bg-neutral-1);
	color: var(--text-neutral-12);
	border: 1px solid var(--border-neutral-4);
	border-radius: 10px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	padding: 20px 22px 18px;
	text-align: left;
}
.mwl-confirm p { margin: 0 0 16px; line-height: 1.45; white-space: pre-line; }
.mwl-confirm-buttons { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/*
 * List rows (plan delete-edit-controls phase 3, Magnus 2026-11-17): a row with two or more actions gets the
 * "More" menu (three dots), a row with one action a single icon button. Built by mwlRowMenu (class.mwlRowMenu.php),
 * opened and closed by js/row-menu. The menu rules were the logbook's; css_logbook keeps only what is special to
 * the logbook table (the menu column, the menu next to the table).
 */
.logMenuWrap { position: relative; display: inline-block; }

/* Resets the site-wide button look so the dots never change the row height */
button.logMenuButton,
button.logMenuButton:hover:enabled,
button.logMenuButton:focus,
button.logMenuButton:active:enabled {
	background: none;
	border: 0;
	border-radius: 3px;
	box-shadow: none;
	margin: 0;
	padding: 0 0.45em;
	height: auto;
	min-height: 0;
	font-size: 1em;
	line-height: 1.2;
	cursor: pointer;
}
button.logMenuButton { color: var(--text-neutral-4); }
/* Black (white in the dark theme) on the hovered row, so the menu is easy to find */
tr:hover button.logMenuButton,
button.logMenuButton:hover:enabled,
button.logMenuButton:active:enabled,
button.logMenuButton[aria-expanded='true'],
button.logMenuButton:focus-visible { color: var(--text-neutral-13); }
button.logMenuButton i { color: inherit; }

/* The row whose menu is open is marked light blue (not the logbook's menu column or its spacer cells) */
tr.logMenuOpenRow > td:not(.logMenuCell):not(.tableSpacerCell) { background-color: var(--bg-info-1); }

.logMenu {
	position: absolute;
	right: 0;
	top: 100%;
	z-index: 50;
	min-width: 8em;
	padding: 0.2em 0;
	background-color: var(--bg-neutral-1);
	border: 1px solid var(--border-neutral-4);
	border-radius: 4px;
	box-shadow: 0 4px 12px var(--shadow-4);
	text-align: left;
	white-space: nowrap;
	letter-spacing: normal;
	font-family: "Exo 2", "Helvetica Neue", Verdana, Arial, sans-serif;
	font-size: 0.8rem;
	font-weight: normal;
}
.logMenu.logMenuUp { top: auto; bottom: 100%; }
.logMenu form { margin: 0; display: block; }

.logMenu .logMenuItem,
.logMenu button.logMenuItem:hover:enabled,
.logMenu button.logMenuItem:focus,
.logMenu button.logMenuItem:active:enabled {
	display: block;
	width: 100%;
	height: auto;
	box-sizing: border-box;
	margin: 0;
	padding: 0.4em 0.9em;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font: inherit;
	line-height: 1.3;
	text-align: left;
	text-decoration: none;
	color: var(--text-neutral-11);
	cursor: pointer;
}
.logMenu .logMenuItem:hover,
.logMenu .logMenuItem:focus-visible,
.logMenu button.logMenuItem:hover:enabled { background-color: var(--bg-neutral-6); }

/* Every icon in the same box, so the texts line up. table.lists (css_tables) gives pen and trash icons padding and a
   coloured square on hover; not inside the menu. */
/* margin-right with !important: css_button sets icon margins inside every <button> to 0 with !important, which
   pushed the text of button items (Delete in a form) out of line with the link items */
.logMenu .logMenuItem i,
.logMenu .logMenuItem i:hover {
	display: inline-block;
	width: 1.6em;
	margin-right: 0.5em !important;
	padding: 0;
	border-radius: 0;
	text-align: center;
	color: var(--text-brand) !important;
	background-color: transparent !important;
}
/* Delete is red, with a light red background on hover */
.logMenu .logMenuItemDanger,
.logMenu .logMenuItemDanger i,
.logMenu .logMenuItemDanger i:hover { color: var(--text-danger-3) !important; }
.logMenu .logMenuItemDanger:hover,
.logMenu .logMenuItemDanger:focus-visible { background-color: var(--bg-danger-1); }

/* A row with one action: a small square icon button with a tooltip (blue outline; red with btn-danger) */
.btn-icon,
a.button.btn-icon {
	width: var(--btn-height-sm, 26px);
	height: var(--btn-height-sm, 26px);
	min-width: 0;
	padding: 0;
	justify-content: center;
	vertical-align: middle;
}
/* i[class] gives these rules more weight than css_tables' "table.lists i.fa-pen-to-square" (padding, and a coloured
   square on hover with !important): the button's own colour and hover are used instead */
.btn-icon i[class],
.btn-icon i[class]:hover {
	padding: 0;
	border-radius: 0;
	color: inherit !important;
	background-color: transparent !important;
}
/* A one-action delete in a row is a small POST form around the button */
form.mwlRowAction { display: inline; margin: 0; }

@media print {
	.logMenuWrap, form.mwlRowAction, .btn-icon { display: none; }
}

/*
 * A form's buttons (plan delete-edit-controls phase 4, Magnus 2026-11-17): Save and the other buttons from the left,
 * Delete alone at the right end, away from Save. Markup:
 *   <div class='mwl-form-footer'> Save, Cancel, ... <span class='mwl-form-footer-end'> Delete </span></div>
 * Only when an existing record is edited and the user may delete it; when adding, there is no Delete.
 * On a narrow screen the buttons wrap and Delete keeps to the right.
 */
.mwl-form-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 12px 0 4px;
	text-align: left;
}
.mwl-form-footer > *,
.mwl-form-footer-end > * { margin: 0; }
.mwl-form-footer-end { margin-left: auto; display: inline-flex; gap: 8px; }
.mwl-form-footer-end form { margin: 0; display: inline; }
@media print {
	.mwl-form-footer { display: none; }
}
