/* cadastre-draw.css — modale de saisie assistée par carte (tracé de parcelle).
   Réutilise .modal / .is-active / .modal-header / .modal-footer de cadastre2.css.
   body.modal-open (abaissement sidebar) vient d'import-cadastre.css, déjà chargé. */

#cadastreDrawModal.modal {
  z-index: 100001; /* au-dessus du modal d'import (100000) et de la sidebar */
}

.cd-card {
  background: var(--card-background, #fff);
  border-radius: var(--radius-xl, 16px);
  width: 92vw;
  max-width: none;
  height: 90vh;
  max-height: 90vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-xl, 0 20px 60px rgba(0, 0, 0, 0.3));
  border: 1px solid var(--border-light, #e5e7eb);
}

.cd-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  font-size: 0.85rem;
}

.cd-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cd-search-input {
  width: 240px;
  max-width: 48vw;
}

.cd-hint {
  color: var(--text-secondary, #6b7280);
}

.cd-stat {
  color: var(--text-primary, #111827);
}

.cd-tools {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cd-map {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

/* Panneau de filtres (parcelles officielles) */
.cd-filters {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  background: var(--surface-muted, #f9fafb);
}

.cd-filters.is-collapsed {
  display: none;
}

.cd-filter-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 14px;
}

/* Groupes de filtres par pays : display:contents → les champs restent dans la grille flex ;
   masquables selon la couche active (Belgique / France). */
.cd-filter-grp {
  display: contents;
}

.cd-filter-grp.is-hidden {
  display: none;
}

.cd-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary, #6b7280);
}

.cd-field input {
  width: 7rem;
  font-weight: 400;
  text-transform: none;
}

.cd-field--narrow input {
  width: 4.5rem;
}

.cd-field--surface input {
  width: 8rem;
}

/* Surface en ha + ares : deux petits champs côte à côte sous un même label. */
.cd-haa {
  display: inline-flex;
  gap: 4px;
}

.cd-field--surface .cd-haa-in {
  width: 4.5rem;
}

/* Masquer les flèches des input number ha/ares → plus de place pour les chiffres saisis. */
.cd-haa-in {
  -moz-appearance: textfield;
  appearance: textfield;
}

.cd-haa-in::-webkit-outer-spin-button,
.cd-haa-in::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cd-filter-clear {
  align-self: flex-end;
}

/* Bouton « Montants » actif (état pressé). */
.cd-tools .btn[aria-pressed="true"] {
  background: var(--primary-color, #3da5d9);
  color: #fff;
}

/* Étiquette de montant DVF au centre d'une parcelle (tooltip Leaflet permanent). */
.leaflet-tooltip.cd-amount-label {
  background: rgba(29, 78, 216, 0.9);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.leaflet-tooltip.cd-amount-label::before {
  display: none; /* pas de flèche */
}

/* ─── Mode « saisie en masse » (multisélection) ──────────────────────────────── */

/* Plein écran en mode masse : maximise la place pour le tableau (sans marge). */
#cadastreDrawModal.cd-mass .cd-card {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border: none;
  border-radius: 0;
}

/* Header (titre + croix) masqué en mode masse pour gagner de la hauteur. La fermeture
   se fait par le bouton « Fermer » du pied de page (#cdMassClose). */
#cadastreDrawModal.cd-mass .modal-header {
  display: none;
}

/* Carte redimensionnable : grande (sélection) ↔ réduite (lecture du tableau). */
#cadastreDrawModal.cd-mass .cd-map {
  flex: 0 0 auto;
  height: 55vh;
  transition: height 0.25s ease;
}

#cadastreDrawModal.cd-mass.cd-map-reduced .cd-map {
  height: 132px;
}

/* Tracé manuel sans objet en masse → on masque ses boutons. */
#cadastreDrawModal.cd-mass #cdUndo,
#cadastreDrawModal.cd-mass #cdClear {
  display: none;
}

/* Bandeau de sélection (compteur + actions). */
.cd-mass-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
  background: var(--surface-muted, #f9fafb);
  font-size: 0.85rem;
}

.cd-mass-sel {
  color: var(--text-secondary, #6b7280);
}

.cd-mass-sel strong {
  color: var(--text-primary, #111827);
}

.cd-mass-bar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* Mode « sélection rectangle » : curseur de visée + bouton à l'état actif. */
.cd-rect-cursor,
.cd-rect-cursor .leaflet-grab,
.cd-rect-cursor .leaflet-interactive {
  cursor: crosshair !important;
}

.cd-mass-rectbtn[aria-pressed="true"] {
  background: var(--primary-color, #3da5d9);
  color: #fff;
}

/* Slot où cadastre-mass.js (Lot B) monte le tableau lignes/groupes. */
.cd-mass-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--border-light, #e5e7eb);
}

.cd-mass-save-slot {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Étiquette section/n° au centre d'une parcelle sélectionnée (tooltip permanent). */
.leaflet-tooltip.cd-mass-label {
  background: rgba(21, 128, 61, 0.92);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.leaflet-tooltip.cd-mass-label::before {
  display: none; /* pas de flèche */
}

/* Étiquette d'une parcelle préchargée depuis un document (ambre — distinct de la sélection). */
.leaflet-tooltip.cd-preload-label {
  background: rgba(180, 83, 9, 0.92);
}

/* Overlay de dépôt de documents (visible uniquement pendant le glisser sur la carte). */
.cd-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 1999; /* au-dessus de Leaflet, juste sous le loader (2000) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(180, 83, 9, 0.12);
  border: 3px dashed #b45309;
  border-radius: inherit;
  pointer-events: none; /* le drop est capté par la modale, pas par l'overlay */
}

.cd-drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 28px;
  background: var(--card-background, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  color: #b45309;
  font-weight: 600;
  text-align: center;
}

.cd-drop-overlay-inner i {
  font-size: 32px;
}

/* Loader bloquant pendant l'analyse des documents (couvre carte + tableau, opaque). */
.cd-mass-loader {
  position: absolute;
  inset: 0;
  z-index: 2000; /* au-dessus des panes/contrôles Leaflet (~1000), sinon la carte le masque */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-background, #fff);
}

.cd-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 280px;
  max-width: 80vw;
  text-align: center;
}

.cd-loader-inner > i {
  font-size: 34px;
  color: var(--primary-color, #3da5d9);
}

.cd-loader-label {
  font-size: 0.9rem;
  color: var(--text-primary, #111827);
}

.cd-loader-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-light, #e5e7eb);
  overflow: hidden;
}

.cd-loader-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: var(--primary-color, #3da5d9);
  transition: width 0.3s ease;
}

.cd-loader-count {
  font-size: 0.78rem;
  color: var(--text-secondary, #6b7280);
}
