/* ========== Reset base ========== */
* {
	box-sizing: border-box;
}

body {
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
	background: #f6f8fa;
	margin: 0;
}
.wrap {
	max-width: 1200px;
	margin: 24px auto;
	padding: 0 16px;
}

/* ========== Header / controlli ========== */
header {
	display: flex;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
}
.controls {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	align-items: center;
}
select, input {
	padding: 8px 10px;
	border: 1px solid #cfd6dd;
	border-radius: 8px;
	background: #fff;
}
.weeknav {
	display: flex;
	gap: 8px;
	align-items: center;
}
.muted {
	color: #6b7280;
	font-size: 12px;
}

/* ========== Bottoni ========== */
.btn {
	padding: 8px 12px;
	border: 1px solid #1a73e8;
	color: #fff;
	background: #1a73e8;
	border-radius: 8px;
	cursor: pointer;
	height: 34px;
}
.btn.secondary {
	background: #fff;
	color: #1a73e8;
}
#book {
	width: 75px;
}
#prev:disabled, #next:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	background: #ddd;
	color: #999;
	border-color: #ccc;
}

/* bottone con stato loading */
.btn.loading {
	position: relative;
	pointer-events: none;
	opacity: .8;
}
.btn.loading::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%,-50%);
	width: 36px;
	height: 6px;
	border-radius: 3px;
	background: linear-gradient(90deg,
	currentColor 25%, transparent 25%, transparent 50%,
	currentColor 50%, currentColor 75%, transparent 75%);
	background-size: 24px 100%;
	animation: moveblocks 1s linear infinite;
}

/* ========== Griglia settimana (desktop) ========== */
.grid {
	position: relative; /* per overlay */
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 10px;
	margin: 20px 4px;
}
.day {
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 12px;
	min-height: 180px;
	scroll-snap-align: start;
}
.day h3 {
	margin: 0 0 6px;
	font-size: 14px;
}
.slot {
	display: block;
	width: 100%;
	text-align: center;
	padding: 8px;
	margin: 8px 0;
	border: 1px solid #cfd6dd;
	border-radius: 8px;
	background: #f8fbfd;
	cursor: pointer;
	font-size: 14px;
}
.slot:hover {
	background: #eef6ff;
}
.slot.unavailable {
	opacity: .35;
	pointer-events: none;
}
.slot.selected {
	border-color: #1a73e8;
	box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

/* evidenzia oggi */
.day.today {
	outline: 2px solid #1a73e8;
	outline-offset: 2px;
}
.day.today h3 {
	color: #1a73e8;
}

/* ========== Footer / errori ========== */
.footerbar {
	margin-top: 16px;
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	align-items: flex-start;
}
.error {
	font-size: 12px;
	color: #b91c1c;
	margin-top: 4px;
}
.invalid {
	border-color: #b91c1c;
	outline-color: #b91c1c;
}
#form-error {
	margin: 12px 0;
	font-size: 14px;
	color: #b91c1c;
}

/* ========== Overlay prenotazione ========= */
#form-overlay {
	position: fixed;
	inset: 0;
	background: rgba(255,255,255,.6);
	backdrop-filter: blur(2px);
	z-index: 9999;
	display: none;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	font-weight: 600;
	color: #1a73e8;
}
#form-overlay::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%,-50%);
	width: 100px;
	height: 15px;
	border-radius: 3px;
	background: linear-gradient(90deg,
	currentColor 25%, transparent 25%, transparent 50%,
	currentColor 50%, currentColor 75%, transparent 75%);
	background-size: 50px 100%;
	animation: moveblocks 1s linear infinite;
}

/* ========== Overlay loading settimana ========= */
.grid.is-loading {
	pointer-events: none;
}
.grid.is-loading::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(255,255,255,.65);
	backdrop-filter: blur(2px);
	z-index: 1;
}
.grid.is-loading::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%,-50%);
	width: 120px;
	height: 16px;
	border-radius: 8px;
	z-index: 2;
	background: linear-gradient(90deg,
	#1a73e8 25%, transparent 25%, transparent 50%,
	#1a73e8 50%, #1a73e8 75%, transparent 75%);
	background-size: 60px 100%;
	animation: moveblocks 1s linear infinite;
}

/* ========== Scorrimento mobile ========== */
.weekrow {
	position: relative;
	display: grid;
	align-items: center;
}
.week-scroller {
	overflow-x: auto;
	overflow-y: visible;
	-webkit-overflow-scrolling: touch;
	scroll-snap-type: x mandatory;
	scroll-padding: 8px;
}
.week-scroller::-webkit-scrollbar {
	display: none;
}
.week-scroller {
	scrollbar-width: none;
}

.harrow {
	display: none;
	width: 36px;
	height: 36px;
	margin: 2px;
	border-radius: 999px;
	border: 1px solid #cfd6dd;
	background: #fff;
	color: #1a73e8;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.harrow:disabled {
	opacity: .4;
	cursor: not-allowed;
}

/* ========== Custom alert ========= */
.custom-alert {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
}
.custom-alert[hidden] {
	display: none !important;
}
.custom-alert-box {
	background: #fff;
	padding: 20px 30px;
	border-radius: 10px;
	max-width: 300px;
	text-align: center;
	box-shadow: 0 4px 12px rgba(0,0,0,.2);
	animation: zoomIn 0.3s ease;
}
.custom-alert-box p {
	margin: 0 0 16px;
	font-size: 16px;
}
.custom-alert-box button {
	padding: 8px 14px;
	background: #1a73e8;
	color: #fff;
	border: none;
	border-radius: 6px;
	cursor: pointer;
}

/* ========== Animazioni ========== */
@keyframes moveblocks {
	0%   { background-position: 0 0; }
	100% { background-position: 24px 0; }
}
@keyframes
	zoomIn {from {
		transform: scale(0.8);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

/* ========== Mobile ========== */
@media (max-width: 1000px) {
	.footerbar div {
		width: 100%;
	}
	.footerbar div input {
		width: 100%;
	}	
	#book {
		margin: auto;
	}
	.weeknav {
		width: 100%;
		justify-content: space-between;
	}

	.weekrow {
		grid-template-columns: auto 1fr auto;
	}
	.harrow {
		display: inline-grid;
		place-items: center;
	}

	.grid {
		display: grid;
		grid-auto-flow: column;
		grid-auto-columns: 100%;
		grid-template-columns: unset;
		gap: 12px;
		margin: 0;
		padding: 8px 4px;
	}

	.day {
		width: calc(100% - 16px);
		box-sizing: border-box;
	}
}
