/* =====================================================================
   Reputiva - pagine di accesso (login, registrazione, password,
   logout, errori). Colori e font dal logo pack (07-brand/palette.txt).
   Mobile first: le regole base sono per il telefono.
   ===================================================================== */

:root {
	--rp-primario: #0B1F3B;
	--rp-secondario: #2F80ED;
	--rp-accento: #00C896;
	--rp-neutro: #E5E7EB;
	--rp-scuro: #111827;
	--rp-gradiente: linear-gradient(45deg, #1F6FE5, #2F80ED 55%, #00C896);

	--ink: #0B1F3B;
	--ink-soft: #334155;
	--muted: #64748B;
	--line: #E5E7EB;
	--bg: #FFFFFF;
	--bg-alt: #F5F7FA;
	--brand: #1F6FE5;          /* bottoni: contrasto AA con il testo bianco */
	--brand-hover: #1A5FC7;
	--brand-soft: #EAF2FE;
	--ok: #00996F;
	--ok-soft: #E3F8F1;
	--err: #D33A3A;
	--err-soft: #FDECEC;
	--warn: #A16207;
	--warn-soft: #FEF6E4;

	--radius: 12px;
	--ease: cubic-bezier(.22, .61, .36, 1);
	--font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; display: block; }
a { color: var(--brand); }
[hidden] { display: none !important; }

.auth-body {
	min-height: 100vh;
	min-height: 100dvh;
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.6;
	color: var(--ink);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
}

/* ============================ STRUTTURA ============================ */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: flex; }
.auth-side { display: none; }

.auth-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	padding: 0 20px;
	padding-left: max(20px, env(safe-area-inset-left));
	padding-right: max(20px, env(safe-area-inset-right));
}

.auth-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	height: 68px;
	flex-shrink: 0;
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--rp-primario); }
.brand-mark { width: 34px; height: auto; }
.brand-word { font-weight: 800; font-size: 1.02rem; letter-spacing: .155em; }

.auth-back {
	display: inline-flex; align-items: center; gap: 8px;
	min-height: 40px; padding: 0 12px;
	border-radius: 999px;
	font-size: .85rem; font-weight: 600;
	color: var(--ink-soft); text-decoration: none;
	transition: background .15s var(--ease), color .15s var(--ease);
}
.auth-back:hover { background: var(--bg-alt); color: var(--ink); }
.auth-back span { display: none; }

.auth-content {
	flex: 1;
	display: flex;
	justify-content: center;
	padding: 16px 0 32px;
}

.auth-panel { width: 100%; max-width: 420px; }
.auth-panel--wide { max-width: 600px; }

.auth-footer {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
	padding: 18px 0 max(18px, env(safe-area-inset-bottom));
	border-top: 1px solid var(--line);
	font-size: .8rem; color: var(--muted);
}
.auth-footer nav { display: flex; gap: 16px; }
.auth-footer a { color: var(--muted); text-decoration: none; }
.auth-footer a:hover { color: var(--ink); }

/* ============================ TESTATA DEL MODULO ============================ */
.auth-icon {
	width: 52px; height: 52px;
	display: grid; place-items: center;
	margin-bottom: 20px;
	border-radius: 14px;
	font-size: 1.3rem;
	color: var(--brand);
	background: var(--brand-soft);
}
.auth-icon--ok { color: var(--ok); background: var(--ok-soft); }
.auth-icon--err { color: var(--err); background: var(--err-soft); }
.auth-icon--warn { color: var(--warn); background: var(--warn-soft); }

.auth-eyebrow {
	display: block; margin-bottom: 6px;
	font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
	color: var(--rp-secondario);
}
.auth-title {
	margin: 0 0 8px;
	font-size: 1.65rem; line-height: 1.2; font-weight: 800; letter-spacing: -.01em;
	color: var(--ink);
}
.auth-subtitle { margin: 0 0 26px; color: var(--muted); font-size: .95rem; }

/* ============================ AVVISI ============================ */
.auth-alert {
	display: flex; align-items: flex-start; gap: 10px;
	margin: 0 0 20px; padding: 12px 14px;
	border-radius: var(--radius);
	font-size: .88rem; line-height: 1.5;
	border: 1px solid transparent;
}
.auth-alert i { margin-top: 3px; flex-shrink: 0; }
.auth-alert a { color: inherit; font-weight: 700; }
.auth-alert--error { color: #9B1C1C; background: var(--err-soft); border-color: #F8CFCF; }
.auth-alert--success { color: #05674C; background: var(--ok-soft); border-color: #BDEEDD; }
.auth-alert--info { color: #174EA6; background: var(--brand-soft); border-color: #CFE0FC; }
.auth-alert--warn { color: #7A4A06; background: var(--warn-soft); border-color: #F6DFAE; }

/* ============================ CAMPI ============================ */
form { margin: 0; }
.auth-field { margin-bottom: 18px; min-width: 0; }
.auth-field label, .field-label {
	display: block; margin-bottom: 7px;
	font-size: .84rem; font-weight: 600; color: var(--ink);
}
.auth-field-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.auth-field-top a { font-size: .8rem; font-weight: 600; text-decoration: none; margin-bottom: 7px; }
.auth-field-top a:hover { text-decoration: underline; }
.req { color: var(--err); }
.opz { color: var(--muted); font-weight: 500; }

.form-control {
	display: block; width: 100%; min-height: 50px;
	padding: 12px 14px;
	font: inherit; font-size: 16px; /* 16px: iOS non zooma sul campo */
	font-weight: 500;
	color: var(--ink);
	background: #fff;
	border: 1.5px solid #D4D9E1;
	border-radius: var(--radius);
	transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
	-webkit-appearance: none; appearance: none;
}
.form-control::placeholder { color: #98A2B3; font-weight: 400; }
.form-control:hover { border-color: #B8C0CC; }
.form-control:focus { outline: none; border-color: var(--rp-secondario); box-shadow: 0 0 0 4px rgba(47, 128, 237, .16); }
.form-control.is-invalid { border-color: var(--err); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 4px rgba(211, 58, 58, .14); }

.auth-password { position: relative; }
.auth-password .form-control { padding-right: 52px; }
.auth-eye {
	position: absolute; top: 50%; right: 5px; transform: translateY(-50%);
	width: 42px; height: 42px;
	display: grid; place-items: center;
	border: 0; border-radius: 9px;
	background: none; color: var(--muted);
	font-size: 1rem; cursor: pointer;
}
.auth-eye:hover { color: var(--ink); background: var(--bg-alt); }
.auth-eye:focus-visible { outline: 2px solid var(--rp-secondario); outline-offset: 1px; }

.auth-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }

.auth-group { margin: 0 0 8px; padding: 0; border: 0; min-width: 0; }
.auth-group legend {
	display: flex; align-items: center; gap: 10px; width: 100%;
	margin-bottom: 14px; padding: 0;
	font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
	color: var(--muted);
}
.auth-group legend::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-group + .auth-group { margin-top: 10px; }

.error-message:empty { display: none; }
.error-message { margin-top: 6px; font-size: .8rem; color: var(--err); }

/* forza password */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 10px; }
.pw-meter span { height: 4px; border-radius: 4px; background: var(--line); transition: background .2s var(--ease); }
.pw-meter.l0 span:nth-child(1) { background: var(--err); }
.pw-meter.l1 span:nth-child(-n+1) { background: #F97316; }
.pw-meter.l2 span:nth-child(-n+2) { background: #EAB308; }
.pw-meter.l3 span:nth-child(-n+3) { background: var(--rp-secondario); }
.pw-meter.l4 span { background: var(--rp-accento); }
.pw-label, .auth-hint { margin: 6px 0 0; font-size: .78rem; color: var(--muted); min-height: 1.2em; }
.auth-hint.is-ok { color: var(--ok); }
.auth-hint.is-err { color: var(--err); }

/* checkbox */
.auth-check {
	display: flex; align-items: flex-start; gap: 11px;
	margin: 4px 0 22px;
	font-size: .86rem; line-height: 1.5; color: var(--ink-soft);
	cursor: pointer;
}
.auth-check input { width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--brand); cursor: pointer; }
.auth-check a { font-weight: 600; }

/* ============================ BOTTONI ============================ */
.auth-submit, .auth-btn {
	display: flex; align-items: center; justify-content: center; gap: 10px;
	width: 100%; min-height: 52px;
	padding: 12px 20px;
	font: inherit; font-size: 1rem; font-weight: 700;
	color: #fff; text-decoration: none;
	background: var(--brand);
	border: 0; border-radius: var(--radius);
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(11, 31, 59, .12), 0 8px 20px -8px rgba(31, 111, 229, .55);
	transition: background .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}
.auth-submit:hover, .auth-btn:hover { background: var(--brand-hover); color: #fff; }
.auth-submit:active, .auth-btn:active { transform: translateY(1px); }
.auth-submit:focus-visible, .auth-btn:focus-visible { outline: 3px solid rgba(47, 128, 237, .45); outline-offset: 2px; }
.auth-submit.is-loading { pointer-events: none; opacity: .85; }

.auth-btn--ghost {
	color: var(--ink); background: #fff;
	border: 1.5px solid #D4D9E1; box-shadow: none;
}
.auth-btn--ghost:hover { color: var(--ink); background: var(--bg-alt); border-color: #B8C0CC; }

.auth-actions { display: grid; gap: 10px; }
.auth-cancel {
	display: flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; border-radius: var(--radius);
	font-size: .92rem; font-weight: 600; color: var(--ink-soft); text-decoration: none;
}
.auth-cancel:hover { background: var(--bg-alt); color: var(--ink); }
button.auth-cancel { width: 100%; border: 0; background: none; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }

/* ============================ LINK SOTTO IL MODULO ============================ */
.auth-divider {
	display: flex; align-items: center; gap: 12px;
	margin: 26px 0 18px;
	font-size: .8rem; color: var(--muted);
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.auth-links { margin-top: 22px; text-align: center; font-size: .88rem; color: var(--muted); display: grid; gap: 8px; }
.auth-links a { font-weight: 600; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ============================ LOGOUT / ERRORI ============================ */
.auth-center { text-align: center; }
.auth-center .auth-icon { margin-left: auto; margin-right: auto; width: 64px; height: 64px; border-radius: 50%; font-size: 1.55rem; }
.auth-code {
	display: block; margin-bottom: 4px;
	font-size: 4.2rem; line-height: 1; font-weight: 800; letter-spacing: -.03em;
	background: var(--rp-gradiente); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-message {
	margin: 0 0 24px; padding: 14px 16px;
	border-radius: var(--radius);
	background: var(--bg-alt);
	font-size: .9rem; color: var(--ink-soft); text-align: left;
}
.auth-progress { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 12px; }
.auth-progress i { display: block; height: 100%; background: var(--rp-gradiente); transform-origin: left; animation: rp-svuota 3s linear forwards; }
@keyframes rp-svuota { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.auth-countdown { margin: 0 0 22px; font-size: .84rem; color: var(--muted); }
.auth-countdown strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.pop { animation: rp-pop .5s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes rp-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }

/* ============================ PANNELLO DEL MARCHIO (desktop) ============================ */
.auth-side-inner { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; }
.auth-side-logo img { width: 240px; height: auto; }
.auth-side-copy { margin-top: auto; }
.auth-side-copy h2 {
	margin: 0 0 22px; max-width: 16ch;
	font-size: 2.05rem; line-height: 1.18; font-weight: 800; letter-spacing: -.015em; color: #fff;
}
.auth-side-copy ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-width: 400px; }
.auth-side-copy li { display: flex; gap: 14px; align-items: flex-start; font-size: .93rem; line-height: 1.5; color: #C9D5E6; }
.auth-side-copy li i {
	width: 34px; height: 34px; flex-shrink: 0;
	display: grid; place-items: center;
	border-radius: 10px;
	background: rgba(255, 255, 255, .08); color: var(--rp-accento);
	font-size: .9rem;
}
.auth-side-card { margin-top: 40px; }
.nfc-card {
	position: relative;
	display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center;
	max-width: 400px; padding: 20px 22px;
	border-radius: 18px;
	background: var(--rp-gradiente);
	box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
	transform: rotate(-3deg);
	overflow: hidden;
}
.nfc-card::after {
	content: ''; position: absolute; inset: 0;
	background: radial-gradient(260px 120px at 85% 0%, rgba(255, 255, 255, .28), transparent 70%);
	pointer-events: none;
}
.nfc-card-mark { width: 54px; grid-row: span 2; }
.nfc-card-text strong { display: block; font-size: 1.05rem; font-weight: 800; color: #fff; }
.nfc-card-text span { display: block; font-size: .8rem; color: rgba(255, 255, 255, .88); }
.nfc-card-stars { color: #FFD166; font-size: .8rem; letter-spacing: 3px; }

/* ============================ BREAKPOINT ============================ */
@media (min-width: 480px) {
	.auth-back span { display: inline; }
	.auth-content { padding-top: 28px; }
}

@media (min-width: 600px) {
	.auth-main { padding: 0 40px; }
	.auth-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
	.auth-actions { grid-template-columns: auto 1fr; align-items: center; }
	.auth-actions .auth-submit { order: 2; }
	.auth-actions .auth-cancel { order: 1; padding: 0 16px; }
	.auth-title { font-size: 1.85rem; }
}

@media (min-width: 1000px) {
	.auth-side {
		display: block;
		position: sticky; top: 0;
		width: 44%; max-width: 620px; height: 100vh;
		padding: 44px 52px 52px;
		overflow: hidden;
		background: var(--rp-primario);
		color: #fff;
	}
	.auth-side::before {
		content: ''; position: absolute; inset: 0; pointer-events: none;
		background:
			radial-gradient(520px 380px at 110% 0%, rgba(47, 128, 237, .45), transparent 65%),
			radial-gradient(460px 360px at -10% 105%, rgba(0, 200, 150, .28), transparent 65%);
	}
	.auth-side::after {
		content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
		background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
		background-size: 22px 22px;
		-webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
		mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
	}
	.auth-main { padding: 0 56px; }
	.auth-top { height: 88px; }
	.auth-top .brand { visibility: hidden; } /* il logo c'e' gia' nel pannello a sinistra */
	.auth-content { align-items: center; padding: 24px 0 48px; }
}

@media (min-width: 1000px) and (max-height: 760px) {
	.auth-side-card { display: none; }
	.auth-side-copy h2 { font-size: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
	.auth-progress i { transform: scaleX(0); }
}
