/* Search panel (top-left) */
#searchPanel { position:absolute; top:0.375rem; left:0.625rem; z-index:1000; display:flex; gap:0.375rem; align-items:center; }
#searchPanel input[type="search"]{
  width:13.75rem;
  padding:0.3125rem 0.625rem;
  border:0.0625rem solid #ccc;
  border-radius:0.25rem;
  background:#fff;
  box-sizing:border-box;
  margin-top:0.3125rem;
}
#searchPanel button{
  background:#fff;
  border:0.0625rem solid #ccc;
  padding:0.3125rem 0.625rem;
  cursor:pointer;
  box-sizing:border-box;
  border-radius:0.25rem;
}
@media (max-width: 48rem){
  #searchPanel input[type="search"]{ width:66vw; }
}

/* Fenêtres filtrage et ajout spot */
#filterPanel, #addSpotPanel {
  position: absolute;
  top: 3.125rem;
  right: 0.625rem;
  margin-right: 3.75rem;
  z-index: 1000;
  background: white;
  border: 0.0625rem solid #ccc;
  padding:  0.5rem;
  border-radius: 0.3125rem;
  display: none;
  max-width: 18.75rem; /* slightly wider for better layout */
  /* Keep within viewport without growing the page height */
  max-height: calc(100vh - 5rem);
  max-height: calc(100dvh - 5rem);
  /* Allow internal scroll when content grows */
  overflow: auto;
}
#addSpotPanel { padding-bottom: 0.1875rem; }
select, input { width: 100%; margin-bottom: 0.3125rem; }
/* Full width controls inside panels, but exclude the close buttons */
#filterPanel button:not(.panel-close-btn), #addSpotPanel button:not(.panel-close-btn) { width: 100%; }
#filterPanel select, #filterPanel input,
#addSpotPanel select, #addSpotPanel input,
#filterPanel button, #addSpotPanel button { box-sizing: border-box; }

/* Compact panel typography and spacing */
#filterPanel, #addSpotPanel { font-size: 0.8125rem; line-height: 1.25; --panel-control-width: 10.625rem; }
#filterPanel label, #addSpotPanel label { display: flex; align-items: center; gap: 0.375rem; justify-content: space-between; margin: 0.25rem 0; }
/* Slightly larger, consistent vertical spacing in Add Spot form */
#addSpotPanel label { margin: 0.375rem 0; }
/* Tighten spacing for the multiline description block and its neighbors */
#addSpotPanel label.tight-block { margin: 0.0625rem 0 0 0; }
#addSpotPanel label.tight-block + label { margin-top: 0; }
#addSpotPanel label.tight-block.long-description { margin: 0.0625rem 0 0 0; }
#addSpotPanel label.tight-block.long-description + label { margin-top: 0; }
#addSpotPanel #spotSlopeAvgLabel { margin-bottom: 0.125rem; }
/* Fixed width, right-aligned controls (uniform length) */
#filterPanel label > input[type="text"],
#filterPanel label > input[type="number"],
#filterPanel label > input[type="search"],
#filterPanel label > input[type="url"],
#filterPanel label > select,
#filterPanel label > textarea,
#filterPanel label > .field-wrapper,
#addSpotPanel label > input[type="text"],
#addSpotPanel label > input[type="number"],
#addSpotPanel label > input[type="search"],
#addSpotPanel label > input[type="url"],
#addSpotPanel label > select,
#addSpotPanel label > textarea,
#addSpotPanel label > .field-wrapper {
  width: var(--panel-control-width);
  flex: 0 0 var(--panel-control-width);
  margin-left: auto;
  margin-bottom: 0;
}
/* Left-align selected text inside selects  */
#filterPanel select, #addSpotPanel select { text-align-last: left; }
/* Wrapper for textarea with bottom-right counter */
.field-wrapper { position: relative; }
.field-wrapper > textarea { width: 100%; box-sizing: border-box; padding-right: 2.25rem; }
.char-counter { position: absolute; right: 0.625rem; bottom: 0.5rem; font-size: 0.75rem; color: var(--rms-text-muted); pointer-events: none; }
.char-counter.limit-reached { color: #dc2626; }
/* Keep checkboxes natural size/alignment */
#filterPanel label > input[type="checkbox"],
#addSpotPanel label > input[type="checkbox"] { flex: 0 0 auto; width: auto; margin: 0; }
/* Tighter controls in panels */
#filterPanel input, #filterPanel select, #filterPanel textarea,
#addSpotPanel input, #addSpotPanel select, #addSpotPanel textarea { padding: 0.375rem 0.5rem; }
#filterPanel button:not(.panel-close-btn),
#addSpotPanel button:not(.panel-close-btn) { padding: 0.375rem 0.625rem; }

/* Make the two drawing buttons sit side-by-side and compact */
#addSpotPanel #drawLineBtn,
#addSpotPanel #clearLineBtn { padding: 0.375rem 0.5rem; }
/* Keep draw row tight even when category changes */
#addSpotPanel .draw-line-row {
  display: flex;
  gap: 0.5rem;
  row-gap: 0.125rem;
  flex-wrap: wrap;
  margin: 0.125rem 0 0;
  align-items: center;
}
#addSpotPanel .draw-line-row label {
  flex: 1 0 100%;
  order: 2;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
/* Reduce padding inside range groups that have inline style */
#filterPanel label > div, #addSpotPanel label > div { padding: 0.25rem 0 !important; }
/* Range groups: keep full width under their titles */
#filterPanel label.range-group { display: block; }
#filterPanel label.range-group .dual-range { width: 100%; }
#penteRange, #longueurRange { width: 100%; }
/* Min/max value row aligned exactly to ends */
#penteRange + div, #longueurRange + div { margin: 0 !important; padding: 0 !important; width: 100%; display: flex; justify-content: space-between; }

/* Add Spot panel: make send button same width as inputs and let reset fill remaining space */
#addSpotPanel .panel-actions { display: flex; gap: 0.5rem; align-items: center; }
#addSpotPanel #spotSendBtn { width: var(--panel-control-width); flex: 0 0 var(--panel-control-width); }
#addSpotPanel #spotResetBtn { width: auto; flex: 1 1 0; }
#addSpotPanel #spotSendStatus {
  display: none;
  min-height: 1rem;
  font-size: 0.75rem;
  color: #0ea5e9;
  text-align: right;
  margin: 0.375rem 0;
}

/* Align draw buttons like Reset/Send: right fixed width, left flexible; keep inner spacing */
#addSpotPanel #drawLineBtn { width: var(--panel-control-width); flex: 0 0 var(--panel-control-width); margin-left: auto; }
#addSpotPanel #clearLineBtn { width: auto; flex: 1 1 0; }
#addSpotPanel .panel-actions { margin: 0.375rem 0; }

/* Panel headers with titles to avoid overlap with close button */
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.375rem; font-weight: 600; }
.panel-header-title { font-size: 0.875rem; margin: 0; padding: 0; }
#filterPanel .panel-close-btn, #addSpotPanel .panel-close-btn { position: static; top: auto; right: auto; width: 1.375rem; height: 1.375rem; }

/* Action row in filter panel */
#filterPanel .panel-actions { display: flex; gap: 0.375rem; }
#filterPanel .panel-actions button { width: auto !important; flex: 1 1 0; margin-top: 0 !important; }

/* Filtres simples couleur */
#filters {
  position: absolute;
  top: 3.125rem;
  left: 0.625rem;
  z-index: 1000;
  background: white;
  border: 0.0625rem solid #ccc;
  padding: 0.3125rem 0.625rem;
}

/* Style de base pour les croix */
.panel-close-btn {
    position: absolute;
    background: none;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0;
    width: 1.5625rem;
    height: 1.5625rem;
    line-height: 1;
    z-index: 10;
    color: #333;
}

.panel-close-btn:hover {
    color: #000;
}

/* Position spécifique pour la croix du panel Filtrer */
#closeFilterPanel {
    top: 0.25rem;
    right: 0.25rem;
}

/* Position spécifique pour la croix du panel Ajouter un spot */
#closeAddSpotPanel {
    top: 0.25rem;
    right: 0.25rem;
}

/* Dual-range slider (two thumbs on one line) */
.dual-range{
  position: relative;
  width: 100%;
  height: 1.375rem;
  box-sizing: border-box;
  padding: 0; /* no horizontal padding; we inset the rails instead */
}
.dual-range .range-base{ position:absolute; left:0.4375rem; right:0.4375rem; top:50%; height:0.25rem; transform:translateY(-50%); background:#e5e7eb; border-radius:0.125rem; z-index:1; }
.dual-range .range-progress{ position:absolute; top:50%; height:0.25rem; transform:translateY(-50%); background:#0ea5e9; border-radius:0.125rem; left:0%; width:0%; z-index:1; }
.dual-range input[type=range]{ position:absolute; left:0.4375rem; top:0; width:calc(100% - 0.875rem); height:1.375rem; margin:0; background:transparent; pointer-events:none; -webkit-appearance:none; appearance:none; z-index:2; }
.dual-range input[type=range]::-webkit-slider-thumb{ -webkit-appearance:none; appearance:none; pointer-events:auto; width:0.875rem; height:0.875rem; border-radius:50%; background:#0ea5e9; border:0.125rem solid #fff; box-shadow:0 0 0 0.0625rem rgba(0,0,0,.1); }
.dual-range input[type=range]::-moz-range-thumb{ pointer-events:auto; width:0.875rem; height:0.875rem; border-radius:50%; background:#0ea5e9; border:0.125rem solid #fff; }
.dual-range input[type=range]::-webkit-slider-runnable-track{ background:transparent; }
.dual-range input[type=range]::-moz-range-track{ background:transparent; }

/* Override search input size: height -1px, mobile width 1/2 */
#searchPanel #searchInput { padding: 0.2813rem 0.625rem; }

/* Hide Leaflet Routing Machine UI (top-right) */
.leaflet-routing-container { display: none !important; }

/* Floating draw status (center-top) */
#drawStatus{
  position: fixed;
  top: 0.625rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  display: none;
  pointer-events: none;
}

/* Status color variants */
#drawStatus.status-ok { background: #2e7d32; color: #fff; }
#drawStatus.status-error { background: #c62828; color: #fff; }
