/* Couche mobile / PWA de la démo ImmoIA. Sans effet au-delà de 48rem : la démo bureau reste intacte. */
.pwa-tabs, .pwa-sub, .pwa-install { display: none; }

@media (max-width: 47.99rem) {
  body.pwa-mobile aside { display: none !important; }
  /* Aucun débordement horizontal : sinon le viewport s'élargit et le dock, fixé, sort de l'écran (vu sur Équipe). */
  html:has(body.pwa-mobile), body.pwa-mobile { overflow-x: hidden; max-width: 100vw; }
  body.pwa-mobile main { min-width: 0; max-width: 100vw; overflow-x: hidden; }
  body.pwa-mobile main { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)) !important; }
  body.pwa-mobile [data-pwa="bandeau"] span:last-child, body.pwa-mobile [data-pwa="bandeau"] a { display: none; }

  /* Le dock : une capsule de verre, cinq icônes, pas de libellé. */
  .pwa-tabs {
    position: fixed; left: 0.875rem; right: 0.875rem; bottom: calc(0.75rem + env(safe-area-inset-bottom)); z-index: 90;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.125rem;
    padding: 0.375rem; border-radius: 1.75rem;
    background: rgba(255, 255, 255, 0.72); backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6);
    box-shadow: 0 12px 40px -14px rgba(14, 35, 65, 0.45), 0 0 0 1px rgba(14, 35, 65, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
  }
  body.pwa-dock-hidden .pwa-tabs { transform: translateY(calc(100% + 1.5rem + env(safe-area-inset-bottom))); opacity: 0; pointer-events: none; }
  .pwa-tabs button {
    display: flex; align-items: center; justify-content: center; height: 3.25rem; min-width: 0; position: relative;
    border: 0; background: transparent; padding: 0; border-radius: 1.375rem; color: #6B7A90;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  }
  .pwa-tabs button:active { transform: scale(0.92); }
  .pwa-tabs button svg { width: 1.5rem; height: 1.5rem; }
  .pwa-tabs button[aria-current="true"] { color: #1D4ED8; background: rgba(60, 122, 250, 0.14); }
  .pwa-tabs .pwa-badge { position: absolute; top: 0.375rem; right: calc(50% - 1.375rem); min-width: 1.05rem; height: 1.05rem; padding: 0 0.25rem; border-radius: 0.55rem; background: #E7000B; color: #fff; font: 700 0.625rem/1 Inter, system-ui, sans-serif; display: grid; place-items: center; border: 2px solid #fff; }

  /* L'assistant se pose juste au-dessus du dock et le suit quand il se masque. */
  body.pwa-mobile [data-pwa="ai-fab"] { right: 1rem !important; bottom: calc(5.75rem + env(safe-area-inset-bottom)) !important; width: 3.25rem !important; height: 3.25rem !important; border-radius: 1.0625rem !important; transition: bottom 0.32s cubic-bezier(0.32, 0.72, 0, 1); }
  body.pwa-mobile [data-pwa="ai-fab"] img { width: 3.25rem !important; height: 3.25rem !important; border-radius: 1.0625rem !important; }
  body.pwa-mobile.pwa-dock-hidden [data-pwa="ai-fab"] { bottom: calc(1rem + env(safe-area-inset-bottom)) !important; }
  body.pwa-mobile [data-pwa="ai-notif"] { right: 1rem !important; left: 1rem !important; width: auto !important; max-width: none !important; bottom: calc(9.75rem + env(safe-area-inset-bottom)) !important; }
  body.pwa-mobile [data-pwa="ai-backdrop"] { background: rgba(14, 35, 65, 0.22) !important; }
  body.pwa-mobile [data-pwa="ai-panel"] { left: 0.5rem !important; right: 0.5rem !important; width: auto !important; max-width: none !important; bottom: calc(5.5rem + env(safe-area-inset-bottom)) !important; height: min(74vh, 40rem) !important; max-height: none !important; border-radius: 1.75rem !important; }

  /* Boutons contextuels sous le bandeau : « Tableau de bord », « Contacts », « Gestion des clés »… */
  .pwa-sub {
    display: flex; gap: 0.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0.625rem 1rem 0.25rem;
    background: #fff; font-family: Inter, system-ui, sans-serif; scrollbar-width: none;
  }
  .pwa-sub::-webkit-scrollbar { display: none; }
  .pwa-sub button {
    flex: none; display: inline-flex; align-items: center; gap: 0.375rem; height: 2.125rem; padding: 0 0.875rem;
    border: 1px solid #E3EAF3; border-radius: 9999px; background: #F7F9FC; color: #0E2341; font-size: 0.8125rem; font-weight: 600;
  }
  .pwa-sub button[aria-current="true"] { background: #E6F2FE; border-color: rgba(60, 122, 250, 0.4); color: #1D4ED8; }

  /* Popup d'installation, uniquement sur le tableau de bord, fermable d'un geste. */
  .pwa-install {
    position: fixed; left: 0.75rem; right: 0.75rem; bottom: calc(5.75rem + env(safe-area-inset-bottom)); z-index: 95;
    display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem 1rem;
    background: #fff; border: 1px solid rgba(14, 35, 65, 0.1); border-radius: 1.75rem; box-shadow: 0 10px 30px -12px rgba(30, 64, 255, 0.28);
    font-family: Inter, system-ui, sans-serif; animation: pwa-in 0.3s ease-out;
  }
  .pwa-install img { width: 3rem; height: 3rem; border-radius: 0.875rem; flex: none; }
  .pwa-install__txt { flex: 1; min-width: 0; }
  .pwa-install__txt b { display: block; font-family: Outfit, Inter, sans-serif; font-size: 0.9375rem; color: #0E2341; }
  .pwa-install__txt span { display: block; margin-top: 0.125rem; font-size: 0.75rem; line-height: 1.35; color: #485971; }
  .pwa-install__btn { flex: none; height: 2.25rem; padding: 0 0.875rem; border: 0; border-radius: 1rem; background: linear-gradient(135deg, #1E40FF 0%, #2F80FF 50%, #38B6FF 100%); color: #fff; font-weight: 600; font-size: 0.8125rem; }
  .pwa-install__close { position: absolute; top: -0.5rem; right: -0.25rem; width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 1px solid #DFE6ED; background: #fff; color: #485971; font-size: 1rem; line-height: 1; display: grid; place-items: center; }
  .pwa-install--ios .pwa-install__btn { display: none; }
  @keyframes pwa-in { from { transform: translateY(1rem); opacity: 0; } to { transform: none; opacity: 1; } }

  /* Contenu des vues : marges réduites, et UNE colonne partout (on ne lit rien à deux colonnes sur un téléphone). */
  body.pwa-mobile main > div { padding-left: 0.875rem !important; padding-right: 0.875rem !important; }
  body.pwa-mobile main div[style*="grid-template-columns:minmax"], body.pwa-mobile main div[style*="grid-template-columns: minmax"],
  body.pwa-mobile main div[style*="grid-template-columns:1fr 1fr"], body.pwa-mobile main div[style*="grid-template-columns: 1fr 1fr"],
  body.pwa-mobile main div[style*="grid-template-columns:240px"], body.pwa-mobile main div[style*="grid-template-columns: 240px"] { grid-template-columns: minmax(0, 1fr) !important; }
  body.pwa-mobile main table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Boîte de réception : texte puis pièces jointes, en colonne. */
  body.pwa-mobile [data-pwa="mail-grid"] { padding: 0.875rem !important; gap: 0.875rem !important; }

  /* Appels : # / durée / à rappeler / statut masqués ; jour, heure et durée sur trois lignes ; puis le numéro, puis l'écoute. */
  body.pwa-mobile [data-pwa="tel-table"] { display: table; width: 100%; }
  body.pwa-mobile [data-pwa="tel-table"] th { font-size: 0.6875rem !important; padding: 0.625rem 0.5rem !important; }
  body.pwa-mobile [data-pwa="tel-table"] th:nth-child(1), body.pwa-mobile [data-pwa="tel-table"] td:nth-child(1),
  body.pwa-mobile [data-pwa="tel-table"] th:nth-child(4), body.pwa-mobile [data-pwa="tel-table"] td:nth-child(4),
  body.pwa-mobile [data-pwa="tel-table"] th:nth-child(6), body.pwa-mobile [data-pwa="tel-table"] td:nth-child(6),
  body.pwa-mobile [data-pwa="tel-table"] th:nth-child(7), body.pwa-mobile [data-pwa="tel-table"] td:nth-child(7) { display: none; }
  body.pwa-mobile [data-pwa="tel-table"] td { padding: 0.625rem 0.5rem !important; font-size: 0.8125rem; }
  body.pwa-mobile [data-pwa="tel-table"] td:nth-child(2) { padding-left: 0.875rem !important; }
  body.pwa-mobile [data-pwa="tel-table"] td:nth-child(2) div { display: none; }
  body.pwa-mobile [data-pwa="tel-date"] span { display: block !important; line-height: 1.3; }
  body.pwa-mobile [data-pwa="tel-date"] span[data-pwa="tel-sep"] { display: none !important; }
  body.pwa-mobile [data-pwa="tel-h"]::before { content: "à "; }
  body.pwa-mobile [data-pwa="tel-h"] { font-size: 0.75rem; }
  body.pwa-mobile [data-pwa="tel-table"] td:nth-child(5) { font-size: 0.75rem !important; white-space: nowrap; }
  body.pwa-mobile [data-pwa="tel-table"] td:last-child { padding-right: 0.875rem !important; }

  /* Paramètres d'accueil : une page, section après section. */
  body.pwa-mobile [data-pwa="gest-tabs"], body.pwa-mobile [data-pwa="gest-title"] { display: none !important; }
  body.pwa-mobile [data-pwa="gest-h"] { display: block !important; }
  body.pwa-mobile [data-pwa="gest-h"]:first-of-type { border-top: 0; padding-top: 0; margin-top: 0.5rem; }
}
