/* Bottom info / route builder panel */
.info-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0px;
  display: grid;
  justify-content: center;
  z-index: 1100;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.info-content {
  width: min(100dvw, 600px);
  background: var(--card);
  border: 1px solid var(--border);
  /* 16px en haut, 0 en bas */
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
  padding: 12px; /* reduce top padding since close is inline now */
  pointer-events: auto;
  position: relative;
}

/* Width modes driven by JS via classes on the panel */
.info-panel.mode-info .info-content { width: min(100dvw, 600px); }
.info-panel.mode-steps .info-content { width: min(100dvw, 900px); }
.info-panel.mode-steps-elev .info-content { width: min(100dvw, 1600px); }

/* In route modes, never display the info details block */
.info-panel.mode-steps .info-details, 
.info-panel.mode-steps-elev .info-details { display: none !important; }

.icon-close {
  position: static; /* inline in actions */
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: grid;
  place-items: center;
  margin-left: 4px;
}
.icon-close:hover { filter: brightness(1.05); }

.info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;}
.info-title { font-weight: 700; }
.info-details { color: var(--muted); font-size: 14px; margin-top: 4px; }
/* Ensure details area can contain a row with an icon on the left */
.info-details .knpt-row { display: flex; align-items: flex-start; gap: 6px; }
.info-details .knpt-row .knpt-text { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.info-actions { display: flex; gap: 8px; align-items: center; }
.route-builder { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.route-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.route-row .label { width: 28px; color: var(--muted); display: grid; place-items: center; }
.route-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  width: 100%;
}
/* Removed .route-options grid + #btp-detour-range since detour slider is dropped */

/* Hidden state handled with [aria-hidden] for a11y */
.info-panel[aria-hidden="true"] { display: none; }

/* Always respect [hidden], even if other rules set display */
[hidden] { display: none !important; }

/* Inline knpt badge for titles and chips (match map knpt style) */
.knpt-badge {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #018752;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  vertical-align: middle;
  margin-right: 4px; /* slightly increased spacing */
  position: relative;
}
.knpt-badge > span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}
/* Ensure badge inner text centers well across browsers when using pt units */
.knpt-badge > span { display:flex; align-items:center; justify-content:center; }

/* Inter-leg chips row */
.inter-steps { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 6px 36px; }
.inter-steps .knpt-badge { margin-right: 0; }

/* Removed obsolete .route-summary and btp-route-summary styles */

/* Start/Finish endpoint markers */
.leaflet-div-icon.route-endpoint {
  background: transparent;
  border: none;
}
.leaflet-div-icon.route-endpoint.start span,
.leaflet-div-icon.route-endpoint.finish span {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border: 2px solid #fff;
}
.leaflet-div-icon.route-endpoint.start span { background: #2e7d32; }
.leaflet-div-icon.route-endpoint.finish span { background: #c62828; }

/* Slight offset so labels don't overlap the vertex exactly */
.leaflet-div-icon.route-endpoint.start span { transform: translate(-10px, -8px); }
.leaflet-div-icon.route-endpoint.finish span { transform: translate(10px, -8px); }

.leg-more { margin: 6px 0 10px 0; }
.leg-more .btn.btn-sm { padding: 6px 10px; font-size: 0.9rem; }
.leg-knpts { list-style: none; margin: 6px 0 0 0; padding: 0; }
.leg-knpts li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed rgba(0,0,0,0.06); }
.leg-knpts li:last-child { border-bottom: none; }
/* Removed duplicate conflicting .knpt-badge rule and unify to 28px green style */
.knpt-text { color:#333; font-size:0.95rem; }

/* New: layout for knpt line with distances */
.knpt-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 2px 0; }
.knpt-line .knpt-badge { flex: 0 0 auto; }
.knpt-line .knpt-dist { flex: 1 1 auto; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Steps container max-height 40vh and scrollable when overflowing */
#btp-steps-wrap { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: start; }
#btp-steps { max-height: 20vh; overflow: auto; }
#btp-elev-toggle.btn.btn-icon { justify-self: start; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); display: grid; place-items: center; }
#btp-elev-toggle.btn.btn-icon:hover { filter: brightness(1.05); }
#btp-elev-toggle.btn.btn-icon[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
#btp-elevation { display: grid; grid-template-rows: 1fr; gap: 8px; max-height: 15vh; overflow: hidden; }
/* Removed #btp-elev-summary specific rule as the summary is no longer present */
#btp-elev-chart { width: 100% !important; height: 100% !important; display: block; }

/* Compact mode: show only the title row and the two right actions (toggle + close) */
.info-panel.compact .info-content { width: max-content; max-width: 96vw; }
.info-panel.compact #btp-route-builder { display: none !important; }
.info-panel.compact #btp-info-details { display: none !important; }
.info-panel.compact .info-actions > *:not(#btp-compact-toggle):not(#btp-close-info) { display: none !important; }

/* Optional: slightly reduce padding in compact for tighter look */
.info-panel.compact .info-content { padding: 8px 10px; }

/* Responsive two-column layout for steps (left) and elevation (right) on wide screens */
@media (min-width: 1000px) {
  #btp-route-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  /* When elevation is hidden, let steps take full width */
  #btp-route-builder.no-elev { grid-template-columns: 1fr; }
  #btp-steps-wrap { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
  #btp-steps { max-height: 20vh; }
  #btp-elevation { max-height: 20vh; height: 100%; }
}

/* Share / Export modal */
#btp-share-modal.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 2000; }
#btp-share-modal.backdrop[aria-hidden="false"] { display: flex; }
#btp-share-modal .sheet { width: min(99dvw, 1200px); max-height: 86vh; overflow: auto; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
#btp-share-modal .sheet header { display:flex; align-items:center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
#btp-share-modal .sheet main { padding: 12px 14px; display: grid; gap: 12px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) {
  #btp-share-modal .sheet main { grid-template-columns: 2fr 1fr; }
}
#btp-share-modal .row { display:flex; flex-wrap:wrap; gap: 10px; align-items:center; }
#btp-share-modal .options { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
#btp-share-modal .btns { display:flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }
#btp-share-modal .print-zone { border: 1px dashed var(--border); padding: 10px; border-radius: 12px; background: var(--cardAlt, #fff); }
#btp-share-modal .print-hint { color: var(--muted); font-size: 13px; margin: -4px 0 4px; }
#btp-share-modal .strip { display:flex; align-items:center; gap: 8px; width: 100%; overflow: visible; }
#btp-share-modal .strip .knpt-badge { flex: 0 0 auto; }
#btp-share-modal .meta { color: var(--muted); font-variant-numeric: tabular-nums; }
/* Slightly better label defaults for the strip */
#btp-share-modal .strip .seg-label { color: var(--muted); text-align: center; line-height: 1.15; white-space: normal; }

/* Print: remove app chrome, print only the strip (real scale) */
@media print {
  @page { size: auto; margin: 8mm; }
  body * { visibility: hidden !important; }
  #btp-printable-area, #btp-printable-area * { visibility: visible !important; }
  /* Keep natural cm sizes; do not force full-page */
  #btp-printable-area { position: static !important; margin: 0 auto !important; padding: 0 !important; width: auto; max-width: none; }
  #wrap #left .strip { gap: 8px; }
}

/* Décalage des contrôles Leaflet quand le panneau est ouvert pour limiter le chevauchement */
.info-panel[aria-hidden="false"] ~ .leaflet-control-container .leaflet-bottom.leaflet-right,
.info-panel:not([aria-hidden]) ~ .leaflet-control-container .leaflet-bottom.leaflet-right {
  margin-bottom: 92px; /* hauteur approx. de l’info-panel visible */
}
