/* =============================================================================
   CartFlows Pro — Smart Login
   ============================================================================= */

/* Overlay mode: keep the inline login UIs hidden regardless of which layout
   is being rendered.
   - `.wcf-customer-login-section` is emitted by the modern / instant /
     multistep renderers; the free plugin slides this down on email match.
   - `form.woocommerce-form-login.login` is rendered by WooCommerce's default
     checkout template on the legacy one-column / two-column / two-step
     layouts (raw [woocommerce_checkout] shortcode) and would otherwise be
     toggled visible when its `.showlogin` link is clicked.
   Both must stay hidden so the modal is the only login surface.
   ============================================================================= */
body.wcf-smart-login-overlay-mode .wcf-customer-login-section,
body.wcf-smart-login-overlay-mode form.woocommerce-form-login.login {
	display: none !important;
}

/* Body scroll lock — applied only while the modal is open.
   `overflow: hidden` prevents background scroll on iOS Safari.
   ============================================================================= */
body.wcf-smart-login-open {
	overflow: hidden;
}

.wcf-smart-login-modal__form {
	margin: 0;
}

/* Overlay backdrop — covers the whole viewport, sits just below the modal.
   z-index 99999 sits at the same level as the WP admin bar; the modal at
   100000 ensures it always paints above admin chrome.
   ============================================================================= */
.wcf-smart-login-overlay {
	position: fixed;
	inset: 0;
	background: rgba( 0, 0, 0, 0.6 );
	z-index: 99999;
}

/* Modal card — fixed centering via top/left 50% + translate(-50%, -50%).
   Use `dvh` (dynamic viewport height) for correct sizing under iOS Safari's
   collapsing URL bar. Sits one z-index above the backdrop.
   ============================================================================= */
.wcf-smart-login-modal {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	background: #fff;
	border-radius: 8px;
	width: 95vw;
	max-width: min( 430px, 95vw );
	/* stylelint-disable-next-line unit-no-unknown -- dvh handles iOS Safari URL bar correctly */
	max-height: 90dvh;
	overflow: auto;
	z-index: 100000;
	padding: 25px 32px 32px;
	box-shadow: 0 10px 40px rgba( 0, 0, 0, 0.15 );
}

/* Modal header
   ============================================================================= */
.wcf-smart-login-modal__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.wcf-smart-login-modal__title {
	font-size: 20px;
	font-weight: 600;
	color: #222;
	margin: 0;
}

.wcf-smart-login-modal__close {
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	color: #666;
	padding: 0;
	min-width: 30px;
	min-height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
}

.wcf-smart-login-modal__close:hover {
	color: #333;
}

.wcf-smart-login-modal__close:focus-visible {
	outline: 2px solid var( --wcf-primary-color, #0073aa );
	outline-offset: 2px;
}

/* Modal form fields
   ============================================================================= */
.wcf-smart-login-modal__field:not( :last-child ) {
	margin-bottom: 16px;
}

.wcf-smart-login-modal__field label {
	display: block;
	margin-bottom: 6px;
	font-weight: 500;
	font-size: 14px;
	color: #444;
}

.wcf-smart-login-modal__field input[type="email"],
.wcf-smart-login-modal__field input[type="password"],
.wcf-smart-login-modal__field input[type="text"] {
	width: 100%;
	padding: var( --wcf-smart-login-field-padding, 12px 14px );
	background: var( --wcf-field-bg-color, #fff );
	border: 1px solid var( --wcf-field-border-color, #dedede );
	border-radius: var( --wcf-smart-login-field-radius, 5px );
	color: var( --wcf-field-text-color, #555 );
	font-size: 14px;
	min-height: var( --wcf-field-min-height, 44px );
	box-sizing: border-box;
	transition: border-color 0.2s;
}

.wcf-smart-login-modal__field input:focus {
	border-color: var( --wcf-primary-color, #0073aa );
	outline: none;
	box-shadow: 0 0 0 2px rgba( 0, 115, 170, 0.15 );
}

.wcf-smart-login-modal__field input:focus-visible {
	outline: 2px solid var( --wcf-primary-color, #0073aa );
	outline-offset: 2px;
}

/* Modal submit button
   Inherits global button colours from the CartFlows CSS variables defined at
   :root (and overridden per page builder / per-step design settings).
   Per-step padding, font and height are applied via checkout-pro-dynamic-css.php.
   ============================================================================= */
.wcf-smart-login-modal__submit {
	width: 100%;
	padding: 12px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	background-color: var( --wcf-btn-bg-color );
	border-color: var( --wcf-btn-bg-color );
	color: var( --wcf-btn-text-color );
}

.wcf-smart-login-modal__submit:hover {
	background-color: var( --wcf-btn-bg-hover-color );
	border-color: var( --wcf-btn-bg-hover-color );
	color: var( --wcf-btn-hover-text-color );
}

.wcf-smart-login-modal__submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Remember-me + forgot-link row (and Back-to-Login row in the forgot view).
   ============================================================================= */
.wcf-smart-login-modal__row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
	font-size: 13px;
	color: #555;
}

.wcf-smart-login-modal__remember {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}

.wcf-smart-login-forgot-link,
.wcf-smart-login-modal__forgot-link,
.wcf-smart-login-modal__back-link {
	color: var( --wcf-primary-color, #0073aa );
	text-decoration: none;
	background: transparent;
	border: 0;
	padding: 0;
	font: inherit;
	cursor: pointer;
}

.wcf-smart-login-forgot-link:hover {
	text-decoration: underline;
}

.wcf-smart-login-forgot-link:focus-visible {
	outline: 2px solid var( --wcf-primary-color, #0073aa );
	outline-offset: 2px;
}

/* Back to login link
   ============================================================================= */
.wcf-smart-login-modal__back-link {
	text-align: center;
	margin-top: 16px;
}

.wcf-smart-login-back-link {
	color: var( --wcf-primary-color, #0073aa );
	text-decoration: none;
	font-size: 13px;
}

.wcf-smart-login-back-link:hover {
	text-decoration: underline;
}

.wcf-smart-login-back-link:focus-visible {
	outline: 2px solid var( --wcf-primary-color, #0073aa );
	outline-offset: 2px;
}

/* Error and success messages
   ============================================================================= */
.wcf-smart-login-modal__error {
	color: #c00;
	background: #fff0f0;
	border: 1px solid #f5c6c6;
	border-radius: 4px;
	padding: 8px 12px;
	margin-bottom: 12px;
	font-size: 13px;
}

.wcf-smart-login-modal__success {
	color: #0a5c0a;
	background: #f0fff0;
	border: 1px solid #c6e8c6;
	border-radius: 4px;
	padding: 8px 12px;
	margin-bottom: 12px;
	font-size: 13px;
}

/* Mobile
   ============================================================================= */
@media ( max-width: 480px ) {
	.wcf-smart-login-modal {
		width: calc( 100vw - 32px );
		padding: 20px;
	}

	.wcf-smart-login-modal__title {
		font-size: 17px;
	}

	.wcf-smart-login-modal__row {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}
}

/* Reduced motion — respect user preference, disable transitions and animations.
   ============================================================================= */
@media ( prefers-reduced-motion: reduce ) {
	.wcf-smart-login-modal,
	.wcf-smart-login-overlay,
	.wcf-smart-login-modal__submit {
		transition: none !important;
		animation: none !important;
	}
}

/* View switching — driven by data-view on the modal. The off-view form and
   off-view title are hidden via attribute selectors. The browser default
   `[hidden] { display: none }` overrides the position:fixed on the modal /
   overlay until JS removes the attribute on open.
   ============================================================================= */
.wcf-smart-login-modal[data-view="login"] [data-view-only="forgot"],
.wcf-smart-login-modal[data-view="forgot"] [data-view-only="login"] {
	display: none;
}

.wcf-smart-login-modal[data-view="login"] [data-view-title="forgot"],
.wcf-smart-login-modal[data-view="forgot"] [data-view-title="login"] {
	display: none;
}
