/* Image de fond unique pour le menu et toutes les pages mobiles.
   fond3.png en flou. Modifier ici pour changer le fond partout. */
:root {
  --bienla-fond-mobile: url('images/fond3.png?v=1');
}

.bienla-page-bg {
  position: relative;
  background-color: #1e293b;
}

.bienla-page-bg::before {
  content: '';
  position: absolute;
  inset: -20px;
  background-image: var(--bienla-fond-mobile);
  background-size: cover;
  background-position: center;
  filter: blur(12px);
  transform: scale(1.08);
  z-index: -1;
}

/* Mode propriétaire : filtre vert flou sur le fond */
body.proprio-mode .bienla-page-bg::after,
body.proprio-mode .page-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(34, 197, 94, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 0;
}
body.proprio-mode .bienla-page-bg + main,
body.proprio-mode main {
  position: relative;
  z-index: 1;
}
.proprio-retour {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  background: rgba(22, 163, 74, 0.9);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.2s;
}
.proprio-retour:hover {
  opacity: 0.95;
  color: white;
}
.proprio-retour::before {
  content: '←';
}

/* Édition inline propriétaire */
.proprio-editable {
  outline: 1px dashed rgba(255,255,255,0.4);
  outline-offset: 2px;
  border-radius: 4px;
}
.proprio-editable:hover {
  outline-color: rgba(255,255,255,0.7);
}
.proprio-editable:focus {
  outline: 2px solid rgba(14,116,144,0.8);
}
.proprio-editable.proprio-saved {
  outline-color: #22c55e;
  transition: outline-color 0.3s;
}

/* Boutons menu : même largeur (grille), texte tronqué si nécessaire */
.livret-menu-layout-item,
.nav-menu-item,
.menu-layout-item { min-width: 0; }
.btn-menu { min-width: 0; width: 100%; }
.btn-menu .btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; word-break: break-word; }

/* Icône emoji dans les boutons menu - optimisées par rapport à la taille du bouton */
.btn-menu .icon.icon-emoji {
  font-size: 4rem;
  line-height: 1;
}
.btn-menu .icon.icon-img {
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-menu .icon.icon-img img {
  width: 5rem;
  height: 5rem;
  object-fit: contain;
}

/* Boutons propriétaire : supprimer (rouge) et changer icône (bleu) */
.menu-proprio-del {
  font-size: 1.25rem;
  line-height: 1;
}
.menu-proprio-icon {
  font-size: 1.125rem;
  line-height: 1;
}
.proprio-editable-img {
  outline: 2px dashed rgba(255,255,255,0.5);
  outline-offset: 4px;
}
.proprio-editable-img:hover {
  outline-color: rgba(14,116,144,0.9);
}

/* Édition mobile mode propriétaire */
.proprio-edit-wrap {
  position: relative;
}
.proprio-edit-btn {
  flex-shrink: 0;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}
.proprio-edit-btn:hover,
.proprio-add-btn:hover {
  opacity: 0.9;
}

/* Modales livret : HTML injecté par content-livret.js — CSS explicite (Tailwind CDN ne scanne pas le JS). */
.livret-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 1rem;
}
.livret-modal-actions .livret-modal-btn {
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.625rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.livret-modal-actions .livret-modal-btn-primary {
  flex: 1 1 8rem;
  background: #0e7490;
  color: #fff;
}
.livret-modal-actions .livret-modal-btn-primary:hover {
  background: #155e75;
}
.livret-modal-actions .livret-modal-btn-neutral {
  background: #e5e7eb;
  color: #0c4a6e;
}
.livret-modal-actions .livret-modal-btn-neutral:hover {
  background: #d1d5db;
}
.livret-modal-actions .livret-modal-btn-danger {
  background: #dc2626;
  color: #fff;
}
.livret-modal-actions .livret-modal-btn-danger:hover {
  background: #b91c1c;
}
.livret-modal-actions .livret-modal-btn-amber {
  background: #f59e0b;
  color: #fff;
}
.livret-modal-actions .livret-modal-btn-amber:hover {
  background: #d97706;
}
.livret-itin-clear-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.625rem 1rem;
  min-height: 2.75rem;
  border-radius: 0.75rem;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #0c4a6e;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.livret-itin-clear-btn:hover {
  background: #e5e7eb;
}
.livret-poly-undo-btn {
  padding: 0.625rem 1rem;
  min-height: 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #0c4a6e;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}
.livret-poly-undo-btn:hover {
  background: #e5e7eb;
}

/* Menu mobile (proprio) : trois ronds alignés (suppr / icône / déplacer), même taille, fond coloré */
.livret-menu-proprio-round {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border-radius: 9999px;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.livret-menu-proprio-del {
  background: #dc2626;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  touch-action: manipulation;
}
.livret-menu-proprio-del:hover {
  background: #b91c1c;
}
.livret-menu-proprio-icon {
  background: #0e7490;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  touch-action: manipulation;
}
.livret-menu-proprio-icon:hover {
  background: #155e75;
}
.livret-menu-drag-handle {
  cursor: grab;
  background: #475569;
  color: #fff;
  touch-action: none;
}
.livret-menu-drag-handle svg {
  display: block;
}
.livret-menu-drag-handle:hover {
  background: #334155;
}
.livret-menu-drag-handle:active {
  cursor: grabbing;
  background: #1e293b;
}

/* Édition bloc : plein écran si largeur < 900px (mobile / fenêtre étroite) */
.livret-edit-panel {
  padding: 1.5rem;
}
.livret-edit-overlay.livret-edit-fullpage-mobile {
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  padding: calc(1.35rem + env(safe-area-inset-top, 0px)) 0.875rem max(0.875rem, env(safe-area-inset-bottom, 0px)) 0.875rem !important;
  box-sizing: border-box !important;
  /* Même ressource que la vue livret (#livret-content-view .page-bg) + voile */
  background-color: #1e293b !important;
  background-image:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.7)),
    var(--bienla-fond-mobile) !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-attachment: scroll !important;
}
body.proprio-mode .livret-edit-overlay.livret-edit-fullpage-mobile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(34, 197, 94, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 0;
}
.livret-edit-fullpage-mobile .livret-edit-panel {
  position: relative;
  z-index: 1;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  border-radius: 1rem !important;
  overflow: hidden !important;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.12) !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}
.livret-edit-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #fff;
}
.livret-edit-header-text {
  flex: 1;
  min-width: 0;
}
.livret-edit-heading {
  margin: 0;
}
.livret-edit-back {
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.5);
  color: #0c4a6e;
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  margin-left: -0.25rem;
}
.livret-edit-back:hover {
  background: rgba(255, 255, 255, 0.75);
}
.livret-edit-back:active {
  opacity: 0.92;
}
.livret-edit-back-icon {
  width: 1.5rem;
  height: 1.5rem;
}
.livret-edit-body {
  -webkit-overflow-scrolling: touch;
}
/* Texte / titre : consignes + zone saisie (surtout mobile plein écran — le bloc contenteditable est caché derrière le modal) */
.livret-edit-hint {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: rgba(30, 41, 59, 0.9);
}
.livret-edit-hint-mobile {
  display: none;
}
.livret-edit-fullpage-mobile .livret-edit-hint-desktop {
  display: none !important;
}
.livret-edit-fullpage-mobile .livret-edit-hint-mobile {
  display: block !important;
}
.livret-edit-text-field-wrap {
  margin-bottom: 1rem;
}
@media (min-width: 900px) {
  .livret-edit-text-field-wrap {
    display: none !important;
  }
}
.livret-edit-text-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0c4a6e;
  margin-bottom: 0.35rem;
}
.livret-edit-textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 7.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #1e293b;
  background: #fff;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}
.livret-edit-fullpage-mobile .livret-edit-textarea {
  background: rgba(255, 255, 255, 0.97);
}
/* Plein écran téléphone : même esprit que #livret-content-view > header */
.livret-edit-fullpage-mobile .livret-edit-header {
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* Même ordre de grandeur que shadow-lg Tailwind sur #livret-content-view > header */
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);
  border-radius: 0;
}
.livret-edit-fullpage-mobile .livret-edit-back {
  background: rgba(255, 255, 255, 0.5);
  color: #0c4a6e;
}
.livret-edit-fullpage-mobile .livret-edit-back:hover,
.livret-edit-fullpage-mobile .livret-edit-back:active {
  background: rgba(255, 255, 255, 0.75);
}
.livret-edit-fullpage-mobile .livret-edit-body {
  padding: 1rem 1rem 0.5rem;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.livret-edit-footer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
}
.livret-edit-footer .livret-modal-actions {
  margin-top: 0;
}
.livret-edit-fullpage-mobile .livret-edit-footer {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(226, 232, 240, 0.9);
}
/* Cartes Leaflet dans les modales édition / ajout bloc (POI, polylignes, itinéraire) */
.livret-editor-map-host {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Modales mes-biens (création, renommage) */
.mes-biens-modal-create,
.mes-biens-modal-rename {
  display: none;
  align-items: center;
  justify-content: center;
}
.mes-biens-modal-create.is-open,
.mes-biens-modal-rename.is-open {
  display: flex;
}

/* Replis « Lien à partager » (liste mes-biens) — focus clavier, taille champ (anti-zoom iOS) */
.mes-biens-link-details > summary:focus {
  outline: none;
}
.mes-biens-link-details > summary:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
  border-radius: 0.25rem;
}
.mes-biens-url-input {
  font-size: 1rem;
  line-height: 1.35;
}

/* Champs sur fond vitré : 16px mini pour éviter le zoom iOS et un rendu « micro » */
.hg-glass-form input:not([type='checkbox']):not([type='radio']),
.hg-glass-form textarea {
  font-size: 1rem;
  line-height: 1.5;
}

@media (min-width: 900px) {
  .livret-edit-back {
    display: none;
  }
  .livret-edit-header {
    border-bottom: none;
    padding: 0 0 0.5rem;
    margin: 0 0 0.25rem;
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-radius: 0;
  }
  .livret-edit-header-text {
    width: 100%;
  }
  .livret-edit-footer {
    border-top: none;
    padding: 0.75rem 0 0;
    background: #fff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

