/**
 * Amazing Meds Custom WPForms - Booking calendar styles
 *
 * Loaded only on pages that contain a Booking field, and on the cancellation
 * screen (see includes/Fields/BookingField.php and
 * includes/Booking/Cancellation.php).
 *
 * ============================================================================
 * WHY ALMOST EVERY VISUAL DECLARATION HERE CARRIES !important
 * ============================================================================
 *
 * WPForms ships a hard reset that targets every descendant of a form:
 *
 *   div.wpforms-container-full, div.wpforms-container-full * {
 *       background: none; border: 0; border-radius: 0; padding: 0; margin: 0;
 *       width: auto; height: auto; position: static; float: none;
 *       font-size: 100%; box-shadow: none; outline: none; overflow: visible;
 *       letter-spacing: normal; text-indent: 0; text-shadow: none;
 *       text-transform: none; visibility: visible;
 *   }
 *
 * `div.wpforms-container-full *` is specificity (0,1,1) - one class plus a type
 * selector - so it already outranks a plain `.amwpf-booking-calendar` (0,1,0),
 * and wpforms-full.min.css loads after this file. On a Divi site it is far
 * worse: WPForms also emits a theme-scoped copy,
 *
 *   .et-db #et-boc .et-l .et_pb_module div.wpforms-container-full *
 *
 * at (1,5,1). An ID in the selector means NO class-based rule can ever win on
 * specificity, however many classes are chained. !important is therefore not
 * laziness here, it is the only mechanism available.
 *
 * The reset is also why layout worked while decoration did not before this was
 * understood: `display`, `grid-template-columns`, `gap`, `color`, `cursor`,
 * `opacity`, `align-items` and `aspect-ratio` are absent from it, so those
 * applied normally. Properties in the list above need !important; properties
 * outside it deliberately do not carry it, so a theme can still adjust them.
 *
 * Colours are declared once as custom properties on .amwpf-booking so a theme
 * or child stylesheet can recolour the whole calendar by overriding those.
 */

.amwpf-booking {
	--amwpf-booking-accent: #1f7ae0;
	--amwpf-booking-accent-soft: #e8f1fb;
	--amwpf-booking-border: #dfe3e8;
	--amwpf-booking-surface: #fff;
	--amwpf-booking-text: #1d2327;
	--amwpf-booking-muted: #8c94a0;
	--amwpf-booking-radius: 8px;

	position: relative !important;
	color: var(--amwpf-booking-text);
}

/* ---------------------------------------------------------------------------
 * Side-by-side layout: calendar left, the rest of the form right.
 *
 * Both classes are applied by assets/js/booking.js, which moves the form's
 * other fields into a single .amwpf-booking-fields wrapper. That leaves the
 * field container with exactly TWO children, which is what makes this a plain
 * two-column grid with no row-spanning tricks: each child auto-places into its
 * own column of row 1, and `align-items: start` keeps the calendar's height
 * from dictating where the fields begin.
 *
 * If the JS does not run, neither class is added and the form falls back to
 * WPForms' normal stacked layout - readable, just not side by side.
 * ------------------------------------------------------------------------- */
.amwpf-booking-split {
	display: grid !important;
	/* The calendar column is capped rather than fluid: a month grid stretched
	 * across half a wide screen produces enormous square day cells. minmax(0,…)
	 * on both tracks lets them shrink instead of overflowing. */
	grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
	column-gap: 2.5rem;
	align-items: start;
}

/* WPForms gives every field a bottom margin; in the left column there is
 * nothing below the calendar for it to separate. */
.amwpf-booking-split>.wpforms-field-amwpf-booking {
	grid-column: 1;
	margin-bottom: 0 !important;
}

.amwpf-booking-split>.amwpf-booking-fields {
	grid-column: 2;
	min-width: 0 !important;
}

@media (max-width: 782px) {
	.amwpf-booking-split {
		grid-template-columns: minmax(0, 1fr);
		row-gap: 1.5rem;
	}

	.amwpf-booking-split>.wpforms-field-amwpf-booking,
	.amwpf-booking-split>.amwpf-booking-fields {
		grid-column: 1;
	}
}

/* ---------------------------------------------------------------------------
 * The submitted value.
 *
 * Visually gone, but deliberately NOT display:none, visibility:hidden, or
 * type="hidden". WPForms configures jQuery Validation with `ignore: ':hidden'`,
 * and jQuery's :hidden matches anything with no layout box - so any of those
 * would make a required Booking field submit empty with no error shown, and let
 * multi-page forms skip past it. A 1px, clipped, fully transparent input still
 * has a layout box, so it validates like a normal field.
 *
 * It sits at the bottom of the calendar because jQuery Validation inserts its
 * error message directly after the input, and that is where the message belongs.
 * ------------------------------------------------------------------------- */
.amwpf-booking-value.amwpf-booking-value {
	position: absolute !important;
	bottom: 0 !important;
	left: 0 !important;
	width: 1px !important;
	height: 1px !important;
	min-height: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0 !important;
	opacity: 0 !important;
	pointer-events: none !important;
	/* clip-path rather than overflow:hidden so the input cannot be scrolled
	 * into view or reveal a caret. */
	clip-path: inset(50%) !important;
}

/* ---------------------------------------------------------------------------
 * Calendar panel
 * ------------------------------------------------------------------------- */
.amwpf-booking-calendar {
	/* Longhand, not the `border` shorthand: a shorthand containing var() cannot
	 * be expanded by the CSSOM, which makes the rule invisible to devtools and
	 * to any script inspecting matched declarations. */
	border-width: 1px !important;
	border-style: solid !important;
	border-color: var(--amwpf-booking-border) !important;
	border-radius: var(--amwpf-booking-radius) !important;
	padding: 1rem !important;
	background-color: var(--amwpf-booking-surface) !important;
	/* Also capped here so the calendar stays calendar-shaped even when the
	 * side-by-side layout is switched off and it is the full form width. */
	max-width: 24rem !important;
}

.amwpf-booking-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	margin: 0 0 0.875rem !important;
}

.amwpf-booking-month {
	flex: 1 1 auto;
	text-align: center;
	font-weight: 600;
	font-size: 1rem !important;
	letter-spacing: -0.01em !important;
	line-height: 1.3;
}

/* Month arrows.
 *
 * 2.75rem is 44px at the default root size - the smallest comfortably tappable
 * target - and the whole square is the hit area, not just the glyph. They were
 * previously 1.9rem circles containing a hairline text chevron, which is what
 * made them hard to hit and easy to miss. The visible border also makes them
 * read as buttons rather than decoration. */
.amwpf-booking-prev,
.amwpf-booking-next {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem !important;
	height: 2.75rem !important;
	padding: 0 !important;
	margin: 0 !important;
	border-width: 1px !important;
	border-style: solid !important;
	border-color: var(--amwpf-booking-border) !important;
	border-radius: 10px !important;
	background-color: var(--amwpf-booking-surface) !important;
	color: var(--amwpf-booking-accent);
	line-height: 1;
	cursor: pointer;
	-webkit-appearance: none !important;
	appearance: none !important;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.amwpf-booking-prev svg,
.amwpf-booking-next svg {
	display: block;
	width: 1.25rem !important;
	height: 1.25rem !important;
	/* The chevron must not swallow the click - the button is the target. */
	pointer-events: none;
}

.amwpf-booking-prev:hover:not(:disabled),
.amwpf-booking-next:hover:not(:disabled) {
	border-color: var(--amwpf-booking-accent) !important;
	background-color: var(--amwpf-booking-accent-soft) !important;
}

.amwpf-booking-prev:active:not(:disabled),
.amwpf-booking-next:active:not(:disabled) {
	background-color: var(--amwpf-booking-accent) !important;
	color: #fff;
}

.amwpf-booking-prev:focus-visible,
.amwpf-booking-next:focus-visible {
	outline: 2px solid var(--amwpf-booking-accent) !important;
	outline-offset: 2px !important;
}

/* Kept visible but inert at the edges of the booking window, so the calendar
 * does not change shape as the customer pages through months. */
.amwpf-booking-prev:disabled,
.amwpf-booking-next:disabled {
	border-color: var(--amwpf-booking-border) !important;
	background-color: transparent !important;
	color: var(--amwpf-booking-muted);
	opacity: 0.4;
	cursor: default;
}

.amwpf-booking-dow,
.amwpf-booking-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 2px;
}

.amwpf-booking-dow {
	margin: 0 0 2px !important;
}

.amwpf-booking-dow span {
	padding: 0.25rem 0 !important;
	text-align: center;
	font-size: 0.7rem !important;
	line-height: 1.2;
	color: var(--amwpf-booking-muted);
}

/* The grid's own messages (loading, error, nothing available) span the full
 * width instead of landing in a single day cell. */
.amwpf-booking-status {
	grid-column: 1 / -1;
	margin: 0 !important;
	padding: 1.25rem 0.25rem !important;
	text-align: center;
	font-size: 0.8rem !important;
	line-height: 1.45;
	color: var(--amwpf-booking-muted);
}

/* ---------------------------------------------------------------------------
 * Day cells
 * ------------------------------------------------------------------------- */
.amwpf-booking-day {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	width: 100% !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background-color: transparent !important;
	font-family: inherit;
	font-size: 0.8rem !important;
	line-height: 1;
	color: var(--amwpf-booking-text);
}

/* Bookable dates. The dot marks them at a glance, matching the reference
 * design, so availability never depends on colour alone. */
.amwpf-booking-day.is-available {
	position: relative !important;
	background-color: var(--amwpf-booking-accent-soft) !important;
	color: var(--amwpf-booking-accent);
	font-weight: 600;
	cursor: pointer;
}

.amwpf-booking-day.is-available:hover {
	background-color: var(--amwpf-booking-accent) !important;
	color: #fff;
}

.amwpf-booking-day.is-available:focus-visible,
.amwpf-booking-time:focus-visible {
	outline: 2px solid var(--amwpf-booking-accent) !important;
	outline-offset: 2px !important;
}

.amwpf-booking-day.is-selected,
.amwpf-booking-day.is-selected:hover {
	background-color: var(--amwpf-booking-accent) !important;
	color: #fff;
}

.amwpf-booking-day.is-unavailable {
	color: var(--amwpf-booking-muted);
	opacity: 0.5;
}

/* The blank cells before the 1st of the month. They inherit the day cell's
 * square sizing above, which is the point - they hold the column open so the
 * 1st lands under the correct weekday. */
.amwpf-booking-day.is-empty {
	background-color: transparent !important;
	pointer-events: none;
}

/* ---------------------------------------------------------------------------
 * Time slots
 * ------------------------------------------------------------------------- */
.amwpf-booking-times {
	/* max-width: 24rem !important;
	margin: 0.875rem 0 0 !important;
	padding: 0.875rem 0 0 !important;
	border-width: 1px 0 0 !important;
	border-style: solid none none !important;
	border-color: var(--amwpf-booking-border) transparent transparent !important; */
	padding-top: 30px !important;
}

/* The time list is shown and hidden with the `hidden` attribute. Browsers give
 * that `display: none` by default, but plenty of themes and resets set
 * `div { display: block }` at a specificity that beats the UA stylesheet, which
 * would leave an empty panel visible before a date is picked. */
.amwpf-booking-times[hidden] {
	display: none !important;
}

.amwpf-booking-times-heading {
	margin: 0 0 0.75rem !important;
	font-size: 0.8125rem !important;
	font-weight: 600;
	letter-spacing: -0.01em !important;
	line-height: 1.4;
	color: var(--amwpf-booking-text);
}

.amwpf-booking-times-list {
	display: grid;
	/* auto-fit with a wider floor than before: the previous 4.75rem produced four
	 * cramped columns, and the two-line buttons (time plus the visitor's date) had
	 * no room to breathe. This lands on three comfortable columns at the calendar's
	 * width and still reflows down to one on a narrow phone. */
	grid-template-columns: repeat(auto-fit, minmax(6.25rem, 1fr));
	gap: 0.5rem;
	/* Tall enough that a normal day's times all fit without scrolling - six rows
	 * of three covers the 16 slots an 8-hour day at 30 minutes produces - while
	 * still capping a genuinely long list so it cannot push the rest of the form
	 * off-screen. */
	max-height: 22rem;
	overflow-y: auto !important;
	/* Room for the scrollbar so it never sits on top of the buttons' focus ring. */
	padding-right: 0.25rem !important;
	/* Rows stay level even when only some buttons carry a second line. */
	align-items: stretch;
	scrollbar-width: thin;
	scrollbar-color: var(--amwpf-booking-border) transparent;
}

/* A slim, unobtrusive scrollbar in WebKit browsers, to match the above. */
.amwpf-booking-times-list::-webkit-scrollbar {
	width: 8px;
}

.amwpf-booking-times-list::-webkit-scrollbar-thumb {
	border: 2px solid transparent;
	border-radius: 8px;
	background-clip: content-box;
	background-color: var(--amwpf-booking-border);
}

.amwpf-booking-times-list::-webkit-scrollbar-thumb:hover {
	background-color: var(--amwpf-booking-muted);
}

.amwpf-booking-time {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.0625rem;
	/* Sized to fit the tallest variant - a time plus the visitor's date - so that
	 * single-line and two-line buttons are the same height and the whole grid
	 * stays even. A floor rather than a fixed height, so a button that still has
	 * to wrap grows instead of clipping. */
	min-height: 3.125rem !important;
	padding: 0.5rem 0.5rem !important;
	margin: 0 !important;
	border-width: 1px !important;
	border-style: solid !important;
	border-color: var(--amwpf-booking-border) !important;
	border-radius: 10px !important;
	background-color: var(--amwpf-booking-surface) !important;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04) !important;
	color: var(--amwpf-booking-text);
	font-family: inherit;
	font-size: 0.8125rem !important;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
	cursor: pointer;
	-webkit-appearance: none !important;
	appearance: none !important;
	/* Times are compared down a column, so they need to line up: tabular figures
	 * give every digit the same advance width. */
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
	transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

/* The visitor's date, shown inside a time button only when the appointment falls
 * on a different calendar day for them than for the clinic (a UTC-5 clinic's
 * afternoon is the next morning in Manila). Deliberately quieter than the time:
 * the time is what is being chosen, the date is the caveat. */
.amwpf-booking-time-day {
	display: block;
	font-size: 0.6875rem !important;
	font-weight: 500;
	letter-spacing: 0.01em !important;
	line-height: 1.3;
	opacity: 0.7;
}

.amwpf-booking-time:hover {
	border-color: var(--amwpf-booking-accent) !important;
	background-color: var(--amwpf-booking-accent-soft) !important;
	box-shadow: 0 2px 6px rgba(16, 24, 40, 0.07) !important;
	color: var(--amwpf-booking-accent);
	transform: translateY(-1px);
}

.amwpf-booking-time:active {
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04) !important;
	transform: translateY(0);
}

.amwpf-booking-time.is-selected,
.amwpf-booking-time.is-selected:hover {
	border-color: var(--amwpf-booking-accent) !important;
	background-color: var(--amwpf-booking-accent) !important;
	box-shadow: 0 2px 8px rgba(31, 122, 224, 0.3) !important;
	color: #fff;
	transform: translateY(0);
}

/* The selected button's date line must stay legible against the accent fill. */
.amwpf-booking-time.is-selected .amwpf-booking-time-day {
	opacity: 0.85;
}

/* Respect a reduced-motion preference: the lift and colour fades are decorative. */
@media (prefers-reduced-motion: reduce) {

	.amwpf-booking-time,
	.amwpf-booking-prev,
	.amwpf-booking-next {
		transition: none;
	}

	.amwpf-booking-time:hover {
		transform: none;
	}
}

/* Which clock the times above are on. Only rendered when the visitor's timezone
 * differs from the booking timezone, so it is usually absent. */
.amwpf-booking-tz-note {
	margin: 0.5rem 0 0 !important;
	font-size: 0.7rem !important;
	line-height: 1.4;
	color: var(--amwpf-booking-muted);
}

.amwpf-booking-tz-note:empty {
	display: none !important;
}

/* ---------------------------------------------------------------------------
 * Summary line
 * ------------------------------------------------------------------------- */
.amwpf-booking-summary {
	display: flex;
	align-items: center;
	gap: 0.45em;
	max-width: 24rem !important;
	margin: 0.75rem 0 0 !important;
	font-size: 0.8rem !important;
	line-height: 1.4;
	color: var(--amwpf-booking-accent);
}

/* Clock icon as an inline SVG data URI - no extra DOM, no icon font, no
 * request. stroke='%231f7ae0' is the accent colour url-encoded ('%23' is '#');
 * it is duplicated here because a background-image cannot read currentColor. */
.amwpf-booking-summary::before {
	content: "";
	flex: 0 0 auto;
	width: 1.05em !important;
	height: 1.05em !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f7ae0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
	background-size: contain !important;
}

/* ---------------------------------------------------------------------------
 * Builder preview
 *
 * A static mock-up of the calendar shape, so the field is recognisable in the
 * form builder without the builder needing live availability data. The builder
 * is not inside .wpforms-container-full, so the reset above does not apply and
 * these rules need no !important.
 * ------------------------------------------------------------------------- */
.amwpf-booking-preview {
	max-width: 320px;
	padding: 12px;
	border: 1px solid #dfe3e8;
	border-radius: 8px;
	background: #fff;
	pointer-events: none;
}

.amwpf-booking-preview-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
	font-size: 13px;
	font-weight: 600;
}

.amwpf-booking-preview-nav {
	color: #1f7ae0;
}

.amwpf-booking-preview-dow,
.amwpf-booking-preview-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 3px;
}

.amwpf-booking-preview-dow span {
	text-align: center;
	font-size: 10px;
	color: #8c94a0;
}

.amwpf-booking-preview-grid {
	margin-top: 3px;
}

.amwpf-booking-preview-grid span {
	aspect-ratio: 1 / 1;
	border-radius: 50%;
	background: #f1f3f5;
}

.amwpf-booking-preview-times {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
	margin-top: 12px;
	padding-top: 10px;
	border-top: 1px solid #dfe3e8;
}

.amwpf-booking-preview-times span {
	height: 26px;
	border: 1px solid #dfe3e8;
	border-radius: 6px;
}

/* ---------------------------------------------------------------------------
 * Cancellation screen
 *
 * Its own standalone document (see Cancellation::render_page), so this
 * stylesheet is all it gets - hence the body-level rules, and no !important
 * anywhere: there is no theme CSS present to compete with.
 * ------------------------------------------------------------------------- */
.amwpf-cancel-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	margin: 0;
	padding: 24px;
	background: #f4f6f8;
	color: #1d2327;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.5;
	box-sizing: border-box;
}

.amwpf-cancel-card {
	width: 100%;
	max-width: 30em;
	padding: 32px;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
	text-align: center;
}

.amwpf-cancel-card h1 {
	margin: 0 0 12px;
	font-size: 1.35em;
}

.amwpf-cancel-card p {
	margin: 0 0 12px;
}

.amwpf-cancel-slot {
	font-size: 1.05em;
	font-weight: 600;
	color: #1f7ae0;
}

.amwpf-cancel-button {
	width: 100%;
	margin-top: 8px;
	padding: 0.75em 1em;
	border: 0;
	border-radius: 8px;
	background: #b32d2e;
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.amwpf-cancel-button:hover {
	background: #8f2424;
}

.amwpf-cancel-keep {
	margin: 14px 0 0;
	font-size: 0.9em;
}

.amwpf-cancel-keep a {
	color: #646970;
}

/* Coloured heading per outcome, so the result reads before the text does. */
.amwpf-cancel-success .amwpf-cancel-card h1 {
	color: #007017;
}

.amwpf-cancel-error .amwpf-cancel-card h1 {
	color: #b32d2e;
}