/**
 * Webmail Login Form - Frontend Styles
 * Prefix: wmlf-
 * Stage 3: Form Validation, Safe Submission Processing & Advanced Password Field Controls
 *
 * @package Webmail_Login_Form
 */

/* ==========================================================================
   1. CSS Variables & Reset
   ========================================================================== */
.wmlf-container {
	--wmlf-primary-color: #0082c9;
	--wmlf-primary-hover: #006fae;
	--wmlf-secondary-color: #f35927;
	--wmlf-secondary-hover: #dc4818;
	--wmlf-border-color: #b0b3b8;
	--wmlf-focus-color: #0082c9;
	--wmlf-error-color: #dc2626;
	--wmlf-error-bg: #fffbfb;
	--wmlf-input-height: 48px;
	--wmlf-btn-height: 48px;
	--wmlf-element-spacing: 18px;

	display: flex;
	width: 100%;
	box-sizing: border-box;
	justify-content: center;
	align-items: center;
	padding-left: 16px;
	padding-right: 16px;
}

.wmlf-container *,
.wmlf-container *::before,
.wmlf-container *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   2. Form Wrapper
   ========================================================================== */
.wmlf-form {
	width: 100%;
	max-width: 380px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	background-color: transparent;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   3. Logo Section
   ========================================================================== */
.wmlf-logo-wrap {
	text-align: center;
	margin-bottom: 32px;
	display: flex;
	justify-content: center;
	align-items: center;
	width: 100%;
}

.wmlf-logo-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	outline: none;
	border: none;
	transition: opacity 0.15s ease;
}

.wmlf-logo-link:hover,
.wmlf-logo-link:focus-visible {
	opacity: 0.9;
}

.wmlf-logo-link:focus-visible {
	outline: 2px solid var(--wmlf-focus-color);
	outline-offset: 4px;
	border-radius: 4px;
}

.wmlf-logo-img {
	width: 170px;
	max-width: 240px;
	height: auto;
	display: inline-block;
	object-fit: contain;
}

.wmlf-logo-fallback {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.wmlf-logo-text {
	font-size: 2.75rem;
	font-weight: 900;
	font-style: italic;
	color: #f35927;
	letter-spacing: -0.04em;
	line-height: 1;
	user-select: none;
	text-transform: none;
}

/* ==========================================================================
   4. Status / Feedback Notice (Success & Error States)
   ========================================================================== */
.wmlf-stage-notice {
	margin-bottom: 18px;
	padding: 12px 16px;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.45;
	color: #0369a1;
	background-color: #f0f9ff;
	border: 1px solid #bae6fd;
	border-radius: 4px;
	text-align: center;
	animation: wmlf-notice-appear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
	word-break: break-word;
}

.wmlf-stage-notice.wmlf-notice-success {
	color: #166534;
	background-color: #f0fdf4;
	border-color: #bbf7d0;
}

.wmlf-stage-notice.wmlf-notice-error {
	color: #991b1b;
	background-color: #fef2f2;
	border-color: #fecaca;
}

@keyframes wmlf-notice-appear {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ==========================================================================
   5. Field Groups & Labels
   ========================================================================== */
.wmlf-field-group {
	margin-bottom: 18px;
	display: flex;
	flex-direction: column;
	position: relative;
	width: 100%;
}

.wmlf-label {
	display: block;
	font-size: 0.9375rem;
	font-weight: 500;
	color: #333333;
	margin-bottom: 6px;
	line-height: 1.35;
	text-align: left;
	cursor: pointer;
}

.wmlf-input-wrap {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
}

/* ==========================================================================
   6. Input Left Icons
   ========================================================================== */
.wmlf-input-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	color: #8c939d;
	z-index: 2;
	transition: color 0.15s ease;
	line-height: 1;
}

.wmlf-input-icon svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
	display: block;
}

.wmlf-input-wrap:focus-within .wmlf-input-icon {
	color: var(--wmlf-focus-color);
}

/* ==========================================================================
   7. Form Inputs & Masking
   ========================================================================== */
.wmlf-input {
	width: 100%;
	height: 48px;
	padding: 8px 14px 8px 44px;
	font-size: 0.9375rem;
	color: #222222;
	background-color: #ffffff;
	border: 1px solid #b0b3b8;
	border-radius: 3px;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
	line-height: normal;
	box-shadow: none;
	appearance: none;
	-webkit-appearance: none;
}

.wmlf-input::placeholder {
	color: #757575;
	opacity: 1;
}

.wmlf-input:focus {
	border-color: #0082c9;
	box-shadow: 0 0 0 1px #0082c9;
}

.wmlf-input:focus-visible {
	outline: 2px solid #0082c9;
	outline-offset: 1px;
}

.wmlf-input-password {
	padding-right: 44px;
}

/**
 * Case 3 Password Masking:
 * Used when Password Field Type is 'text' but Frontend Masking is 'always_masked'.
 * Allows the browser to handle the element as a text input while visually masking characters.
 */
.wmlf-masked-text {
	-webkit-text-security: disc !important;
	text-security: disc !important;
}

/* Validation error state */
.wmlf-input.wmlf-input-error {
	border-color: #dc2626 !important;
	box-shadow: 0 0 0 1px #dc2626 !important;
	background-color: #fffbfb;
}

.wmlf-input.wmlf-input-error:focus-visible {
	outline-color: #dc2626 !important;
}

/* Accessible inline error feedback */
.wmlf-field-error {
	margin-top: 6px;
	font-size: 0.8125rem;
	line-height: 1.35;
	color: #dc2626;
	font-weight: 500;
	text-align: left;
	animation: wmlf-notice-appear 0.15s ease-out;
}

/* ==========================================================================
   8. Password Show / Hide Toggle
   ========================================================================== */
.wmlf-password-toggle {
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	background: transparent;
	border: none;
	padding: 6px;
	min-width: 36px;
	min-height: 36px;
	cursor: pointer;
	color: #8c939d;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: color 0.15s ease, background-color 0.15s ease;
	line-height: 1;
	z-index: 3;
}

.wmlf-password-toggle:hover {
	color: #4b5563;
	background-color: rgba(0, 0, 0, 0.04);
}

.wmlf-password-toggle:focus-visible {
	outline: 2px solid var(--wmlf-focus-color);
	outline-offset: 1px;
	color: #4b5563;
}

.wmlf-password-toggle svg {
	width: 18px;
	height: 18px;
	display: block;
}

/* ==========================================================================
   9. Buttons, Loading Spinner & Action Groups
   ========================================================================== */
.wmlf-action-group {
	margin-top: 2px;
	margin-bottom: 18px;
	width: 100%;
}

.wmlf-button {
	width: 100%;
	height: 48px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	border: none;
	border-radius: 4px;
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	line-height: 1;
	user-select: none;
	box-shadow: none;
}

.wmlf-button:focus-visible {
	outline: 2px solid var(--wmlf-focus-color);
	outline-offset: 2px;
}

.wmlf-button:active:not(:disabled) {
	transform: scale(0.99);
}

.wmlf-button:disabled,
.wmlf-button.is-loading {
	opacity: 0.72;
	cursor: not-allowed !important;
	pointer-events: none;
}

.wmlf-btn-spinner {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.wmlf-spin {
	animation: wmlf-spin 0.8s linear infinite;
}

@keyframes wmlf-spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

.wmlf-btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.wmlf-btn-icon svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
	display: block;
}

.wmlf-btn-icon-left {
	margin-right: 8px;
}

.wmlf-btn-icon-right {
	margin-left: 8px;
}

/* Primary Button (cPanel Webmail Blue) */
.wmlf-button-primary {
	background-color: #0082c9;
	color: #ffffff;
}

.wmlf-button-primary:hover:not(:disabled),
.wmlf-button-primary:focus:not(:disabled) {
	background-color: #006fae;
	color: #ffffff;
}

/* Secondary Button (cPanel Orange) */
.wmlf-button-secondary {
	background-color: #f35927;
	color: #ffffff;
}

.wmlf-button-secondary:hover:not(:disabled),
.wmlf-button-secondary:focus:not(:disabled) {
	background-color: #dc4818;
	color: #ffffff;
}

.wmlf-cpanel-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.wmlf-cpanel-badge svg {
	width: 22px;
	height: 14px;
	fill: #ffffff;
	display: block;
}

/* ==========================================================================
   10. OR Divider
   ========================================================================== */
.wmlf-divider {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	margin: 22px 0;
	position: relative;
}

.wmlf-divider-line {
	flex: 1;
	height: 1px;
	background-color: #d1d5db;
}

.wmlf-divider-text {
	padding: 4px 10px;
	font-size: 0.75rem;
	font-weight: 700;
	color: #6b7280;
	border: 1px solid #d1d5db;
	border-radius: 9999px;
	background-color: #ffffff;
	margin: 0 12px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	line-height: 1;
	user-select: none;
}

/* ==========================================================================
   11. Responsive Layout & Mobile Optimization
   ========================================================================== */
@media (max-width: 480px) {
	.wmlf-container {
		padding-left: 12px;
		padding-right: 12px;
	}

	.wmlf-form {
		max-width: 100%;
	}

	.wmlf-input {
		font-size: 16px; /* Prevents auto-zooming on iOS Safari */
		height: 46px;
	}

	.wmlf-button {
		height: 46px;
	}

	.wmlf-logo-text {
		font-size: 2.25rem;
	}

	.wmlf-divider {
		margin: 18px 0;
	}
}

@media (max-width: 360px) {
	.wmlf-container {
		padding-left: 8px;
		padding-right: 8px;
	}

	.wmlf-logo-text {
		font-size: 2rem;
	}

	.wmlf-input {
		padding-left: 38px;
	}

	.wmlf-input-icon {
		left: 10px;
	}
}
