/* ================= Carte plein écran ================= */

/* La page entière devient la carte : pas de défilement, pas de pied de page. */
body:has(.screen-map) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body:has(.screen-map) .footer {
  display: none;
}
.container:has(.screen-map) {
  max-width: none;
  padding: 0;
  display: flex;
  min-height: 0;
}
.screen-map {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Fond de carte "Nuit" (OpenFreeMap recoloré) : sombre dès l'ouverture, jamais de carte claire */
.map-canvas {
  position: absolute;
  inset: 0;
  z-index: 0; /* contient les calques Leaflet sous les panneaux */
  background: #2e2b29;
}

/* ---------- Marqueurs ---------- */
.lawyer-marker {
  display: grid;
  place-items: center;
  cursor: pointer;
}
.lm-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  border: 4px solid var(--black);
  transition: transform 0.15s;
}
.lawyer-marker:hover .lm-dot,
.lawyer-marker:focus-visible .lm-dot {
  transform: scale(1.15);
}
.lawyer-marker.is-selected .lm-dot {
  width: 28px;
  height: 28px;
  border-width: 5px;
}
.lawyer-marker.is-selected {
  z-index: 1000 !important;
}
.me-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--black);
  border: 4px solid var(--field);
  outline: 1px solid var(--black);
}

/* ---------- Commandes posées sur la carte ---------- */
.map-top {
  position: absolute;
  z-index: 2;
  inset-block-start: 12px;
  inset-inline: 12px;
  display: grid;
  gap: 8px;
  pointer-events: none; /* la carte reste manipulable entre les boutons */
}
.map-top > * {
  pointer-events: auto;
}
.map-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#situation-slot {
  flex: 1;
  min-width: 0;
}
.urgent-btn {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 1.3rem;
  border: none;
  border-radius: var(--pill);
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--urgent);
  cursor: pointer;
  transition: background-color 0.15s;
}
.urgent-btn:hover {
  background: var(--urgent-dark);
}
.situation-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  min-height: 46px;
  padding-inline: 1.2rem 0.35rem;
  border-radius: var(--pill);
  font-weight: 600;
  color: var(--black);
  background: var(--gold);
}
/* Texte long sur petit écran : coupé proprement avec "…" au lieu de pousser les boutons */
.situation-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.situation-pill button {
  flex-shrink: 0;
}
.situation-pill.is-urgent {
  color: #ffffff;
  background: var(--urgent);
}
.situation-pill button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  color: inherit;
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
}
.fab {
  flex-shrink: 0;
  margin-inline-start: auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: var(--field);
  color: var(--ink);
  cursor: pointer;
}
.fab:hover {
  background: var(--card);
}
.fab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* Filtres : une seule bande de pilules qu'on fait défiler du doigt, la sélection en noir.
   Le fondu sur le bord indique qu'il y a d'autres choix à côté. */
.chips {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-inline: -12px; /* la bande va jusqu'aux bords de l'écran */
  padding: 2px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 36px), transparent 100%);
}
:root[dir='rtl'] .chips {
  -webkit-mask-image: linear-gradient(to left, #000 0, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to left, #000 0, #000 calc(100% - 36px), transparent 100%);
}
.chips::-webkit-scrollbar {
  display: none;
}
.chips::after {
  content: '';
  flex: 0 0 24px; /* espace en fin de bande pour que le dernier filtre sorte du fondu */
}
.chip-group {
  display: contents;
}
.lang-filter {
  flex-shrink: 0;
}
.chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--field);
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  background: var(--card);
}
.chip.is-on {
  color: var(--page);
  background: var(--black);
  border-color: var(--black);
  font-weight: 600;
}
.lang-filter select {
  min-height: 38px;
  width: auto;
  padding: 0 0.9rem;
  font-size: 0.86rem;
  border: 1px solid var(--line);
  background: var(--field);
}
/* Langue choisie : même noir que les pilules sélectionnées */
.lang-filter select:has(option:checked:not([value=''])) {
  color: var(--page);
  background-color: var(--black);
  border-color: var(--black);
}

/* ---------- Panneau du bas ---------- */
.sheet {
  position: absolute;
  z-index: 2;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 54%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color: var(--ink);
  background: var(--page);
  border-radius: var(--radius) var(--radius) 0 0;
  transition: max-height 0.25s ease;
}
.sheet.is-collapsed {
  max-height: 128px;
}
.sheet-handle {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 30px;
  border: none;
  background: none;
  cursor: pointer;
}
.grab {
  width: 42px;
  height: 5px;
  border-radius: 5px;
  background: var(--line);
}
.sheet-body {
  overflow-y: auto;
  padding: 0 20px 12px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.sheet-foot {
  margin: 0;
  padding: 8px 20px 12px;
  font-size: 0.7rem;
  color: var(--ink-muted);
}
.sheet-head {
  display: grid;
  gap: 2px;
}
.sheet-title {
  margin: 0;
  font-size: 1.45rem;
}
.sheet-hero {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
}
.sheet-sub,
.sheet-text.small {
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.sheet-text {
  margin: 0;
  color: var(--ink-muted);
}
.sheet-actions {
  display: grid;
  gap: 8px;
}

.active-request {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  padding: 0 0.6rem 0 1.2rem;
  border-radius: var(--pill);
  color: var(--page);
  text-decoration: none;
  background: var(--black);
}
.active-request strong {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 1rem;
  border-radius: var(--pill);
  font-size: 0.85rem;
  color: var(--black);
  background: var(--gold);
}

.lawyer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.lawyer-row {
  width: 100%;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--card);
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
:root[dir='rtl'] .lawyer-row {
  padding: 10px 10px 10px 16px;
}
.lawyer-row:hover {
  background: var(--card-hover);
}
.lawyer-main {
  display: grid;
  min-width: 0;
}
.lawyer-main strong {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lawyer-main small {
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gold);
  background: var(--black);
}
.avatar-lg {
  width: 58px;
  height: 58px;
  font-size: 1rem;
}
.distance {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.back-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.back-link::before {
  content: '‹';
  font-size: 1.4rem;
  line-height: 1;
}
:root[dir='rtl'] .back-link::before {
  content: '›';
}
.detail-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
}
.verified {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  min-height: 28px;
  padding: 0 0.75rem;
  border-radius: var(--pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--black);
  background: var(--gold);
}
/* Fiche : lignes "libellé · valeur" séparées par un filet (comme "Overview") */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  margin: 0;
  font-size: 0.92rem;
}
.detail-list dt,
.detail-list dd {
  padding-block: 0.7rem;
  border-block-end: 1px solid var(--line);
}
.detail-list dd {
  margin: 0;
  text-align: end;
  color: var(--ink-muted);
}
.detail-list dt:last-of-type,
.detail-list dd:last-of-type {
  border-block-end: none;
}

/* ---------- Fenêtre "Que se passe-t-il ?" ---------- */
.urgent-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.urgent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.urgent-dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  display: grid;
  gap: 12px;
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--page);
  color: var(--ink);
}
.urgent-dialog h2 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
}
.muted-dark {
  margin: 0;
  color: var(--ink-muted);
}
.situations {
  display: grid;
  gap: 8px;
}
.situation {
  display: grid;
  gap: 2px;
  min-height: 66px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.situation strong {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 500;
}
.situation small {
  color: var(--ink-muted);
}
.situation.is-urgent {
  background: #f3dfd9;
}
.situation:hover {
  border-color: var(--gold-deep);
}
.emergency-numbers {
  margin: 0;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  background: var(--gold-soft);
}

/* Grand écran : le panneau devient une colonne à gauche (à droite en arabe). */
@media (min-width: 900px) {
  .sheet {
    inset-block: 12px;
    inset-inline: 12px auto;
    bottom: 12px;
    width: 400px;
    max-height: none;
    border-radius: var(--radius);
  }
  .sheet.is-collapsed {
    max-height: none;
  }
  .sheet-handle {
    display: none;
  }
  .sheet-body {
    padding-top: 22px;
    flex: 1;
  }
  .map-top {
    inset-inline-start: 424px;
  }
  .chips {
    margin-inline: 0;
    padding-inline: 0;
  }
  .urgent-panel {
    align-items: center;
  }
  .urgent-dialog {
    border-radius: var(--radius);
  }
}

/* ---------- Version application ---------- */
/* Commandes du haut sous l'encoche de l'iPhone quand la carte occupe tout l'écran */
body.is-fullscreen .map-top {
  inset-block-start: calc(12px + env(safe-area-inset-top, 0px));
}
/* Avec la barre d'onglets, c'est elle qui gère la zone du bas de l'iPhone */
body.has-tabbar .sheet {
  padding-bottom: 0;
}
/* Pas de rebond de page sur la carte */
body:has(.screen-map) {
  overscroll-behavior: none;
}
/* Langue, pour les visiteurs (téléphone : la barre du haut est masquée sur la carte) */
.map-lang {
  flex-shrink: 0;
  min-height: 46px;
  padding: 0 1rem;
  border: none;
  border-radius: var(--pill);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}
.map-lang + .fab {
  margin-inline-start: 0;
}
#situation-slot + .map-lang {
  margin-inline-start: auto;
}
@media (min-width: 900px) {
  .map-lang {
    display: none;
  }
  .map-lang + .fab {
    margin-inline-start: auto;
  }
}

/* ================= Panneau de la carte : fond sombre, contenu clair ================= */
.sheet {
  --sheet-text: #f4f0e6;
  --sheet-muted: #bdb5a6;
  --sheet-line: rgba(255, 255, 255, 0.12);
  --sheet-block: rgba(255, 255, 255, 0.07);
  --sheet-block-hover: rgba(255, 255, 255, 0.12);
  background: var(--black);
  color: var(--sheet-text);
}
.sheet .grab {
  background: rgba(255, 255, 255, 0.25);
}
.sheet :is(h2, h3, .sheet-title, .sheet-hero) {
  color: var(--sheet-text);
}
.sheet :is(.sheet-text, .sheet-sub, .eyebrow, .muted) {
  color: var(--sheet-muted);
}
.sheet .sheet-foot {
  color: var(--sheet-muted);
  border-block-start: 1px solid var(--sheet-line);
}
.sheet a:not(.btn) {
  color: var(--gold);
}
/* Boutons inversés sur fond sombre */
.sheet .btn-primary {
  background: var(--page);
  color: var(--black);
}
.sheet .btn-primary:hover:not(:disabled) {
  background: #ffffff;
}
.sheet .btn-light {
  background: var(--sheet-block-hover);
  color: var(--sheet-text);
}
.sheet .btn-light:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}
/* Demande en cours */
.sheet .active-request {
  background: var(--sheet-block);
  color: var(--sheet-text);
  border: 1px solid rgba(226, 180, 58, 0.45);
}
/* Liste des avocats */
.sheet .lawyer-row {
  background: var(--sheet-block);
  color: var(--sheet-text);
}
.sheet .lawyer-row:hover {
  background: var(--sheet-block-hover);
  border-color: rgba(226, 180, 58, 0.5);
}
.sheet .lawyer-main small {
  color: var(--sheet-muted);
}
.sheet .avatar {
  background: var(--sheet-block-hover);
  color: var(--gold);
}
.sheet .distance {
  color: var(--sheet-text);
}
/* Fiche d'un avocat */
.sheet .back-link {
  color: var(--sheet-text);
}
.sheet .detail-list :is(dt, dd) {
  border-block-end-color: var(--sheet-line);
}
.sheet .detail-list dt {
  color: var(--sheet-text);
}
.sheet .detail-list dd {
  color: var(--sheet-muted);
}
@media (min-width: 900px) {
  .sheet {
    border: none;
  }
}

/* ---------- Charte noir / blanc / or sur la carte ---------- */
/* Boutons blancs posés sur la carte : contour noir pour bien les distinguer */
.fab,
.map-lang {
  border: 1px solid var(--line);
}
/* Fenêtre "Que se passe-t-il ?" : blanche, choix délimités par un filet noir */
.urgent-dialog {
  border-top: 1px solid var(--line);
}
.situation {
  border: 1px solid var(--line);
}
.situation:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
/* Panneau du bas : noir pur */
.sheet {
  background: var(--black);
}
@media (min-width: 900px) {
  .urgent-dialog {
    border: 1px solid var(--line);
  }
}

/* =====================================================================
   VERSION NUIT (inspirée des applications de VTC)
   Fond sombre, boutons ronds sombres, repère client avec nom de rue,
   avocats disponibles en points dorés qui "pulsent".
   ===================================================================== */
.map-canvas,
.map-canvas .leaflet-container {
  background: #2e2b29;
}
.map-canvas .leaflet-gl-layer {
  filter: none;
}

/* Boutons ronds sombres (menu ☰, me localiser) */
.map-round {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #262626;
  color: #ffffff;
  cursor: pointer;
}
.map-round:hover {
  background: #333333;
}
.map-round svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* "Me localiser" : en bas à droite, toujours juste au-dessus du panneau du bas */
.fab-locate {
  position: absolute;
  z-index: 2;
  inset-inline-end: 16px;
  bottom: calc(var(--sheet-h, 45%) + 14px);
  transition: bottom 0.25s ease;
}
@media (min-width: 900px) {
  .fab-locate {
    bottom: 24px;
  }
}

/* Filtres sur fond sombre : pilules sombres, la sélection en blanc */
.chip,
.lang-filter select {
  color: #ffffff;
  background-color: rgba(38, 38, 38, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.chip:hover {
  background-color: #333333;
}
.chip.is-on {
  color: #000000;
  background: #ffffff;
  border-color: #ffffff;
}
.lang-filter select:has(option:checked:not([value=''])) {
  color: #000000;
  background-color: #ffffff;
  border-color: #ffffff;
}

/* Avocats disponibles : point doré avec un anneau qui pulse */
.lm-dot {
  position: relative;
  width: 16px;
  height: 16px;
  border: 2px solid #1a1a1a;
  outline: 5px solid rgba(201, 162, 39, 0.28);
  background: var(--gold);
}
.lm-dot::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid rgba(201, 162, 39, 0.65);
  animation: lawyer-ping 2s ease-out infinite;
}
.lawyer-marker.is-selected .lm-dot {
  width: 24px;
  height: 24px;
  outline: 6px solid rgba(255, 255, 255, 0.35);
}
@keyframes lawyer-ping {
  to {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* Repère du client : carré blanc + silhouette, tige, étiquette avec le nom de la rue */
.me-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
}
/* Remet à zéro l'ancien style du point du client */
.me-marker span {
  all: unset;
}
.me-card {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 2px;
  width: max-content;
  min-width: 150px;
  max-width: min(260px, 70vw);
  padding: 10px 14px;
  border-radius: 12px;
  background: #1f1f1f;
  color: #ffffff;
  text-align: start;
  white-space: nowrap;
}
.me-card small {
  color: #a3a3a3;
  font-size: 0.78rem;
}
.me-card strong {
  font-size: 0.98rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-pin {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ffffff;
  color: #000000;
  border: 2px solid #000000;
}
.me-pin svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}
.me-marker .me-stick {
  display: block;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: #ffffff;
}
.me-marker .me-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  outline: 4px solid rgba(255, 255, 255, 0.25);
}

/* Menu latéral (bouton ☰) */
.map-menu {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.map-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.map-menu-panel {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(300px, 82vw);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(20px + env(safe-area-inset-bottom, 0px));
  background: #000000;
  color: #ffffff;
  overflow-y: auto;
  animation: menu-in 0.22s ease;
}
:root[dir='rtl'] .map-menu-panel {
  animation-name: menu-in-rtl;
}
.map-menu-panel .brand {
  color: #ffffff;
  margin-block-end: 16px;
}
.map-menu-panel > a:not(.brand),
.map-menu-panel > button {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border: none;
  border-radius: 12px;
  background: none;
  color: #ffffff;
  font: inherit;
  font-size: 1rem;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.map-menu-panel > a:not(.brand):hover,
.map-menu-panel > button:hover {
  background: #1f1f1f;
}
.map-menu-close {
  margin-block-start: auto;
  color: #a3a3a3 !important;
}
@keyframes menu-in {
  from {
    transform: translateX(-100%);
  }
}
@keyframes menu-in-rtl {
  from {
    transform: translateX(100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .lm-dot::after,
  .map-menu-panel {
    animation: none;
  }
}

/* Visiteur sans compte : invitation à créer un compte, sous la liste des avocats */
.guest-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
