*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	--green:      #3aaa35;
	--green-dark: #2d8a29;
	--navy:       #241e46;
	--white:      #ffffff;
	--text:       #2c3e50;
	--muted:      #7f8c8d;
	--border:     #dde3e7;
	--nav-h:      68px;
}

html, body {
	height: 100%;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background-color: var(--green);
	overflow: hidden;
}

/* Tile-pattern shared across both screens */
body::before {
	content: '';
	position: fixed;
	inset: 0;
	background-image: url('assets/TilePatternSfondo.svg');
	background-repeat: repeat;
	background-size: 160px 148px; /* preserves 263:244 viewBox ratio */
	opacity: 0.18;
	pointer-events: none;
	z-index: 0;
}

/* ════════════════════════════════
	 Screen management
════════════════════════════════ */
.screen {
	position: fixed;
	inset: 0;
	display: none;
	z-index: 1;
}

.screen.active { display: block; }

#screen-auth,
#screen-login,
#screen-activate {
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* ════════════════════════════════
	 Auth / Registration screen
════════════════════════════════ */
.auth-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 48px 20px 36px;
	min-height: 100%;
	gap: 24px;
}

.auth-logo {
	width: 130px;
	height: 130px;
	filter: drop-shadow(0 6px 18px rgba(0,0,0,0.22));
	flex-shrink: 0;
}

.auth-card {
	width: 100%;
	max-width: 420px;
	background: var(--white);
	border-radius: 22px;
	padding: 28px 24px 24px;
	box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.auth-title {
	font-size: 22px;
	font-weight: 800;
	color: var(--text);
	margin-bottom: 6px;
}

.auth-sub {
	font-size: 14px;
	color: var(--muted);
	line-height: 1.5;
	margin-bottom: 22px;
}

/* Fields */
.field {
	margin-bottom: 16px;
}

.field label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--text);
	margin-bottom: 6px;
}

.field label .optional {
	font-weight: 400;
	color: var(--muted);
}

.field input {
	width: 100%;
	height: 50px;
	border: 1.5px solid var(--border);
	border-radius: 10px;
	padding: 0 14px;
	font-size: 16px; /* keeps iOS from auto-zooming */
	color: var(--text);
	background: #fafafa;
	outline: none;
	transition: border-color 0.18s, background 0.18s;
	appearance: none;
	-webkit-appearance: none;
}

.field input:focus {
	border-color: var(--green);
	background: var(--white);
}

/* Native browser validation feedback */
.field input:invalid:not(:focus):not(:placeholder-shown) {
	border-color: #e74c3c;
}

/* ── Input con pulsante reveal password ── */
.input-with-reveal {
	position: relative;
	display: flex;
	align-items: center;
}

.input-with-reveal .field input,
.input-with-reveal input {
	flex: 1;
	padding-right: 48px; /* spazio per il bottone */
}

.reveal-btn {
	position: absolute;
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	padding: 4px;
	cursor: pointer;
	line-height: 0;
	-webkit-tap-highlight-color: transparent;
}

.eye-icon {
	width: 22px;
	height: 22px;
	opacity: 0.35;
	transition: opacity 0.15s;
	display: block;
}

.eye-icon.revealed { opacity: 0.75; }

/* ── QR Code (Yu Code tab) ── */
.qr-container {
	background: var(--white);
	border-radius: 16px;
	padding: 16px;
	box-shadow: 0 6px 24px rgba(0,0,0,0.18);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.qr-image {
	width: 190px;
	height: 190px;
	object-fit: contain;
	border-radius: 8px;
}

.qr-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
	letter-spacing: 0.2px;
}

/* Codice di attivazione: input grande e centrato */
#act-code {
	text-align: center;
	font-size: 26px;
	font-weight: 700;
	letter-spacing: 10px;
	font-variant-numeric: tabular-nums;
}

/* Messaggi di errore del form */
.form-error {
	min-height: 0;
	font-size: 13px;
	color: #e74c3c;
	text-align: center;
	margin-top: 8px;
	line-height: 1.4;
}

.form-error:empty { margin-top: 0; }

/* Pulsante secondario (testo + link) */
.btn-link {
	display: block;
	width: 100%;
	background: none;
	border: none;
	color: var(--muted);
	font-size: 14px;
	cursor: pointer;
	text-align: center;
	padding: 14px 0 0;
	transition: color 0.15s;
}

.btn-link:hover { color: var(--green-dark); }

/* Submit button */
.btn-primary {
	display: block;
	width: 100%;
	height: 52px;
	margin-top: 24px;
	background: var(--green);
	color: var(--white);
	border: none;
	border-radius: 12px;
	font-size: 17px;
	font-weight: 700;
	letter-spacing: 0.3px;
	cursor: pointer;
	transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover  { background: var(--green-dark); }
.btn-primary:active { transform: scale(0.98); }

/* ════════════════════════════════
	 App shell
════════════════════════════════ */
.app {
	position: relative;
	height: 100vh;
	height: 100dvh;
	display: flex;
	flex-direction: column;
	background: transparent; /* body's green shows through */
	overflow: hidden;
}

/* Views container */
.views {
	position: relative;
	flex: 1;
	overflow: hidden;
}

.view {
	position: absolute;
	inset: 0;
	display: none;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.view.active {
	display: flex;
	flex-direction: column;
}

/* ── Mappa (Tab 3 – Yu Bike map) ── */

/* Spinge la mappa a fondo schermo e la centra orizzontalmente */
#view-bikemap {
	justify-content: flex-end;
	align-items: center;
}

.map-wrap {
	position: relative;
	width: 100%;
	max-width: 512px;
	flex: 1 0 0;       /* cresce fino a occupare lo spazio disponibile */
	max-height: 512px; /* mai più alta di 512 px */
	overflow: hidden;
	background: #e8e4d9;
}

/* Barra di stato GPS in cima alla mappa */
.map-topbar {
	position: absolute;
	top: 0; left: 0; right: 0;
	z-index: 11;
	background: rgba(0, 0, 0, 0.60);
	color: #fff;
	font-size: 12px;
	padding: 6px 12px;
	pointer-events: none;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#map-container {
	position: absolute;
	inset: 0;
	overflow: hidden;
	cursor: grab;
}
#map-container:active { cursor: grabbing; }

#map-container img {
	display: block;    /* evita spazi bianchi inline tra le tile */
}

.map-ctrl {
	position: absolute;
	z-index: 10;
	width: 36px;
	height: 36px;
	cursor: pointer;
	opacity: 0.82;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
	-webkit-user-select: none;
}

/* Pan: ai quattro bordi, centrati sul proprio asse */
.pan-up    { top:    34px; left: 50%; transform: translateX(-50%) rotate(-90deg); }
.pan-down  { bottom:  8px; left: 50%; transform: translateX(-50%)  rotate(90deg); }
.pan-left  { left:    8px; top:  50%; transform: translateY(-50%) rotate(180deg); }
.pan-right { right:   8px; top:  50%; transform: translateY(-50%);                }

/* Zoom: angolo in alto a destra (sotto la topbar) */
/*.zoom-in  { top:  34px; right: 8px; }
.zoom-out { top:  78px; right: 8px; }*/
.zoom-out { bottom:  34px; right: 8px; }
.zoom-in { bottom:  78px; right: 8px; }
.whereIam { bottom:  136px; right: 8px; }

/* Etichetta attesa GPS (nascosta dopo la prima fix) */
.map-status {
	position: absolute;
	bottom: 52px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 12px;
	padding: 4px 14px;
	border-radius: 20px;
	pointer-events: none;
	white-space: nowrap;
}

/* ── Blocco orientamento landscape (forza portrait sui browser mobile) ── */
@media screen and (orientation: landscape) {
	html {
		transform: rotate(-90deg);
		transform-origin: left top;
		width: 100vh;
		height: 100vw;
		overflow: hidden;
		position: fixed;
		top: 100%;
		left: 0;
	}
}

/* ── Yu Code hero ── */
.hero {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 32px 28px 16px;
	gap: 22px;
	text-align: center;
}

.logo-img {
	width: 160px;
	height: 160px;
	filter: drop-shadow(0 6px 20px rgba(0,0,0,0.22));
}

.greeting {
	font-size: 34px;
	font-weight: 800;
	color: var(--white);
	letter-spacing: -0.5px;
}

.subtitle {
	font-size: 17px;
	line-height: 1.65;
	color: var(--white);
	max-width: 280px;
}

.subtitle strong { font-weight: 700; }

/* ── Lista yuBiker vicini (tab Home) ── */
.nearby-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	max-width: 320px;
}

.nearby-empty {
	font-size: 15px;
	color: rgba(255,255,255,0.80);
	text-align: center;
	padding: 4px 0;
}

.nearby-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: rgba(255,255,255,0.14);
	border-radius: 10px;
	padding: 10px 14px;
}

.nearby-row span {
	font-size: 15px;
	font-weight: 600;
	color: var(--white);
}

.btn-apri {
	background: var(--green);
	color: var(--white);
	border: none;
	border-radius: 8px;
	padding: 6px 14px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.4px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background 0.15s;
	white-space: nowrap;
}

.btn-apri:hover  { background: var(--green-dark); }
.btn-apri:active { transform: scale(0.96); }
.btn-apri:disabled {
	background: var(--muted);
	opacity: 0.55;
	cursor: not-allowed;
	transform: none;
}

.account-btn {
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px;
	width: 112px;
	-webkit-tap-highlight-color: transparent;
}

.account-btn img { width: 100%; height: auto; }

/* Fisso poco sopra la barra di navigazione, centrato */
#account-btn {
	position: absolute;
	bottom: 12px;
	left: 50%;
	transform: translateX(-50%);
}

/* ── Inner placeholder views (tabs 2–5) ── */
.inner-view {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 28px;
	gap: 16px;
	text-align: center;
}

.inner-view h2 {
	font-size: 28px;
	font-weight: 800;
	color: var(--white);
}

.inner-view p {
	font-size: 16px;
	line-height: 1.55;
	color: rgba(255,255,255,0.85);
	max-width: 280px;
}

/* ── Bottom Navigation ── */
.bottom-nav {
	position: relative;
	z-index: 10;
	display: flex;
	background: var(--white);
	height: var(--nav-h);
	padding-bottom: env(safe-area-inset-bottom, 0px);
	box-shadow: 0 -2px 10px rgba(0,0,0,0.10);
}

.nav-item {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	cursor: pointer;
	padding: 4px 2px;
	-webkit-tap-highlight-color: transparent;
}

.nav-item img {
	width: 100%;
	max-width: 50px;
	height: auto;
}

/* Active / inactive icon toggling */
.nav-item .icon-active   { display: none; }
.nav-item .icon-inactive { display: block; }

.nav-item.active .icon-active   { display: block; }
.nav-item.active .icon-inactive { display: none; }

/* ── Popup info marker yuBike ── */
.yubike-popup {
	position: absolute;
	z-index: 25;
	transform: translate(-50%, calc(-100% - 12px));
	background: #fff;
	border-radius: 10px;
	padding: 26px 16px 12px;   /* top extra per la X */
	filter: drop-shadow(0 4px 14px rgba(0,0,0,0.28));
	font-size: 13px;
	line-height: 1.8;
	color: var(--text);
	white-space: nowrap;
	min-width: 140px;
}

.yubike-popup::after {
	content: '';
	position: absolute;
	bottom: -12px;
	left: 50%;
	transform: translateX(-50%);
	border: 12px solid transparent;
	border-top-color: #fff;
	border-bottom: none;
}

.popup-close {
	position: absolute;
	top: 5px;
	right: 9px;
	/*background: none;*/
	border-radius: 5px;
	border: none;
	font-size: 14px;
	font-weight: bolder;
	color: var(--muted);
	cursor: pointer;
	line-height: 1;
	padding: 2px 4px 4px 4px;
	-webkit-tap-highlight-color: transparent;
}

.popup-close:hover { color: var(--text); }

.popup-content {
	font-size: 13px;
	line-height: 1.7;
	color: var(--text);
}

.popup-spacer {
	height: 6px;
}

.popup-guidami {
	display: block;
	width: 100%;
	margin-top: 10px;
	padding: 5px 0;
	background: var(--green);
	color: #fff;
	border: none;
	border-radius: 7px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background 0.15s;
}

.popup-guidami:hover { background: var(--green-dark); }
