/**
 * Enterprise Shell — branded /login presentation.
 * Scoped exclusively under body.enterprise-login.
 * Does not style Desk, launcher, forms, or other website pages.
 */

body.enterprise-login {
	--es-login-blue: #285f9f;
	--es-login-blue-deep: #1f4f87;
	--es-login-blue-hero: #1a3f73;
	--es-login-primary: #2f6fbf;
	--es-login-primary-hover: #275fa5;
	--es-login-primary-focus: rgba(47, 111, 191, 0.32);
	--es-login-text: #111827;
	--es-login-text-muted: #64748b;
	--es-login-page-bottom: #f4f7fb;
	--es-login-card-border: rgba(15, 23, 42, 0.08);
	--es-login-input-border: #d7dee8;
	--es-login-input-bg: #ffffff;
	--es-login-radius: 18px;
	--es-login-shadow: 0 18px 50px rgba(15, 40, 80, 0.14), 0 2px 8px rgba(15, 40, 80, 0.06);
	--es-login-gutter: clamp(12px, 3.5vw, 28px);

	margin: 0;
	min-height: 100dvh;
	background: var(--es-login-page-bottom) !important;
	color: var(--es-login-text);
	color-scheme: light;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
	overflow-y: auto;
}

html:has(body.enterprise-login) {
	overflow-x: hidden;
	overflow-y: auto;
	height: auto;
	min-height: 100%;
}

/* Neutralize Frappe login.bundle / website chrome on this page only */
body.enterprise-login .web-footer,
body.enterprise-login .navbar,
body.enterprise-login .page-header-wrapper,
body.enterprise-login .page-breadcrumbs {
	display: none !important;
}

body.enterprise-login .page-content-wrapper,
body.enterprise-login .page_content,
body.enterprise-login main.container,
body.enterprise-login #page-login {
	max-width: none;
	width: 100%;
	margin: 0;
	padding: 0;
	min-height: 0;
}

body.enterprise-login .page-content-wrapper {
	min-height: 100dvh;
}

/* ---------- Two-tone patterned background ---------- */

body.enterprise-login .enterprise-login-page {
	position: relative;
	isolation: isolate;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	padding:
		max(12px, env(safe-area-inset-top))
		max(var(--es-login-gutter), env(safe-area-inset-right))
		max(12px, env(safe-area-inset-bottom))
		max(var(--es-login-gutter), env(safe-area-inset-left));
	box-sizing: border-box;
}

body.enterprise-login .enterprise-login-background {
	position: fixed;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	overflow: hidden;
}

body.enterprise-login .enterprise-login-background__top,
body.enterprise-login .enterprise-login-background__bottom {
	position: absolute;
	left: 0;
	right: 0;
	overflow: hidden;
}

body.enterprise-login .enterprise-login-background__top {
	top: 0;
	height: 50%;
	background: linear-gradient(
		180deg,
		var(--es-login-blue) 0%,
		color-mix(in srgb, var(--es-login-blue) 92%, var(--es-login-blue-deep)) 100%
	);
}

body.enterprise-login .enterprise-login-background__bottom {
	top: 50%;
	bottom: 0;
	background: var(--es-login-page-bottom);
}

/* Repeated SDRB watermark via CSS (no DOM image grid) */
body.enterprise-login .enterprise-login-background__top::before,
body.enterprise-login .enterprise-login-background__bottom::before {
	content: "";
	position: absolute;
	/* Oversized + rotated for a soft diagonal lattice */
	inset: -18%;
	background-image: var(--es-login-watermark);
	background-repeat: repeat;
	background-size: 148px auto;
	transform: rotate(-14deg);
	pointer-events: none;
}

body.enterprise-login .enterprise-login-background__top::before {
	/* Lighter mark on blue */
	opacity: 0.16;
	filter: brightness(0) invert(1);
	background-position: 0 0;
}

body.enterprise-login .enterprise-login-background__bottom::before {
	/* Much softer mark on light ground */
	opacity: 0.055;
	filter: none;
	background-position: 72px 64px;
}

/* ---------- Stage / card ---------- */

body.enterprise-login .enterprise-login-stage {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: clamp(12px, 3vh, 36px) 0;
	box-sizing: border-box;
}

body.enterprise-login .enterprise-login-section {
	width: 100%;
	max-width: 520px;
	margin: 0 auto;
}

body.enterprise-login .for-forgot,
body.enterprise-login .for-login-with-email-link,
body.enterprise-login .for-signup,
body.enterprise-login .for-email-login {
	display: none;
}

body.enterprise-login .enterprise-login-card.page-card,
body.enterprise-login .login-content.page-card {
	width: 100%;
	max-width: 520px;
	margin: 0 auto;
	padding: clamp(28px, 4.5vw, 44px) clamp(22px, 4vw, 40px) clamp(22px, 3vw, 32px);
	background: #ffffff !important;
	border: 1px solid var(--es-login-card-border) !important;
	border-radius: var(--es-login-radius) !important;
	box-shadow: var(--es-login-shadow);
	box-sizing: border-box;
}

body.enterprise-login .enterprise-login-card form,
body.enterprise-login .login-content.page-card form {
	max-width: none;
	margin: 0;
	width: 100%;
}

/* ---------- Brand / logo ---------- */

body.enterprise-login .enterprise-login-brand.page-card-head {
	padding: 0 0 8px;
	margin: 0 0 8px;
	text-align: center;
}

body.enterprise-login .enterprise-login-logo,
body.enterprise-login .enterprise-login-brand img.app-logo {
	display: block;
	width: min(200px, 56%);
	max-width: 200px;
	height: auto;
	aspect-ratio: 316 / 359;
	object-fit: contain;
	margin: 0 auto 18px;
	animation: es-login-logo-breathe 4.5s ease-in-out infinite;
	will-change: transform;
}

@keyframes es-login-logo-breathe {
	0%,
	100% {
		transform: translateY(0) scale(1);
	}
	50% {
		transform: translateY(-5px) scale(1.015);
	}
}

@media (prefers-reduced-motion: reduce) {
	body.enterprise-login .enterprise-login-logo,
	body.enterprise-login .enterprise-login-brand img.app-logo {
		animation: none;
	}
}

body.enterprise-login .enterprise-login-title,
body.enterprise-login .enterprise-login-brand h1,
body.enterprise-login .enterprise-login-brand h4 {
	margin: 0;
	font-size: clamp(1.35rem, 2.4vw, 1.7rem);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
	color: var(--es-login-blue-hero);
}

body.enterprise-login .enterprise-login-title-accent {
	color: var(--es-login-primary);
}

body.enterprise-login .enterprise-login-subtitle {
	margin: 10px 0 0;
	font-size: 0.95rem;
	line-height: 1.45;
	color: var(--es-login-text-muted);
	font-weight: 400;
}

/* ---------- Fields ---------- */

body.enterprise-login .enterprise-login-fields {
	margin-top: 22px;
}

body.enterprise-login .enterprise-login-field.form-group {
	margin-bottom: 16px;
}

body.enterprise-login .enterprise-login-label.form-label {
	display: block;
	margin: 0 0 7px;
	font-size: 0.875rem;
	font-weight: 600;
	color: #334155;
	text-align: left;
	position: static !important;
	width: auto !important;
	height: auto !important;
	clip: auto !important;
	overflow: visible !important;
}

body.enterprise-login .enterprise-login-input-wrap {
	position: relative;
}

body.enterprise-login .enterprise-login-field-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	color: #94a3b8;
	pointer-events: none;
}

body.enterprise-login .enterprise-login-input.form-control,
body.enterprise-login .enterprise-login-fields input[type="text"],
body.enterprise-login .enterprise-login-fields input[type="email"],
body.enterprise-login .enterprise-login-fields input[type="password"] {
	height: 48px;
	min-height: 48px;
	padding: 0 44px 0 44px !important;
	margin-bottom: 0 !important;
	border: 1px solid var(--es-login-input-border) !important;
	border-radius: 12px !important;
	background: var(--es-login-input-bg) !important;
	color: var(--es-login-text) !important;
	font-size: 0.975rem !important;
	line-height: 1.3;
	box-shadow: none !important;
	caret-color: var(--es-login-primary);
	-webkit-text-fill-color: var(--es-login-text);
}

body.enterprise-login .enterprise-login-input.form-control::placeholder {
	color: #9aa7b8 !important;
	opacity: 1;
}

body.enterprise-login .enterprise-login-input.form-control:hover {
	border-color: #b8c4d4 !important;
}

body.enterprise-login .enterprise-login-input.form-control:focus {
	outline: none !important;
	border-color: var(--es-login-primary) !important;
	box-shadow: 0 0 0 3px var(--es-login-primary-focus) !important;
}

body.enterprise-login .page-card-body.invalid .enterprise-login-input.form-control,
body.enterprise-login .page-card-body.invalid input {
	border-color: #e11d48 !important;
}

body.enterprise-login .enterprise-login-toggle-password {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #94a3b8;
	cursor: pointer;
	font-size: 0; /* hide Frappe Show/Hide text if injected */
	line-height: 0;
}

body.enterprise-login .enterprise-login-toggle-password:hover,
body.enterprise-login .enterprise-login-toggle-password:focus-visible {
	color: var(--es-login-primary);
	background: rgba(47, 111, 191, 0.08);
	outline: none;
}

body.enterprise-login .enterprise-login-toggle-password:focus-visible {
	box-shadow: 0 0 0 3px var(--es-login-primary-focus);
}

body.enterprise-login .enterprise-login-toggle-password svg {
	display: block;
	width: 18px;
	height: 18px;
}

body.enterprise-login .enterprise-login-toggle-password.is-visible .enterprise-login-eye-open {
	display: none;
}

body.enterprise-login .enterprise-login-toggle-password.is-visible .enterprise-login-eye-closed {
	display: block !important;
}

body.enterprise-login .enterprise-login-forgot,
body.enterprise-login .forgot-password-message.enterprise-login-forgot {
	text-align: right;
	margin: -4px 0 4px;
	line-height: 1.2;
}

body.enterprise-login .enterprise-login-forgot a,
body.enterprise-login .forgot-password-message > a,
body.enterprise-login .page-card-body .forgot-password-message a {
	color: var(--es-login-primary) !important;
	font-size: 0.875rem;
	font-weight: 500;
	text-decoration: none;
}

body.enterprise-login .enterprise-login-forgot a:hover,
body.enterprise-login .enterprise-login-forgot a:focus-visible {
	text-decoration: underline;
	outline: none;
}

/* ---------- Actions ---------- */

body.enterprise-login .enterprise-login-actions {
	margin-top: 18px;
}

body.enterprise-login .enterprise-login-submit.btn-primary,
body.enterprise-login .page-card-actions .btn-primary.btn-login,
body.enterprise-login .page-card-actions .btn-primary.btn-forgot,
body.enterprise-login .page-card-actions .btn-primary.btn-login-with-email-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: 0.75rem 1rem;
	border: none !important;
	border-radius: 12px !important;
	background: linear-gradient(
		180deg,
		color-mix(in srgb, var(--es-login-primary) 92%, white) 0%,
		var(--es-login-primary) 100%
	) !important;
	color: #ffffff !important;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	box-shadow: 0 8px 18px rgba(47, 111, 191, 0.28);
	transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

body.enterprise-login .enterprise-login-submit.btn-primary:hover,
body.enterprise-login .page-card-actions .btn-primary:hover {
	background: var(--es-login-primary-hover) !important;
	transform: translateY(-1px);
	box-shadow: 0 10px 22px rgba(47, 111, 191, 0.34);
	color: #ffffff !important;
}

body.enterprise-login .enterprise-login-submit.btn-primary:focus-visible,
body.enterprise-login .page-card-actions .btn-primary:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--es-login-primary-focus), 0 8px 18px rgba(47, 111, 191, 0.28);
}

body.enterprise-login .enterprise-login-submit.btn-primary:disabled,
body.enterprise-login .enterprise-login-submit.is-busy {
	opacity: 0.78;
	cursor: not-allowed;
	transform: none;
	pointer-events: none;
}

body.enterprise-login .enterprise-login-secondary-btn,
body.enterprise-login .enterprise-login-alt-btn {
	min-height: 44px;
	border-radius: 12px !important;
	border: 1px solid var(--es-login-input-border) !important;
	background: #f8fafc !important;
	color: #334155 !important;
	font-weight: 600;
	box-shadow: none !important;
}

body.enterprise-login .enterprise-login-alt-btn:hover,
body.enterprise-login .enterprise-login-secondary-btn:hover {
	background: #eef3f9 !important;
	border-color: #c5d0de !important;
}

body.enterprise-login .enterprise-login-divider {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 20px 0 14px;
	color: var(--es-login-text-muted);
	font-size: 0.82rem;
	text-transform: lowercase;
}

body.enterprise-login .enterprise-login-divider::before,
body.enterprise-login .enterprise-login-divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: #e2e8f0;
}

body.enterprise-login .enterprise-login-divider span {
	flex: 0 0 auto;
}

body.enterprise-login .enterprise-login-alt-buttons .login-button-wrapper {
	min-width: 100% !important;
	padding: 0 !important;
	margin-bottom: 10px;
}

body.enterprise-login .enterprise-login-secure {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 18px 0 0;
	color: #94a3b8;
	font-size: 0.8rem;
	line-height: 1.3;
}

body.enterprise-login .enterprise-login-security-icon {
	flex: 0 0 auto;
	color: #94a3b8;
}

body.enterprise-login .enterprise-login-signup,
body.enterprise-login .enterprise-login-back {
	margin-top: 14px;
	color: var(--es-login-text-muted);
	font-size: 0.9rem;
}

body.enterprise-login .enterprise-login-signup a,
body.enterprise-login .enterprise-login-back a {
	color: var(--es-login-primary);
	font-weight: 600;
	text-decoration: none;
}

body.enterprise-login .enterprise-login-signup a:hover,
body.enterprise-login .enterprise-login-back a:hover {
	text-decoration: underline;
}

/* ---------- Footer ---------- */

body.enterprise-login .enterprise-login-footer {
	position: relative;
	z-index: 1;
	flex: 0 0 auto;
	padding: 8px 8px max(10px, env(safe-area-inset-bottom));
	text-align: center;
}

body.enterprise-login .enterprise-login-footer p {
	margin: 0;
	color: #94a3b8;
	font-size: 0.8rem;
	line-height: 1.4;
}

body.enterprise-login .enterprise-login-noscript {
	position: relative;
	z-index: 2;
	max-width: 420px;
	margin: 24px auto;
	padding: 20px;
	background: #fff;
	border-radius: 12px;
	text-align: center;
}

/* ---------- Auth error wiggle (preserve Frappe class) ---------- */

body.enterprise-login .invalid-login {
	animation: es-login-wiggle 0.45s linear;
}

@keyframes es-login-wiggle {
	8%,
	41% {
		transform: translateX(-8px);
	}
	25%,
	58% {
		transform: translateX(8px);
	}
	75% {
		transform: translateX(-4px);
	}
	92% {
		transform: translateX(4px);
	}
	0%,
	100% {
		transform: translateX(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	body.enterprise-login .invalid-login {
		animation: none;
	}
}

/* ---------- Dark-mode / forced-colors safety ---------- */

@media (prefers-color-scheme: dark) {
	body.enterprise-login {
		color-scheme: light;
	}

	body.enterprise-login .enterprise-login-card.page-card,
	body.enterprise-login .login-content.page-card {
		background: #ffffff !important;
		color: var(--es-login-text);
	}

	body.enterprise-login .enterprise-login-input.form-control,
	body.enterprise-login .enterprise-login-fields input {
		background: #ffffff !important;
		color: var(--es-login-text) !important;
		-webkit-text-fill-color: var(--es-login-text);
	}
}

html[data-theme="dark"] body.enterprise-login,
body.enterprise-login[data-theme="dark"] {
	/* Keep branded light login regardless of Desk theme cookie */
	background: var(--es-login-page-bottom) !important;
}

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

@media (max-width: 1024px) {
	body.enterprise-login .enterprise-login-section,
	body.enterprise-login .enterprise-login-card.page-card {
		max-width: 480px;
	}
}

@media (max-width: 768px) {
	body.enterprise-login .enterprise-login-background__top {
		height: 42%;
	}

	body.enterprise-login .enterprise-login-background__bottom {
		top: 42%;
	}

	body.enterprise-login .enterprise-login-logo,
	body.enterprise-login .enterprise-login-brand img.app-logo {
		width: min(168px, 48%);
	}

	body.enterprise-login .enterprise-login-card.page-card,
	body.enterprise-login .login-content.page-card {
		padding: 26px 20px 22px;
		border-radius: 16px !important;
	}

	body.enterprise-login .enterprise-login-background__top::before,
	body.enterprise-login .enterprise-login-background__bottom::before {
		background-size: 120px auto;
	}
}

@media (max-width: 480px) {
	body.enterprise-login {
		--es-login-gutter: 14px;
	}

	body.enterprise-login .enterprise-login-stage {
		justify-content: flex-start;
		padding-top: max(18px, 4vh);
	}

	body.enterprise-login .enterprise-login-logo,
	body.enterprise-login .enterprise-login-brand img.app-logo {
		width: min(148px, 52%);
		margin-bottom: 14px;
	}

	body.enterprise-login .enterprise-login-title {
		font-size: 1.28rem;
	}

	body.enterprise-login .enterprise-login-subtitle {
		font-size: 0.9rem;
	}

	body.enterprise-login .enterprise-login-input.form-control {
		min-height: 46px;
		height: 46px;
	}
}

/* Short viewports / landscape phones — prefer scroll over unreachable fields */
@media (max-height: 720px) {
	body.enterprise-login .enterprise-login-stage {
		justify-content: flex-start;
		padding-top: 16px;
		padding-bottom: 12px;
	}

	body.enterprise-login .enterprise-login-logo,
	body.enterprise-login .enterprise-login-brand img.app-logo {
		width: min(132px, 40%);
		margin-bottom: 10px;
	}

	body.enterprise-login .enterprise-login-fields {
		margin-top: 12px;
	}

	body.enterprise-login .enterprise-login-card.page-card {
		padding: 20px 18px 16px;
	}
}

@media (max-height: 560px) and (orientation: landscape) {
	body.enterprise-login .enterprise-login-background__top {
		height: 36%;
	}

	body.enterprise-login .enterprise-login-background__bottom {
		top: 36%;
	}

	body.enterprise-login .enterprise-login-secure {
		margin-top: 10px;
	}
}

@media (min-width: 1440px) {
	body.enterprise-login .enterprise-login-section,
	body.enterprise-login .enterprise-login-card.page-card {
		max-width: 540px;
	}
}
