/* ================================================================
   TableLibre — Google Maps style
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --lj:       #dc2626;
  --lj-light: #fef2f2;
  --lj-mid:   #fee2e2;
  --rj:       #ea580c;
  --rj-light: #fff7ed;
  --rj-mid:   #ffedd5;
  --blue:     #1a73e8;
  --text:     #202124;
  --text-2:   #5f6368;
  --border:   #e8eaed;
  --surface:  #fff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow:    0 2px 6px rgba(0,0,0,.14), 0 1px 4px rgba(0,0,0,.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.10);
  --radius:   12px;
  font-size: 14px;
}

body {
  font-family: 'Roboto', 'Google Sans', system-ui, -apple-system, sans-serif;
  background: #e5e3df;
  overflow: hidden;
}

/* ================================================================
   Carte — plein écran
   ================================================================ */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* Leaflet contrôles repositionnés */
.leaflet-top.leaflet-right .leaflet-control-zoom {
  margin-top: 12px;
  margin-right: 12px;
}

.leaflet-control-zoom a {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-2) !important;
  font-size: 16px !important;
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  box-shadow: var(--shadow-sm) !important;
}

.leaflet-control-zoom a:hover {
  background: #f1f3f4 !important;
  color: var(--text) !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(255,255,255,.7) !important;
  color: #888 !important;
}

/* ================================================================
   Overlay — colonne flottante top-left
   ================================================================ */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 400;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
  width: 480px;
}

/* Panels ont pointer-events actifs */
.panel,
#filter-row,
#sidebar { pointer-events: auto; }

/* ================================================================
   Barre de recherche
   ================================================================ */
.search-panel {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  padding: 0 6px 0 14px;
  height: 52px;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--lj);
  box-shadow: 0 0 0 3px rgba(220,38,38,.18);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.search-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

#search-form input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  min-width: 0;
}

#search-form input::placeholder { color: var(--text-2); }

#search-form select {
  border: none;
  outline: none;
  font-size: 0.78rem;
  color: var(--text-2);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px 2px;
}

/* Déconnexion */
.logout-btn {
  display: flex;
  align-items: center;
  color: #bdc1c6;
  padding: 4px;
  border-radius: 50%;
  transition: color .15s;
  text-decoration: none;
}
.logout-btn:hover { color: #dc2626; }

/* Info-bulle ℹ */
.info-btn {
  position: relative;
  display: flex;
  align-items: center;
  color: #bdc1c6;
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 50%;
  transition: color .15s;
}

.info-btn:hover,
.info-btn:focus { color: var(--text-2); outline: none; }

.info-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-2);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  pointer-events: none;
}

.info-tooltip strong { color: var(--text); }

.info-btn:hover .info-tooltip,
.info-btn:focus .info-tooltip { display: block; }

#btn-search {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--lj);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

#btn-search:hover { background: #b91c1c; }
#btn-search:disabled { background: #d1d5db; cursor: not-allowed; }

/* ================================================================
   Chips de filtres
   ================================================================ */
#filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.chips-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all .12s;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.chip:hover {
  background: #f8f9fa;
  border-color: #bdc1c6;
  color: var(--text);
}

.chip.active-lj {
  background: var(--lj);
  border-color: var(--lj);
  color: #fff;
  box-shadow: 0 1px 4px rgba(220,38,38,.35);
}

.chip.active-rj {
  background: var(--rj);
  border-color: var(--rj);
  color: #fff;
  box-shadow: 0 1px 4px rgba(234,88,12,.35);
}

.chip.active-arr {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.chip .count {
  font-size: 0.68rem;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

.chip-reset {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.74rem;
  color: var(--text-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all .12s;
}

.chip-reset:hover {
  background: #fef2f2;
  border-color: var(--lj);
  color: var(--lj);
}

/* ================================================================
   Sidebar résultats
   ================================================================ */
#sidebar {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.sidebar-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.results-count {
  font-size: 0.75rem;
  color: var(--text-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#status {
  font-size: 0.72rem;
  color: var(--text-2);
}

.status-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--lj);
  font-weight: 500;
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid #fca5a5;
  border-top-color: var(--lj);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-error { color: var(--lj); font-weight: 500; }

#results-list {
  list-style: none;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: #e0e0e0 transparent;
}

#results-list::-webkit-scrollbar { width: 4px; }
#results-list::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

/* ================================================================
   Cards résultats
   ================================================================ */
.result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-item:hover { background: #f8f9fa; }

.result-item.active {
  background: #f1f3f4;
}

.result-item.active.lj { border-left-color: var(--lj); }
.result-item.active.rj { border-left-color: var(--rj); }

.result-item.no-coords { opacity: .45; }

.result-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .3px;
}

/* Jugements d'ouverture / conversion */
.badge-open-lj { background: #fef2f2; color: #dc2626; }      /* rouge vif */
.badge-open-rj { background: #fff7ed; color: #c2410c; }      /* orange */
.badge-conv-lj { background: #4c0519; color: #fda4af; }      /* bordeaux */

/* Rétrocompat (utilisé par les filtres chips) */
.badge-LJ  { background: #fef2f2; color: #dc2626; }
.badge-RJ  { background: #fff7ed; color: #c2410c; }
.badge-date { background: #f1f3f4; color: var(--text-2); }
.badge-arr  { background: #f1f3f4; color: #80868b; }

.result-addr {
  font-size: 0.73rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Séparateur entre cards */
.result-item + .result-item {
  border-top: 1px solid #f1f3f4;
}

/* ================================================================
   Popup Leaflet — style info-window Google Maps
   ================================================================ */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.2), 0 1px 6px rgba(0,0,0,.12);
  border: none;
  min-width: 260px;
  max-width: 310px;
}

.leaflet-popup-tip-container { display: none; }

.leaflet-popup-close-button {
  color: var(--text-2) !important;
  font-size: 18px !important;
  padding: 6px 8px !important;
  top: 4px !important;
  right: 4px !important;
}

.leaflet-popup-content { margin: 0; }

.popup-inner {
  padding: 14px 16px 8px;
}

.popup-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 5px;
  padding-right: 20px; /* espace bouton fermer */
}

.popup-section {
  border-top: 1px solid var(--border);
  padding: 7px 0 4px;
}

.popup-section-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #9aa0a6;
  margin-bottom: 3px;
}

.popup-row {
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.45;
  margin-top: 1px;
}

.popup-label {
  color: #9aa0a6;
  margin-right: 4px;
  font-size: .73rem;
}

.popup-na { color: #d1d5db; font-style: italic; }

.popup-footer {
  background: #f8f9fa;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: .7rem;
  color: #9aa0a6;
}

.popup-bodacc-link {
  color: var(--blue);
  font-weight: 600;
  font-size: .73rem;
  text-decoration: none;
  white-space: nowrap;
}

.popup-bodacc-link:hover { text-decoration: underline; }

/* Sources de données */
.sidebar-sources {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 0.68rem;
  line-height: 1.6;
  color: #9aa0a6;
  flex-shrink: 0;
}

.sidebar-sources a {
  color: #9aa0a6;
  text-decoration: none;
}

.sidebar-sources a:hover {
  color: var(--text-2);
  text-decoration: underline;
}

/* ================================================================
   Utilitaires
   ================================================================ */
.hidden { display: none !important; }

/* ================================================================
   Bouton flottant haut-droit
   ================================================================ */
#top-right-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
}

#top-right-btn a {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #dc2626;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s, border-color .15s;
  white-space: nowrap;
  font-family: 'Google Sans', system-ui, -apple-system, sans-serif;
}

#top-right-btn a:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  border-color: #fca5a5;
}

#top-right-btn a.btn-account {
  color: #374151;
}

#top-right-btn a.btn-account:hover {
  border-color: #d1d5db;
}

/* ================================================================
   Plan gratuit — bandeau
   ================================================================ */
.plan-banner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #92400e;
  line-height: 1.5;
  margin-top: 8px;
  width: 480px;
}

.plan-banner strong { color: #78350f; }

.plan-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #a16207;
  font-size: 0.85rem;
  flex-shrink: 0;
  padding: 2px 4px;
  line-height: 1;
}

.plan-banner-close:hover { color: #78350f; }

/* ================================================================
   Modale alertes
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: #111; background: #f3f4f6; }

#alert-form { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-input {
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  color: #111;
  outline: none;
  transition: border-color .15s;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.form-input:focus { border-color: #dc2626; }

.check-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.check-group--radio {
  flex-direction: row;
  gap: 20px;
}

.check-label {
  font-size: 0.85rem;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.check-label input { accent-color: #dc2626; cursor: pointer; }

.btn-submit {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
  font-family: inherit;
  margin-top: 2px;
}
.btn-submit:hover { background: #b91c1c; }
.btn-submit:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }

.alert-success {
  margin: 0 20px 20px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 18px 18px 16px;
  font-size: 0.875rem;
  color: #166534;
  text-align: center;
}
.alert-success.hidden { display: none; }

/* ================================================================
   Pills arrondissements (modale alertes)
   ================================================================ */
.arr-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding: 2px 0;
}

.arr-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s, color .12s;
  white-space: nowrap;
}
.arr-pill:hover { border-color: #fca5a5; color: #dc2626; }
.arr-pill.selected {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.arr-pill.tous {
  font-weight: 700;
}
.arr-pill.disabled {
  opacity: .38;
}
