/* ==========================================================
   SITE MOBILE — partie COMMUNE à toutes les pages
   idf-immobilier.com — Version 1.0 — 16/11/2026
   ----------------------------------------------------------
   À charger APRÈS style_index_v2.css sur chaque page :
     <link rel="stylesheet" href="css/site_mobile.css?v=1">
   et, en bas de page, avant les scripts :
     <?php include __DIR__ . '/includes/mobile_nav.php'; ?>

   Contenu : en-tête compact, barre de navigation du bas,
   panneau « Plus », pied de page réduit, bannière cookies,
   champs de formulaire sans zoom sur iPhone.
   Tout est limité aux écrans de 768 px et moins.
   ========================================================== */

.m-tabbar, .m-sheet, .m-hdr-search { display: none; }

@media (max-width: 768px) {

  :root {
    --m-tabbar-h: 62px;
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    --idf-tabbar-h: calc(var(--m-tabbar-h) + var(--m-safe-b)); /* lue aussi par la bannière d'installation */
  }

  /* Champs : 16 px minimum, sinon l'iPhone zoome à chaque saisie */
  input.form-control, select.form-select, textarea.form-control,
  input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="search"], select, textarea {
    font-size: 16px !important;
  }

  /* ---------- En-tête compact ---------- */
  .main-header .navbar { padding: 10px 0 !important; }
  .main-header .container-fluid { padding-left: 16px; padding-right: 12px; flex-wrap: nowrap; }
  .main-header .navbar-brand { max-width: none !important; margin-right: auto; }
  .logo-title { font-size: 1.22rem !important; letter-spacing: -0.6px; }
  .logo-slogan { font-size: 9px !important; letter-spacing: 0.3px; }
  .pwa-mode .main-header { padding-top: env(safe-area-inset-top, 0px); }

  /* Pages avec barre du bas : le menu déroulant devient inutile */
  body.has-tabbar { padding-bottom: calc(var(--idf-tabbar-h) + 8px) !important; }
  body.has-tabbar .main-header .navbar-toggler,
  body.has-tabbar .main-header .navbar-collapse { display: none !important; }

  .m-hdr-search {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--bleu-50, #f0f6ff); color: var(--bleu, #0064E0); font-size: 18px;
    border: 1px solid var(--bleu-clair, #e8f1fd);
  }
  .m-hdr-search:active { background: var(--bleu-clair, #e8f1fd); }

  /* ---------- Pied de page réduit à l'essentiel ---------- */
  .footer-dark, .site-footer { margin-top: 24px !important; text-align: center; }
  .footer-dark .container, .site-footer .container { padding-top: 18px !important; padding-bottom: 14px !important; }
  .footer-dark .row > div, .site-footer .row > div { margin-bottom: 10px !important; }
  .footer-dark h5, .site-footer h5 { display: none; }
  .footer-dark .row > div:first-child p, .site-footer .row > div:first-child p { display: none; }              /* texte de présentation */
  .footer-dark .row > div:first-child::before, .site-footer .row > div:first-child::before {
    content: 'IDF-IMMOBILIER.COM'; display: block;
    font-family: var(--font-display, sans-serif); font-weight: 900; font-size: 1rem; letter-spacing: -0.4px; color: #fff;
  }
  /* Liens : on ne garde que ceux qui ne sont pas déjà dans la barre du bas */
  .footer-links, .ft-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin: 0; }
  .footer-links li, .ft-links li { margin: 0 !important; font-size: 13px; }
  .footer-links li:has(a[href="/"]),
  .footer-links li:has(a[href="index.php"]),
  .footer-links li:has(a[href*="annonces_locations"]),
  .footer-links li:has(a[href*="annonces_ventes"]),
  .footer-links li:has(a[href*="annonces_ville"]),
  .footer-links li:has(a[href*="publier_annonce"]),
  .footer-links li:has(a[href*="accueil_pro"]),
  .ft-links li:has(a[href="index.php"]), .ft-links li:has(a[href*="annonces_locations"]), .ft-links li:has(a[href*="annonces_ventes"]),
  .ft-links li:has(a[href*="annonces_ville"]), .ft-links li:has(a[href*="publier_annonce"]), .ft-links li:has(a[href*="accueil_pro"]),
  .ft-links li:has(a[href*="carte_"]), .ft-links li:has(a[href*="annonces_departement"]) { display: none; }
  .footer-dark .row > div:last-child p, .site-footer .row > div:last-child p { font-size: 13px; margin-bottom: 4px; }
  .footer-hr, .ft-hr { margin: 10px 0 !important; }
  /* Appli / mobile : pas de recherche avancée, de carte ni d'annonces par ville */
  .villes-pop-block,
  .idf-card[href*="recherche_avancee"], .idf-card[href*="cartes_annonces"],
  .footer-links li:has(a[href*="recherche_avancee"]), .footer-links li:has(a[href*="cartes_annonces"]),
  .ft-links li:has(a[href*="recherche_avancee"]), .ft-links li:has(a[href*="cartes_annonces"]) { display: none !important; }
  /* Mobile + appli : plus de pied de page (contact et mentions légales sont dans « Plus ») */
  .footer-dark, .site-footer, body > footer[role="contentinfo"] { display: none !important; }

  /* ---------- Bannière cookies compacte ---------- */
  #cookieBanner {
    left: 10px !important; right: 10px !important; bottom: 10px !important;
    padding: 12px 14px !important; border-radius: 14px; font-size: 13px; line-height: 1.4;
    box-shadow: 0 8px 28px rgba(0,0,0,.25); z-index: 9200 !important;
  }
  body.has-tabbar #cookieBanner { bottom: calc(var(--idf-tabbar-h) + 8px) !important; }
  #cookieBanner > div { gap: 10px !important; }
  #cookieBanner > div > div { display: flex; gap: 8px; width: 100%; }
  #cookieBanner .btn { flex: 1; margin: 0 !important; padding: 8px 10px; border-radius: 10px; font-weight: 600; }

  /* ---------- Liste d'annonces compacte avec photo (accueil, locations, ventes…) ---------- */
  .m-list { list-style: none; margin: 0; padding: 4px 0; }
  .m-list li + li .m-list-item { border-top: 1px solid var(--gris-100, #f0f2f5); }
  .m-list-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    color: inherit !important; -webkit-tap-highlight-color: transparent;
  }
  .m-list-item:active { background: var(--gris-50, #f8fafc); }
  .m-list-photo {
    width: 76px; height: 64px; border-radius: 10px; overflow: hidden; flex-shrink: 0;
    background: var(--gris-100, #f0f2f5); display: flex; align-items: center; justify-content: center;
    color: var(--gris-400); font-size: 20px;
  }
  .m-list-photo img { width: 100%; height: 100%; object-fit: cover; }
  .m-list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .m-list-price { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--bleu, #0064E0); }
  .m-list-price small { font-size: 12px; font-weight: 500; color: var(--gris-500); }
  .m-list-title { font-size: 13.5px; font-weight: 600; color: var(--gris-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-list-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--gris-500); min-width: 0; }
  .m-list-meta > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-list-meta .badge-dpe { padding: 1px 7px; font-size: 11px; min-width: 0; margin-left: auto; flex-shrink: 0; }
  .m-list-chev { color: var(--gris-300); font-size: 14px; }
  .m-list-visited { display: none; font-size: 11px; font-weight: 700; color: var(--vert, #00A86B); margin-left: 6px; }
  .visited-row .m-list-visited { display: inline; }
  .visited-row .m-list-title { color: var(--gris-500, #6b7280); }
  .m-list-new { font-size: 10.5px; font-weight: 700; color: #fff; background: var(--orange, #FF8C00); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }

  /* ---------- Barre de navigation du bas ---------- */
  .m-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9000;
    height: var(--idf-tabbar-h); padding: 0 6px var(--m-safe-b);
    background: rgba(255,255,255,0.96);
    -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,.05);
  }
  .m-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; padding: 0; color: var(--gris-500, #6b7280) !important; text-decoration: none !important;
    font-family: var(--font-display, sans-serif); font-weight: 600; font-size: 10.5px; letter-spacing: 0.1px;
    -webkit-tap-highlight-color: transparent; position: relative;
  }
  .m-tab .bi { font-size: 21px; line-height: 1; }
  .m-tab.is-active { color: var(--bleu, #0064E0) !important; }
  .m-tab.is-active::before {
    content: ''; position: absolute; top: 0; left: 50%; width: 26px; height: 3px; margin-left: -13px;
    border-radius: 0 0 3px 3px; background: var(--bleu, #0064E0);
  }
  .m-tab-count {
    position: absolute; top: 7px; left: 50%; margin-left: 7px;
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--gris-100, #f0f2f5); color: var(--gris-700, #555); font-size: 9.5px; font-weight: 800;
    display: flex; align-items: center; justify-content: center; border: 1.5px solid #fff;
  }
  .m-tab-publier .m-tab-plus {
    width: 44px; height: 32px; border-radius: 12px; background: var(--bleu, #0064E0); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
    box-shadow: 0 3px 10px rgba(0,100,224,.35);
  }
  .m-tab-publier { color: var(--bleu, #0064E0) !important; }

  /* ---------- Panneau « Plus » ---------- */
  .m-sheet { display: block; position: fixed; inset: 0; z-index: 10050; pointer-events: none; }
  .m-sheet-backdrop { position: absolute; inset: 0; background: rgba(15,20,35,.45); opacity: 0; transition: opacity .2s; }
  .m-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
    border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + var(--m-safe-b));
    transform: translateY(105%); visibility: hidden;
    transition: transform .25s cubic-bezier(.3,.8,.3,1), visibility 0s linear .25s;
    max-height: 80vh; overflow-y: auto;
  }
  .m-sheet.is-open { pointer-events: auto; }
  .m-sheet.is-open .m-sheet-backdrop { opacity: 1; }
  .m-sheet.is-open .m-sheet-panel { transform: none; visibility: visible; transition-delay: 0s; }
  .m-sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--gris-300, #ccc); margin: 4px auto 12px; }
  .m-sheet-title { font-family: var(--font-display, sans-serif); font-weight: 800; font-size: 1.05rem; color: var(--noir, #1a1a2e); margin: 0 4px 10px; }
  .m-sheet-list { list-style: none; margin: 0; padding: 0; }
  .m-sheet-list a {
    display: flex; align-items: center; gap: 14px; padding: 12px 6px; color: var(--gris-900, #2d2d3f) !important;
    font-weight: 600; font-size: 15px; border-radius: 12px; text-decoration: none !important;
  }
  .m-sheet-list a:active { background: var(--gris-50, #f8fafc); }
  .m-sheet-list li + li a { border-top: 1px solid var(--gris-100, #f0f2f5); border-radius: 0; }
  .m-sheet-ico {
    width: 38px; height: 38px; border-radius: 10px; background: var(--bleu-50, #f0f6ff); color: var(--bleu, #0064E0);
    display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
  }
  .m-sheet-list small { display: block; font-weight: 400; font-size: 12.5px; color: var(--gris-500, #6b7280); }
  .m-sheet-list .bi-chevron-right { margin-left: auto; color: var(--gris-300, #ccc); font-size: 13px; }
  body.m-sheet-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .m-sheet-panel, .m-sheet-backdrop { transition: none; }
}

/* Barre du bas : la clé (Locations) en bleu, la maison (Ventes) en vert,
   comme partout sur le site (v3, 17/11/2026) */
@media (max-width: 768px) {
  .m-tab[href$="annonces_locations.php"] .bi { color: var(--bleu, #0064E0); }
  .m-tab[href$="annonces_ventes.php"] .bi { color: var(--vert, #00A86B); }
  .m-tab[href$="annonces_locations.php"].is-active { color: var(--bleu, #0064E0) !important; }
  .m-tab[href$="annonces_ventes.php"].is-active { color: var(--vert, #00A86B) !important; }
  .m-tab[href$="annonces_ventes.php"].is-active::before { background: var(--vert, #00A86B); }
}
