/* MASARAT login (www/login.html). Loaded on the login page only, after Frappe's login.bundle.css.
 * Right-to-left first; the brand panel sits on the reading-start side (right). */

body[data-path="login"] {
	background: #f3f5f8;
	--msl-navy: #0b1f3a;
	--msl-navy-2: #143766;
	--msl-blue: #1d4e89;
	--msl-blue-soft: #e8f0fa;
	--msl-text: #0f1b2d;
	--msl-muted: #5b6b7d;
	--msl-line: #dfe5ec;
	--msl-red: #c62828;
	--msl-green: #2e7d32;
	--msl-radius: 14px;
	font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
/* One typeface for everything on the page, form controls included (browsers do not inherit it into inputs and buttons). */
.msl, .msl input, .msl button, .msl .es-button, .msl h1, .msl h2, .msl p { font-family: inherit; letter-spacing: 0; }
body[data-path="login"] .page-content-wrapper,
body[data-path="login"] .page_content,
body[data-path="login"] main.container,
body[data-path="login"] .container { max-width: none; min-height: 100vh; margin: 0; padding: 0; }
body[data-path="login"] .page-breadcrumbs,
body[data-path="login"] .page-header-wrapper,
body[data-path="login"] .page-footer,
body[data-path="login"] .web-footer { display: none; }

.msl {
	min-height: 100vh;
	display: grid;
	grid-template-columns: minmax(360px, 44%) 1fr;
	color: var(--msl-text);
}
.msl-icon { width: 18px; height: 18px; flex: none; }

/* ---------- Brand panel ---------- */
.msl-brand {
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 40px;
	padding: 48px 56px;
	color: #eef3fa;
	background:
		radial-gradient(900px 500px at 110% -10%, rgba(255, 255, 255, 0.10), transparent 60%),
		radial-gradient(600px 400px at -20% 110%, rgba(64, 140, 230, 0.28), transparent 60%),
		linear-gradient(160deg, var(--msl-navy) 0%, var(--msl-navy-2) 60%, var(--msl-blue) 100%);
}
.msl-brand::after {
	/* Quiet dotted texture, no image request. */
	content: "";
	position: absolute;
	inset: 0;
	background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
	background-size: 22px 22px;
	mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
	pointer-events: none;
}
.msl-brand > * { position: relative; z-index: 1; }
.msl-brand, .msl-brand h2, .msl-brand p { text-align: start; }

.msl-brand-top { display: flex; align-items: center; gap: 16px; width: fit-content; color: inherit; text-decoration: none; }
.msl-brand-top:hover { color: inherit; text-decoration: none; opacity: 0.92; }
.msl-brand-top:focus-visible { outline: 3px solid rgba(143, 195, 255, 0.6); outline-offset: 6px; border-radius: 22px; }
.msl-logo-tile {
	display: grid;
	place-items: center;
	width: 76px;
	height: 76px;
	flex: none;
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
	padding: 10px;
}
.msl-logo-tile img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* The MASARAT mark is already a filled tile: no white frame around it. */
.msl-logo-tile.is-default { padding: 0; background: transparent; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); }
.msl-school { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.35; color: #fff; }
.msl-school-sub { margin: 2px 0 0; font-size: 14px; color: rgba(238, 243, 250, 0.72); }

.msl-brand-title {
	margin: 0 0 18px;
	font-size: clamp(30px, 2.9vw, 44px);
	line-height: 1.35;
	font-weight: 700;
	color: #fff;
}
/* The second line in a lighter accent, with a soft highlight under it. */
.msl-accent {
	display: block;
	width: fit-content;
	margin-top: 4px;
	padding-bottom: 6px;
	background:
		linear-gradient(90deg, #8fc3ff, #cfe5ff) text,
		linear-gradient(90deg, rgba(143, 195, 255, 0), rgba(143, 195, 255, 0.55)) no-repeat bottom / 100% 4px;
	-webkit-background-clip: text, border-box;
	background-clip: text, border-box;
	color: transparent;
}
.msl-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 18px;
	padding: 6px 14px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.08);
	font-size: 13px;
	font-weight: 500;
	color: #dbe8f7;
}
.msl-eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: #8fc3ff; box-shadow: 0 0 0 4px rgba(143, 195, 255, 0.18); }
.msl-brand-text { margin: 0 0 30px; max-width: 26em; font-size: 16px; line-height: 1.9; text-wrap: pretty; color: rgba(238, 243, 250, 0.8); }
.msl-features { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.msl-features li { display: flex; align-items: center; gap: 12px; font-size: 15px; line-height: 1.5; color: #f2f6fb; }
.msl-features .msl-icon {
	width: 36px;
	height: 36px;
	padding: 8px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.10);
	border: 1px solid rgba(255, 255, 255, 0.14);
}

.msl-powered { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: rgba(238, 243, 250, 0.62); }
.msl-powered img { width: 20px; height: 20px; opacity: 0.85; }
.msl-powered b { color: rgba(255, 255, 255, 0.9); font-weight: 700; }

/* ---------- Form side ---------- */
.msl-main {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 24px;
	min-width: 0;
	padding: 40px 24px 24px;
}
/* Centred when it fits, scrolls from the top when it does not (margin auto never clips the top). */
.msl-panel { margin-block: auto 0; }
.msl-foot { margin-block: 0 auto; }
.msl-panel { width: min(420px, 100%); }

/* Frappe's page card, reset to the MASARAT look. */
.msl .for-login .page-card.msl-card,
.msl .for-forgot .page-card.msl-card,
.msl .for-signup .page-card.msl-card,
.msl .for-email-login .page-card.msl-card,
.msl .for-login-with-email-link .page-card.msl-card {
	max-width: none;
	min-height: 0;
	margin: 0;
	padding: 36px 32px 32px;
	border: 1px solid var(--msl-line);
	border-radius: 22px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(15, 27, 45, 0.04), 0 18px 48px rgba(15, 27, 45, 0.08);
}

.msl-head { display: flex; flex-direction: column; align-items: flex-start; text-align: start; margin-bottom: 28px; }
.msl-head-logo { display: none; width: 64px; height: 64px; object-fit: contain; margin-bottom: 14px; }
.msl-title { margin: 0; line-height: 1.4; font-size: 26px; font-weight: 700; color: var(--msl-navy); }
.msl-subtitle { margin: 6px 0 0; font-size: 15px; line-height: 1.7; text-wrap: pretty; color: var(--msl-muted); }

.msl-body { display: flex; flex-direction: column; gap: 18px; }
.msl-field { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.msl-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.msl-label { margin: 0; line-height: 1.5; font-size: 14px; font-weight: 600; color: var(--msl-text); }

.msl-input { position: relative; display: flex; align-items: center; width: 100%; }
.msl-input > .msl-icon {
	position: absolute;
	right: 14px;
	color: #8a99aa;
	pointer-events: none;
	z-index: 2;
}
.msl .msl-card .msl-body .msl-input input.form-control {
	width: 100%;
	height: 50px;
	/* Physical sides: the input is dir=ltr (addresses), while the icon sits on the right of the RTL page. */
	padding: 0 44px 0 16px;
	border: 1.5px solid var(--msl-line);
	border-radius: 12px;
	background: #f9fbfd;
	color: var(--msl-text);
	font-size: 15px;
	line-height: 1.4;
	text-align: right;
	box-shadow: none;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.msl .msl-card .msl-body .msl-input input.form-control::placeholder { color: #a3b0be; font-weight: 400; text-align: right; }
.msl .msl-card .msl-body .password-field input.form-control { padding-left: 50px; }
.msl .msl-card .msl-body .msl-input input.form-control:hover { border-color: #c5d0dc; }
.msl .msl-card .msl-body .msl-input input.form-control:focus {
	outline: none;
	background: #fff;
	border-color: var(--msl-blue);
	box-shadow: 0 0 0 4px rgba(29, 78, 137, 0.14);
}
.msl .msl-card .msl-body .msl-input:focus-within > .msl-icon { color: var(--msl-blue); }

/* Show / hide password: a real button on the left (end) side of the field. */
.msl-eye {
	position: absolute;
	left: 6px;
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: #7b8a9b;
	cursor: pointer;
	z-index: 3;
}
.msl-eye:hover { background: var(--msl-blue-soft); color: var(--msl-blue); }
.msl-eye:focus-visible { outline: 3px solid rgba(29, 78, 137, 0.35); outline-offset: 1px; }
.msl .msl-card .msl-body .password-field .toggle-password {
	position: static;
	transform: none;
	stroke: currentColor;
	width: 18px;
	height: 18px;
}

/* Errors (Frappe adds .invalid and fills .field-error). */
.msl .msl-card .msl-body .field-error { font-size: 13px; color: var(--msl-red); }
.msl .msl-card .msl-body.invalid .msl-input input.form-control,
.msl .msl-card .msl-body .form-group.invalid .msl-input input.form-control {
	border-color: #e3a3a3;
	background: #fffafa;
}
.msl .es-alert { border-radius: 12px; font-size: 14px; }

/* «نسيت كلمة المرور؟» under the password field, on the reading-start side, where the eye looks first. */
.msl-forgot {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 6px;
	margin-top: 2px;
	padding: 4px 2px;
	color: var(--msl-blue);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}
.msl-forgot .msl-icon { width: 16px; height: 16px; }
.msl-forgot:hover { color: var(--msl-navy); text-decoration: underline; text-underline-offset: 4px; }
.msl-forgot:focus-visible { outline: 3px solid rgba(29, 78, 137, 0.35); outline-offset: 2px; border-radius: 6px; }
.msl-link { color: var(--msl-blue); font-size: 14px; font-weight: 600; text-decoration: none; }
.msl-link:hover { color: var(--msl-navy); text-decoration: underline; }

/* Buttons */
.msl-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
.msl .es-button.msl-primary,
.msl .es-button.msl-secondary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	height: 50px;
	border-radius: 12px;
	font-size: 16px;
	font-weight: 600;
	line-height: 1;
	padding-block: 0 2px;
	text-decoration: none;
	transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.msl .es-button.msl-primary {
	border: 0;
	background: var(--msl-navy);
	color: #fff;
	box-shadow: 0 8px 20px rgba(11, 31, 58, 0.18);
}
.msl .es-button.msl-primary:hover:not(:disabled) { background: var(--msl-blue); }
.msl .es-button.msl-primary:active:not(:disabled) { transform: translateY(1px); }
.msl .es-button.msl-primary:disabled { background: #9aa8b8; box-shadow: none; cursor: not-allowed; }
.msl .es-button.msl-primary:focus-visible,
.msl .es-button.msl-secondary:focus-visible { outline: 3px solid rgba(29, 78, 137, 0.35); outline-offset: 2px; }
.msl .es-button.msl-secondary {
	border: 1.5px solid var(--msl-line);
	background: #fff;
	color: var(--msl-navy);
	font-size: 15px;
}
.msl .es-button.msl-secondary:hover { border-color: var(--msl-blue); background: var(--msl-blue-soft); color: var(--msl-navy); }

.msl-divider { display: flex; align-items: center; gap: 14px; margin: 4px 0; color: #94a2b2; font-size: 13px; }
.msl-divider::before,
.msl-divider::after { content: ""; flex: 1; height: 1px; background: var(--msl-line); }

.msl-back { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; }
.msl-back .msl-icon { width: 16px; height: 16px; }
.msl-resend { margin: 0; font-size: 14px; color: var(--msl-muted); text-align: center; }
.masarat-reset-note { margin: 4px 0 0; font-size: 14px; line-height: 1.8; text-align: center; }
.masarat-reset-note.is-ok { color: var(--msl-green); }
.masarat-reset-note.is-error { color: var(--msl-red); }

/* New accounts */
.msl-new { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.msl-new-title { grid-column: 1 / -1; margin: 0 0 2px; font-size: 14px; font-weight: 600; color: var(--msl-muted); text-align: start; }
.msl-new-card {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	padding: 12px;
	border: 1px solid var(--msl-line);
	border-radius: var(--msl-radius);
	background: #fff;
	color: var(--msl-text);
	text-decoration: none;
	transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.msl-new-card:hover { border-color: #b9c9dc; box-shadow: 0 8px 22px rgba(15, 27, 45, 0.07); color: var(--msl-text); text-decoration: none; transform: translateY(-1px); }
.msl-new-card:focus-visible { outline: 3px solid rgba(29, 78, 137, 0.35); outline-offset: 2px; }
.msl-new-card > span:nth-child(2) { flex: 1; min-width: 0; display: grid; gap: 2px; }
.msl-new-card b { font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--msl-navy); }
.msl-new-card small { font-size: 12px; line-height: 1.5; color: var(--msl-muted); }
.msl-new-card > .msl-icon { display: none; }
.msl-new-icon {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	flex: none;
	border-radius: 11px;
	background: var(--msl-blue-soft);
	color: var(--msl-blue);
}

.msl-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: 13px; color: #8494a6; }
.msl-foot a { color: inherit; text-decoration: none; }
.msl-foot a:hover { color: var(--msl-blue); text-decoration: underline; }
.msl-noscript { padding: 16px; border-radius: 12px; background: #fff4e5; text-align: center; }

/* ---------- Responsive ---------- */

/* Large screens: a little more room, never a stretched form. */
@media (min-width: 1600px) {
	.msl { grid-template-columns: minmax(520px, 46%) 1fr; }
	.msl-brand { padding: 64px 88px; }
	.msl-brand-body { max-width: 560px; }
	.msl-panel { width: 460px; }
}

/* Laptops: narrower brand column. */
@media (max-width: 1200px) and (min-width: 961px) {
	.msl { grid-template-columns: minmax(340px, 42%) 1fr; }
	.msl-brand { padding: 40px 40px; }
	.msl-features li { font-size: 14px; }
}

/* Short desktop windows (1366×680, browser with toolbars): fit without scrolling. */
@media (min-width: 961px) and (max-height: 820px) {
	.msl-brand { padding-block: 32px; gap: 24px; }
	.msl-logo-tile { width: 64px; height: 64px; border-radius: 17px; }
	.msl-brand-title { font-size: 32px; margin-bottom: 12px; }
	.msl-eyebrow { margin-bottom: 12px; padding: 4px 12px; }
	.msl-brand-text { margin-bottom: 18px; font-size: 15px; line-height: 1.8; }
	.msl-features { gap: 8px; }
	.msl-features .msl-icon { width: 32px; height: 32px; padding: 7px; }
	.msl-main { gap: 14px; padding: 20px 24px 14px; }
	.msl .for-login .page-card.msl-card,
	.msl .for-forgot .page-card.msl-card,
	.msl .for-signup .page-card.msl-card,
	.msl .for-email-login .page-card.msl-card,
	.msl .for-login-with-email-link .page-card.msl-card { padding: 24px 28px 22px; }
	.msl-head { margin-bottom: 18px; }
	.msl-title { font-size: 23px; }
	.msl-subtitle { margin-top: 4px; font-size: 14px; }
	.msl-body { gap: 14px; }
	.msl .msl-card .msl-body .msl-input input.form-control { height: 46px; }
	.msl-actions { margin-top: 18px; gap: 10px; }
	.msl .es-button.msl-primary,
	.msl .es-button.msl-secondary { height: 46px; }
	.msl-divider { margin: 0; }
	.msl-new { margin-top: 14px; gap: 8px; }
}
@media (min-width: 961px) and (max-height: 640px) {
	.msl-features { display: none; }
	.msl-new-card small { display: none; }
}

/* Tablets and phones: the brand panel becomes a header. */
@media (max-width: 960px) {
	.msl { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
	.msl-brand { gap: 0; padding: 22px 22px 64px; }
	.msl-brand-body,
	.msl-powered { display: none; }
	.msl-brand-top { justify-content: center; }
	.msl-logo-tile { width: 58px; height: 58px; border-radius: 16px; padding: 8px; }
	.msl-school { font-size: 19px; }
	.msl-main { padding: 0 20px 24px; gap: 20px; }
	/* The card rises into the header; the header keeps room for it, so nothing is cut. */
	.msl-panel { position: relative; z-index: 2; margin-top: -42px; margin-bottom: 0; width: min(460px, 100%); }
	.msl-foot { margin-top: 0; }
	.msl .for-login .page-card.msl-card,
	.msl .for-forgot .page-card.msl-card,
	.msl .for-signup .page-card.msl-card,
	.msl .for-email-login .page-card.msl-card,
	.msl .for-login-with-email-link .page-card.msl-card {
		min-height: 0;
		padding: 28px 24px 24px;
		border: 1px solid var(--msl-line);
		border-radius: 20px;
	}
}

/* Phones */
@media (max-width: 520px) {
	.msl-brand { padding: 18px 16px 56px; }
	.msl-brand-top { gap: 12px; }
	.msl-logo-tile { width: 50px; height: 50px; border-radius: 14px; padding: 6px; }
	.msl-school { font-size: 17px; }
	.msl-school-sub { font-size: 12px; }
	.msl-main { padding: 0 12px 20px; }
	.msl-panel { margin-top: -38px; }
	.msl .for-login .page-card.msl-card,
	.msl .for-forgot .page-card.msl-card,
	.msl .for-signup .page-card.msl-card,
	.msl .for-email-login .page-card.msl-card,
	.msl .for-login-with-email-link .page-card.msl-card { padding: 24px 18px 20px; border-radius: 18px; }
	.msl-head { margin-bottom: 20px; }
	.msl-title { font-size: 22px; }
	.msl-subtitle { font-size: 14px; }
	.msl-new { grid-template-columns: 1fr; }
	/* 16px inputs stop iOS from zooming into the field. */
	.msl .msl-card .msl-body .msl-input input.form-control { font-size: 16px; }
}
@media (max-width: 360px) {
	.msl-title { font-size: 20px; }
	.msl-label-row { flex-wrap: wrap; row-gap: 4px; }
	.msl-new-card small { display: none; }
}

/* Phones held sideways: a slim header. */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
	.msl-brand { padding: 10px 16px; }
	.msl-logo-tile { width: 40px; height: 40px; border-radius: 11px; padding: 5px; }
	.msl-panel { margin-top: 16px; }
	.msl-school-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.msl * { transition: none !important; }
}
