/* ==========================================================================
   Pause Toilette : thème clair (un seul mode)
   ==========================================================================

   PALETTE : pour changer les couleurs du site, modifie UNIQUEMENT les valeurs ci-dessous.
   Le rouge sert à : la boule d'accueil et son bouton, les marqueurs de la carte,
   la barre de couleur à gauche des cartes d'options, le bouton "Envoyer" et les alertes.
   (Les fonds des cartes, les textes et les bordures restent neutres.)
   ========================================================================== */

:root {
  color-scheme: light;

  /* --- Rouge de la marque (bouton, marqueurs, bouton Envoyer) */
  --brand: #ff333a;
  /* --- Rouge plus sombre pour les petits textes d'alerte (ex. "Fermé") */
  --brand-strong: #c8232a;
  /* --- Rose très léger : fond d'un vote "Non" sélectionné */
  --brand-soft: #fdeeee;
  /* --- Jaune de la pastille du bouton */
  --accent: #ffde38;
  /* --- Contour noir de la boule */
  --ink: #111111;

  /* --- Couleurs neutres */
  --bg: #f6f7f9;          /* fond de page */
  --surface: #ffffff;     /* cartes et fenêtres */
  --surface-2: #f1f3f6;   /* boutons discrets, champs de saisie */
  --text: #16181d;
  --muted: #626b78;
  --line: #e3e6eb;

  /* --- Couleurs d'état */
  --ok: #1b8f7d;   --ok-soft: #e1f5f1;      /* gratuit, accessible, ouvert */
  --warn: #b86d0c; --warn-soft: #fff1d9;    /* payant, à confirmer */
  --info: #2f6fd0; --info-soft: #e7f0fd;    /* toilette dans un établissement */

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 12px 32px rgba(18, 22, 30, 0.18);
  --shadow-sm: 0 2px 8px rgba(18, 22, 30, 0.14);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
.is-hidden { display: none !important; }

#map { width: 100%; height: 100%; background: var(--bg); }

/* ------------------------------------------------------------------ Carte (Leaflet) */

.leaflet-top { top: var(--safe-top); }
.leaflet-top.leaflet-left { left: 6px; }

.leaflet-bar { border: none !important; box-shadow: var(--shadow-sm) !important; border-radius: 14px !important; overflow: hidden; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--surface); color: var(--text); border-bottom: 1px solid var(--line);
  width: 38px; height: 38px; line-height: 38px; font-size: 18px;
}
.leaflet-bar a:last-child { border-bottom: none; }

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.82) !important;
  color: var(--muted) !important;
  font-size: 10px;
  border-top-left-radius: 8px;
}

/* Fenêtres d'info : l'espace intérieur est du PADDING (et non une marge) pour que le bas ne colle pas au bord */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}
.leaflet-popup-content { margin: 0; padding: 16px 16px 20px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-tip { background: var(--surface); box-shadow: none; }
.leaflet-popup-close-button { color: var(--muted) !important; font-size: 20px !important; top: 6px !important; right: 8px !important; }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--text) !important; }

/* ------------------------------------------------------------------ 1. Écran d'accueil */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(60% 45% at 85% 8%, rgba(255, 222, 56, 0.35), transparent 70%),
    radial-gradient(70% 50% at 10% 95%, rgba(255, 51, 58, 0.18), transparent 70%),
    var(--bg);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.welcome-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.welcome-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.welcome-logo { width: 104px; height: 104px; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.16)); }
.welcome-title { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }

.welcome-hint {
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  max-width: 320px;
  margin: 0 0 150px 0; /* laisse la place au bouton au centre */
  line-height: 1.45;
}

/* ------------------------------------------------------------------ 2. Bouton sphère cartoon */

.btn-cartoon-ball {
  position: fixed;
  z-index: 2500;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 40px);
  --ball: 92px;
  width: var(--ball);
  height: var(--ball);
  border-radius: 50%;
  background-color: var(--brand);
  border: 7px solid var(--ink);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  display: block;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  padding: 0;
  outline: none;
  overflow: hidden;
  animation: ballPulse 2.4s ease-in-out infinite;
  transition:
    top 0.8s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.8s cubic-bezier(0.25, 1, 0.5, 1),
    width 0.5s ease,
    height 0.5s ease,
    box-shadow 0.2s ease;
}

@keyframes ballPulse {
  0%, 100% { box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(255, 51, 58, 0.45); }
  50%      { box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35), 0 0 0 16px rgba(255, 51, 58, 0); }
}

.btn-cartoon-ball:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Position finale en bouton flottant une fois la carte affichée */
body.app-started .btn-cartoon-ball {
  top: calc(100% - 85px - var(--safe-bottom));
  transform: translateX(-50%);
  --ball: 72px;
  width: var(--ball);
  height: var(--ball);
  animation: none;
}

.btn-cartoon-ball:active { transform: translate(-50%, 40px) scale(0.92); transition: transform 0.08s ease; }
body.app-started .btn-cartoon-ball:active { transform: translateX(-50%) translateY(3px) scale(0.92); transition: transform 0.08s ease; }

.cartoon-shadow-crescent {
  position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset calc(var(--ball) * 0.2) calc(var(--ball) * -0.2) 0 0 #b31625; pointer-events: none;
}
.cartoon-yellow-dot {
  position: absolute; top: 12%; right: 14%; width: 20%; height: 20%;
  background-color: var(--accent); border-radius: 50%; pointer-events: none;
}

/* ------------------------------------------------------------------ 3. Volet bas */

.status-panel {
  position: absolute;
  bottom: calc(120px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  width: calc(100% - 28px);
  max-width: 400px;
  /* laisse au moins la moitié de l'écran à la carte ; dvh suit la barre d'adresse mobile */
  max-height: 40vh;
  max-height: 40dvh;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  font-size: 13px;
  animation: sheetIn 0.25s ease-out;
}

@keyframes sheetIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-weight: 700; font-size: 15px; color: var(--text);
}

.btn-close {
  background: var(--surface-2); border: none; color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%; font-size: 20px; line-height: 1;
}
.btn-close:hover { color: var(--text); }

.panel-note { margin: 6px 0 10px; color: var(--muted); font-size: 13px; }
.panel-note.small { font-size: 11px; margin: 8px 0 6px; }
.panel-reason { color: var(--brand-strong); font-size: 12px; margin-bottom: 8px; font-weight: 600; }

/* Options : lignes de liste séparées par un filet, pastille numérotée identique au marqueur de la carte */
.urgent-choice-item {
  display: flex;
  gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}
.urgent-choice-item:last-child { border-bottom: none; }
.urgent-choice-item:hover, .urgent-choice-item:active { background: var(--surface-2); }

.opt-badge {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 800;
}
.choice-facility .opt-badge { background: var(--info); }
.opt-body { flex: 1; min-width: 0; }

.opt-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.opt-dist { flex: none; font-weight: 700; font-size: 14px; color: var(--muted); }
.opt-address { font-weight: 600; font-size: 14px; color: var(--text); line-height: 1.35; }
.opt-name { margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--text); }
.opt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip.chip-ok   { background: var(--ok-soft);   color: var(--ok);   border-color: transparent; }
.chip.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.note-facility { display: block; margin-top: 4px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.note-facility .exist-ok   { color: var(--ok);   font-weight: 700; }
.note-facility .exist-warn { color: var(--warn); font-weight: 700; }

.list-sep { margin: 12px 2px 8px; font-size: 11px; font-weight: 700; color: var(--info); text-transform: uppercase; letter-spacing: 0.4px; }

/* Boutons du volet */
.btn-toggle-others {
  width: 100%; padding: 10px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; margin-top: 2px;
}
.btn-toggle-others:active { background: var(--line); }
.btn-toggle-others.spaced { margin-top: 10px; }
.btn-toggle-others.btn-teal { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-toggle-others.btn-red { background: var(--brand); border-color: var(--brand); color: #fff; }
#others-container { margin-top: 6px; }

/* Lien texte pour plier/déplier la liste, chevron dessiné en CSS */
.btn-link {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none; padding: 4px 0; cursor: pointer;
  color: var(--brand-strong); font-size: 14px; font-weight: 700;
}
.btn-link::after {
  content: ''; width: 7px; height: 7px; margin-top: -4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform 0.2s;
}
.btn-link.is-open::after { margin-top: 3px; transform: rotate(-135deg); }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.others-hidden { display: none; }

/* Bouton pour rouvrir le volet des résultats après la croix */
.btn-reopen {
  position: absolute; z-index: 999; left: 50%; transform: translateX(-50%);
  bottom: calc(120px + var(--safe-bottom));
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-reopen[hidden] { display: none; }
.btn-reopen:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-row { display: flex; gap: 8px; margin: 4px 0 6px; }
.btn-row .btn-toggle-others { margin: 0; flex: 1; }

/* Saisie d'adresse manuelle */
.manual-address-box { margin-top: 6px; }
.manual-address-box input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 15px; outline: none; background: var(--surface-2); color: var(--text);
}
.manual-address-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 51, 58, 0.15); }
.manual-suggestions-list {
  list-style: none; margin: 6px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); max-height: 160px; overflow-y: auto;
}
.manual-suggestions-list:empty { display: none; }
.manual-suggestions-list li { padding: 10px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); line-height: 1.3; }
.manual-suggestions-list li:last-child { border-bottom: none; }
.manual-suggestions-list li:hover { background: var(--surface-2); }
.manual-suggestions-list li.empty { color: var(--muted); cursor: default; }

/* ------------------------------------------------------------------ Marqueurs */

.poi-urgent-marker {
  background-color: var(--brand); color: #fff; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 3px 10px rgba(200, 35, 42, 0.5);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
.poi-urgent-marker.poi-facility { background-color: var(--info); box-shadow: 0 3px 10px rgba(47, 111, 208, 0.5); }

.user-marker {
  background-color: #1f9d8a; width: 16px; height: 16px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 10px rgba(31, 157, 138, 0.9); position: relative;
}
.user-marker::after {
  content: ''; position: absolute; inset: -7px; border: 2px solid #1f9d8a; border-radius: 50%;
  animation: pulse 1.8s infinite ease-out; opacity: 0.6;
}
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.8; } 100% { transform: scale(2.2); opacity: 0; } }

/* ------------------------------------------------------------------ Fenêtre d'info d'un toilette */

.tp-rank { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.tp-title { font-size: 17px; font-weight: 800; line-height: 1.25; padding-right: 20px; }
.tp-address { margin: 6px 0 8px; font-weight: 600; font-size: 13px; color: var(--text); }
.tp-status { margin-bottom: 8px; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }

/* Ouvert / fermé : petite pastille de couleur CSS (pas d'emoji) */
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; }
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; flex: none; }
.badge-open { color: var(--ok); }
.badge-muted { color: var(--muted); font-weight: 600; }
.badge-muted::before { display: none; }
.hours-detail { color: var(--muted); font-size: 11px; margin-left: 6px; }

/* Votes */
.vote-box, .review-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.vote-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.vote-actions, .vote-reasons { display: flex; gap: 8px; flex-wrap: wrap; }
.vote-reasons { margin-top: 8px; }

.vote-btn {
  flex: 1; padding: 9px 10px; font-size: 12px; font-weight: 700; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; color: var(--text); cursor: pointer; touch-action: manipulation;
}
.vote-btn { transition: background 0.15s, border-color 0.15s, color 0.15s; }
.vote-btn:disabled { opacity: 0.55; }
/* Survol : rouge pour "Non" et ses raisons, vert pour "Oui" (mêmes couleurs que l'état voté) */
.vote-btn:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.vote-up:hover:not(:disabled)  { background: var(--ok-soft);    border-color: var(--ok);    color: var(--ok); }
.vote-up.voted   { background: var(--ok-soft);   border-color: var(--ok);   color: var(--ok); }
.vote-down.voted { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.vote-msg, .review-msg { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.vote-msg:empty, .review-msg:empty { display: none; }

/* Avis */
.review-actions { display: flex; gap: 18px; flex-wrap: wrap; }
.link-btn { background: none; border: none; padding: 2px 0; font-size: 12.5px; font-weight: 700; color: var(--info); cursor: pointer; }
.review-list { margin-top: 10px; display: grid; gap: 8px; font-size: 12px; color: var(--muted); }
.review-item { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.review-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; color: var(--text); font-size: 12px; }
.review-date { color: var(--muted); font-weight: 500; font-size: 11px; }
.review-comment { margin-top: 3px; color: var(--text); white-space: pre-wrap; word-break: break-word; }

.review-form { margin-top: 10px; display: grid; gap: 10px; }
.review-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer;
}
.chip-btn.selected { background: var(--text); border-color: var(--text); color: #fff; }
.review-text {
  width: 100%; resize: none; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.review-text:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 51, 58, 0.15); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }  /* champ piège anti-robots */
.review-foot { display: flex; justify-content: space-between; align-items: center; }
.review-counter { font-size: 11px; color: var(--muted); }
.btn-send { background: var(--brand); color: #fff; border: none; border-radius: 10px; padding: 9px 18px; font-size: 12px; font-weight: 800; cursor: pointer; }
.btn-send:disabled { opacity: 0.55; }
.review-note { font-size: 11px; color: var(--muted); }

/* Itinéraires : boutons sobres, la couleur de l'appli n'apparaît que dans une pastille */
.popup-actions { display: flex; gap: 8px; margin-top: 16px; }
.leaflet-container .popup-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 8px; font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px;  /* écrase la couleur bleue des liens de Leaflet */
  transition: background 0.15s, border-color 0.15s;
}
.leaflet-container .popup-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--app-color); }
.leaflet-container .popup-btn:active { background: var(--line); }
.popup-btn::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--app-color); }
.btn-maps { --app-color: #34a853; }
.btn-waze { --app-color: #33ccff; }

/* ------------------------------------------------------------------ Grands écrans */

@media (min-width: 768px) {
  .status-panel { top: calc(20px + var(--safe-top)); right: 20px; bottom: auto; left: auto; transform: none; max-height: 80vh; width: 340px; animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
