/* ==========================================================================
   AREA SOCI — Rifiniture mobile app-like (attive solo <=900px)
   Caricato DOPO styles.css. Riusa i token blu del brand (styles.css :root).
   Sopra i 900px questo file è inerte: il desktop resta invariato.
   ========================================================================== */

/* I componenti mobile-only sono nascosti di default (desktop) */
.bottom-nav { display: none; }
.mobile-topbar { display: none; }

/* Su desktop il wrapper tessera non deve influenzare il layout:
   display:contents lo rende "invisibile" al flusso (header e grid si
   dispongono come prima del redesign). Diventa una card solo su mobile. */
.dashboard-top { display: contents; }

@media (max-width: 900px) {
  /* Su mobile la sidebar sparisce: si naviga con la bottom nav */
  #sidebar { display: none; }

  #app { flex-direction: column; }
  #main-content {
    max-width: 100%;
    /* spazio in fondo per non finire sotto la bottom nav fissa */
    padding: 1.25rem 1rem calc(72px + env(safe-area-inset-bottom));
  }

  /* ---------- Bottom navigation ---------- */
  .bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 900;
    display: flex;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgb(0 0 0 / 0.06);
  }
  .bottom-nav__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 6px 2px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.1;
  }
  .bottom-nav__item svg { width: 24px; height: 24px; flex-shrink: 0; }
  .bottom-nav__item.active { color: var(--primary); }

  /* ---------- Header sticky contestuale ---------- */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 800;
    /* bleed a tutta larghezza oltre il padding di #main-content */
    margin: -1.25rem -1rem 2rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
  }
  .mobile-topbar__title {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
  }
  .mobile-topbar__logout {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 600;
  }

  /* Titolo di sezione già nell'header: nascondi gli h2 duplicati
     (tranne la dashboard, dove serve il benvenuto personalizzato) */
  .page:not(#page-dashboard) .page-header h2 { display: none; }

  /* ---------- Tessera socio (home) ---------- */
  .dashboard-top {
    display: block;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
  }
  /* Intestazione tessera: banda blu con nome associazione */
  .dashboard-top .page-header {
    margin: 0;
    padding: 1.25rem 1.25rem 1rem;
    background: var(--gradient);
    color: var(--white);
  }
  .dashboard-top .page-header h2 {
    display: block;
    color: var(--white);
    font-size: 1.4rem;
    margin: 0;
  }
  .dashboard-top .page-header p { color: rgba(255, 255, 255, 0.85); }

  /* Le stat diventano celle interne alla tessera, senza bordo/ombra propri.
     Il gap di 1px su sfondo --border disegna le linee tra le celle. */
  .dashboard-top #dashboard-stats {
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    margin: 0;
    padding: 0;
  }
  .dashboard-top #dashboard-stats .stat-card {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: var(--white);
  }
  .dashboard-top #dashboard-stats .stat-card:hover {
    transform: none;
    box-shadow: none;
  }

  /* ---------- Rifiniture pagine ---------- */
  /* Target tap adeguati (>=44px) */
  .download-btn,
  .filtro-chip,
  .btn-primary,
  .btn-secondary { min-height: 44px; }
  .filtro-chip { display: inline-flex; align-items: center; }

  /* Template a colonna singola su telefono */
  .template-grid { grid-template-columns: 1fr; }

  /* Input >=16px: evita lo zoom automatico di iOS al focus */
  .field input,
  .field select,
  .field textarea,
  .risorse-search { font-size: 16px; }

  /* Storico richieste: titolo lungo + data + badge stanno stretti su una
     riga sola. Su mobile li impiliamo (titolo sopra, meta sotto). */
  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .history-meta { white-space: normal; }

  /* ---------- Micro-interazioni ---------- */
  .page:not(.hidden) { animation: asMobilePageIn 0.25s ease-out; }
  .bottom-nav__item { transition: color 0.15s ease, transform 0.1s ease; }
  .bottom-nav__item:active { transform: scale(0.92); }
}

@keyframes asMobilePageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Accessibilità: chi preferisce meno movimento non vede le animazioni mobile */
@media (prefers-reduced-motion: reduce) {
  .page:not(.hidden) { animation: none; }
  .bottom-nav__item { transition: none; }
}

