/* ==========================================================================
   Terrazza Booking – frontend
   Personalizzazione: --tsb-accent / --tsb-text (da Impostazioni) e le variabili sotto.
   ========================================================================== */
.tsb {
	--tsb-accent: #d9a441;
	--tsb-accent-soft: color-mix(in srgb, var(--tsb-accent) 18%, #fff);
	--tsb-text: #1f2328;
	--tsb-muted: #8a8f98;
	--tsb-border: #e6e6e6;
	--tsb-bg: #fff;
	--tsb-radius: 8px;
	--tsb-shadow: 0 12px 40px rgba(0, 0, 0, .14);
	--tsb-font: inherit;
	color: var(--tsb-text);
	font-family: var(--tsb-font);
	font-size: 15px;
	line-height: 1.45;
	box-sizing: border-box;
}
.tsb *, .tsb *::before, .tsb *::after { box-sizing: inherit; }
.tsb [hidden] { display: none !important; }
.tsb button { font: inherit; }

/* ---------- Pulsanti ---------- */
.tsb-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 0 22px;
	border: 1px solid transparent; border-radius: var(--tsb-radius);
	font-weight: 600; cursor: pointer; text-decoration: none;
	transition: filter .15s, background .15s, opacity .15s;
}
.tsb-btn--primary { background: var(--tsb-accent); color: var(--tsb-text); }
.tsb-btn--primary:hover { filter: brightness(.95); }
.tsb-btn--ghost { background: transparent; color: var(--tsb-text); border-color: var(--tsb-border); }
.tsb-btn--ghost:hover { border-color: var(--tsb-text); }
.tsb-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.tsb-btn:focus-visible, .tsb-field:focus-visible, .tsb-cal__day:focus-visible { outline: 2px solid var(--tsb-text); outline-offset: 2px; }

/* ---------- Barra di ricerca ---------- */
.tsb-search {
	position: relative;
	display: flex; align-items: stretch; gap: 10px;
	width: 100%; max-width: 820px; margin: 0 auto;
}
.tsb-search__dates {
	position: relative; flex: 1.4;
	display: flex; align-items: stretch;
	background: var(--tsb-bg); border-radius: var(--tsb-radius);
	border: 1px solid var(--tsb-border);
}
.tsb-search__sep { width: 1px; background: var(--tsb-border); margin: 10px 0; }
.tsb-field {
	flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2px;
	min-height: 56px; padding: 8px 14px;
	background: var(--tsb-bg); border: 0; border-radius: var(--tsb-radius);
	text-align: left; color: var(--tsb-text); cursor: pointer;
}
.tsb-field--guests { flex: 1; border: 1px solid var(--tsb-border); position: relative; }
.tsb-field__label { font-size: 11px; color: var(--tsb-muted); letter-spacing: .02em; }
.tsb-field__value { font-size: 15px; font-weight: 500; white-space: nowrap; }
.tsb-field.is-empty .tsb-field__value { color: var(--tsb-muted); font-weight: 400; }
.tsb-search.is-open .tsb-field--date.is-active { box-shadow: inset 0 -2px 0 var(--tsb-accent); }
.tsb-field__select {
	appearance: none; -webkit-appearance: none;
	border: 0; background: transparent; padding: 0 22px 0 0; margin: 0;
	font: inherit; font-size: 15px; font-weight: 500; color: var(--tsb-text); cursor: pointer;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231f2328' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right center;
}
.tsb-field__select:focus { outline: none; }
.tsb-search__submit { flex: 0 0 auto; min-width: 190px; min-height: 58px; }
.tsb-search--floating .tsb-search__dates,
.tsb-search--floating .tsb-field--guests { border-color: transparent; box-shadow: 0 2px 10px rgba(0,0,0,.08); }

/* Popover calendario: si apre sopra la barra (come nell'Hero), sotto se non c'è spazio. */
.tsb-popover {
	position: absolute; z-index: 9999; left: 0; bottom: calc(100% + 10px);
	width: min(700px, calc(100vw - 32px));
	background: var(--tsb-bg); border-radius: var(--tsb-radius); box-shadow: var(--tsb-shadow);
	padding: 18px 22px 20px;
}
.tsb-search--below .tsb-popover { bottom: auto; top: calc(100% + 10px); }

/* ---------- Calendario ---------- */
.tsb-cal { position: relative; }
.tsb-cal__nav { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; pointer-events: none; }
.tsb-cal__arrow {
	pointer-events: auto; width: 34px; height: 30px; border: 0; background: transparent;
	font-size: 18px; color: var(--tsb-text); cursor: pointer; border-radius: 6px;
}
.tsb-cal__arrow:hover:not(:disabled) { background: #f4f4f4; }
.tsb-cal__arrow:disabled { color: #d0d0d0; cursor: default; }
.tsb-cal__months { display: grid; grid-template-columns: repeat(2, 1fr); gap: 32px; }
.tsb-cal[data-months="1"] .tsb-cal__months { grid-template-columns: 1fr; }
.tsb-cal__title { text-align: center; font-weight: 500; height: 30px; line-height: 30px; text-transform: lowercase; }
.tsb-cal__title::first-letter { text-transform: none; }
.tsb-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; margin-top: 8px; }
.tsb-cal__dow { text-align: center; font-size: 12px; color: var(--tsb-muted); padding-bottom: 6px; }
.tsb-cal__day {
	position: relative; height: 40px; border: 0; background: transparent; padding: 0;
	font-size: 14px; color: var(--tsb-text); cursor: pointer;
}
.tsb-cal__day > span {
	display: inline-flex; align-items: center; justify-content: center;
	width: 36px; height: 36px; border-radius: 6px;
}
.tsb-cal__day:hover:not(:disabled) > span { box-shadow: inset 0 0 0 1px var(--tsb-text); }
.tsb-cal__day:disabled { cursor: default; color: #c4c7cc; }
.tsb-cal__day.is-past { color: #d6d8db; }
.tsb-cal__day.is-booked > span { text-decoration: line-through; }
.tsb-cal__day.is-booked:disabled { color: #b9bcc2; }
.tsb-cal__day.is-checkout-only:not(:disabled) { color: var(--tsb-text); }
.tsb-cal__day.is-checkout-only > span { text-decoration: none; }
.tsb-cal__day.is-today > span { font-weight: 700; }
.tsb-cal__day.is-in-range,
.tsb-cal__day.is-hover-range { background: var(--tsb-accent-soft); }
.tsb-cal__day.is-start > span,
.tsb-cal__day.is-end > span { background: var(--tsb-accent); color: var(--tsb-text); font-weight: 600; }
.tsb-cal__day.is-start { background: linear-gradient(90deg, transparent 50%, var(--tsb-accent-soft) 50%); }
.tsb-cal__day.is-end { background: linear-gradient(90deg, var(--tsb-accent-soft) 50%, transparent 50%); }
.tsb-cal__day.is-start.is-end, .tsb-cal__day.is-start:last-child { background: transparent; }
/* Tooltip "Minimo N notti" */
.tsb-cal__day[data-tip]:hover::after {
	content: attr(data-tip);
	position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
	background: #111; color: #fff; font-size: 12px; white-space: nowrap;
	padding: 5px 9px; border-radius: 6px; z-index: 2; pointer-events: none;
}

/* ---------- Checkout ---------- */
.tsb-checkout { max-width: 1120px; margin: 0 auto; }
.tsb-steps { display: flex; gap: 12px; list-style: none; padding: 0; margin: 0 0 28px; font-size: 14px; color: var(--tsb-muted); }
.tsb-steps li { display: flex; align-items: center; gap: 12px; }
.tsb-steps li + li::before { content: '›'; color: var(--tsb-muted); }
.tsb-steps li.is-active { color: var(--tsb-text); text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--tsb-accent); text-decoration-thickness: 2px; }
.tsb-steps li.is-done { color: var(--tsb-text); }
.tsb-checkout__grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: start; }
.tsb-h { font-size: 22px; font-weight: 600; margin: 0 0 18px; }
.tsb-search--inline { max-width: none; margin-bottom: 18px; }
.tsb-inline-cal { border: 1px solid var(--tsb-border); border-radius: var(--tsb-radius); padding: 18px 20px; }
.tsb-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tsb-input { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--tsb-border); border-radius: var(--tsb-radius); padding: 8px 14px; background: var(--tsb-bg); position: relative; }
.tsb-input:focus-within { border-color: var(--tsb-text); }
.tsb-input > span { font-size: 12px; color: var(--tsb-muted); }
.tsb-input input, .tsb-input textarea { border: 0 !important; outline: 0; padding: 0 !important; margin: 0; font: inherit; color: var(--tsb-text); background: transparent; box-shadow: none !important; min-height: 24px; width: 100%; }
.tsb-input--full { margin-top: 14px; }
.tsb-input:has(.is-invalid) { border-color: #c0392b; }
.tsb-input__err { font-style: normal; font-size: 12px; color: #c0392b; }
.tsb-input__err:empty { display: none; }
.tsb-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.tsb-methods { display: grid; gap: 10px; margin-bottom: 18px; }
.tsb-method { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--tsb-border); border-radius: var(--tsb-radius); padding: 14px 16px; cursor: pointer; }
.tsb-method:has(input:checked) { border-color: var(--tsb-accent); box-shadow: 0 0 0 1px var(--tsb-accent); }
.tsb-method input { margin-top: 3px; accent-color: var(--tsb-accent); }
.tsb-method__body { display: flex; flex-direction: column; gap: 2px; }
.tsb-method__body small { color: var(--tsb-muted); }
.tsb-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.tsb-check input { margin-top: 3px; accent-color: var(--tsb-accent); }
.tsb-check a { color: inherit; text-decoration: underline; }
.tsb-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.tsb-actions--start { justify-content: flex-start; margin-top: 12px; }
.tsb-msg { margin: 12px 0 0; font-size: 14px; }
.tsb-msg:empty { display: none; }
.tsb-msg.is-error { color: #c0392b; }
.tsb-msg.is-ok { color: #1e7e34; }
.tsb-muted { color: var(--tsb-muted); }
.tsb-small { font-size: 13px; }

/* Riepilogo */
.tsb-summary {
	position: sticky; top: 24px;
	border: 1px solid var(--tsb-border); border-radius: 12px; padding: 22px; background: var(--tsb-bg);
}
.tsb-summary__title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.tsb-summary__property { margin: 0 0 16px; color: var(--tsb-muted); font-size: 14px; }
.tsb-summary__body { transition: opacity .15s; }
.tsb-summary__body.is-loading { opacity: .4; }
.tsb-summary__dates { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; padding: 14px 0; border-top: 1px solid var(--tsb-border); border-bottom: 1px solid var(--tsb-border); }
.tsb-summary__dates small { display: block; font-size: 12px; color: var(--tsb-muted); }
.tsb-summary__rows { margin: 14px 0 0; }
.tsb-summary__rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.tsb-summary__rows dt, .tsb-summary__rows dd { margin: 0; }
.tsb-summary__rows .is-total { border-top: 1px solid var(--tsb-border); margin-top: 8px; padding-top: 12px; font-weight: 700; font-size: 17px; }
.tsb-summary__pay { background: var(--tsb-accent-soft); border-radius: var(--tsb-radius); padding: 8px 12px; }
.tsb-summary__pay .is-strong { font-weight: 700; }

/* Pagina stato */
.tsb-status { max-width: 720px; margin: 0 auto; }
.tsb-status__head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.tsb-card { border: 1px solid var(--tsb-border); border-radius: 12px; padding: 18px 20px; margin-top: 18px; background: var(--tsb-bg); }
.tsb-badge { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #eef0f2; }
.tsb-badge--confirmed { background: #e3f4e8; color: #1e7e34; }
.tsb-badge--pending_payment { background: var(--tsb-accent-soft); }
.tsb-badge--expired, .tsb-badge--cancelled, .tsb-badge--conflict { background: #fbe9e7; color: #c0392b; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
	.tsb-checkout__grid { grid-template-columns: 1fr; }
	.tsb-summary { position: static; order: -1; }
}
@media (max-width: 640px) {
	.tsb-search { flex-direction: column; }
	.tsb-search__submit { width: 100%; }
	.tsb-grid2 { grid-template-columns: 1fr; }
	.tsb-inline-cal { padding: 12px; }
}
/* Pannello calendario mobile (spostato nel <body> dal JS) */
.tsb-popover.tsb-popover--sheet {
	position: fixed; z-index: 100000; left: 0; right: 0; bottom: 0; top: auto;
	width: auto; max-height: 88vh; overflow: auto;
	border-radius: 16px 16px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
	box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
.tsb-backdrop { position: fixed; inset: 0; z-index: 99999; background: rgba(0, 0, 0, .45); }
html.tsb-no-scroll, html.tsb-no-scroll body { overflow: hidden; }
