/* ==================================================================
   Alter Ego — smartphone
   Le stesse pagine e gli stessi pannelli dell'app, riorganizzati per
   il pollice: barra in basso, tasti grandi, pannelli a tutto schermo.
   Tutto è agganciato a `.ae-app.is-mobile`, che il JS mette quando lo
   schermo è stretto (e toglie se l'operatore chiede la versione
   completa). Sul desktop questo foglio non fa nulla.
   ================================================================== */

/* Elementi mobile: nascosti finché non serve */
.ae-tabbar, .ae-sheet, .ae-mobile-on { display: none; }

/* ------------------------------------------------------------------
   Barra in basso
   ------------------------------------------------------------------ */
.ae-app.is-mobile .ae-tabbar {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 320;
	padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
	background: color-mix(in srgb, var(--ae-surface) 92%, transparent);
	backdrop-filter: saturate(160%) blur(14px);
	-webkit-backdrop-filter: saturate(160%) blur(14px);
	border-top: 1px solid color-mix(in srgb, var(--ae-border) 80%, transparent);
	box-shadow: 0 -6px 24px rgba(15, 23, 42, .08);
}
.ae-app.is-mobile .ae-tab {
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
	min-height: 52px; padding: 4px 2px; border: 0; background: transparent; border-radius: 12px;
	font: inherit; font-size: .68rem; font-weight: 600; letter-spacing: .01em;
	color: color-mix(in srgb, var(--ae-text) 62%, transparent); text-decoration: none; cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.ae-app.is-mobile .ae-tab svg { width: 22px; height: 22px; }
.ae-app.is-mobile .ae-tab:active { background: var(--ae-surface-2); }
.ae-app.is-mobile .ae-tab.is-active { color: var(--ae-accent); background: transparent; box-shadow: none; border-bottom: 0; }
.ae-app.is-mobile .ae-tab.is-active svg { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--ae-accent) 60%, transparent)); }

/* Il «+» è il tasto che si usa di più: sporge e si vede. */
.ae-app.is-mobile .ae-tab--new { color: var(--ae-text); }
.ae-app.is-mobile .ae-tab-plus {
	display: grid; place-items: center; width: 46px; height: 46px; margin-top: -22px; border-radius: 50%;
	color: #fff;
	background: linear-gradient(135deg, color-mix(in srgb, var(--ae-accent) 78%, #fff), var(--ae-accent));
	box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--ae-accent) 95%, transparent), 0 0 0 4px var(--ae-surface);
}
.ae-app.is-mobile .ae-tab-plus svg { width: 26px; height: 26px; }
.ae-app.is-mobile .ae-tab--new:active .ae-tab-plus { transform: scale(.94); }

/* ------------------------------------------------------------------
   Fogli a scorrimento dal basso (Nuovo, Menu)
   ------------------------------------------------------------------ */
.ae-app.is-mobile .ae-sheet { display: block; position: fixed; inset: 0; z-index: 330; }
.ae-app.is-mobile .ae-sheet[hidden] { display: none; }
.ae-app.is-mobile .ae-sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 24, .55); backdrop-filter: blur(3px); }
.ae-app.is-mobile .ae-sheet-panel {
	position: absolute; left: 0; right: 0; bottom: 0;
	max-height: 86vh; overflow-y: auto;
	padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
	background: var(--ae-surface); color: var(--ae-text);
	border-radius: 22px 22px 0 0;
	box-shadow: 0 -20px 60px rgba(0, 0, 0, .35);
	animation: ae-sheet-up .26s cubic-bezier(.22, .61, .36, 1);
}
@keyframes ae-sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.ae-app.is-mobile .ae-sheet-grip { display: block; width: 44px; height: 5px; border-radius: 3px; margin: 4px auto 14px; background: color-mix(in srgb, var(--ae-text) 18%, transparent); }
.ae-app.is-mobile .ae-sheet-panel h2 { margin: 0 0 14px; font-size: 1.05rem; font-weight: 700; }

.ae-app.is-mobile .ae-sheet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ae-app.is-mobile .ae-sheet-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ae-app.is-mobile .ae-sheet-tile {
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
	min-height: 84px; padding: 12px 8px; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--ae-border) 80%, transparent);
	background: color-mix(in srgb, var(--c, var(--ae-accent)) 8%, var(--ae-surface));
	color: var(--ae-text); text-decoration: none; font: inherit; font-size: .8rem; font-weight: 600; text-align: center; cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.ae-app.is-mobile .ae-sheet-tile svg { width: 26px; height: 26px; color: var(--c, var(--ae-accent)); }
.ae-app.is-mobile .ae-sheet-tile:active { transform: scale(.97); background: color-mix(in srgb, var(--c, var(--ae-accent)) 16%, var(--ae-surface)); }
.ae-app.is-mobile .ae-sheet-tile.is-active { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.ae-app.is-mobile .ae-sheet-tile.is-accent { background: color-mix(in srgb, var(--c) 20%, var(--ae-surface)); }
.ae-app.is-mobile .ae-sheet-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 18px; padding-top: 14px; border-top: 1px solid color-mix(in srgb, var(--ae-border) 80%, transparent); }
.ae-app.is-mobile .ae-sheet-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 8px 2px; font: inherit; font-size: .84rem; color: color-mix(in srgb, var(--ae-text) 70%, transparent); text-decoration: none; cursor: pointer; }

/* ------------------------------------------------------------------
   La pagina: cosa cambia quando siamo al telefono
   ------------------------------------------------------------------ */
.ae-app.is-mobile { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

/* La barra in alto si riduce a insegna + Chiedi + avatar. */
.ae-app.is-mobile .ae-nav,
.ae-app.is-mobile .ae-quick,
.ae-app.is-mobile .ae-page-print,
.ae-app.is-mobile .ae-topbar-right .ae-theme-toggle,
.ae-app.is-mobile .ae-topbar-right .ae-global-search-btn { display: none !important; }
.ae-app.is-mobile .ae-topbar { padding: 8px 12px; gap: 8px; justify-content: space-between; }
.ae-app.is-mobile .ae-topbar-right { margin-left: auto; }
.ae-app.is-mobile .ae-brand-logo { height: 30px; }

/* Home: via il sistema solare (bello, ma grande quanto lo schermo),
   restano saluto, «Chiedi», azioni e i numeri. */
.ae-app.is-mobile .ae-system { display: none !important; }
.ae-app.is-mobile .ae-sky { min-height: 0; padding-bottom: 8px; }
.ae-app.is-mobile .ae-hero { padding: 18px 16px 8px; }
.ae-app.is-mobile .ae-hero-title { font-size: 1.5rem; }
.ae-app.is-mobile .ae-hero-ask { flex-wrap: wrap; }
.ae-app.is-mobile .ae-hero-ask-input { flex: 1 1 100%; min-height: 46px; font-size: 1rem; }
.ae-app.is-mobile .ae-hero-ask-search { display: none; }
.ae-app.is-mobile .ae-hero-actions { display: none; }         /* c'è il «+» in basso */
.ae-app.is-mobile .ae-telemetry { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
.ae-app.is-mobile .ae-tile { min-height: 96px; }
.ae-app.is-mobile .ae-signals { grid-template-columns: 1fr !important; }
.ae-app.is-mobile .ae-console { display: none; }

/* Elenchi: testate compatte, filtri scorrevoli, azioni piene. */
.ae-app.is-mobile .ae-main { padding: 12px 12px 0; }
.ae-app.is-mobile .ae-page-head { flex-direction: column; align-items: stretch; gap: 10px; }
.ae-app.is-mobile .ae-page-head h1 { font-size: 1.35rem; }
.ae-app.is-mobile .ae-page-actions { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.ae-app.is-mobile .ae-page-actions .ae-btn { flex: none; min-height: 42px; }
.ae-app.is-mobile .ae-filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.ae-app.is-mobile .ae-filters > * { flex: none; }
.ae-app.is-mobile .ae-filters .ae-search-box { flex: 1 0 100%; }
.ae-app.is-mobile .ae-filters .ae-input { min-height: 44px; font-size: 1rem; }
.ae-app.is-mobile .ae-viewmode { display: none; }
.ae-app.is-mobile .ae-alpha { display: none; }
.ae-app.is-mobile .ae-grid { grid-template-columns: 1fr !important; }

/* Pannelli laterali e finestre: a tutto schermo, con chiusura a portata. */
.ae-app.is-mobile .ae-drawer-panel,
.ae-app.is-mobile .ae-modal-panel { width: 100% !important; max-width: none !important; height: 100dvh; max-height: none; border-radius: 0; }
.ae-app.is-mobile .ae-drawer-head, .ae-app.is-mobile .ae-modal-head { position: sticky; top: 0; z-index: 2; background: var(--ae-surface); padding: 10px 12px; }
.ae-app.is-mobile .ae-drawer-head .ae-icon-btn em, .ae-app.is-mobile .ae-drawer-full { display: none; }
.ae-app.is-mobile .ae-drawer-close, .ae-app.is-mobile .ae-modal-close { width: 44px; height: 44px; }
.ae-app.is-mobile .ae-drawer-body, .ae-app.is-mobile .ae-modal-body { padding: 12px 14px calc(24px + env(safe-area-inset-bottom, 0px)); }

/* Tocchi grandi ovunque: 44px è il minimo che un pollice centra. */
.ae-app.is-mobile .ae-btn, .ae-app.is-mobile .ae-icon-btn, .ae-app.is-mobile .ae-mini-row, .ae-app.is-mobile .ae-sig-row { min-height: 44px; }
.ae-app.is-mobile .ae-input, .ae-app.is-mobile select, .ae-app.is-mobile textarea { font-size: 1rem; }
.ae-app.is-mobile a[href^="tel:"], .ae-app.is-mobile a[href^="mailto:"] {
	display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 999px;
	background: color-mix(in srgb, var(--ae-accent) 10%, transparent); color: var(--ae-accent); font-weight: 600; text-decoration: none;
}

/* Ricerca globale: parte dall'alto, tastiera sotto. */
.ae-app.is-mobile .ae-palette-panel { top: 8px; left: 8px; right: 8px; width: auto; max-height: 80dvh; }
.ae-app.is-mobile .ae-palette-input { min-height: 48px; font-size: 1.05rem; }

/* Piè di pagina: sul telefono è solo scorrimento in più. */
.ae-app.is-mobile .ae-footer { display: none; }

/* Chi ha scelto la versione completa su uno schermo stretto ha un
   tasto discreto per tornare indietro. */
.ae-app.is-narrow:not(.is-mobile) .ae-mobile-on {
	display: grid; place-items: center; position: fixed; right: 14px; bottom: 14px; z-index: 320;
	width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
	background: var(--ae-accent); box-shadow: 0 10px 24px -8px var(--ae-accent);
}
.ae-app.is-narrow:not(.is-mobile) .ae-mobile-on[hidden] { display: none; }

/* Al buio */
.ae-app[data-theme="dark"].is-mobile .ae-tabbar { background: color-mix(in srgb, var(--ae-surface) 88%, transparent); box-shadow: 0 -6px 28px rgba(0, 0, 0, .45); }
.ae-app[data-theme="dark"].is-mobile .ae-sheet-panel { background: color-mix(in srgb, var(--ae-surface) 96%, #fff); }

/* Con un foglio aperto la pagina sotto non scorre. */
html.ae-sheet-open, html.ae-sheet-open body { overflow: hidden; }
