/**
 * The deposit popup.
 *
 * Everything is scoped under .vf-deposit. That is not tidiness — this stylesheet
 * loads on car pages that already carry a model stylesheet of their own, and the
 * model stylesheets are ports of VinFast's markup where bare `section`, `img`,
 * `h2`, `p` and `.btn` are all styled. A rule here that is not scoped would be
 * fighting nine of those at once.
 *
 * Three things Flatsome already owns and that had to be undone rather than
 * out-specified:
 *
 *   `button`  — flatsome.css gives the bare tag min-height:2.5em, min-width:24px,
 *               margin-right:1em, padding:0 1.2em, line-height:2.4em and
 *               text-transform:uppercase. The two min-* are the half that hurts,
 *               because a minimum beats the width and height a later, more
 *               specific rule sets: the 36px close button computes to 44px tall
 *               and sits an em away from the corner it was aimed at. Same trap
 *               assets/css/models/minio.css records at length.
 *
 *   [hidden]  — is display:none in the *browser's* stylesheet, the weakest sheet
 *               there is, so the `display:flex` below would silently un-hide the
 *               modal and every page would load with the form already open. The
 *               !important rule is what stops that. Same as
 *               `.vf6 [hidden]` in assets/css/models/vf6.css.
 *
 *   inputs    — Flatsome styles input[type=text], input[type=tel], textarea and
 *               input[type=submit] on the bare selectors, so each is set out in
 *               full here rather than adjusted.
 */

.vf-deposit {
	--vf-deposit-blue: #1464f4;
	--vf-deposit-ink: #0f172a;
	--vf-deposit-muted: #64748b;
	--vf-deposit-line: #dfe3ea;
	--vf-deposit-error: #d02b2b;

	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	font-family: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.vf-deposit[hidden] {
	display: none !important;
}

.vf-deposit__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 15, 26, 0.62);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.vf-deposit.is-open .vf-deposit__backdrop {
	opacity: 1;
}

.vf-deposit__dialog {
	position: relative;
	width: 100%;
	max-width: 460px;
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	background: #fff;
	border-radius: 16px;
	padding: 34px 28px 28px;
	box-shadow: 0 24px 64px rgba(10, 15, 26, 0.28);
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.vf-deposit.is-open .vf-deposit__dialog {
	opacity: 1;
	transform: none;
}

/* ---------------------------------------------------------------- close */

.vf-deposit__close {
	position: absolute;
	top: 12px;
	right: 12px;
	/* The four Flatsome inherits, undone. */
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	line-height: 1;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--vf-deposit-muted);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.vf-deposit__close:hover,
.vf-deposit__close:focus-visible {
	background: #f1f4f9;
	color: var(--vf-deposit-ink);
}

.vf-deposit__close svg {
	width: 20px;
	height: 20px;
	fill: none;
	display: block;
}

/* ----------------------------------------------------------------- head */

.vf-deposit__head {
	margin-bottom: 22px;
	padding-right: 32px;
}

.vf-deposit__title {
	margin: 0;
	font-size: 22px;
	font-weight: 800;
	line-height: 1.25;
	letter-spacing: -0.01em;
	color: var(--vf-deposit-ink);
	text-transform: none;
}

.vf-deposit__model {
	margin: 10px 0 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--vf-deposit-muted);
}

.vf-deposit__model strong {
	color: var(--vf-deposit-blue);
	font-weight: 800;
}

.vf-deposit__intro {
	margin: 8px 0 0;
	font-size: 14px;
	line-height: 1.55;
	color: var(--vf-deposit-muted);
}

/* ----------------------------------------------------------------- form */

.vf-deposit__body .wpcf7 {
	margin: 0;
}

.vf-deposit__body .wpcf7-form > p {
	margin: 0 0 16px;
}

.vf-deposit-field {
	display: block;
	margin: 0;
	font-size: 14px;
	color: var(--vf-deposit-ink);
}

.vf-deposit-label {
	display: block;
	margin-bottom: 7px;
	font-weight: 700;
	line-height: 1.3;
}

.vf-deposit-label i {
	color: var(--vf-deposit-error);
	font-style: normal;
}

.vf-deposit__body input[type="text"],
.vf-deposit__body input[type="tel"],
.vf-deposit__body textarea {
	display: block;
	width: 100%;
	margin: 0;
	padding: 12px 14px;
	box-sizing: border-box;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.4;
	color: var(--vf-deposit-ink);
	background: #fff;
	border: 1px solid var(--vf-deposit-line);
	border-radius: 10px;
	box-shadow: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vf-deposit__body textarea {
	min-height: 88px;
	resize: vertical;
}

.vf-deposit__body input[type="text"]::placeholder,
.vf-deposit__body input[type="tel"]::placeholder,
.vf-deposit__body textarea::placeholder {
	color: #a5adba;
}

.vf-deposit__body input[type="text"]:focus,
.vf-deposit__body input[type="tel"]:focus,
.vf-deposit__body textarea:focus {
	outline: none;
	border-color: var(--vf-deposit-blue);
	box-shadow: 0 0 0 3px rgba(20, 100, 244, 0.15);
}

.vf-deposit__body .wpcf7-not-valid {
	border-color: var(--vf-deposit-error);
}

/**
 * The message under a field it rejected.
 *
 * Three classes deep, and the background and padding are reset rather than left
 * alone: something in the stack draws this as a full-width grey band under the
 * input — measured in the browser, where it came out with a grey fill the field
 * above it does not have. Two boxes stacked, one grey and one white, read as a
 * second field rather than as an error about the first.
 */
.vf-deposit__body .wpcf7-form .wpcf7-not-valid-tip {
	display: block;
	margin-top: 6px;
	padding: 0;
	border: 0;
	background: none;
	font-size: 13px;
	line-height: 1.4;
	font-weight: 600;
	color: var(--vf-deposit-error);
}

/* --------------------------------------------------------------- submit */

/**
 * The submit row is styled twice on purpose.
 *
 * CF7 runs its form template through wpcf7_autop(), which wraps the inline
 * content of a block-level element in a <p> — so what arrives is
 * `<div class="vf-deposit-actions"><p><input type="submit"><input type="hidden"></p></div>`
 * and not the flex row the div alone would have made. Styling both the div and
 * the paragraph inside it means the row is right whether autop wrapped it or not,
 * which matters because that is a plugin's formatting decision and not ours.
 *
 * The spinner is a third child: CF7's script inserts
 * `<span class="wpcf7-spinner">` immediately after any `.has-spinner` control the
 * moment the form initialises, so the row must have room for it before it exists.
 */
.vf-deposit-actions,
.vf-deposit-actions > p {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
}

.vf-deposit-actions {
	margin-top: 22px;
}

.vf-deposit-actions > p {
	flex: 1 1 auto;
	min-width: 0;
}

.vf-deposit__body input[type="submit"] {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 14px 20px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 800;
	line-height: 1.2;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #fff;
	background: var(--vf-deposit-blue);
	border: 0;
	border-radius: 10px;
	box-shadow: none;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.1s ease;
}

.vf-deposit__body input[type="submit"]:hover {
	background: #0d51cd;
}

.vf-deposit__body input[type="submit"]:active {
	transform: translateY(1px);
}

.vf-deposit__body input[type="submit"]:disabled {
	opacity: 0.6;
	cursor: default;
}

.vf-deposit__note {
	margin: 14px 0 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--vf-deposit-muted);
}

.vf-deposit__note a {
	color: var(--vf-deposit-blue);
}

/* -------------------------------------------------------------- replies */

/**
 * Four classes deep, on purpose — and counted rather than guessed.
 *
 * Contact Form 7's own stylesheet colours this box per status from selectors like
 * `.wpcf7 form.invalid .wpcf7-response-output`: three classes *and an element*,
 * so (0,3,1). A three-class rule here reads as heavier than it is and loses — the
 * box came out with CF7's 2px #ffb900 border inside an otherwise red panel, which
 * is a screenshot away and invisible in the CSS. Four classes clears every one of
 * them without an !important.
 */
.vf-deposit .vf-deposit__body .wpcf7-form .wpcf7-response-output {
	margin: 18px 0 0;
	padding: 13px 15px;
	font-size: 14px;
	line-height: 1.5;
	border: 1px solid var(--vf-deposit-error);
	border-radius: 10px;
	color: var(--vf-deposit-error);
	background: #fff5f5;
}

.vf-deposit .vf-deposit__body .wpcf7-form.sent .wpcf7-response-output {
	border-color: #1f9d55;
	color: #14663a;
	background: #eefaf2;
	margin-top: 0;
	padding: 18px;
	font-size: 15px;
	text-align: center;
}

/**
 * After a successful send, the fields go and the message stays.
 *
 * Contact Form 7 puts a `sent` class on the form itself, so this needs no script
 * — which matters, because the alternative is a dialog that still shows an empty
 * form under the words "cảm ơn" and invites a second identical submission.
 */
.vf-deposit__body .wpcf7-form.sent > p,
.vf-deposit__body .wpcf7-form.sent .vf-deposit-actions,
.vf-deposit__body .wpcf7-form.sent .vf-deposit__note {
	display: none;
}

.vf-deposit__body .wpcf7-spinner {
	margin: 0;
}

/* ------------------------------------------------------------ responsive */

/**
 * On a phone the dialog is a sheet off the bottom edge.
 *
 * A centred card on a 390px screen with the keyboard open leaves the submit
 * button under the keyboard and nothing to scroll to it with. Anchored to the
 * bottom, the field being typed into and the button stay together.
 */
@media (max-width: 600px) {
	.vf-deposit {
		align-items: flex-end;
		padding: 0;
	}

	.vf-deposit__dialog {
		max-width: none;
		max-height: 92vh;
		max-height: 92dvh;
		border-radius: 20px 20px 0 0;
		padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
		transform: translateY(28px);
	}

	.vf-deposit__title {
		font-size: 20px;
	}

	.vf-deposit__body input[type="text"],
	.vf-deposit__body input[type="tel"],
	.vf-deposit__body textarea {
		/* 16px or iOS zooms the whole page in when the field takes focus, and
		   never zooms back out. */
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vf-deposit__backdrop,
	.vf-deposit__dialog {
		transition: none;
	}

	.vf-deposit__dialog {
		transform: none;
	}
}
