/**
 * Calendario e orari del modulo di prenotazione (tema Ticket v1.7).
 *
 * Ridisegna il datepicker jQuery UI di WooCommerce Bookings nelle pagine prodotto:
 * scheda bianca, mese a sinistra con frecce rotonde, giorni prenotabili in verde chiaro,
 * data scelta in verde pieno, orari a griglia. Il verde resta l'unico colore e indica
 * sempre la disponibilita'.
 * Sostituisce le vecchie regole del calendario in style.css (v1.6 e precedenti).
 * Legenda e titolo degli orari: js/tkt-calendar.js. PWA e totem non usano il tema.
 */

.wc-bookings-booking-form {
	--tkt-cal-green: #176d3b;       /* data/orario scelto: testo bianco 6.4:1 */
	--tkt-cal-green-ink: #11522c;   /* numeri sui giorni prenotabili */
	--tkt-cal-green-soft: #e3f1e7;  /* giorno prenotabile */
	--tkt-cal-green-soft-hover: #cfe7d6;
	--tkt-cal-ring: rgba(23, 109, 59, 0.24);
	--tkt-cal-ink: #1d211f;
	--tkt-cal-muted: #6c736f;
	--tkt-cal-off: #b4bab6;         /* giorno non prenotabile */
	--tkt-cal-line: #e2e6e3;
	--tkt-cal-sold: #a3261c;
	--tkt-cal-sold-soft: #fbeceb;
	--tkt-cal-radius: 18px;
	--tkt-cal-cell-radius: 12px;
	--tkt-cal-cell-h: 48px;
	--tkt-cal-gap: 6px;
}

/* ---------- Scheda ---------- */

/* La scheda e' il contenitore esterno: Bookings e jQuery UI ridisegnano (o svuotano) solo
   .picker, quindi la legenda accodata dopo .picker resta al suo posto. */
.wc-bookings-booking-form .wc-bookings-date-picker {
	max-width: 560px;
	margin: 0;
	padding: 20px 20px 8px !important;
	border: 1px solid var(--tkt-cal-line);
	border-radius: var(--tkt-cal-radius);
	background: #fff;
	box-shadow: 0 1px 2px rgba(17, 40, 27, 0.05), 0 10px 28px -12px rgba(17, 40, 27, 0.14);
	line-height: 1.5;
}

.wc-bookings-booking-form .wc-bookings-date-picker .picker,
.wc-bookings-booking-form .wc-bookings-date-picker .picker.hasDatepicker {
	margin: 0;
	line-height: 1;
}

.wc-bookings-booking-form .wc-bookings-date-picker-timezone-block {
	display: none;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker {
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--tkt-cal-ink);
	font-family: "Titillium Web", Arial, sans-serif;
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
}

/* ---------- Intestazione: mese a sinistra, frecce a destra ---------- */

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-header {
	position: relative;
	margin: 0 0 12px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: var(--tkt-cal-ink);
	text-transform: none;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-title {
	margin: 0;
	padding: 6px 104px 6px 4px;
	font-size: 1.3rem;
	font-weight: 600;
	line-height: 28px;
	text-align: left;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-title .ui-datepicker-year {
	color: var(--tkt-cal-muted);
	font-weight: 400;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next {
	position: absolute;
	top: 0;
	left: auto;
	display: block;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--tkt-cal-line) !important;
	border-radius: 50%;
	background: #fff !important;
	color: var(--tkt-cal-ink);
	cursor: pointer;
	opacity: 1;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev {
	right: 48px;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next {
	right: 0;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev:hover,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next:hover,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev.ui-state-hover,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next.ui-state-hover {
	border-color: var(--tkt-cal-green) !important;
	background: var(--tkt-cal-green) !important;
	color: #fff;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev.ui-state-disabled,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next.ui-state-disabled {
	border-color: var(--tkt-cal-line) !important;
	background: #fff !important;
	color: var(--tkt-cal-ink);
	opacity: 0.3;
	cursor: default;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev:focus-visible,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next:focus-visible {
	outline: 2px solid var(--tkt-cal-green) !important;
	outline-offset: 2px;
}

/* Freccia disegnata in CSS al posto dello sprite PNG di jQuery UI */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev span.ui-icon,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next span.ui-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	display: block;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	background: currentColor !important;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
	overflow: hidden;
	text-indent: -9999px;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev span.ui-icon {
	transform: scaleX(-1);
}

/* ---------- Griglia ---------- */

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar {
	width: calc(100% + 2 * var(--tkt-cal-gap));
	margin: 0 calc(-1 * var(--tkt-cal-gap));
	border: 0;
	border-collapse: separate;
	border-spacing: var(--tkt-cal-gap);
	background: transparent !important;
	font-size: 1rem;
	table-layout: fixed;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar th {
	padding: 0 0 4px;
	border: 0 !important;
	background: none;
	color: var(--tkt-cal-muted);
	font-size: 0.8rem;
	font-weight: 600;
	text-align: center;
	text-transform: uppercase;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td {
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
	opacity: 1;
}

/* Base di ogni giorno: <a> se prenotabile, <span> se no */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td .ui-state-default {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: var(--tkt-cal-cell-h);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--tkt-cal-cell-radius);
	background: transparent !important;
	box-shadow: none !important;
	color: var(--tkt-cal-off) !important;
	font-weight: 400;
	line-height: 1;
	text-align: center;
	text-decoration: none !important;
	text-shadow: none !important;
}

/* Giorno prenotabile (anche se parzialmente prenotato) */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td a.ui-state-default {
	background: var(--tkt-cal-green-soft) !important;
	color: var(--tkt-cal-green-ink) !important;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td a.ui-state-default:hover {
	background: var(--tkt-cal-green-soft-hover) !important;
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td a.ui-state-default:active {
	transform: scale(0.94);
}

.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td a.ui-state-default:focus-visible {
	outline: 2px solid var(--tkt-cal-green) !important;
	outline-offset: 2px;
}

/* Giorni del mese prima/dopo: nascosti, ogni griglia mostra un solo mese */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td.ui-datepicker-other-month .ui-state-default {
	visibility: hidden;
}

/* Esaurito (non i giorni chiusi per regola) */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td.fully_booked:not(.not_bookable_by_rules) .ui-state-default {
	background: var(--tkt-cal-sold-soft) !important;
	color: var(--tkt-cal-sold) !important;
	font-weight: 400;
	text-decoration: line-through !important;
	text-decoration-thickness: 1.5px !important;
}

/* Oggi: puntino sotto il numero */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td.ui-datepicker-today .ui-state-default::after {
	content: "";
	position: absolute;
	bottom: 7px;
	left: 50%;
	width: 5px;
	height: 5px;
	margin-left: -2.5px;
	border-radius: 50%;
	background: currentColor;
}

/* Data scelta. jQuery UI segna "oggi" come giorno corrente anche prima che il visitatore
   scelga: il verde pieno compare solo quando il campo giorno e' davvero compilato.
   I giorni di un biglietto su piu' giorni (bookable-range) restano verdi anche al passaggio del mouse. */
.wc-bookings-booking-form .wc-bookings-date-picker:not(:has(.booking_date_day:placeholder-shown)) table.ui-datepicker-calendar td.ui-datepicker-current-day a.ui-state-default,
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker table.ui-datepicker-calendar td.bookable-range a.ui-state-default {
	background: var(--tkt-cal-green) !important;
	box-shadow: 0 0 0 3px var(--tkt-cal-ring), 0 6px 14px -6px rgba(23, 109, 59, 0.6) !important;
	color: #fff !important;
	opacity: 1 !important;
}

/* ---------- Legenda (aggiunta da js/tkt-calendar.js dopo .picker) ---------- */

.wc-bookings-booking-form .tkt-cal-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	margin: 6px 0 0;
	padding: 12px 4px 6px;
	border-top: 1px solid var(--tkt-cal-line);
	color: var(--tkt-cal-muted);
	font-size: 0.85rem;
	line-height: 1.3;
	list-style: none;
}

.wc-bookings-booking-form .tkt-cal-legend li {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
}

.wc-bookings-booking-form .tkt-cal-legend li::before {
	content: "";
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	border-radius: 4px;
}

.wc-bookings-booking-form .tkt-cal-legend .tkt-cal-legend__free::before {
	background: var(--tkt-cal-green-soft);
	box-shadow: inset 0 0 0 1px rgba(17, 82, 44, 0.18);
}

.wc-bookings-booking-form .tkt-cal-legend .tkt-cal-legend__chosen::before {
	background: var(--tkt-cal-green);
}

.wc-bookings-booking-form .tkt-cal-legend .tkt-cal-legend__sold::before {
	background: linear-gradient(to top right, transparent calc(50% - 1px), var(--tkt-cal-sold) calc(50% - 1px), var(--tkt-cal-sold) calc(50% + 1px), transparent calc(50% + 1px)), var(--tkt-cal-sold-soft);
}

/* ---------- Orari ---------- */

/* style.css fissa .form-field a 40px: il contenitore degli orari cresce con la griglia */
.wc-bookings-booking-form div.form-field.form-field-wide {
	height: auto;
}

.wc-bookings-booking-form .time-picker-fieldset {
	max-width: 560px;
}

.wc-bookings-booking-form .tkt-slots-head {
	display: none;
	margin: 0 0 14px;
}

.wc-bookings-booking-form .time-picker-fieldset.tkt-has-slots .tkt-slots-head {
	display: block;
}

.wc-bookings-booking-form .tkt-slots-head h4 {
	margin: 0;
}

.wc-bookings-booking-form .tkt-slots-date {
	margin: 4px 0 0;
	color: var(--tkt-cal-muted);
	font-size: 1rem;
}

.wc-bookings-booking-form .tkt-slots-date:empty {
	display: none;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker {
	display: grid !important;
	grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	overflow: visible;
	list-style: none;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li {
	float: none;
	width: auto;
	min-width: 0;
	height: auto !important;
	margin: 0;
	padding: 0;
}

/* il <li> vuoto del template prima della scelta della data */
.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li:empty {
	display: none;
}

/* messaggi di Bookings al posto degli orari (es. "nessun orario disponibile") */
.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li:not(.block) {
	grid-column: 1 / -1;
	color: var(--tkt-cal-muted);
	font-size: 1rem;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: auto !important;
	height: auto !important;
	min-height: 48px;
	padding: 6px 8px;
	border: 1px solid var(--tkt-cal-line) !important;
	border-radius: var(--tkt-cal-cell-radius);
	background: #fff !important;
	box-shadow: 0 1px 2px rgba(17, 40, 27, 0.05);
	color: var(--tkt-cal-ink) !important;
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a:hover,
.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a:focus {
	border-color: var(--tkt-cal-green) !important;
	background: var(--tkt-cal-green-soft) !important;
	color: var(--tkt-cal-green-ink) !important;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a:focus-visible {
	outline: 2px solid var(--tkt-cal-green) !important;
	outline-offset: 2px;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a:active {
	transform: scale(0.96);
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a.selected {
	border-color: var(--tkt-cal-green) !important;
	background: var(--tkt-cal-green) !important;
	box-shadow: 0 0 0 3px var(--tkt-cal-ring), 0 6px 14px -6px rgba(23, 109, 59, 0.6);
	color: #fff !important;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a small.booking-spaces-left {
	display: block;
	margin: 2px 0 0;
	color: inherit;
	font-size: 0.72rem;
	font-weight: 400;
	opacity: 0.8;
}

.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li.fully_booked a {
	border-color: transparent !important;
	background: #f3f4f3 !important;
	box-shadow: none;
	color: var(--tkt-cal-off) !important;
	text-decoration: line-through !important;
	opacity: 1;
}

/* Bootstrap Italia colora di arancio ogni elemento a fuoco: nel calendario l'anello resta, ma verde
   (con il contorno pieno di :focus-visible per chi naviga da tastiera). */
.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker a:focus:not(.focus--mouse),
.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a:focus:not(.focus--mouse) {
	border-color: var(--tkt-cal-green) !important;
	box-shadow: 0 0 0 3px var(--tkt-cal-ring) !important;
}

/* ---------- Tooltip di Bookings sui giorni ---------- */

.wc-bookings-date-tooltip {
	padding: 7px 11px;
	border: 0;
	border-radius: 8px;
	background: #1d211f;
	box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.35);
	color: #fff;
	font-family: "Titillium Web", Arial, sans-serif;
	font-size: 13px;
	line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
	.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev,
	.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-next,
	.wc-bookings-booking-form .wc-bookings-date-picker table.ui-datepicker-calendar td a.ui-state-default,
	.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a {
		transition: none;
	}
	.wc-bookings-booking-form .wc-bookings-date-picker table.ui-datepicker-calendar td a.ui-state-default:active,
	.wc-bookings-booking-form .time-picker-fieldset ul.block-picker li a:active {
		transform: none;
	}
}

/* Smartphone: scheda piu' compatta, celle sempre >= 40px */
@media (max-width: 575.98px) {
	.wc-bookings-booking-form {
		--tkt-cal-cell-h: 42px;
		--tkt-cal-cell-radius: 10px;
		--tkt-cal-gap: 4px;
		--tkt-cal-radius: 16px;
	}
	.wc-bookings-booking-form .wc-bookings-date-picker {
		padding: 16px 12px 6px !important;
	}
	.wc-bookings-booking-form .wc-bookings-date-picker .ui-datepicker .ui-datepicker-title {
		font-size: 1.2rem;
	}
	.wc-bookings-booking-form .time-picker-fieldset ul.block-picker {
		grid-template-columns: repeat(3, 1fr);
	}
}
