/**
 * Guesto Pre-Book — GuesTO React / shadcn visual system.
 * Uses --g-* tokens from neve-guesto theme (fallbacks included).
 */

.guesto-prebook {
	--g-font: 'Inter', system-ui, -apple-system, sans-serif;
	--g-background: hsl(220, 20%, 97%);
	--g-foreground: hsl(215, 28%, 14%);
	--g-card: hsl(0, 0%, 100%);
	--g-primary: hsl(215, 28%, 17%);
	--g-primary-fg: hsl(210, 40%, 98%);
	--g-accent: hsl(38, 92%, 50%);
	--g-accent-fg: hsl(30, 50%, 10%);
	--g-muted: hsl(220, 14%, 96%);
	--g-muted-fg: hsl(220, 9%, 46%);
	--g-border: hsl(220, 13%, 91%);
	--g-success: hsl(142, 71%, 45%);
	--g-destructive: hsl(0, 72%, 51%);
	--g-radius: 6px;
	--g-radius-lg: 8px;
	--g-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--g-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--g-ease-out: cubic-bezier(0.16, 1, 0.3, 1);

	font-family: var(--g-font);
	color: var(--g-foreground);
	max-width: 640px;
	margin: 0 auto;
	-webkit-font-smoothing: antialiased;
}

/* Card shell (also styled when nested in theme section) */
.guesto-prebook__card {
	background: var(--g-card);
	border: 1px solid var(--g-border);
	border-radius: var(--g-radius-lg);
	box-shadow: var(--g-shadow-sm);
	overflow: hidden;
	transition: box-shadow 0.35s ease, transform 0.35s var(--g-ease);
}

#guesto-prebook.is-visible .guesto-prebook__card {
	animation: guesto-scale-in 0.55s var(--g-ease-out) both;
}

#guesto-prebook.is-visible .guesto-prebook__card:hover {
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
}

@keyframes guesto-scale-in {
	from {
		opacity: 0;
		transform: scale(0.96);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.guesto-prebook__card-header {
	padding: 16px 24px;
	border-bottom: 1px solid var(--g-border);
}

.guesto-prebook__card-title {
	margin: 0 0 4px;
	font-size: 1rem;
	font-weight: 600;
	color: var(--g-foreground);
	letter-spacing: -0.01em;
}

.guesto-prebook__card-desc {
	margin: 0;
	font-size: 0.875rem;
	color: var(--g-muted-fg);
	line-height: 1.45;
}

.guesto-prebook__card-body {
	padding: 20px 24px 24px;
}

/* —— Connected rail stepper —— */
.guesto-prebook__steps {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	list-style: none;
	margin: 0 0 1.75rem;
	padding: 0;
	position: relative;
}

.guesto-prebook__steps::before {
	content: "";
	position: absolute;
	top: 1rem;
	left: calc(16.66% + 1rem);
	right: calc(16.66% + 1rem);
	height: 2px;
	background: var(--g-border);
	z-index: 0;
}

.guesto-prebook__steps::after {
	content: "";
	position: absolute;
	top: 1rem;
	left: calc(16.66% + 1rem);
	height: 2px;
	width: 0;
	background: var(--g-success);
	z-index: 0;
	border-radius: 1px;
	transition: width 0.55s var(--g-ease-out);
	pointer-events: none;
}

#guesto-prebook[data-step="otp"] .guesto-prebook__steps::after {
	width: calc(33.33% - 1rem);
}

#guesto-prebook[data-step="confirmation"] .guesto-prebook__steps::after {
	width: calc(66.66% - 2rem);
}

@keyframes gp-step-pop {
	0% { transform: scale(0.85); }
	60% { transform: scale(1.08); }
	100% { transform: scale(1); }
}

.guesto-prebook__steps li.is-done .guesto-prebook__step-circle::after {
	animation: gp-check-in 0.35s var(--g-ease-out) 0.1s both;
}

@keyframes gp-check-in {
	from {
		opacity: 0;
		transform: rotate(-45deg) translateY(-1px) scale(0.5);
	}
	to {
		opacity: 1;
		transform: rotate(-45deg) translateY(-1px) scale(1);
	}
}

.guesto-prebook__steps li {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	position: relative;
	z-index: 1;
	text-align: center;
	padding: 0;
	background: none;
	border: none;
	border-radius: 0;
	box-shadow: none;
	transform: none;
	transition: none;
}

.guesto-prebook__step-circle {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-size: 0.75rem;
	font-weight: 600;
	border: 2px solid var(--g-border);
	background: var(--g-card);
	color: var(--g-muted-fg);
	transition: background 0.3s var(--g-ease), border-color 0.3s var(--g-ease), color 0.3s var(--g-ease), box-shadow 0.3s var(--g-ease);
}

.guesto-prebook__step-label {
	font-size: 0.6875rem;
	font-weight: 500;
	color: var(--g-muted-fg);
	line-height: 1.2;
	max-width: 5.5rem;
	transition: color 0.3s ease, font-weight 0.3s ease;
}

.guesto-prebook__steps li.is-active .guesto-prebook__step-circle {
	background: var(--g-primary);
	border-color: var(--g-primary);
	color: var(--g-primary-fg);
	box-shadow: 0 0 0 4px hsl(215 28% 17% / 0.1);
	animation: gp-step-pop 0.4s var(--g-ease-out);
}

.guesto-prebook__steps li.is-active .guesto-prebook__step-label {
	color: var(--g-foreground);
	font-weight: 600;
}

.guesto-prebook__steps li.is-done .guesto-prebook__step-circle {
	background: var(--g-success);
	border-color: var(--g-success);
	color: #fff;
	font-size: 0;
}

.guesto-prebook__steps li.is-done .guesto-prebook__step-circle::after {
	content: "";
	width: 0.65rem;
	height: 0.35rem;
	border-left: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(-45deg) translateY(-1px);
}

.guesto-prebook__steps li.is-done .guesto-prebook__step-label {
	color: var(--g-muted-fg);
}

/* Status banner */
.guesto-prebook__status {
	margin-bottom: 1rem;
	padding: 10px 14px;
	border-radius: var(--g-radius);
	background: hsl(0 72% 51% / 0.08);
	color: var(--g-destructive);
	border: 1px solid hsl(0 72% 51% / 0.2);
	font-size: 0.8125rem;
	font-weight: 500;
	animation: gp-fade-in 0.35s ease-out both;
}

.guesto-prebook__status.is-success {
	background: hsl(142 71% 45% / 0.08);
	color: hsl(142 71% 32%);
	border-color: hsl(142 71% 45% / 0.25);
}

@keyframes gp-fade-in {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Panel transitions */
.guesto-prebook__panel.is-entering {
	animation: gp-panel-in 0.4s var(--g-ease) both;
}

.guesto-prebook__panel.is-leaving {
	animation: gp-panel-out 0.25s ease both;
	pointer-events: none;
}

@keyframes gp-panel-in {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes gp-field-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.guesto-prebook__panel.is-entering .guesto-prebook__form > * {
	animation: gp-field-in 0.42s var(--g-ease-out) both;
}

.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(1) { animation-delay: 0.04s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(2) { animation-delay: 0.08s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(3) { animation-delay: 0.12s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(4) { animation-delay: 0.16s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(5) { animation-delay: 0.2s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(6) { animation-delay: 0.24s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(7) { animation-delay: 0.28s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(8) { animation-delay: 0.32s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(9) { animation-delay: 0.36s; }
.guesto-prebook__panel.is-entering .guesto-prebook__form > *:nth-child(10) { animation-delay: 0.4s; }

@keyframes gp-panel-out {
	from { opacity: 1; transform: translateY(0); }
	to { opacity: 0; transform: translateY(-6px); }
}

.guesto-prebook__panel-title {
	margin: 0 0 0.35rem;
	font-size: 1rem;
	font-weight: 600;
	color: var(--g-foreground);
}

.guesto-prebook__panel-text {
	margin: 0 0 1rem;
	font-size: 0.875rem;
	color: var(--g-muted-fg);
	line-height: 1.5;
}

.guesto-prebook__panel-text--muted {
	font-size: 0.8125rem;
}

/* —— Form grid —— */
.guesto-prebook__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 0;
}

.guesto-prebook__grid--3 {
	grid-template-columns: 1fr 1fr 1fr;
}

.guesto-field {
	margin-bottom: 12px;
}

.guesto-field label {
	display: block;
	font-size: 13px;
	font-weight: 500;
	color: var(--g-foreground);
	margin-bottom: 4px;
}

.guesto-field label span[aria-hidden="true"] {
	color: var(--g-destructive);
}

.guesto-field input[type="text"],
.guesto-field input[type="email"],
.guesto-field input[type="tel"],
.guesto-field input[type="date"],
.guesto-field input[type="time"],
.guesto-field select {
	height: 36px;
	width: 100%;
	padding: 0 12px;
	font-size: 14px;
	font-family: var(--g-font);
	border: 1px solid var(--g-border);
	border-radius: var(--g-radius);
	background: var(--g-card);
	color: var(--g-foreground);
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.guesto-field input:focus,
.guesto-field select:focus {
	outline: none;
	border-color: var(--g-primary);
	box-shadow: 0 0 0 2px hsl(215 28% 17% / 0.15);
}

.guesto-field input:focus-visible,
.guesto-field select:focus-visible,
.guesto-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 2px hsl(215 28% 17% / 0.15);
}

.guesto-field.is-invalid input,
.guesto-field.is-invalid select {
	border-color: var(--g-destructive);
	box-shadow: 0 0 0 2px hsl(0 72% 51% / 0.12);
}

.guesto-field__hint {
	margin: 4px 0 0;
	font-size: 12px;
	color: var(--g-muted-fg);
}

.guesto-field__error {
	margin: 4px 0 0;
	font-size: 13px;
	font-weight: 500;
	color: var(--g-destructive);
}

/* Other field expand */
.guesto-field--other {
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	margin-bottom: 0 !important;
	transition: max-height 0.3s var(--g-ease), opacity 0.25s ease, margin 0.25s ease;
}

.guesto-field--other.is-open {
	max-height: 6rem;
	opacity: 1;
	margin-bottom: 12px !important;
}

/* Consent */
.guesto-field--consent {
	padding: 12px;
	background: var(--g-muted);
	border: 1px solid var(--g-border);
	border-radius: var(--g-radius);
	margin-bottom: 16px;
}

.guesto-checkbox {
	display: flex;
	gap: 0.65rem;
	align-items: flex-start;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
	cursor: pointer;
}

.guesto-checkbox input {
	margin-top: 2px;
	width: 1rem;
	height: 1rem;
	accent-color: var(--g-primary);
	flex-shrink: 0;
}

/* Buttons */
.guesto-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	padding: 0 16px;
	font-family: var(--g-font);
	font-size: 14px;
	font-weight: 500;
	border-radius: var(--g-radius);
	border: 1px solid transparent;
	cursor: pointer;
	text-decoration: none;
	transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.2s var(--g-ease-out), box-shadow 0.2s ease;
}

.guesto-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.guesto-btn--primary {
	background: var(--g-primary);
	color: var(--g-primary-fg);
	border-color: var(--g-primary);
	width: 100%;
}

@media (min-width: 640px) {
	.guesto-btn--primary {
		width: auto;
		min-width: 200px;
	}
}

.guesto-btn--primary:hover:not(:disabled) {
	opacity: 0.92;
	transform: translateY(-1px);
	box-shadow: 0 6px 16px hsl(215 28% 17% / 0.22);
}

.guesto-btn--primary:active:not(:disabled) {
	transform: translateY(0);
	transition-duration: 0.08s;
}

.guesto-btn--ghost {
	background: transparent;
	border-color: var(--g-border);
	color: var(--g-foreground);
}

.guesto-btn--ghost:hover:not(:disabled) {
	background: var(--g-muted);
}

.guesto-btn--link {
	background: transparent;
	border: none;
	color: var(--g-muted-fg);
	padding: 0 8px;
	height: auto;
	font-size: 13px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.guesto-btn--link:hover:not(:disabled) {
	color: var(--g-foreground);
}

.guesto-prebook__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
	margin-top: 0.5rem;
}

/* OTP step */
.guesto-prebook__otp {
	max-width: 420px;
	margin: 0 auto;
	text-align: center;
}

.guesto-prebook__otp .guesto-prebook__panel-title,
.guesto-prebook__otp .guesto-prebook__panel-text {
	text-align: center;
}

#guesto-otp-code {
	height: 48px;
	font-size: 1.25rem;
	font-weight: 600;
	font-family: ui-monospace, 'Cascadia Code', monospace;
	letter-spacing: 0.35em;
	text-align: center;
}

.guesto-prebook__otp .guesto-prebook__actions {
	justify-content: center;
}

.guesto-prebook__otp .guesto-btn--primary {
	width: 100%;
}

/* Confirmation */
.guesto-prebook__confirmation {
	text-align: center;
	padding: 0.5rem 0 0;
	animation: gp-fade-in 0.4s ease-out both;
}

.guesto-prebook__confirm-icon {
	width: 3rem;
	height: 3rem;
	margin: 0 auto 1rem;
	border-radius: 50%;
	background: hsl(142 71% 45% / 0.12);
	color: var(--g-success);
	display: grid;
	place-items: center;
	animation: gp-confirm-pop 0.55s var(--g-ease-out) 0.1s both;
}

@keyframes gp-confirm-pop {
	0% {
		opacity: 0;
		transform: scale(0.6);
	}
	70% {
		transform: scale(1.08);
	}
	100% {
		opacity: 1;
		transform: scale(1);
	}
}

.guesto-prebook__confirm-icon svg {
	width: 1.5rem;
	height: 1.5rem;
	stroke: currentColor;
	stroke-width: 2.5;
	fill: none;
}

.guesto-prebook__confirm-mail {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	font-size: 0.875rem;
	color: var(--g-foreground);
}

.guesto-prebook__confirm-mail svg {
	width: 1rem;
	height: 1rem;
	stroke: var(--g-muted-fg);
	stroke-width: 2;
	fill: none;
	flex-shrink: 0;
}

@media (max-width: 640px) {
	.guesto-prebook__card-body {
		padding: 16px;
	}

	.guesto-prebook__card-header {
		padding: 14px 16px;
	}

	.guesto-prebook__grid,
	.guesto-prebook__grid--3 {
		grid-template-columns: 1fr;
	}

	.guesto-prebook__steps::before {
		left: calc(16.66% + 0.5rem);
		right: calc(16.66% + 0.5rem);
	}

	.guesto-prebook__step-label {
		font-size: 0.625rem;
		max-width: 4.5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.guesto-prebook__panel.is-entering,
	.guesto-prebook__panel.is-leaving,
	.guesto-prebook__panel.is-entering .guesto-prebook__form > *,
	.guesto-prebook__status,
	.guesto-prebook__confirmation,
	.guesto-prebook__confirm-icon,
	.guesto-prebook__step-circle,
	#guesto-prebook.is-visible .guesto-prebook__card,
	.guesto-prebook__steps::after {
		animation: none !important;
		transition: none !important;
	}

	#guesto-prebook[data-step="otp"] .guesto-prebook__steps::after {
		width: calc(33.33% - 1rem);
	}

	#guesto-prebook[data-step="confirmation"] .guesto-prebook__steps::after {
		width: calc(66.66% - 2rem);
	}
}
