/* === VIATOR — COUCHE « APPLICATION » (chargée en dernier, surcharge style.css et mobile.css) ===
   Mise en page unique ordinateur + téléphone : barre de titre fine, recherche flottante sur la carte,
   filtres toujours visibles, boutons d'action en bas à droite (zone du pouce), navigation en bas. */
:root {
  --brand: #17402a;
  --brand-2: #1e6b3e;
  --brand-soft: #e7f2ea;
  --accent: #f2a93b;
  --ink: #15211a;
  --muted: #5d6b63;
  --line: #e2e7e3;
  --surface: #ffffff;
  --bg: #f3f5f2;
  --app-header-h: 52px;
  --app-nav-h: calc(62px + env(safe-area-inset-bottom));
  --app-shadow: 0 2px 6px rgba(16, 40, 28, .10), 0 8px 24px rgba(16, 40, 28, .10);
  --app-radius: 14px;
}

html, body { height: 100dvh; overflow: hidden; background: var(--bg); }
body { padding: 0 !important; min-height: 0 !important; font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); }

/* ---------- Barre de titre ---------- */
body > header {
  position: fixed !important; top: 0; left: 0; right: 0; z-index: 1300;
  height: var(--app-header-h) !important; padding: 0 12px env(safe-area-inset-top) !important;
  padding-top: env(safe-area-inset-top) !important;
  background: var(--brand) !important; box-shadow: none !important; backdrop-filter: none !important;
  display: flex; align-items: center; text-align: left;
}
body > header .header-top { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
body > header h1 { display: flex; align-items: center; gap: 8px; margin: 0 !important; font: 700 19px/1 'Playfair Display', Georgia, serif !important; color: #fff; letter-spacing: .2px; white-space: nowrap; }
body > header h1 svg { width: 26px; height: 26px; flex: none; }
.app-demo-badge { font: 600 10px/1 'Inter', sans-serif; letter-spacing: .6px; text-transform: uppercase; color: var(--brand); background: var(--accent); padding: 4px 6px; border-radius: 6px; }
#favBtn, #filterToggle, #filterStatus, #breadcrumb { display: none !important; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-actions button, .app-install-btn {
  min-width: 0 !important; min-height: 36px !important; height: 36px; padding: 0 12px !important;
  border-radius: 999px !important; border: 1px solid rgba(255,255,255,.28) !important;
  background: rgba(255,255,255,.10) !important; color: #fff !important;
  font: 600 13px/1 'Inter', sans-serif !important; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-actions button:hover, .app-install-btn:hover { background: rgba(255,255,255,.2) !important; }
.app-install-btn { background: var(--accent) !important; color: var(--brand) !important; border-color: var(--accent) !important; }
.app-install-btn[hidden] { display: none !important; }

/* ---------- Carte plein écran ---------- */
.map-wrap {
  position: fixed !important; left: 0; right: 0; z-index: 1;
  top: var(--app-header-h) !important; bottom: var(--app-nav-h) !important;
  left: 0 !important; right: 0 !important;
}
#map { position: absolute !important; inset: 0; min-height: 0 !important; }
#filterCollapse { display: none !important; }
.leaflet-top.leaflet-left { top: 112px; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--app-shadow) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-control-zoom a { width: 40px !important; height: 40px !important; line-height: 40px !important; color: var(--ink) !important; }
@media (max-width: 768px) { .leaflet-control-zoom { display: none; } }

/* ---------- Recherche flottante + filtres ---------- */
#addrSearchBar {
  position: fixed !important; top: calc(var(--app-header-h) + 10px) !important; left: 10px; right: 10px;
  z-index: 1250 !important; display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 0 !important; background: transparent !important; border: 0 !important; box-shadow: none !important;
  pointer-events: none;
}
#addrSearchBar > * { pointer-events: auto; }
@media (min-width: 769px) { #addrSearchBar { right: auto; width: 460px; } }
.app-search-pill {
  flex: 1 1 100%; display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 6px 0 14px;
  background: var(--surface); border-radius: 999px; box-shadow: var(--app-shadow);
}
.app-search-pill svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
#addrSearchBar .as-icon { display: none; }
#addressInput {
  flex: 1; min-width: 0; height: 100%; border: 0 !important; outline: none; background: transparent !important;
  font: 16px 'Inter', sans-serif !important; color: var(--ink); padding: 0 !important; box-shadow: none !important;
}
#globalSearchBtn {
  flex: none; height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--brand-2); color: #fff;
  font: 600 14px 'Inter', sans-serif; cursor: pointer;
}
#globalSearchBtn:disabled { opacity: .6; }
#addressClear { position: static !important; flex: none; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; display: none; padding: 6px; }
#addressClear.visible { display: block; }
#addressSuggestions { top: 54px !important; left: 0; right: 0; border-radius: var(--app-radius) !important; box-shadow: var(--app-shadow) !important; }

.app-chips {
  flex: 1 1 100%; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px;
  -webkit-overflow-scrolling: touch; mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.app-chips::-webkit-scrollbar { display: none; }
.app-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 13px/1 'Inter', sans-serif; cursor: pointer; box-shadow: 0 1px 3px rgba(16,40,28,.12); white-space: nowrap;
}
.app-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.app-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.app-chip.country { background: var(--brand-soft); border-color: #cfe3d5; color: var(--brand); }
.app-chip.country.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.app-chip-sep { flex: none; width: 1px; margin: 6px 2px; background: rgba(0,0,0,.15); }

/* ---------- Boutons d'action (en bas à droite) ---------- */
.locate-btn, .search-btn, .addpoi-btn {
  position: absolute !important; right: 12px !important; top: auto !important;
  width: 48px !important; height: 48px !important; border-radius: 50% !important;
  background: var(--surface) !important; color: var(--ink) !important; border: 0 !important;
  box-shadow: var(--app-shadow) !important; display: flex !important; align-items: center; justify-content: center;
  font-size: 0 !important; z-index: 1000;
}
.locate-btn svg, .search-btn svg, .addpoi-btn svg { width: 22px; height: 22px; }
.addpoi-btn { bottom: 16px !important; width: 56px !important; height: 56px !important; background: var(--brand-2) !important; color: #fff !important; }
.addpoi-btn svg { width: 26px; height: 26px; }
.search-btn { bottom: 82px !important; }
.locate-btn { bottom: 140px !important; }
.photo-btn, #iaFab, .ia-assistant-fab, .back-to-top { display: none !important; }

/* ---------- Onglet de zone (en bas à gauche) ---------- */
.zone-info-tab {
  position: fixed !important; left: 12px !important; right: auto !important;
  bottom: calc(var(--app-nav-h) + 16px) !important; z-index: 1100 !important;
  max-width: calc(100vw - 100px); padding: 10px 14px !important; border-radius: 999px !important;
  background: var(--surface) !important; border: 0 !important; box-shadow: var(--app-shadow) !important;
  font: 600 13px/1.2 'Inter', sans-serif !important; color: var(--brand) !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zone-info { position: fixed !important; left: 0; right: 0; bottom: var(--app-nav-h); z-index: 1150; border-radius: 18px 18px 0 0; }

/* ---------- Navigation du bas ---------- */
.bottom-nav {
  height: var(--app-nav-h) !important; padding-bottom: env(safe-area-inset-bottom) !important;
  background: var(--surface) !important; border-top: 1px solid var(--line) !important; z-index: 1400 !important;
  box-shadow: 0 -2px 12px rgba(16,40,28,.06) !important;
}
.bottom-nav-btn { color: var(--muted) !important; font: 600 11px/1.1 'Inter', sans-serif !important; gap: 4px !important; }
.bottom-nav-btn::before { display: none !important; }
.bottom-nav-btn .bn-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 28px; border-radius: 999px; font-size: 0 !important; }
.bottom-nav-btn .bn-icon svg { width: 22px; height: 22px; }
.bottom-nav-btn.active { color: var(--brand) !important; }
.bottom-nav-btn.active .bn-icon { background: var(--brand-soft); }
@media (min-width: 769px) {
  .bottom-nav { left: 50% !important; transform: translateX(-50%); width: 420px !important; bottom: 14px !important; height: 62px !important; padding: 0 !important; border-radius: 20px; border: 1px solid var(--line) !important; box-shadow: var(--app-shadow) !important; }
  .map-wrap { bottom: 0 !important; }
  .zone-info-tab { bottom: 24px !important; }
  .addpoi-btn { bottom: 24px !important; } .search-btn { bottom: 92px !important; } .locate-btn { bottom: 150px !important; }
}

/* ---------- Pages Circuits / Liste ---------- */
.circuit-fullpage, .app-list-page { top: var(--app-header-h) !important; bottom: var(--app-nav-h) !important; z-index: 1200 !important; }
@media (min-width: 769px) { .circuit-fullpage, .app-list-page { bottom: 0 !important; padding-bottom: 90px; } }
.app-list-page {
  position: fixed; left: 0; right: 0; display: none; flex-direction: column; background: var(--bg); overflow: hidden;
}
.app-list-page.open { display: flex; }
.app-list-head { padding: 16px 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.app-list-head h2 { margin: 0 0 4px; font: 700 20px 'Playfair Display', Georgia, serif; color: var(--brand); }
.app-list-head p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.app-list-head input { width: 100%; box-sizing: border-box; height: 42px; border-radius: 12px; border: 1px solid var(--line); padding: 0 14px; font: 16px 'Inter', sans-serif; background: var(--bg); }
.app-list-body { flex: 1; overflow-y: auto; padding: 10px 12px 20px; display: grid; gap: 8px; align-content: start; max-width: 760px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.app-card {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--app-radius); background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.app-card:hover { border-color: #bcd5c4; }
.app-card-thumb { width: 64px; height: 64px; flex: none; border-radius: 10px; background: var(--brand-soft) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.app-card-main { min-width: 0; flex: 1; }
.app-card-main strong { display: block; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-card-main span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.app-card-meta { font-size: 12px; color: var(--brand-2); font-weight: 600; white-space: nowrap; }
.app-empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

.circuit-fullpage { background: var(--bg) !important; }
.circuit-fp-header { display: flex !important; align-items: center; gap: 8px; padding: 14px 16px !important; background: var(--surface) !important; border-bottom: 1px solid var(--line); }
.circuit-fp-header h2 { flex: 1; margin: 0 !important; font: 700 20px 'Playfair Display', Georgia, serif !important; color: var(--brand) !important; }
.circuit-fp-close, .circuit-fp-back { width: 38px; height: 38px; border-radius: 50% !important; border: 1px solid var(--line) !important; background: var(--surface) !important; color: var(--ink) !important; font-size: 16px !important; cursor: pointer; flex: none; }
.circuit-tabs { display: flex !important; gap: 8px !important; overflow-x: auto; padding: 10px 12px !important; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.circuit-tab { flex: none; padding: 8px 13px !important; border-radius: 999px !important; border: 1px solid var(--line) !important; background: var(--surface) !important; color: var(--ink) !important; font: 600 13px/1 'Inter', sans-serif !important; cursor: pointer; white-space: nowrap; }
.circuit-tab.active { background: var(--brand) !important; color: #fff !important; border-color: var(--brand) !important; }
.circuit-fp-body { max-width: 760px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.circuit-search-bar input { height: 42px; border-radius: 12px !important; border: 1px solid var(--line) !important; font-size: 16px !important; }

/* Hors de la carte : pas de recherche flottante ni de boutons de carte par-dessus les pages. */
body[data-app-tab="list"] #addrSearchBar, body[data-app-tab="circuit"] #addrSearchBar,
body[data-app-tab="list"] .zone-info-tab, body[data-app-tab="circuit"] .zone-info-tab { display: none !important; }

/* ---------- Popups de la carte ---------- */
.leaflet-popup-content-wrapper { border-radius: 16px !important; box-shadow: var(--app-shadow) !important; }
.leaflet-popup-content { font-family: 'Inter', sans-serif; }

/* ---------- Bannière « mode hors ligne » ---------- */
.app-offline { position: fixed; top: calc(var(--app-header-h) + 112px); white-space: nowrap; left: 50%; transform: translateX(-50%); z-index: 1500; background: #3b3b3b; color: #fff; font: 600 12px 'Inter', sans-serif; padding: 6px 12px; border-radius: 999px; }
.app-offline[hidden] { display: none; }
