/**
 * Fast Adv Transfers booking form.
 *
 * Everything is scoped under .fat-form-wrap and inherits the theme's font and
 * colour, so the form sits inside an existing Elementor page without looking
 * bolted on. Borders and surfaces are drawn with currentColor at low opacity
 * rather than fixed greys, which keeps it readable on light and dark themes.
 *
 * Four colours cannot be inherited, because a solid button, a floating panel
 * and an error need a fill of their own. Each is a token a theme can override:
 * --fat-accent, --fat-on-accent, --fat-panel and --fat-danger.
 *
 * --fat-panel and --fat-panel-text back the suggestion dropdown and the sticky
 * mobile bar. The script reads the page's real background colour on load and
 * sets both from it, so the panel matches the site rather than the visitor's
 * operating system preference. The values here are only the fallback used
 * before that runs. To pin them yourself:
 *
 *   .fat-form-wrap { --fat-panel: #fff; --fat-panel-text: #1a1a1a; }
 */

.fat-form-wrap {
	--fat-gap: 1rem;
	--fat-radius: 8px;
	--fat-line: color-mix(in srgb, currentColor 22%, transparent);
	--fat-muted: color-mix(in srgb, currentColor 65%, transparent);
	--fat-surface: color-mix(in srgb, currentColor 5%, transparent);
	--fat-accent: var(--e-global-color-primary, #1a1a1a);
	--fat-on-accent: #fff;
	--fat-panel: #fff;
	--fat-panel-text: #1a1a1a;
	--fat-danger: #b3261e;

	color: inherit;
	font-family: inherit;
	font-size: inherit;
}

@media (prefers-color-scheme: dark) {

	.fat-form-wrap {
		--fat-danger: #ff8a80;

		/* Only a fallback: the script replaces these from the real page
		   background as soon as it runs. The accent is deliberately not
		   flipped here, because a near white button on a light site would
		   disappear for a visitor whose system is set to dark. */
		--fat-panel: #16181a;
		--fat-panel-text: #f2f2f2;
	}
}

/**
 * Padding and borders must count inside a declared width, or a 100% wide input
 * grows past its grid column and overlaps the field beside it. Most themes set
 * this globally, but the form cannot assume that, so it sets it for its own
 * subtree only.
 */
.fat-form-wrap,
.fat-form-wrap *,
.fat-form-wrap *::before,
.fat-form-wrap *::after {
	box-sizing: border-box;
}

.fat-form-wrap [hidden] {
	display: none !important;
}

.fat-sr-only {
	border: 0;
	clip-path: inset(50%);
	height: 1px;
	margin: 0;
	overflow: hidden;
	padding: 0;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

.fat-form {
	display: flex;
	flex-direction: column;
	gap: var(--fat-gap);
	margin: 0;
}

.fat-form fieldset {
	border: 0;
	margin: 0;
	min-width: 0;
	padding: 0;
}

/* Progress ---------------------------------------------------------------- */

.fat-progress {
	display: flex;
	gap: 0.5rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.fat-progress__step {
	align-items: center;
	display: flex;
	flex: 1 1 0;
	font-size: 0.875em;
	gap: 0.5rem;
	min-width: 0;
	opacity: 0.45;
}

.fat-progress__step.is-current,
.fat-progress__step.is-done {
	opacity: 1;
}

.fat-progress__num {
	align-items: center;
	border: 1px solid var(--fat-line);
	border-radius: 50%;
	display: flex;
	flex: none;
	font-weight: 700;
	height: 1.9em;
	justify-content: center;
	width: 1.9em;
}

.fat-progress__step.is-current .fat-progress__num {
	background: var(--fat-accent);
	border-color: transparent;
	color: var(--fat-on-accent);
}

.fat-progress__step.is-done .fat-progress__num {
	background: var(--fat-surface);
	border-color: currentColor;
}

.fat-progress__label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fat-progress__step::after {
	background: var(--fat-line);
	content: "";
	flex: 1 1 auto;
	height: 1px;
	min-width: 0.5rem;
}

.fat-progress__step:last-child::after {
	display: none;
}

@media (max-width: 520px) {

	.fat-progress__label {
		display: none;
	}

	.fat-progress__step.is-current .fat-progress__label {
		display: block;
	}
}

/* Progressive reveal ------------------------------------------------------ */

/**
 * A short fade so a section arriving reads as a response to what the visitor
 * just chose, rather than the page jumping under them.
 */
[data-fat-reveal]:not([hidden]) {
	animation: fat-reveal 220ms ease-out;
}

@keyframes fat-reveal {

	from {
		opacity: 0;
		transform: translateY(-4px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {

	[data-fat-reveal]:not([hidden]) {
		animation: none;
	}
}

.fat-link--add::before {
	content: "+ ";
	text-decoration: none;
}

/* Steps ------------------------------------------------------------------- */

.fat-step {
	display: flex;
	flex-direction: column;
	gap: var(--fat-gap);
}

.fat-step__title {
	font-size: 1.15em;
	line-height: 1.3;
	margin: 0;
}

.fat-step__title:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

/* Rows -------------------------------------------------------------------- */

.fat-row {
	display: grid;
	gap: var(--fat-gap);
	grid-template-columns: 1fr;
}

@media (min-width: 600px) {

	.fat-row {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 900px) {

	.fat-row {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.fat-field,
.fat-destination {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	min-width: 0;
}

.fat-label {
	display: block;
	font-size: 0.875em;
	font-weight: 600;
	line-height: 1.3;
	padding: 0;
}

.fat-optional,
.fat-lock {
	color: var(--fat-muted);
	font-weight: 400;
}

/* Inputs ------------------------------------------------------------------ */

.fat-form input[type="text"],
.fat-form input[type="date"],
.fat-form input[type="time"],
.fat-form input[type="number"],
.fat-form select,
.fat-form textarea {
	background: transparent;
	border: 1px solid var(--fat-line);
	border-radius: var(--fat-radius);
	color: inherit;
	font: inherit;
	line-height: 1.4;
	max-width: 100%;
	padding: 0.65em 0.8em;
	width: 100%;
}

.fat-form textarea {
	resize: vertical;
}

.fat-form input.is-locked {
	background: var(--fat-surface);
	color: var(--fat-muted);
	cursor: default;
}

.fat-form input[aria-invalid="true"],
.fat-form select[aria-invalid="true"] {
	border-color: var(--fat-danger);
}

.fat-form input:focus-visible,
.fat-form select:focus-visible,
.fat-form textarea:focus-visible,
.fat-form button:focus-visible,
.fat-form a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.fat-error {
	color: var(--fat-danger);
	font-size: 0.85em;
	line-height: 1.35;
	margin: 0;
}

/* Trip type --------------------------------------------------------------- */

.fat-segmented {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.fat-segment {
	border: 1px solid var(--fat-line);
	border-radius: var(--fat-radius);
	cursor: pointer;
	flex: 1 1 auto;
	min-width: 8rem;
	padding: 0.65em 0.9em;
	text-align: center;
}

.fat-segment input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.fat-segment:has(input:checked) {
	background: var(--fat-surface);
	border-color: currentColor;
	box-shadow: inset 0 0 0 1px currentColor;
}

.fat-segment:has(input:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Fallback for browsers without :has(). */
.fat-segment input:checked + span {
	font-weight: 600;
}

/* Destination search ------------------------------------------------------ */

.fat-combo__box {
	position: relative;
}

.fat-combo__list {
	background: var(--fat-panel);
	border: 1px solid var(--fat-line);
	border-radius: var(--fat-radius);
	box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
	color: var(--fat-panel-text);
	left: 0;
	list-style: none;
	margin: 0;
	max-height: 16rem;
	overflow-y: auto;
	padding: 0.25rem;
	position: absolute;
	right: 0;
	top: calc(100% + 4px);
	z-index: 30;
}

.fat-combo__option {
	border-radius: calc(var(--fat-radius) - 3px);
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	margin: 0;
	padding: 0.5rem 0.65rem;
}

.fat-combo__option.is-active,
.fat-combo__option:hover {
	background: var(--fat-surface);
}

.fat-combo__name {
	line-height: 1.3;
}

.fat-combo__zone {
	color: var(--fat-muted);
	font-size: 0.8em;
}

.fat-form-wrap .fat-form .fat-link,
.fat-form-wrap .fat-form .fat-toggle {
	background: none !important;
	border: 0 !important;
	border-radius: 0;
	box-shadow: none;
	color: inherit !important;
	cursor: pointer;
	font: inherit;
	letter-spacing: normal;
	min-width: 0;
	text-decoration: underline;
	text-transform: none;
	width: auto;
}

.fat-link {
	align-self: flex-start;
	font-size: 0.85em;
	padding: 0;
}

/* Vehicles ---------------------------------------------------------------- */

.fat-vehicles {
	display: grid;
	gap: 0.5rem;
	grid-template-columns: 1fr;
}

.fat-vehicles--more {
	margin-top: 0.5rem;
}

@media (min-width: 560px) {

	.fat-vehicles--more {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 900px) {

	.fat-vehicles--more {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.fat-vehicle {
	border: 1px solid var(--fat-line);
	border-radius: var(--fat-radius);
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	padding: 0.85em;
	position: relative;
}

.fat-vehicle input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.fat-vehicle.is-selected {
	background: var(--fat-surface);
	border-color: currentColor;
	box-shadow: inset 0 0 0 1px currentColor;
}

.fat-vehicle:has(input:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* The recommendation gets the room, the alternatives stay compact. */
.fat-vehicles--primary .fat-vehicle {
	align-items: baseline;
	display: grid;
	gap: 0.15rem 1rem;
	grid-template-columns: 1fr auto;
	padding: 1.1em;
}

.fat-vehicles--primary .fat-vehicle__badge {
	grid-column: 1 / -1;
}

.fat-vehicles--primary .fat-vehicle__price {
	font-size: 1.6em;
	grid-column: 2;
	grid-row: 2 / 4;
	text-align: right;
}

.fat-vehicle__badge {
	align-self: start;
	background: var(--fat-accent);
	border-radius: 999px;
	color: var(--fat-on-accent);
	font-size: 0.7em;
	font-weight: 700;
	justify-self: start;
	letter-spacing: 0.04em;
	padding: 0.25em 0.7em;
	text-transform: uppercase;
}

.fat-vehicle__name {
	font-weight: 600;
}

.fat-vehicle__meta {
	color: var(--fat-muted);
	font-size: 0.8em;
	line-height: 1.3;
}

.fat-vehicle__price {
	font-size: 1.05em;
	font-weight: 700;
}

.fat-toggle {
	align-self: flex-start;
	font-size: 0.9em;
	padding: 0.25rem 0;
}

.fat-toggle::after {
	content: " \25BE";
	text-decoration: none;
}

.fat-toggle[aria-expanded="true"]::after {
	content: " \25B4";
}

/* Extras ------------------------------------------------------------------ */

.fat-check {
	align-items: center;
	cursor: pointer;
	display: flex;
	gap: 0.5rem;
	padding: 0.2rem 0;
}

/* Summary and navigation -------------------------------------------------- */

/**
 * The total and the button travel together at the end of the row. Anchoring
 * them as one group means the button does not sit stranded in empty space
 * while the total is still hidden, and it does not jump sideways once a price
 * appears.
 */
.fat-summary {
	align-items: center;
	border-top: 1px solid var(--fat-line);
	display: flex;
	flex-wrap: wrap;
	gap: 1.25rem;
	justify-content: flex-end;
	padding-top: var(--fat-gap);
}

.fat-total {
	align-items: baseline;
	display: flex;
	gap: 0.5rem;
}

.fat-total__label {
	color: var(--fat-muted);
	font-size: 0.8em;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.fat-total__value {
	font-size: 1.5em;
	line-height: 1.2;
}

.fat-nav {
	display: flex;
	gap: 0.5rem;
}

.fat-form-wrap .fat-form .fat-back {
	background: none !important;
	border: 1px solid var(--fat-line) !important;
	border-radius: var(--fat-radius);
	color: inherit !important;
	cursor: pointer;
	font: inherit;
	letter-spacing: normal;
	padding: 0.75em 1.25em;
	text-transform: none;
	width: auto;
}

/**
 * Themes style every <button> on the page, usually with selectors specific
 * enough to beat anything reasonable written here, and they load in an order
 * this plugin does not control. Left alone the brand colour set in the
 * settings is ignored and the buttons come out in the theme's own colours.
 * Only the properties that decide how the control reads are forced.
 */
.fat-form-wrap .fat-form .fat-submit {
	background: var(--fat-accent) !important;
	border: 1px solid var(--fat-accent) !important;
	border-radius: var(--fat-radius);
	color: var(--fat-on-accent) !important;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	letter-spacing: normal;
	min-width: 11rem;
	padding: 0.8em 1.75em;
	text-transform: none;
	width: auto;
}

.fat-submit:hover,
.fat-back:hover {
	opacity: 0.9;
}

.fat-submit:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.fat-form .fat-submit:focus-visible {
	outline: 2px solid var(--fat-accent);
	outline-offset: 2px;
}

/* Messages ---------------------------------------------------------------- */

.fat-errors {
	border: 1px solid var(--fat-danger);
	border-left-width: 4px;
	border-radius: var(--fat-radius);
	margin-bottom: var(--fat-gap);
	padding: 0.75em 1em;
}

.fat-errors ul {
	list-style: disc;
	margin: 0;
	padding-left: 1.25em;
}

.fat-unavailable {
	background: var(--fat-surface);
	border-radius: var(--fat-radius);
	margin: 0;
	padding: 0.75em 1em;
}

/* Waiting for a choice, not a problem, so it reads quieter. */
.fat-unavailable.is-hint {
	background: none;
	color: var(--fat-muted);
	font-size: 0.9em;
	padding: 0;
}

/* Sticky bar -------------------------------------------------------------- */

@media (max-width: 781px) {

	.fat-form-wrap {
		--fat-gap: 0.85rem;

		padding-bottom: 5.5rem;
	}

	.fat-summary {
		background: var(--fat-panel);
		border-top: 1px solid var(--fat-line);
		color: var(--fat-panel-text);
		bottom: 0;
		box-shadow: 0 -4px 16px rgb(0 0 0 / 12%);
		flex-wrap: nowrap;
		left: 0;
		margin: 0;
		padding: 0.75rem 1rem;
		padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
		position: fixed;
		right: 0;
		z-index: 40;
	}

	.fat-summary {
		gap: 0.75rem;
		justify-content: space-between;
	}

	.fat-summary .fat-total__value {
		font-size: 1.25em;
	}

	.fat-nav {
		flex: 1 1 auto;
		justify-content: flex-end;
	}

	.fat-submit {
		min-width: 0;
		padding-left: 1.25em;
		padding-right: 1.25em;
	}
}

@media (max-width: 360px) {

	.fat-segment {
		min-width: 100%;
	}

	.fat-summary {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
	}

	.fat-total__label {
		display: none;
	}

	.fat-submit {
		padding-left: 1em;
		padding-right: 1em;
	}
}
