/*
 * Booking UI. Spec 11.3 for the grid states, 13.1 for RTL, 13.3 for focus.
 *
 * Two rules that are not style preferences:
 *  1. Logical properties only. No margin-left, no padding-right, no left/right.
 *     The Dari site is RTL and physical properties silently break it.
 *  2. Colour is never the only signal. Every state pairs a fill with a border and
 *     a word, so it survives colour blindness and a bad phone screen in sunlight.
 *
 * Tokens come from the theme. Fallbacks are here so the plugin still looks
 * deliberate if it is ever activated on another theme.
 */

.nbb {
	--nbb-garnet: var(--wp--preset--color--garnet, #5C0D18);
	--nbb-red: var(--wp--preset--color--red, #C81E2D);
	--nbb-red-soft: var(--wp--preset--color--red-soft, #FBEDEE);
	--nbb-ink: var(--wp--preset--color--ink, #16110F);
	--nbb-ink-soft: var(--wp--preset--color--ink-soft, #5B524E);
	--nbb-line: var(--wp--preset--color--line, #E6DEDB);
	--nbb-surface: var(--wp--preset--color--surface, #FFFFFF);

	color: var(--nbb-ink);
	max-inline-size: 60rem;
	margin-inline: auto;
}

/* ------------------------------ choices ------------------------------ */

.nbb__choice {
	border: 0;
	padding: 0;
	margin: 0 0 1.5rem;
}

.nbb__choice legend {
	font-weight: 600;
	font-size: 1rem;
	padding: 0;
	margin-block-end: 0.5rem;
}

.nbb__choice-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.nbb__pill {
	position: relative;
	display: inline-flex;
}

.nbb__pill input {
	position: absolute;
	opacity: 0;
	inset-inline-start: 0;
	inset-block-start: 0;
	inline-size: 100%;
	block-size: 100%;
	margin: 0;
	cursor: pointer;
}

.nbb__pill span {
	display: inline-flex;
	align-items: baseline;
	gap: 0.5rem;
	padding: 0.625rem 1.125rem;
	border: 1px solid var(--nbb-line);
	border-radius: 999px;
	background: var(--nbb-surface);
	font-weight: 500;
	transition: border-color 120ms ease, background-color 120ms ease;
}

.nbb__pill input:checked + span {
	border-color: var(--nbb-red);
	background: var(--nbb-red-soft);
	font-weight: 600;
}

/* Focus is visible on the label, since the input itself is transparent. */
.nbb__pill input:focus-visible + span {
	outline: 2px solid var(--nbb-red);
	outline-offset: 2px;
}

.nbb__price {
	font-style: normal;
	font-size: 0.875rem;
	color: var(--nbb-ink-soft);
}

/* ----------------------------- calendar ------------------------------ */

.nbb__calendar-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-block: 2rem 1rem;
}

.nbb__range {
	font-size: 1.125rem;
	margin: 0;
	font-weight: 600;
}

.nbb__nav {
	inline-size: 2.75rem;
	block-size: 2.75rem;
	border: 1px solid var(--nbb-line);
	border-radius: 8px;
	background: var(--nbb-surface);
	font-size: 1.25rem;
	cursor: pointer;
	color: var(--nbb-ink);
}

.nbb__nav:hover {
	border-color: var(--nbb-red);
	color: var(--nbb-red);
}

/* The arrows are glyphs, so they must flip with the writing direction. */
[dir="rtl"] .nbb__nav {
	transform: scaleX(-1);
}

.nbb__grid-wrap {
	overflow-x: auto;
	padding-block-end: 0.5rem;
}

.nbb__grid {
	display: flex;
	gap: 0.75rem;
	min-inline-size: min-content;
}

.nbb__day {
	flex: 1 0 7.5rem;
	min-inline-size: 7.5rem;
}

.nbb__day-label {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--nbb-ink-soft);
	margin: 0 0 0.5rem;
	text-align: center;
}

/* ------------------------- the six slot states ------------------------ */

.nbb__slot {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.125rem;
	inline-size: 100%;
	padding: 0.625rem 0.5rem;
	margin-block-end: 0.5rem;
	border: 1px solid var(--nbb-line);
	border-radius: 8px;
	background: var(--nbb-surface);
	color: var(--nbb-ink);
	font: inherit;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
	transition: background-color 120ms ease, border-color 120ms ease;
}

.nbb__slot-time {
	font-weight: 600;
	/* Times stay Latin in both languages so nobody misreads them at checkout. */
	direction: ltr;
	unicode-bidi: isolate;
}

.nbb__slot-tag {
	font-size: 0.6875rem;
	text-transform: none;
	letter-spacing: 0;
}

/* Hovered */
.nbb__slot--available:hover {
	background: var(--nbb-red-soft);
	border-color: var(--nbb-red);
}

/* Selected, held by you */
.nbb__slot--held_by_you {
	background: var(--nbb-red);
	border-color: var(--nbb-red);
	color: #fff;
	font-weight: 600;
}

/* Held by someone else, and booked, share a muted treatment plus a word. */
.nbb__slot--reserved,
.nbb__slot--booked {
	background: var(--nbb-surface);
	color: color-mix(in srgb, var(--nbb-ink-soft) 45%, transparent);
	border-style: dashed;
	cursor: not-allowed;
}

.nbb__slot--booked {
	border-style: solid;
}

/* Past or outside the notice window: hidden on mobile, muted on desktop. */
.nbb__slot--past {
	display: none;
}

@media (min-width: 700px) {
	.nbb__slot--past {
		display: flex;
		opacity: 0.35;
		cursor: not-allowed;
	}
}

.nbb__slot:focus-visible {
	outline: 2px solid var(--nbb-red);
	outline-offset: 2px;
}

.nbb__empty,
.nbb__loading {
	color: var(--nbb-ink-soft);
	padding: 2rem 0;
}

.nbb__legend {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
	font-size: 0.8125rem;
	color: var(--nbb-ink-soft);
	margin-block: 1rem;
}

.nbb__key::before {
	content: "";
	display: inline-block;
	inline-size: 0.75rem;
	block-size: 0.75rem;
	border-radius: 3px;
	margin-inline-end: 0.375rem;
	border: 1px solid var(--nbb-line);
	vertical-align: -1px;
}

.nbb__key--free::before { background: var(--nbb-surface); }
.nbb__key--held::before { background: var(--nbb-surface); border-style: dashed; }
.nbb__key--booked::before { background: var(--nbb-line); }

/* ------------------------------ the hold ------------------------------ */

.nbb__hold {
	border: 1px solid var(--nbb-red);
	background: var(--nbb-red-soft);
	border-radius: 12px;
	padding: 1.25rem;
	margin-block: 1.5rem;
	text-align: center;
}

.nbb__hold-label {
	margin: 0 0 0.25rem;
	font-size: 0.875rem;
	color: var(--nbb-ink-soft);
}

.nbb__countdown {
	margin: 0;
	font-size: 2.25rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	/* mm:ss reads left to right in both languages. */
	direction: ltr;
	unicode-bidi: isolate;
	color: var(--nbb-ink);
}

/* Under two minutes it turns red. No flashing, no sound. */
.nbb__countdown.is-urgent {
	color: var(--nbb-red);
}

.nbb__extend {
	margin-block-start: 0.75rem;
	font-size: 0.9375rem;
}

.nbb__extend p {
	margin: 0 0 0.5rem;
}

.nbb__link {
	background: none;
	border: 0;
	padding: 0;
	margin-block-start: 0.75rem;
	color: var(--nbb-ink-soft);
	text-decoration: underline;
	cursor: pointer;
	font: inherit;
}

/* ------------------------------- buttons ------------------------------ */

.nbb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	padding: 0.875rem 1.5rem;
	border-radius: 8px;
	border: 1px solid transparent;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	min-block-size: 44px;
}

.nbb__btn--primary {
	background: var(--nbb-red);
	color: #fff;
	inline-size: 100%;
}

.nbb__btn--primary:hover {
	background: var(--nbb-garnet);
}

.nbb__btn--primary:disabled {
	opacity: 0.6;
	cursor: wait;
}

.nbb__btn--quiet {
	background: var(--nbb-surface);
	border-color: var(--nbb-red);
	color: var(--nbb-red);
}

.nbb__btn:focus-visible {
	outline: 2px solid var(--nbb-ink);
	outline-offset: 2px;
}

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

.nbb__form {
	margin-block-start: 2rem;
	border-block-start: 1px solid var(--nbb-line);
	padding-block-start: 2rem;
}

.nbb__field {
	margin-block-end: 1.25rem;
}

.nbb__field label {
	display: block;
	font-weight: 500;
	margin-block-end: 0.375rem;
}

.nbb__field input,
.nbb__field textarea {
	inline-size: 100%;
	padding: 0.75rem;
	border: 1px solid var(--nbb-line);
	border-radius: 8px;
	font: inherit;
	color: var(--nbb-ink);
	background: var(--nbb-surface);
	/* 16px minimum, or iOS zooms the page on focus. */
	font-size: max(1rem, 16px);
}

.nbb__field input:focus-visible,
.nbb__field textarea:focus-visible {
	outline: 2px solid var(--nbb-red);
	outline-offset: 1px;
	border-color: var(--nbb-red);
}

.nbb__field input[aria-invalid="true"] {
	border-color: var(--nbb-red);
}

.nbb__err {
	display: block;
	color: var(--nbb-red);
	font-size: 0.875rem;
	margin-block-start: 0.25rem;
	min-block-size: 1.25em;
}

/* Honeypot. Off screen rather than display:none, which some bots skip. */
.nbb__hp {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.nbb__policy {
	font-size: 0.875rem;
	color: var(--nbb-ink-soft);
	margin-block-start: 1rem;
}

.nbb__error {
	background: var(--nbb-red-soft);
	border: 1px solid var(--nbb-red);
	border-radius: 8px;
	padding: 0.875rem 1rem;
	margin-block: 1rem;
	color: var(--nbb-garnet);
}

/* Screen reader only. Announcements at 5 min, 2 min and expiry. */
.nbb__announce {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------------------------- hero chips ----------------------------- */

.nb-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	list-style: none;
	padding: 0;
	margin: 1.5rem 0 0;
}

.nb-chip {
	display: inline-flex;
	flex-direction: column;
	gap: 0.125rem;
	padding: 0.625rem 1rem;
	border: 1px solid var(--wp--preset--color--line, #E6DEDB);
	border-radius: 999px;
	text-decoration: none;
	color: inherit;
	background: var(--wp--preset--color--surface, #fff);
	min-block-size: 44px;
	justify-content: center;
}

.nb-chip:hover {
	border-color: var(--wp--preset--color--red, #C81E2D);
	background: var(--wp--preset--color--red-soft, #FBEDEE);
}

.nb-chip__date {
	font-size: 0.75rem;
	color: var(--wp--preset--color--ink-soft, #5B524E);
}

.nb-chip__time {
	font-weight: 600;
	direction: ltr;
	unicode-bidi: isolate;
}

.nb-chips-empty {
	margin-block-start: 1.5rem;
}

.nb-waitlist {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-block-start: 0.5rem;
}

.nb-waitlist label {
	flex: 1 0 100%;
	font-size: 0.875rem;
}

.nb-waitlist input {
	flex: 1 1 14rem;
	padding: 0.75rem;
	border: 1px solid var(--wp--preset--color--line, #E6DEDB);
	border-radius: 8px;
	font: inherit;
	font-size: max(1rem, 16px);
}

.nb-waitlist button {
	padding: 0.75rem 1.25rem;
	border: 0;
	border-radius: 8px;
	background: var(--wp--preset--color--red, #C81E2D);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	min-block-size: 44px;
}

/* ------------------------- affiliate bar, s.7 ------------------------- */

.nb-affiliate {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	background: var(--wp--preset--color--garnet, #5C0D18);
	color: #fff;
	padding-inline: 1rem;
	/* Must stay under 44px on mobile so it never pushes the hero off screen. */
	min-block-size: 40px;
	font-size: 0.875rem;
}

.nb-affiliate p {
	margin: 0;
}

.nb-affiliate a {
	color: #fff;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.nb-affiliate__close {
	background: none;
	border: 0;
	color: #fff;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	padding: 0.5rem;
	opacity: 0.8;
}

.nb-affiliate__close:hover {
	opacity: 1;
}

/* --------------------------- manage booking --------------------------- */

.nb-manage {
	max-inline-size: 40rem;
	margin-inline: auto;
}

.nb-manage__status {
	display: inline-block;
	padding: 0.25rem 0.75rem;
	border-radius: 999px;
	font-size: 0.8125rem;
	font-weight: 600;
	background: var(--wp--preset--color--line, #E6DEDB);
	color: var(--wp--preset--color--ink, #16110F);
}

.nb-manage__status--confirmed {
	background: var(--wp--preset--color--red-soft, #FBEDEE);
	color: var(--wp--preset--color--garnet, #5C0D18);
}

.nb-manage__status--cancelled {
	text-decoration: line-through;
}

.nb-manage__note {
	color: var(--wp--preset--color--ink-soft, #5B524E);
	font-size: 0.875rem;
}

.nb-manage__facts {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.5rem 1.5rem;
	margin-block: 1.5rem;
	padding-block: 1.5rem;
	border-block: 1px solid var(--wp--preset--color--line, #E6DEDB);
}

.nb-manage__facts dt {
	font-weight: 600;
	color: var(--wp--preset--color--ink-soft, #5B524E);
}

.nb-manage__facts dd {
	margin: 0;
	overflow-wrap: anywhere;
}

.nb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.875rem 1.5rem;
	border-radius: 8px;
	border: 1px solid var(--wp--preset--color--red, #C81E2D);
	background: var(--wp--preset--color--red, #C81E2D);
	color: #fff;
	text-decoration: none;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	min-block-size: 44px;
}

.nb-btn--quiet {
	background: transparent;
	color: var(--wp--preset--color--red, #C81E2D);
}

.nb-btn--whatsapp {
	background: #25D366;
	border-color: #25D366;
	color: #06281a;
}

.nb-manage__actions {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	align-items: center;
	margin-block-start: 1.5rem;
}

.nb-manage__refund {
	flex: 1 0 100%;
	font-size: 0.875rem;
	color: var(--wp--preset--color--ink-soft, #5B524E);
	margin: 0;
}

/* ---------------------------- reduced motion --------------------------- */

@media (prefers-reduced-motion: reduce) {
	.nbb *,
	.nb-chip,
	.nb-btn {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}
