/**
 * MachForm login-style pages base.
 *
 * Used primarily by index.php, login_verify.php, login_tsv_setup.php, reset.php,
 * installer.php and upgrade.php
 *
 * No hard-coded colors belong in this file. Specific color themes are defined in login-[theme].css, which is loaded after this file.
 *
 * The page is one card: a panel in the admin header's colour holding the logo (#header), beside the form (#main), with
 * the admin #main frame's corners and edge. Below 640px the panel becomes a band across the top of the card.
 *
 * Legacy rules in main.css / main.mobile.css are shared with other pages, so they are
 * neutralized here rather than deleted.
 */

/* ---------- Page ---------- */
html {
	height: auto;
}
body.mf-login {
	position: relative;
	min-height: 100vh;
	height: auto;
	margin: 0;
	font-family: "InterVariable", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.5;
	color: var(--text);
	background: var(--page-bg);
	overflow-x: hidden;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}
body.mf-login *,
body.mf-login *::before,
body.mf-login *::after {
	box-sizing: border-box;
}

/* centred on the page; a card taller than the window makes the page taller, so it scrolls */
body.mf-login #bg {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	padding: 40px 16px;
	background: none;
}

/* ---------- Card ---------- */
/* the panel and the form side by side, the footer line under both */
body.mf-login #container {
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	width: 100%;
	max-width: 760px;
	margin: 0 auto;
}
/* the card's edge, drawn over the panel and the form so it runs round both: the admin frame's ring, or its border on Dark */
body.mf-login #container::after {
	content: "";
	grid-row: 1;
	grid-column: 1 / -1;
	border: var(--card-border);
	border-radius: 10px;
	box-shadow: var(--card-shadow);
	pointer-events: none;
}

/* ---------- Panel and logo ---------- */
body.mf-login #header {
	grid-row: 1;
	grid-column: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 0;
	margin: 0;
	padding: 32px;
	text-align: center;
	background: var(--panel);
	border-radius: 10px 0 0 10px;
	box-shadow: none;
	text-shadow: none;
}
body.mf-login #header > .clear {
	display: none;
}
/* the yellow line under the logo, as under the admin header's current item */
body.mf-login #header::after {
	content: "";
	display: block;
	flex: none;
	width: 44px;
	height: 3px;
	margin-top: 20px;
	background: var(--panel-line);
}
/* the admin header's logo box: a custom logo's size isn't known until it loads, so its box is the tallest a logo can be */
body.mf-login #logo {
	display: flex; /* main.mobile.css hides #logo below 480px */
	align-items: center;
	justify-content: center;
	float: none;
	width: 100%;
	height: 40px;
	margin: 0;
	text-align: center;
}
/* the built-in logo's size is in its markup (mf_get_login_logo_markup()) */
body.mf-login #logo:has(> img[height]) {
	height: auto;
}
/* the admin header's limits (main.css #logo img), never stretched: the built-in logo keeps the size in its markup while it
   loads, drawn inside it at its own proportions */
body.mf-login #logo img {
	display: block;
	flex: none;
	max-width: 190px;
	max-height: 40px;
	margin: 0;
	object-fit: contain;
}

/* ---------- Form side ---------- */
body.mf-login #main {
	grid-row: 1;
	grid-column: 2;
	float: none;
	width: auto;
	max-width: none;
	min-width: 0;
	margin: 0;
	padding: 40px 36px 36px;
	background: var(--main-fill);
	border: none;
	border-radius: 0 10px 10px 0;
	box-shadow: none;
}

/* inner legacy wrappers become plain blocks */
body.mf-login #content,
body.mf-login #content > .post {
	float: none;
	width: auto;
	margin: 0;
	padding: 0;
	background: none;
	color: inherit;
	border-radius: 0;
}
body.mf-login .post {
	width: auto !important; /* beats .login_page .post / .installer_page .post { width: 400px !important } */
}
body.mf-login .post::after {
	display: none;
}
body.mf-login #main > .clear {
	display: none;
}

/* ---------- Heading and intro ---------- */
body.mf-login #login_logo,
body.mf-login .post > div > div > img {
	display: none; /* decorative shield / status icons, not part of the design */
}
/* the admin page titles' serif */
body.mf-login .post h3 {
	margin: 0;
	padding: 0;
	font-family: "Source Serif 4", Georgia, serif;
	font-size: 27px;
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: 0;
	text-align: center;
	color: var(--heading);
	text-shadow: none;
}
body.mf-login .post h3 + p {
	margin: 8px 0 28px;
	font-size: 0.93rem;
	font-weight: 400;
	text-align: center;
	color: var(--label);
}
body.mf-login .post h3 + p + div {
	display: none; /* legacy dotted divider */
}

/* ---------- Form layout ---------- */
body.mf-login #standard_login_block {
	margin: 0;
}
body.mf-login form.appnitro {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 1rem;
}
body.mf-login form.appnitro > ul {
	display: flex;
	flex-direction: column;
	gap: 18px;
	margin: 0;
	padding: 0;
	list-style: none;
}
body.mf-login form.appnitro li {
	width: auto !important; /* beats .login_page li / .installer_page li { width: 97% !important } */
	margin: 0;
	padding: 0;
	background: none;
}

/* plain content rows (installer/upgrade info, 2FA instructions) */
body.mf-login form.appnitro > ul > li {
	font-size: 0.9rem;
	line-height: 1.55;
	color: var(--text);
	overflow-wrap: anywhere; /* long words in the installer's and upgrade's messages wrap inside the form side */
}
body.mf-login form.appnitro li b,
body.mf-login form.appnitro li strong {
	font-weight: 600;
	color: var(--text);
}

/* ---------- Labels ---------- */
body.mf-login form.appnitro label.desc {
	display: block;
	margin: 0 0 7px;
	padding: 0;
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 500;
	line-height: 1.4;
	color: var(--label);
}

/* ---------- Text inputs ---------- */
body.mf-login form.appnitro input.text {
	display: block;
	width: 100%;
	margin: 0;
	font: inherit;
	font-size: 0.95rem;
	line-height: 1.4;
	color: var(--text);
	background: none;
	background-color: var(--field);
	border: 1px solid var(--field-border);
	border-radius: 8px;
	padding: 13px 14px;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
	        appearance: none;
	transition: border-color .2s, box-shadow .2s;
}
body.mf-login form.appnitro li[class*="mf-icon-"] input.text {
	padding-left: 42px;
}
body.mf-login form.appnitro .mf-password-wrap > input.text {
	padding-right: 44px;
}
body.mf-login form.appnitro input.text::placeholder {
	color: var(--placeholder);
	opacity: 1;
}
/* a 2px edge in the focus colour, drawn without moving the text */
body.mf-login form.appnitro input.text:focus {
	border-color: var(--focus);
	box-shadow: 0 0 0 1px var(--focus);
}

body.mf-login .mf-field-help {
	display: block;
	margin-top: 7px;
	font-size: 0.8rem;
	line-height: 1.4;
	color: var(--label);
}

/*
 * Leading field icons. Drawn on the field's wrapper div rather than the input
 * background, because Chrome forces background-image: none !important on
 * autofilled inputs, which would erase an input-background icon.
 */
body.mf-login li[class*="mf-icon-"] > div:first-of-type {
	position: relative;
}
body.mf-login li[class*="mf-icon-"] > div:first-of-type::before {
	content: "";
	position: absolute;
	left: 14px;
	top: 50%;
	width: 18px;
	height: 18px;
	transform: translateY(-50%);
	background-repeat: no-repeat;
	background-position: center;
	background-size: 18px 18px;
	pointer-events: none;
	z-index: 1;
}
body.mf-login li.mf-icon-email > div:first-of-type::before {
	background-image: var(--icon-email);
}
body.mf-login li.mf-icon-user > div:first-of-type::before {
	background-image: var(--icon-user);
}
body.mf-login li.mf-icon-lock > div:first-of-type::before {
	background-image: var(--icon-lock);
}
body.mf-login li.mf-icon-key > div:first-of-type::before {
	background-image: var(--icon-key);
}
body.mf-login li.mf-icon-shield > div:first-of-type::before {
	background-image: var(--icon-shield);
}

/* ---------- Show password toggle ---------- */
body.mf-login .mf-password-wrap {
	position: relative;
}
body.mf-login .mf-pw-toggle {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 1;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	display: grid;
	place-items: center;
	background: none;
	border: none;
	border-radius: 6px;
	color: var(--text);
	opacity: .6;
	cursor: pointer;
	float: none;
	box-shadow: none;
}
body.mf-login .mf-pw-toggle:hover {
	opacity: 1;
	background: var(--chip);
}
body.mf-login .mf-pw-toggle.is-active {
	opacity: 1;
}
body.mf-login .mf-pw-toggle:focus {
	outline: none;
}
body.mf-login .mf-pw-toggle:focus-visible {
	opacity: 1;
	outline: 2px solid var(--focus);
	outline-offset: 0;
}
body.mf-login .mf-pw-toggle svg {
	display: block;
	width: 18px;
	height: 18px;
}

/* ---------- Remember me / forgot password row ---------- */
body.mf-login #li_remember_me {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	font-size: 0.85rem;
	line-height: 1.4;
}
body.mf-login #remember_me_span {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
body.mf-login #admin_remember {
	width: 16px;
	height: 16px;
	margin: 0;
	accent-color: var(--link);
	cursor: pointer;
}
body.mf-login #admin_remember:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}
body.mf-login #li_remember_me label.choice {
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: inherit;
	font-weight: 400;
	line-height: inherit;
	color: var(--label);
	cursor: pointer;
}
body.mf-login #admin_forgot {
	float: none;
	margin-left: auto; /* stays right-aligned when "Remember me" is hidden in reset mode */
}

/* ---------- Links ---------- */
body.mf-login a:link,
body.mf-login a:visited,
body.mf-login #admin_forgot {
	font-family: inherit;
	font-weight: 500;
	color: var(--link);
	text-decoration: none;
}
body.mf-login a:hover {
	color: var(--link-hover);
	text-decoration: underline;
}
body.mf-login a:focus {
	outline: none;
}
/* a link inside a line of text is underlined, so it isn't told apart by its colour alone */
body.mf-login #footer a:is(:link, :visited),
body.mf-login form.appnitro li p a:is(:link, :visited),
body.mf-login #li_login_tsv_setup a.app_link {
	text-decoration: underline;
	text-underline-offset: 2px;
}
body.mf-login a:focus-visible {
	border-radius: 2px;
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* ---------- Submit button ---------- */
/* the admin's green button (bb_green in bb_buttons.css): its colour and shadow, with a hover dark enough for its words */
body.mf-login #li_submit {
	margin: 0;
	padding: 0;
}
body.mf-login #submit_button {
	position: static;
	top: auto;
	display: block;
	float: none;
	width: 100%;
	margin: 4px 0 0;
	font: inherit;
	font-size: 0.97rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--btn-text);
	text-shadow: none;
	background: var(--btn-bg);
	border: none;
	border-radius: 8px;
	padding: 14px;
	cursor: pointer;
	box-shadow: var(--btn-shadow);
	outline: none;
	transition: background-color .2s;
}
body.mf-login #submit_button:focus,
body.mf-login #submit_button:active {
	top: auto;
	background: var(--btn-bg);
	color: var(--btn-text);
	box-shadow: var(--btn-shadow);
}
body.mf-login #submit_button:hover {
	background: var(--btn-bg-hover);
	color: var(--btn-text);
}
/* keyboard focus: the button's own colour, with the focus ring around it */
body.mf-login #submit_button:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}
body.mf-login #submit_button:disabled {
	cursor: default;
	background: var(--btn-bg);
	opacity: .7;
}
body.mf-login #submit_button [class^="icon-"],
body.mf-login #submit_button [class*=" icon-"] {
	display: none; /* decorative icon, not part of the design */
}
body.mf-login .forgot_password_loader {
	float: none;
	padding-top: 10px;
	text-align: center;
}

/* ---------- Error and notice messages ---------- */
body.mf-login form.appnitro :is(#li_login_notification, #li_installer_notification, li.mf-notice) {
	margin: 0;
	padding: 12px 14px;
	border-radius: 8px;
	font-size: 0.88rem;
	line-height: 1.45;
	text-align: left;
	background: var(--error-bg);
	border: 1px solid var(--error-border);
	color: var(--error-text);
}
body.mf-login form.appnitro :is(#li_login_notification, #li_installer_notification, li.mf-notice).mf-notice-success {
	background: var(--success-bg);
	border-color: var(--success-border);
	color: var(--success-text);
}
body.mf-login form.appnitro :is(#li_login_notification, #li_installer_notification, li.mf-notice) h5 {
	margin: 0;
	font-family: inherit;
	font-size: inherit;
	font-weight: 500;
	line-height: inherit;
	color: inherit;
}
body.mf-login form.appnitro :is(#li_login_notification, #li_installer_notification, li.mf-notice) :is(a:link, a:visited, b, strong) {
	color: inherit;
}
body.mf-login form.appnitro :is(#li_login_notification, #li_installer_notification, li.mf-notice) a {
	text-decoration: underline;
}

/* ---------- SSO (only rendered when SAML SSO is enabled) ---------- */
/* an outline button under Sign In, after an "or" divider; the only button when SSO is the only way to sign in */
body.mf-login #sso_login_block {
	margin: 18px 0 0;
	padding: 0;
	list-style: none;
}
body.mf-login #sso_login_block.is_sso_exclusive {
	margin: 0;
	padding: 0;
}
body.mf-login #sso_login_block li {
	width: auto !important; /* beats .login_page li { width: 97% !important }, so the button is as wide as Sign In */
	margin: 0;
	padding: 0;
}
body.mf-login #sso_login_block li + li {
	margin-top: 18px;
}
body.mf-login #sso_login_block li > span {
	display: flex;
	align-items: center;
	gap: 12px;
}
body.mf-login .separator-horizontal {
	flex: 1;
	min-width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	border: none;
	background: var(--divider);
}
body.mf-login .separator-title {
	padding: 0;
	font-size: 0.8rem;
	font-weight: 400;
	line-height: 1.4;
	color: var(--label);
}
body.mf-login #sso_signin_btn {
	position: static;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin: 0;
	padding: 11px;
	font: inherit;
	font-size: 0.88rem;
	font-weight: 500;
	color: var(--text);
	text-shadow: none;
	text-decoration: none;
	background: var(--sso-bg);
	border: 1px solid var(--field-border);
	border-radius: 8px;
	box-shadow: none;
	transition: background-color .2s;
}
body.mf-login #sso_signin_btn:hover {
	background: var(--sso-bg-hover);
	color: var(--text);
	text-decoration: none;
}
body.mf-login #sso_signin_btn:active {
	top: auto;
}
body.mf-login #sso_signin_btn:focus-visible {
	border-radius: 8px;
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* ---------- 2FA setup (login_tsv_setup.php) ---------- */
body.mf-login #li_login_tsv_setup > ul {
	margin: 0;
	padding: 0;
	list-style: none;
}
body.mf-login #li_login_tsv_setup li {
	color: var(--label);
	font-size: 0.88rem;
	line-height: 1.55;
}
body.mf-login #li_login_tsv_setup li.tsv_setup_title {
	margin: 18px 0 4px;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--text);
}
body.mf-login #li_login_tsv_setup li.tsv_setup_title:first-child {
	margin-top: 0;
}
body.mf-login #li_login_tsv_setup strong {
	color: var(--text);
	overflow-wrap: anywhere;
}
body.mf-login #li_login_tsv_setup a.app_link {
	font-family: inherit;
	color: var(--link) !important; /* beats #li_login_tsv_setup a.app_link { color: #bd3d20 !important } */
}
body.mf-login .mf-qr-wrap {
	margin: 14px 0;
	text-align: center;
}
body.mf-login #qrcode {
	display: inline-block;
	padding: 12px;
	line-height: 0;
	background: var(--qr-bg); /* scanners need a light quiet zone around the code */
	border-radius: 8px;
}

/* ---------- Password strength (reset.php) ---------- */
body.mf-login #password-strength-container {
	margin: 10px 0 0;
}
body.mf-login #password-strength-meter {
	height: 6px;
	border-radius: 999px;
	background: var(--divider);
}
body.mf-login #password-strength-bar {
	border-radius: 999px;
}
body.mf-login #password-strength-bar.strength-weak   { background-color: var(--strength-weak); }
body.mf-login #password-strength-bar.strength-fair   { background-color: var(--strength-fair); }
body.mf-login #password-strength-bar.strength-good   { background-color: var(--strength-good); }
body.mf-login #password-strength-bar.strength-strong { background-color: var(--strength-strong); }
body.mf-login #password-strength-text {
	margin-top: 6px;
	font-size: 0.8rem;
	font-weight: 600;
}
body.mf-login #password-strength-text.strength-weak   { color: var(--strength-weak); }
body.mf-login #password-strength-text.strength-fair   { color: var(--strength-fair); }
body.mf-login #password-strength-text.strength-good   { color: var(--strength-good); }
body.mf-login #password-strength-text.strength-strong { color: var(--strength-strong); }
body.mf-login #password-criteria-list {
	margin: 10px 0 0;
	padding: 0;
	list-style: none;
	font-size: 0.8rem;
	line-height: 1.4;
}
body.mf-login #password-criteria-list li,
body.mf-login #password-criteria-list li.criteria-fail,
body.mf-login #password-criteria-list li.criteria-fail .criteria-icon::before {
	color: var(--label);
}
body.mf-login #password-criteria-list li.criteria-pass,
body.mf-login #password-criteria-list li.criteria-pass .criteria-icon::before {
	color: var(--strength-strong);
}

/* ---------- Footer ---------- */
body.mf-login #footer {
	grid-row: 2;
	grid-column: 1 / -1;
	float: none;
	width: 100%;
	margin: 24px 0 0;
	padding: 0;
	font-size: 0.88rem;
	text-align: center;
	color: var(--page-text);
}
body.mf-login #footer .copyright {
	float: none;
	margin: 0;
	color: var(--page-text);
}
body.mf-login #footer a:link,
body.mf-login #footer a:visited {
	color: var(--link);
	border-bottom: none;
}
body.mf-login #footer a:hover {
	color: var(--link-hover);
}

/* ---------- Responsive ---------- */
/* the panel becomes a band across the top of the card, with a yellow line along its bottom edge */
@media (max-width: 639px) {
	body.mf-login #bg {
		padding: 24px 16px;
	}
	body.mf-login #container {
		grid-template-columns: minmax(0, 1fr);
		max-width: 420px;
	}
	body.mf-login #container::after {
		grid-row: 1 / 3;
		grid-column: 1;
	}
	body.mf-login #header {
		padding: 20px 16px 18px;
		border-bottom: 3px solid var(--panel-line);
		border-radius: 10px 10px 0 0;
	}
	body.mf-login #header::after {
		display: none;
	}
	body.mf-login #main {
		grid-row: 2;
		grid-column: 1;
		padding: 26px 22px 24px;
		border-radius: 0 0 10px 10px;
	}
	body.mf-login .post h3 {
		font-size: 24px;
	}
	body.mf-login #footer {
		grid-row: 3;
		margin-top: 18px;
	}
}
@media (max-width: 420px) {
	/* 16px stops iOS Safari from zooming the page when a field gets focus */
	body.mf-login form.appnitro input.text {
		font-size: 1rem;
	}
}
