/**
 * Front-end booking form.
 *
 * Two-column layout with framed labels sitting flush on each control, so it
 * reads as one solid block rather than a stack of loose inputs.
 *
 * Contrast strategy, because this is what most often goes wrong when a plugin
 * lands in somebody else's theme:
 *
 * - Loose body text inherits the theme's colour. A plugin cannot know whether
 *   the page behind it is light or dark, so it must not guess.
 * - Every control carries BOTH its own background and its own text colour, so
 *   it is legible whatever is behind it.
 */

.rb-form-wrap {
	/* Brand */
	--rb-accent: #8a1c2b;
	--rb-accent-contrast: #ffffff;

	/* The label bars */
	--rb-bar-bg: #16130f;
	--rb-bar-text: #ffffff;

	/* Controls */
	--rb-field-bg: #ffffff;
	--rb-field-bg-muted: #f2efec;
	--rb-field-text: #24211d;
	--rb-field-muted: #6b655d;
	--rb-field-border: #cdc8c1;
	--rb-field-border-soft: #e2ded9;

	/* Status */
	--rb-error: #9b1c1c;
	--rb-error-bg: #fdf2f2;
	--rb-success: #1a6b3c;
	--rb-success-bg: #f1f8f3;

	--rb-radius: 3px;
	--rb-gap: 1.25rem;

	width: 100%;
	text-align: left;
	color: inherit;
	box-sizing: border-box;
}

.rb-form-wrap *,
.rb-form-wrap *::before,
.rb-form-wrap *::after {
	box-sizing: inherit;
}

.rb-form-heading {
	margin: 0 0 1.25rem;
	color: inherit;
}

/* --------------------------------------------------------------------
 * Layout
 * ----------------------------------------------------------------- */

.rb-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0 var(--rb-gap);
	align-items: start;
}

.rb-layout-single .rb-grid {
	grid-template-columns: 1fr;
}

.rb-col {
	min-width: 0;
}

.rb-field {
	margin-bottom: var(--rb-gap);
}

/* Stack on anything narrower than a tablet. Container queries would be
   better, but this has to work inside page builders that do not provide a
   containment context. */
@media screen and (max-width: 782px) {
	.rb-grid {
		grid-template-columns: 1fr;
	}
}

/* --------------------------------------------------------------------
 * Framed labels, flush on top of their control
 * ----------------------------------------------------------------- */

.rb-bar {
	display: block;
	background: var(--rb-bar-bg);
	color: var(--rb-bar-text);
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1.3;
	text-align: center;
	padding: 0.55rem 0.75rem;
	border-radius: var(--rb-radius) var(--rb-radius) 0 0;
	margin: 0;
}

/* --------------------------------------------------------------------
 * Controls. Uniform height so the two columns line up across the grid.
 * ----------------------------------------------------------------- */

.rb-control {
	display: block;
	width: 100%;
	min-height: 3.25rem;
	padding: 0.75rem 0.9rem;
	border: 1px solid var(--rb-field-border);
	border-top: 0;
	border-radius: 0 0 var(--rb-radius) var(--rb-radius);
	background: var(--rb-field-bg);
	color: var(--rb-field-text);
	font: inherit;
	line-height: 1.4;
}

.rb-control:focus,
.rb-control:focus-visible {
	outline: 2px solid var(--rb-accent);
	outline-offset: -2px;
}

.rb-input::placeholder,
.rb-textarea::placeholder {
	color: var(--rb-field-muted);
	opacity: 1;
}

.rb-textarea {
	resize: vertical;
	min-height: 6rem;
	border-radius: 0 0 var(--rb-radius) var(--rb-radius);
}

/* Same chevron as the date and time pickers, so the three controls in the
   left column look like a set rather than three different widgets. */
.rb-select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b655d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-position: right 1rem center;
	background-repeat: no-repeat;
	padding-right: 2.5rem;
	cursor: pointer;
}

/* --------------------------------------------------------------------
 * Date and time pickers
 * ----------------------------------------------------------------- */

.rb-picker-wrap {
	position: relative;
}

.rb-picker {
	text-align: left;
	cursor: pointer;
	color: var(--rb-field-muted);
	position: relative;
	padding-right: 2.5rem;
}

.rb-picker.has-value {
	color: var(--rb-field-text);
	font-weight: 600;
}

.rb-picker::after {
	content: "";
	position: absolute;
	right: 1rem;
	top: 50%;
	width: 0.5rem;
	height: 0.5rem;
	margin-top: -0.35rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	opacity: 0.6;
}

/* No opacity here. Fading a white control on a dark page lets the black
   through and turns it muddy grey. Use a muted fill instead. */
.rb-picker:disabled {
	cursor: not-allowed;
	background: var(--rb-field-bg-muted);
	color: var(--rb-field-muted);
	opacity: 1;
}

.rb-popover {
	position: absolute;
	z-index: 50;
	top: calc(100% + 4px);
	left: 0;
	/* A fixed, compact panel. Stretching it to the field width made the day
	   cells enormous, because they are square. */
	width: 19rem;
	max-width: 90vw;
	background: var(--rb-field-bg);
	color: var(--rb-field-text);
	border: 1px solid var(--rb-field-border);
	border-radius: var(--rb-radius);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
	padding: 0.75rem;
}

.rb-popover[hidden] {
	display: none;
}

.rb-popover-times {
	width: 17rem;
	max-height: 16rem;
	overflow-y: auto;
}

/* --------------------------------------------------------------------
 * Calendar
 * ----------------------------------------------------------------- */

.rb-cal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.5rem;
	gap: 0.5rem;
}

.rb-cal-title {
	font-weight: 700;
	font-size: 0.95rem;
	color: var(--rb-field-text);
	flex: 1 1 auto;
	text-align: center;
}

.rb-cal-nav {
	appearance: none;
	flex: 0 0 auto;
	border: 1px solid var(--rb-field-border-soft);
	background: var(--rb-field-bg);
	color: var(--rb-field-text);
	border-radius: var(--rb-radius);
	width: 2rem;
	height: 2rem;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.rb-cal-nav:hover:not(:disabled) {
	background: var(--rb-field-bg-muted);
}

.rb-cal-nav:disabled {
	opacity: 0.3;
	cursor: default;
}

.rb-cal-row {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 1px;
}

.rb-cal-dayname {
	text-align: center;
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--rb-field-muted);
	padding: 0.3rem 0;
}

.rb-cal-cell {
	aspect-ratio: 1 / 1;
}

.rb-cal-day {
	appearance: none;
	width: 100%;
	height: 100%;
	min-height: 2.1rem;
	border: 1px solid transparent;
	border-radius: var(--rb-radius);
	background: var(--rb-field-bg-muted);
	color: var(--rb-field-text);
	font: inherit;
	font-size: 0.82rem;
	cursor: pointer;
	padding: 0;
}

.rb-cal-day:hover:not(:disabled) {
	border-color: var(--rb-accent);
}

.rb-cal-day:focus-visible {
	outline: 2px solid var(--rb-accent);
	outline-offset: 1px;
}

.rb-cal-day.is-unavailable {
	background: transparent;
	color: var(--rb-field-muted);
	opacity: 0.45;
	cursor: default;
	text-decoration: line-through;
}

.rb-cal-day.is-selected {
	background: var(--rb-accent);
	color: var(--rb-accent-contrast);
	border-color: var(--rb-accent);
	font-weight: 700;
}

.rb-cal-status {
	margin: 0.5rem 0 0;
	font-size: 0.8rem;
	color: var(--rb-field-muted);
	text-align: center;
	min-height: 1.1em;
}

/* --------------------------------------------------------------------
 * Time slots
 * ----------------------------------------------------------------- */

.rb-times {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(4.75rem, 1fr));
	gap: 0.4rem;
}

.rb-slot {
	appearance: none;
	border: 1px solid var(--rb-field-border);
	border-radius: var(--rb-radius);
	background: var(--rb-field-bg);
	color: var(--rb-field-text);
	font: inherit;
	font-size: 0.85rem;
	padding: 0.55rem 0.4rem;
	min-height: 2.6rem;
	cursor: pointer;
	white-space: nowrap;
	text-align: center;
}

.rb-slot:hover {
	border-color: var(--rb-accent);
}

.rb-slot:focus-visible {
	outline: 2px solid var(--rb-accent);
	outline-offset: 1px;
}

.rb-slot.is-selected {
	background: var(--rb-accent);
	color: var(--rb-accent-contrast);
	border-color: var(--rb-accent);
	font-weight: 700;
}

/* --------------------------------------------------------------------
 * Message toggle, consent, honeypot
 * ----------------------------------------------------------------- */

.rb-message-row {
	display: flex;
	justify-content: flex-end;
	margin-bottom: var(--rb-gap);
}

.rb-message-field[hidden] {
	display: none;
}

.rb-hint {
	margin: 0.4rem 0 0;
	font-size: 0.85rem;
	color: inherit;
	opacity: 0.75;
}

.rb-hint a {
	color: inherit;
}

.rb-field-check .rb-check {
	display: flex;
	gap: 0.6rem;
	align-items: flex-start;
	font-size: 0.9rem;
	line-height: 1.5;
	cursor: pointer;
	color: inherit;
}

.rb-field-check input {
	margin-top: 0.25rem;
	flex: 0 0 auto;
}

/* Off-screen rather than display:none, because some bots skip anything that
   is not rendered. */
.rb-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* --------------------------------------------------------------------
 * Buttons
 * ----------------------------------------------------------------- */

.rb-button {
	appearance: none;
	border: 0;
	border-radius: var(--rb-radius);
	background: var(--rb-accent);
	color: var(--rb-accent-contrast);
	font: inherit;
	font-weight: 600;
	padding: 0.75rem 1.5rem;
	min-height: 2.9rem;
	cursor: pointer;
	line-height: 1.3;
}

.rb-button:hover:not(:disabled) {
	filter: brightness(1.12);
}

.rb-button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.rb-button:disabled {
	opacity: 0.6;
	cursor: default;
}

.rb-button-primary {
	width: 100%;
	padding: 1rem 1.5rem;
	min-height: 3.4rem;
	font-size: 1.05rem;
}

.rb-button-secondary {
	padding: 0.6rem 1.2rem;
	min-height: 2.6rem;
	font-size: 0.9rem;
}

.rb-button-danger {
	background: var(--rb-error);
	margin-top: 1rem;
}

/* --------------------------------------------------------------------
 * Alerts
 * ----------------------------------------------------------------- */

.rb-alert {
	padding: 0.875rem 1rem;
	margin-bottom: 1.25rem;
	border-radius: var(--rb-radius);
	border-left: 3px solid transparent;
}

.rb-alert[hidden] {
	display: none;
}

.rb-alert-error {
	background: var(--rb-error-bg);
	border-left-color: var(--rb-error);
	color: var(--rb-error);
}

.rb-alert-success {
	background: var(--rb-success-bg);
	border-left-color: var(--rb-success);
	color: var(--rb-success);
}

.rb-alert-title {
	margin: 0 0 0.5rem;
	font-weight: 700;
	color: inherit;
}

.rb-alert ul,
.rb-alert li,
.rb-alert p {
	color: inherit;
}

.rb-alert ul {
	margin: 0;
	padding-left: 1.125rem;
}

.rb-alert p:last-child {
	margin-bottom: 0;
}

.rb-reference {
	font-weight: 700;
	letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------
 * Guest self-service panel
 * ----------------------------------------------------------------- */

.rb-manage {
	max-width: 34rem;
}

.rb-manage-card {
	border: 1px solid var(--rb-field-border-soft);
	border-radius: var(--rb-radius);
	padding: 1.5rem;
	background: var(--rb-field-bg);
	color: var(--rb-field-text);
}

.rb-manage-status {
	margin: 0 0 0.5rem;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--rb-field-muted);
}

.rb-manage-summary {
	margin: 0 0 0.35rem;
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--rb-field-text);
}

.rb-manage-ref {
	margin: 0;
	color: var(--rb-field-muted);
	letter-spacing: 0.03em;
}

.rb-loading {
	color: inherit;
	opacity: 0.75;
}

/* --------------------------------------------------------------------
 * Dark sites
 *
 * Add rb-dark to the wrapper, or set the variables yourself. Deliberately
 * NOT tied to prefers-color-scheme: the form should match the SITE, not the
 * visitor's operating system preference.
 * ----------------------------------------------------------------- */

.rb-form-wrap.rb-dark {
	--rb-bar-bg: #0d0b09;
	--rb-bar-text: #ffffff;
	--rb-field-bg: #26241f;
	--rb-field-bg-muted: #32302a;
	--rb-field-text: #f4f1ec;
	--rb-field-muted: #b0a99f;
	--rb-field-border: #4a453e;
	--rb-field-border-soft: #3a3630;
	--rb-error-bg: #33191a;
	--rb-success-bg: #17281d;
	--rb-error: #f0a3a3;
	--rb-success: #8fd6a8;
}

/* --------------------------------------------------------------------
 * Motion preferences
 * ----------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.rb-form-wrap * {
		scroll-behavior: auto !important;
		transition: none !important;
		animation: none !important;
	}
}
