/* ==========================================================
   FICHE ANNONCE — VERSION MOBILE / APPLICATION
   idf-immobilier.com — Version 1.1 — 17/11/2026 (barre d'onglets + en-tête comme partout)
   ----------------------------------------------------------
   Chargée après style_annonce_v2.css et style_index_v2.css.
   Tout est limité aux écrans de 768 px et moins : la fiche
   sur ordinateur ne change pas.
   --theme / --theme-light : bleu (location) ou vert (vente),
   définies dans lire_annonce.php.
   ========================================================== */

.m-topbar, .m-contact-bar, .m-gal-count { display: none; }

/* Petit message « Lien copié » (toutes tailles d'écran) */
#m-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px);
  background: #1a1a2e; color: #fff; padding: 10px 18px; border-radius: 30px;
  font-family: var(--font-body, sans-serif); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30000;
}
#m-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 768px) {

  :root { --m-bar-h: 70px; --m-safe-b: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--m-bar-h) + var(--m-safe-b)) !important; background: var(--fond-page, #f5f7fb); }

  /* ---------- En-tête compact ---------- */
  .main-header .navbar { padding: 8px 0 !important; }
  .main-header .container-fluid { padding-left: 14px; padding-right: 10px; }
  .logo-title { font-size: 1.15rem !important; letter-spacing: -0.5px; }
  .logo-slogan { display: none !important; }
  .main-header .navbar-toggler { padding: 6px 9px; border-radius: 10px; }
  .pwa-mode .main-header { padding-top: env(safe-area-inset-top, 0px); }

  /* ---------- Ordre des blocs sur téléphone ---------- */
  main.container { display: flex; flex-direction: column; padding-left: 0; padding-right: 0; margin-top: 0 !important; }
  main.container > * { margin-left: 12px; margin-right: 12px; }
  .m-order-back      { order: 0; }
  .m-order-alert     { order: 1; }
  .m-order-photos    { order: 2; }
  .m-order-h1        { order: 3; }
  .m-order-principal { order: 4; }
  .m-order-video     { order: 5; }
  .m-order-desc      { order: 6; }
  .m-order-carac     { order: 7; }
  .m-order-dpe       { order: 8; }
  .m-order-row       { order: 9; }

  /* ---------- Barre retour / partager ---------- */
  .m-topbar {
    display: flex; align-items: center; gap: 10px; padding: 10px 0 8px;
  }
  .m-back {
    display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px 7px 8px; border-radius: 20px;
    background: #fff; border: 1px solid var(--gris-200, #e5e7eb); color: var(--gris-900, #2d2d3f) !important;
    font-family: var(--font-display, sans-serif); font-weight: 600; font-size: 14px;
  }
  .m-topbar-type { font-family: var(--font-display, sans-serif); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; margin-left: auto; }
  .m-share {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--gris-200, #e5e7eb); background: #fff;
    color: var(--gris-900, #2d2d3f); display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
  }

  /* ---------- Photos : bandeau qui défile au doigt ---------- */
  .m-order-photos {
    margin: 0 !important; padding: 0 !important; background: transparent !important; box-shadow: none !important;
    border: 0 !important; border-radius: 0 !important; position: relative;
  }
  .m-order-photos > .bloc-title { display: none; }
  .m-order-photos > p.text-muted { margin: 0 12px; padding: 40px 0; text-align: center; background: #fff; border-radius: 16px; }
  .m-order-photos .gallery-grid {
    display: flex !important; grid-template-columns: none !important; gap: 8px !important;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    padding: 0 12px; scroll-padding-left: 12px;
  }
  .m-order-photos .gallery-grid::-webkit-scrollbar { display: none; }
  .m-order-photos .gallery-item {
    flex: 0 0 88%; height: 250px !important; border-radius: 16px !important; overflow: hidden;
    scroll-snap-align: start; margin: 0 !important; position: relative;
  }
  .m-order-photos .gallery-item:only-child { flex-basis: 100%; }
  .m-order-photos .gallery-item img { width: 100% !important; height: 100% !important; object-fit: cover; aspect-ratio: auto; }
  .m-order-photos .gallery-overlay { display: none !important; }
  .m-gal-count {
    display: inline-flex; align-items: center; gap: 5px; position: absolute; right: 22px; bottom: 10px;
    background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
    pointer-events: none;
  }

  /* Visionneuse plein écran */
  #photoModal img { max-width: 100vw !important; max-height: 80vh !important; border-radius: 0 !important; }
  #photoModal .photo-nav { font-size: 38px !important; padding: 10px !important; }
  #photoModalClose { top: calc(10px + env(safe-area-inset-top, 0px)) !important; right: 16px !important; font-size: 38px !important; }

  /* ---------- Titre ---------- */
  .annonce-h1 { font-size: 1.12rem !important; line-height: 1.35 !important; margin-top: 14px !important; margin-bottom: 10px !important; }

  /* ---------- Bloc principal ---------- */
  .bloc-principal { padding: 14px !important; border-radius: 16px !important; }
  .bloc-principal-top { gap: 8px; }
  .annonce-badge { font-size: 12px !important; }
  .m-hide-btn { display: none !important; }
  .annonce-actions { display: none !important; } /* partage = bouton de la barre du haut */
  .bloc-infos-admin { gap: 6px 14px !important; font-size: 13px !important; flex-wrap: wrap; }
  .key-features-pills { gap: 6px !important; flex-wrap: wrap; }
  .feature-pill { font-size: 13px !important; padding: 6px 10px !important; }
  .bloc-prix { padding: 12px 14px !important; border-radius: 12px !important; }
  .prix-value { font-size: 1.6rem !important; }
  .bloc-details-location { gap: 8px !important; }

  /* ---------- Sections ---------- */
  .bloc-section { padding: 16px 14px !important; border-radius: 16px !important; margin-bottom: 12px !important; }
  .bloc-title { font-size: 1.02rem !important; margin-bottom: 12px !important; }
  .description-text { font-size: 15px; line-height: 1.6; }
  .carac-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 6px !important; }
  .carac-pill { font-size: 13px !important; padding: 8px 10px !important; }
  .carac-pill.off { display: none !important; } /* sur téléphone : seulement les équipements présents */
  .energy-details > div { margin-bottom: 10px; }

  /* ---------- Carte + contact : le contact d'abord ---------- */
  .m-order-row { margin: 0 !important; --bs-gutter-x: 0; }
  .m-order-row > [class*="col-"] { padding: 0 12px; margin-bottom: 12px !important; }
  .m-contact-col { order: -1; }
  #map { height: 240px !important; }
  #contact-form { scroll-margin-top: 70px; }

  /* Formulaire de contact : champs confortables, pas de zoom iPhone */
  .contact-form .form-control { font-size: 16px !important; height: 48px; border-radius: 12px !important; }
  .contact-form textarea.form-control { height: auto; min-height: 110px; }
  .contact-form .form-label { font-size: 13px; margin-bottom: 4px; font-weight: 600; }
  .contact-form .mb-3 { margin-bottom: 12px !important; }
  .contact-form .btn-submit { width: 100%; height: 52px; border-radius: 12px !important; font-size: 16px; font-weight: 700; }
  .btn-show-phone, .phone-revealed { width: 100%; border-radius: 12px !important; }

  /* ---------- Barre de contact fixe ---------- */
  .m-contact-bar {
    display: flex; align-items: center; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9000;
    padding: 10px 12px calc(10px + var(--m-safe-b));
    background: rgba(255,255,255,.97);
    -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--gris-200, #e5e7eb); box-shadow: 0 -4px 18px rgba(0,0,0,.06);
  }
  .m-cb-price { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
  .m-cb-price strong { font-family: var(--font-display, sans-serif); font-weight: 800; font-size: 17px; white-space: nowrap; }
  .m-cb-price strong small { font-size: 11px; font-weight: 500; color: var(--gris-500, #6b7280); }
  .m-cb-price span { font-size: 12px; color: var(--gris-500, #6b7280); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-cb-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 16px;
    border-radius: 12px; font-family: var(--font-display, sans-serif); font-weight: 700; font-size: 15px;
    white-space: nowrap; -webkit-tap-highlight-color: transparent;
  }
  .m-cb-call { background: #fff; border: 1.5px solid; }
  .m-cb-msg { color: #fff !important; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
  .m-cb-btn:active { transform: scale(.97); }

  /* Avec la barre d'onglets du site : la barre de contact se pose juste au-dessus */
  body.has-tabbar { padding-bottom: calc(var(--idf-tabbar-h, 64px) + var(--m-bar-h) + 6px) !important; }
  body.has-tabbar .m-contact-bar { bottom: var(--idf-tabbar-h, 64px); padding-bottom: 10px; box-shadow: 0 -2px 10px rgba(0,0,0,.05); }
  body.has-tabbar #pwa-install-banner { bottom: calc(var(--idf-tabbar-h, 64px) + var(--m-bar-h)) !important; }
  body.has-tabbar #m-toast { bottom: calc(var(--idf-tabbar-h, 64px) + var(--m-bar-h) + 14px); }
  body.has-tabbar #cookieBanner { bottom: calc(var(--idf-tabbar-h, 64px) + var(--m-bar-h) + 8px) !important; }

  /* Bannières en bas : au-dessus de la barre de contact */
  #pwa-install-banner { bottom: calc(var(--m-bar-h) + var(--m-safe-b)) !important; }
  #m-toast { bottom: calc(var(--m-bar-h) + var(--m-safe-b) + 14px); }

  .footer-dark { margin-top: 18px !important; }
}

@media (max-width: 360px) {
  .m-cb-btn { padding: 0 12px; font-size: 14px; }
  .m-cb-price strong { font-size: 15px; }
}