/**
 * Booking modal feedback: the success screen and the inline notice that
 * replaced the browser alert() calls in assets/js/booking-modal.js.
 *
 * Plain CSS (no build step), enqueued next to the booking modal script from
 * inc/register-scripts.php. Values follow the theme tokens
 * (assets/sass/variables/_colors-design.scss): primary #292521, secondary
 * #FEBE00, base-dark #6F6963, footer-border-light #D2CCC5, and the waitlist
 * overlay (assets/sass/booking-components/_waitlist.scss) it sits beside.
 */

/* ---------- Success screen ---------- */

.booking-success {
	position: absolute;
	inset: 0;
	z-index: 30;
	display: flex;
	flex-direction: column;
	background-color: var(--wp--preset--color--white);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.booking-success::-webkit-scrollbar {
	display: none;
}

.booking-success[hidden] {
	display: none;
}

.booking-success__header {
	display: flex;
	justify-content: flex-end;
	padding: 1.5rem 1.5rem 0;
}

.booking-success__content {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 0.5rem 1.5rem 2rem;
}

.booking-success__badge {
	width: 5.5rem;
	height: 5.5rem;
	border-radius: 50%;
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--primary);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 0 0 0.625rem color-mix(in srgb, var(--wp--preset--color--secondary) 18%, transparent);
	margin: 1rem 0 1.75rem;
}

.booking-success__badge svg {
	width: 2.75rem;
	height: 2.75rem;
}

.booking-success__title {
	font-family: 'Nexa Text BG', Arial, sans-serif;
	font-size: 1.75rem;
	font-weight: 800;
	line-height: 1.2;
	color: var(--wp--preset--color--primary);
	margin: 0 0 0.5rem;
	outline: none;
}

.booking-success__lead {
	font-size: 1.125rem;
	font-weight: 300;
	line-height: 1.75rem;
	color: var(--wp--preset--color--base-dark);
	margin: 0 0 1.75rem;
}

.booking-success__summary {
	width: 100%;
	margin: 0 0 2rem;
	padding: 0.5rem 1.5rem;
	background-color: var(--wp--preset--color--surface-muted);
	border-radius: 1rem;
	text-align: left;
}

.booking-success__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	padding: 0.875rem 0;
}

.booking-success__row + .booking-success__row {
	border-top: 1px dashed var(--wp--preset--color--footer-border-light);
}

.booking-success__row[hidden] {
	display: none;
}

.booking-success__label {
	flex-shrink: 0;
	font-size: 0.875rem;
	font-weight: 400;
	line-height: 1.375rem;
	color: var(--wp--preset--color--base-dark);
	margin: 0;
}

.booking-success__value {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.375rem;
	color: var(--wp--preset--color--primary);
	text-align: right;
	margin: 0;
	overflow-wrap: anywhere;
}

.booking-success__done {
	width: 100%;
	height: 3.5rem;
	margin-top: auto;
	padding: 0.25rem 2.5rem;
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	border: 1px solid var(--wp--preset--color--primary);
	border-radius: 99px;
	font-family: 'Nexa Text BG', Arial, sans-serif;
	font-size: 0.875rem;
	font-weight: 800;
	line-height: 1.125rem;
	letter-spacing: 0.09625rem;
	text-transform: uppercase;
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.booking-success__done:hover,
.booking-success__done:focus-visible {
	opacity: 0.85;
}

/* Entrance: badge pops, check draws, the rest rises in. */
.booking-success.is-visible .booking-success__badge {
	animation: zd-booking-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.booking-success.is-visible .booking-success__check {
	stroke-dasharray: 24;
	stroke-dashoffset: 24;
	animation: zd-booking-draw 0.4s ease-out 0.3s forwards;
}

.booking-success.is-visible .booking-success__title,
.booking-success.is-visible .booking-success__lead,
.booking-success.is-visible .booking-success__summary,
.booking-success.is-visible .booking-success__done {
	animation: zd-booking-rise 0.4s ease-out both;
}

.booking-success.is-visible .booking-success__title { animation-delay: 0.15s; }
.booking-success.is-visible .booking-success__lead { animation-delay: 0.2s; }
.booking-success.is-visible .booking-success__summary { animation-delay: 0.28s; }
.booking-success.is-visible .booking-success__done { animation-delay: 0.36s; }

@keyframes zd-booking-pop {
	from { transform: scale(0.5); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

@keyframes zd-booking-draw {
	to { stroke-dashoffset: 0; }
}

@keyframes zd-booking-rise {
	from { transform: translateY(0.75rem); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

/* ---------- Inline notice (validation / booking errors) ---------- */

.booking-notice {
	position: absolute;
	left: 0.75rem;
	right: 0.75rem;
	bottom: calc(var(--zd-booking-footer-h, 5rem) + 0.5rem);
	z-index: 25;
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 0.875rem 0.75rem 0.875rem 1rem;
	background-color: var(--wp--preset--color--white);
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--error) 30%, transparent);
	border-left: 4px solid var(--wp--preset--color--error);
	border-radius: 0.75rem;
	box-shadow: var(--wp--preset--shadow--raised);
	opacity: 0;
	transform: translateY(0.5rem);
	transition: opacity 0.2s ease, transform 0.2s ease;
	pointer-events: none;
}

.booking-notice.is-visible {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.booking-notice__icon {
	flex-shrink: 0;
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 50%;
	background-color: var(--wp--preset--color--error);
	color: var(--wp--preset--color--white);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.875rem;
	font-weight: 800;
	line-height: 1;
}

.booking-notice__text {
	flex: 1;
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.375rem;
	color: var(--wp--preset--color--primary);
	margin: 0.0625rem 0 0;
}

.booking-notice__close {
	flex-shrink: 0;
	background: none;
	border: none;
	padding: 0.125rem;
	margin: -0.125rem 0 0;
	color: var(--wp--preset--color--base-dark);
	cursor: pointer;
	display: flex;
}

.booking-notice__close:hover,
.booking-notice__close:focus-visible {
	color: var(--wp--preset--color--primary);
}

.booking-notice__close svg {
	width: 1.25rem;
	height: 1.25rem;
}

/* ------------------------------------------------------------------
 * Confirm screen (template-parts/booking/components/booking-confirm.php)
 * Last step before the booking is sent. Built on .booking-success.
 * ------------------------------------------------------------------ */

.booking-confirm__header {
	justify-content: space-between;
	align-items: center;
}

.booking-confirm__back {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.25rem 0;
	background: none;
	border: 0;
	color: var(--wp--preset--color--primary);
	font-family: 'Nexa Text BG', Arial, sans-serif;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
}

.booking-confirm__back svg {
	width: 1.5rem;
	height: 1.5rem;
}

.booking-confirm__content {
	padding-top: 1rem;
}

/* „Потвърждавам“ is pinned to the bottom of the screen, like „Напред“ / „Запази“
   in the modal footer (booking-modal.scss → &__footer): the actions box dissolves
   (display: contents) so the bar can stick to the scrolling .booking-success, and
   „Промени данните“ moves above it and scrolls with the summary. */
.booking-confirm__actions {
	display: contents;
}

.booking-confirm .booking-confirm__edit {
	order: 1;
	margin-top: auto;
}

.booking-confirm__bar {
	order: 2;
	position: sticky;
	bottom: 0;
	z-index: 2;
	width: calc(100% + 3rem);
	margin: 0.75rem -1.5rem -2rem;
	padding: 0.75rem 1.5rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
	background-color: var(--wp--preset--color--white);
}

.booking-confirm__bar::before {
	content: "";
	position: absolute;
	top: -1.25rem;
	left: 0;
	right: 0;
	height: 1.25rem;
	background: linear-gradient(to top, var(--wp--preset--color--white), transparent);
	pointer-events: none;
}

.booking-confirm__submit {
	margin-top: 0;
}

.booking-confirm__submit:disabled {
	opacity: 0.6;
	cursor: wait;
}

.booking-confirm__edit {
	width: 100%;
	height: 3.5rem;
	padding: 0.25rem 2.5rem;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--primary);
	border: 1px solid var(--wp--preset--color--footer-border-light);
	border-radius: 99px;
	font-family: 'Nexa Text BG', Arial, sans-serif;
	font-size: 0.875rem;
	font-weight: 800;
	letter-spacing: 0.09625rem;
	text-transform: uppercase;
	cursor: pointer;
	transition: border-color 0.2s ease;
}

.booking-confirm__edit:hover,
.booking-confirm__edit:focus-visible {
	border-color: var(--wp--preset--color--primary);
}

.booking-confirm.is-visible .booking-confirm__actions {
	animation: zd-booking-rise 0.4s ease-out 0.36s both;
}

@media (prefers-reduced-motion: reduce) {
	.booking-success.is-visible *,
	.booking-notice {
		animation: none !important;
		transition: none !important;
	}

	.booking-success.is-visible .booking-success__check {
		stroke-dashoffset: 0;
	}
}

/* ---------- Invalid patient-form field ---------- */
/* Set by BookingModal.failField() on the field that failed validation
   (missing / wrong phone, bad email…); cleared as soon as the user types. */

.booking-patient-form .booking-patient-form__field.is-invalid .booking-patient-form__input {
	border-color: var(--wp--preset--color--error);
	border-bottom-color: var(--wp--preset--color--error);
	box-shadow: 0 0 0 1px var(--wp--preset--color--error);
}

.booking-patient-form .booking-patient-form__field.is-invalid .booking-patient-form__label,
.booking-patient-form .booking-patient-form__field.is-invalid .booking-patient-form__input:focus ~ .booking-patient-form__label,
.booking-patient-form .booking-patient-form__field.is-invalid .booking-patient-form__input:not(:placeholder-shown) ~ .booking-patient-form__label {
	color: var(--wp--preset--color--error);
}
/* ---------- Doctor name on a time slot ----------
 * Cabinet calendars (the duty pediatrician, 27) aggregate several doctors'
 * calendars; each slot then names the doctor who performs it
 * (`doctor_name` in the availability cache). Shown under the time, small.
 */

.booking-time-slot__main {
	display: flex;
	flex-direction: column;
	min-width: 0;
	text-align: left;
}

.booking-time-slot__doctor {
	font-size: 0.8125rem;
	font-weight: 300;
	line-height: 1.25;
	color: var(--wp--preset--color--base-dark);
	overflow-wrap: anywhere;
}

/* ---------- Exam-only mode (add-on service, API `is_exam_required`) ----------
 * The add-on row's „Запиши час" on the doctor page (and `?zapishi=pregled`)
 * puts `.is-exam-only` on the modal: only the primary/secondary exam cards stay,
 * with a note naming the add-on. Wired in template-parts/booking/booking-box.php. */
.booking-services__exam-note {
	display: none;
	margin: 0 0 1rem;
	padding: 0.875rem 1rem;
	border-radius: 0.75rem;
	background-color: var(--wp--preset--color--surface-muted);
	color: var(--wp--preset--color--base-dark);
	font-size: 0.9375rem;
	line-height: 1.45;
}

.booking-modal.is-exam-only .booking-services__exam-note {
	display: block;
}

.booking-modal.is-exam-only [data-service-select]:not([data-exam-kind]) {
	display: none;
}

/* „Уведоми ме за по-ранен час“ on the confirm screen (booking-confirm.php,
 * inc/waitlist-earlier-slot.php). The label reuses .zd-patient-picker__save. */
.booking-confirm__earlier {
	width: 100%;
	margin: 1.25rem 0 1.5rem;
	text-align: left;
}

.booking-confirm__earlier[hidden] {
	display: none;
}

.booking-confirm__earlier .zd-patient-picker__save {
	margin-top: 0;
	align-items: flex-start;
}

.booking-success__earlier {
	margin-top: 1rem;
}

/* ---------- Patient fields: the label floats whenever the field has a value ----------
 * The SCSS (booking-components/_patient-form.scss) floats it on :focus and
 * :not(:placeholder-shown). Some Android browsers keep :placeholder-shown while the
 * keyboard composes a word, or after autofill, so the label printed over the value.
 * booking-patients.js also sets .is-filled on input/change/autofill; :autofill is
 * the CSS side of the same thing. Same look as the SCSS float. */
.booking-modal .booking-patient-form__field.is-filled .booking-patient-form__label,
.booking-modal .booking-patient-form__field:focus-within .booking-patient-form__label {
	top: -0.625rem;
	left: 0;
	font-size: 0.75rem;
	font-weight: 500;
	color: var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--white);
}

/* Separate rules: a browser that does not know one of the selectors drops only that rule. */
.booking-modal .booking-patient-form__input:-webkit-autofill ~ .booking-patient-form__label {
	top: -0.625rem;
	font-size: 0.75rem;
	color: var(--wp--preset--color--primary);
}

.booking-modal .booking-patient-form__input:autofill ~ .booking-patient-form__label {
	top: -0.625rem;
	font-size: 0.75rem;
	color: var(--wp--preset--color--primary);
}

/* ---------- Booking modal on phones: tighter frame, one-line labels ----------
 * Alek, 2026-12-05: „reduce text size so it fits one line, may also reduce margins
 * and paddings on mobile too to fit“. 24px → 16px around the steps, the field
 * label at rest the size of the typed text (14px), and a label never wraps under
 * the calendar icon of the birth date. */
@media (max-width: 767px) {
	.booking-modal .booking-modal__header {
		padding: 1rem 1rem 0.75rem;
	}

	.booking-modal .booking-modal__progress-wrapper {
		padding: 0.75rem 1rem;
	}

	.booking-modal .booking-step__content {
		padding: 1rem;
	}

	.booking-modal .booking-step__section {
		margin-bottom: 1.25rem;
	}

	.booking-modal .booking-patient-form {
		margin-top: 1rem;
	}

	.booking-modal .booking-patient-form__label {
		font-size: 0.875rem;
		max-width: 100%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	/* „Рождена дата на пациента (по желание)“ sits beside the calendar button. */
	.booking-modal .zd-patient-picker .zd-date ~ .booking-patient-form__label {
		max-width: calc(100% - 2.75rem);
		font-size: 0.8125rem;
	}

	.booking-modal .booking-patient-type {
		padding-top: 0.25rem;
	}
}
