/* ==========================================================================
   Safe & Cozy — search bar
   The hero booking strip, plus its two popovers: an Airbnb-style range
   calendar and a MakeMyTrip-style guest stepper.

   Field names match [rv_search_form], so this whole component becomes a
   template override at yourtheme/rv-rental-booking/search-form.php.
   ========================================================================== */

.sc-searchbar {
	position: relative;
	display: flex;
	align-items: stretch;
	gap: var(--sc-space-2);
	width: 100%;
	/* About 1000px at desktop width in every design. */
	max-width: 1000px;
	padding: var(--sc-space-2);
	border-radius: var(--sc-radius-xl);
	background: var(--sc-surface);
	box-shadow: var(--sc-shadow-bar);
}

/* --- Fields --------------------------------------------------------------- */

.sc-searchbar__field {
	display: flex;
	flex: 1 1 0;
	min-width: 0;
	border-radius: var(--sc-radius-lg);
	transition: background-color var(--sc-dur) var(--sc-ease);
}

/* Place names run longer than "Add guests", so the first field gets a little
   more room rather than truncating. */
.sc-searchbar__field[data-sc-field="location"] {
	flex-grow: 1.3;
}

.sc-searchbar__field + .sc-searchbar__field {
	box-shadow: -1px 0 0 var(--sc-line);
}

/* The open segment lifts out of the bar, the way Airbnb highlights it. */
.sc-searchbar__field.is-open {
	background: var(--sc-cream);
	box-shadow: none;
}

.sc-searchbar__field.is-open + .sc-searchbar__field,
.sc-searchbar__field:has(+ .sc-searchbar__field.is-open) {
	box-shadow: none;
}

/* Label and trigger share a layout so an <input> and a <button> field match. */
.sc-searchbar__control {
	display: flex;
	align-items: center;
	gap: var(--sc-space-3);
	width: 100%;
	min-width: 0;
	padding: var(--sc-space-3) var(--sc-space-4);
	border: 0;
	border-radius: inherit;
	background: none;
	color: var(--sc-green-900);
	text-align: left;
	cursor: pointer;
}

.sc-searchbar__control svg {
	width: 22px;
	height: 22px;
	color: var(--sc-green-900);
}

/* Takes the field's width. Left to size itself it wraps the text box, which
   a browser draws 20 characters wide — too short for "Where do you want to
   go?" however wide the field is. */
.sc-searchbar__text {
	flex: 1 1 auto;
	min-width: 0;
}

.sc-searchbar__label {
	display: block;
	margin-bottom: 2px;
	color: var(--sc-muted);
	font-size: 13px;
	line-height: 1.2;
}

.sc-searchbar__input,
.sc-searchbar__value {
	display: block;
	width: 100%;
	min-width: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--sc-ink);
	font: inherit;
	font-size: var(--sc-fs-sm);
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sc-searchbar__input::placeholder {
	color: var(--sc-ink);
	opacity: 1;
	font-weight: 600;
}

.sc-searchbar__input:focus {
	outline: 0;
}

/* Nothing chosen yet — read as placeholder, not as a value. */
.sc-searchbar__value.is-empty {
	color: var(--sc-ink);
}

.sc-searchbar__submit {
	flex: none;
	align-self: center;
	padding-block: 15.2px;
	padding-inline: var(--sc-space-8);
	border-radius: var(--sc-radius-md);
	font-size: var(--sc-fs-body);
}

/* --------------------------------------------------------------------------
   Popovers
   -------------------------------------------------------------------------- */

.sc-pop {
	position: absolute;
	top: calc(100% + 12px);
	left: 0;
	/* Above the sticky header, which sits at 50. */
	z-index: 60;
	padding: var(--sc-space-5);
	border: 1px solid var(--sc-line-soft);
	border-radius: var(--sc-radius-lg);
	background: var(--sc-surface);
	box-shadow: 0 10px 44px rgb(20 40 30 / 18%);
	color: var(--sc-body);
}

.sc-pop[hidden] {
	display: none;
}

.sc-pop__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sc-space-4);
	margin-top: var(--sc-space-4);
	padding-top: var(--sc-space-4);
	border-top: 1px solid var(--sc-line-soft);
}

.sc-pop__hint {
	font-size: var(--sc-fs-xs);
	color: var(--sc-muted);
}

.sc-pop__link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--sc-green-900);
	font-size: var(--sc-fs-xs);
	font-weight: 700;
	text-decoration: underline;
	cursor: pointer;
}

.sc-pop__done {
	padding: 8px 17.6px;
	border: 0;
	border-radius: var(--sc-radius-sm);
	background: var(--sc-green-900);
	color: var(--sc-on-dark);
	font-size: var(--sc-fs-xs);
	font-weight: 700;
	cursor: pointer;
}

.sc-pop__done:hover {
	background: var(--sc-green-700);
}

/* --------------------------------------------------------------------------
   Calendar
   -------------------------------------------------------------------------- */

.sc-cal__head {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: var(--sc-space-3);
}

.sc-cal__nav {
	position: absolute;
	top: 50%;
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	margin-top: -16px;
	border: 1px solid var(--sc-line);
	border-radius: var(--sc-radius-pill);
	background: var(--sc-surface);
	color: var(--sc-green-900);
	cursor: pointer;
	transition: border-color var(--sc-dur) var(--sc-ease);
}

.sc-cal__nav:hover:not(:disabled) {
	border-color: var(--sc-green-900);
}

.sc-cal__nav:disabled {
	opacity: 0.3;
	cursor: default;
}

.sc-cal__nav svg {
	width: 14px;
	height: 14px;
}

.sc-cal__nav--prev {
	left: 0;
}

.sc-cal__nav--prev svg {
	transform: rotate(90deg);
}

.sc-cal__nav--next {
	right: 0;
}

.sc-cal__nav--next svg {
	transform: rotate(-90deg);
}

.sc-cal__months {
	display: flex;
	gap: var(--sc-space-8);
}

.sc-cal__month {
	width: 266px;
}

.sc-cal__caption {
	margin-bottom: var(--sc-space-3);
	color: var(--sc-green-900);
	font-size: var(--sc-fs-sm);
	font-weight: 700;
	text-align: center;
}

.sc-cal__grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
}

.sc-cal__dow {
	padding-bottom: var(--sc-space-2);
	color: var(--sc-muted);
	font-size: 11px;
	font-weight: 600;
	text-align: center;
}

/* The cell carries the range band; the button inside carries the circle. */
.sc-cal__cell {
	position: relative;
	padding: 1px 0;
}

.sc-cal__cell.is-in-range {
	background: var(--sc-cream);
}

.sc-cal__cell.is-start {
	background: linear-gradient(to right, transparent 50%, var(--sc-cream) 50%);
}

.sc-cal__cell.is-end {
	background: linear-gradient(to left, transparent 50%, var(--sc-cream) 50%);
}

.sc-cal__cell.is-start.is-end {
	background: none;
}

.sc-cal__day {
	display: grid;
	place-items: center;
	width: 100%;
	aspect-ratio: 1;
	padding: 0;
	border: 0;
	border-radius: var(--sc-radius-pill);
	background: none;
	color: var(--sc-ink);
	font-size: var(--sc-fs-xs);
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s var(--sc-ease),
		color 0.15s var(--sc-ease);
}

/* Endpoints keep their dark circle under the cursor. */
.sc-cal__cell:not(.is-start):not(.is-end) .sc-cal__day:hover:not(:disabled) {
	background: var(--sc-line-soft);
}

.sc-cal__day:disabled {
	color: var(--sc-line);
	cursor: default;
	text-decoration: line-through;
}

.sc-cal__day.is-today {
	font-weight: 800;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.sc-cal__cell.is-start .sc-cal__day,
.sc-cal__cell.is-end .sc-cal__day {
	background: var(--sc-green-900);
	color: var(--sc-on-dark);
	font-weight: 700;
}

/* --------------------------------------------------------------------------
   Guest stepper
   -------------------------------------------------------------------------- */

.sc-pop--guests {
	left: auto;
	right: 0;
	width: 340px;
}

.sc-guest {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sc-space-4);
	padding-block: var(--sc-space-3);
}

.sc-guest + .sc-guest {
	border-top: 1px solid var(--sc-line-soft);
}

.sc-guest__name {
	display: block;
	color: var(--sc-green-900);
	font-size: var(--sc-fs-sm);
	font-weight: 700;
}

.sc-guest__note {
	display: block;
	color: var(--sc-muted);
	font-size: var(--sc-fs-xs);
}

.sc-guest__stepper {
	display: flex;
	align-items: center;
	gap: var(--sc-space-3);
	flex: none;
}

.sc-guest__btn {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--sc-line);
	border-radius: var(--sc-radius-pill);
	background: var(--sc-surface);
	color: var(--sc-green-900);
	cursor: pointer;
	transition: border-color var(--sc-dur) var(--sc-ease),
		color var(--sc-dur) var(--sc-ease);
}

.sc-guest__btn:hover:not(:disabled) {
	border-color: var(--sc-green-900);
}

.sc-guest__btn:disabled {
	border-color: var(--sc-line-soft);
	color: var(--sc-line);
	cursor: default;
}

.sc-guest__btn svg {
	width: 13px;
	height: 13px;
}

.sc-guest__count {
	min-width: 24px;
	color: var(--sc-ink);
	font-size: var(--sc-fs-sm);
	font-weight: 600;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Narrow screens
   -------------------------------------------------------------------------- */

/* Three fields plus a button never fit comfortably below ~1000px, so the bar
   stacks for the whole tablet range rather than squeezing the labels. */
@media (max-width: 991px) {
	.sc-searchbar {
		flex-direction: column;
		gap: 0;
		padding: var(--sc-space-2) var(--sc-space-2) var(--sc-space-3);
	}

	.sc-searchbar__field + .sc-searchbar__field {
		box-shadow: 0 -1px 0 var(--sc-line);
	}

	.sc-searchbar__field.is-open,
	.sc-searchbar__field.is-open + .sc-searchbar__field {
		box-shadow: none;
	}

	.sc-searchbar__submit {
		align-self: stretch;
		margin-top: var(--sc-space-3);
		margin-inline: var(--sc-space-2);
		padding-block: 13.6px;
	}

	/* Popovers span the bar instead of hanging off one segment. */
	.sc-pop {
		left: 0;
		right: 0;
		width: auto;
		max-height: min(70vh, 512px);
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.sc-cal__months {
		gap: var(--sc-space-6);
	}

	.sc-cal__month {
		width: 100%;
	}
}

/* One month at a time once two will not fit. */
@media (max-width: 700px) {
	.sc-cal__month + .sc-cal__month {
		display: none;
	}
}

/* --------------------------------------------------------------------------
   Location suggestions
   -------------------------------------------------------------------------- */

.sc-pop--locations {
	width: min(380px, 100%);
	max-height: 340px;
	overflow-y: auto;
	padding: 8px;
}

.sc-locations__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: 10px;
	color: var(--sc-ink);
	font-size: 15px;
	font-weight: 500;
	cursor: pointer;
	transition: background-color 0.15s var(--sc-ease);
}

.sc-locations__item[hidden] {
	display: none;
}

.sc-locations__item svg {
	width: 18px;
	height: 18px;
	color: var(--sc-muted);
}

.sc-locations__item:hover,
.sc-locations__item.is-active {
	background: var(--sc-cream);
}

.sc-locations__empty {
	padding: 12px;
	color: var(--sc-muted);
	font-size: 14px;
}

/* --------------------------------------------------------------------------
   Escaping the builder's row

   WPBakery sets `overflow: hidden` on .vc_row, which clips any popover opened
   from inside one — the calendar gets cut off at the section's edge. Only rows
   that actually contain one of our bars are opened back up, so a row using
   overflow for a parallax or video background is left alone.
   -------------------------------------------------------------------------- */

.vc_row:has(.sc-searchbar),
.vc_row:has(.sc-searchbar) .wpb_column,
.vc_row:has(.sc-searchbar) .vc_column-inner,
.vc_row:has(.sc-searchbar) .wpb_wrapper {
	overflow: visible;
}

/* --------------------------------------------------------------------------
   Keyword mode

   The Marketplace bar searches listings rather than dates: a category picker,
   then one wide keyword field. Same shell, same submit button.
   -------------------------------------------------------------------------- */

.sc-searchbar--keyword .sc-searchbar__field[data-sc-field="category"] {
	flex: 0 0 auto;
	max-width: 240px;
}

.sc-searchbar--keyword {
	max-width: 980px;
}

.sc-searchbar--keyword .sc-searchbar__field[data-sc-field="keyword"] {
	flex: 1 1 auto;
}

/* The keyword box is the whole field, so its text block takes the room the
   two-line booking labels do not need. */
.sc-searchbar--keyword .sc-searchbar__text {
	flex: 1 1 auto;
}

.sc-searchbar__select {
	width: 100%;
	min-width: 0;
	padding: 0;
	border: 0;
	appearance: none;
	background: none;
	color: var(--sc-green-900);
	font: inherit;
	font-size: var(--sc-fs-sm);
	font-weight: 600;
	cursor: pointer;
}

.sc-searchbar__select:focus-visible {
	outline: 2px solid var(--sc-green-700);
	outline-offset: 3px;
	border-radius: 4px;
}

/* The control is a <label>, so the caret is decoration rather than a control
   of its own. */
.sc-searchbar__caret {
	width: 16px;
	height: 16px;
	flex: none;
	color: var(--sc-muted);
}

.sc-searchbar--keyword .sc-searchbar__input {
	font-weight: 400;
}

@media (max-width: 767px) {
	.sc-searchbar--keyword .sc-searchbar__field[data-sc-field="category"] {
		max-width: none;
	}
}

/* --------------------------------------------------------------------------
   The booking plugin's form, drawn as this bar

   [rv_search_form] and [rv_search] render the bar through a theme override,
   usually on a page that is otherwise the theme's. The wrapper borrows the
   .sc-page scope for type and tokens, but none of its page-level backdrop
   or clipping — the popovers must be free to overhang.
   -------------------------------------------------------------------------- */

.sc-booking-search {
	overflow: visible;
	margin-bottom: var(--sc-space-8);
	background: transparent;
}

.sc-booking-search__heading {
	margin-bottom: var(--sc-space-4);
	color: var(--sc-green-900);
	font-size: var(--sc-fs-h3);
}
