/* rb_parcours_v1 — styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  background: #1a1a2e;
  color: #e0e0e0;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Toolbar ── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  height: 48px;
  flex-shrink: 0;
  z-index: 1000;
}
.toolbar-title {
  font-weight: 700;
  font-size: 16px;
  color: #e94560;
  min-width: 130px;
}
.toolbar-actions { display: flex; gap: 6px; }
.tool-btn {
  padding: 5px 12px;
  background: #0f3460;
  border: 1px solid #3388ff;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
  white-space: nowrap;
}
.tool-btn:hover  { background: #1a3a6a; }
.tool-btn.active { background: #e94560; border-color: #e94560; }

/* ── Bouton Mesure (contrôle carte, sous le sélecteur de fond) ──
   Même gabarit que .leaflet-control-layers-toggle en mode touch (44x44,
   rayon 5px, bordure 2px — voir leaflet.css .leaflet-touch .leaflet-control-
   layers), plutôt que .leaflet-bar dont le gabarit varie avec .leaflet-touch
   et ne correspond jamais exactement à celui du bouton fond de carte. */
.rb-mesure-ctrl {
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  border-radius: 5px;
}
#btn-mesure {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  box-sizing: border-box;
  background: #16213e;
  background-clip: padding-box;
  color: #FF4444;
  border: 2px solid rgba(0,0,0,0.2);
  border-radius: 5px;
  text-decoration: none;
}
#btn-mesure svg { width: 26px; height: 26px; }
#btn-mesure:hover  { background-color: #1a3a6a; }
#btn-mesure.active { background-color: #e94560; color: #fff; }

/* ── Boîte info Mesure (même esprit que .distance-info-panel de
   rb_sylren_raceviewer_v1 : petite boîte flottante, header icône + titre +
   texte de guidage, pas de barre pleine largeur). ── */
#mesure-bar {
  position: fixed;
  bottom: 90px;
  right: 10px;
  z-index: 1000;
  min-width: 260px;
  max-width: 320px;
  background: rgba(22,33,62,0.96);
  border: 1px solid #0f3460;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 12px 15px;
}
#mesure-bar .mesure-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  color: #e0e0e0;
}
#mesure-bar .mesure-title svg { width: 16px; height: 16px; flex-shrink: 0; }
#mesure-bar .mesure-hint {
  margin-top: 4px;
  font-size: 12px;
  color: #a0aec0;
}

/* ── Layout principal (panneau gauche + carte) ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* ── Panneau latéral GAUCHE repliable ── */
#panel {
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  transition: width 0.25s ease;
  z-index: 500;
}
#panel.panel-open   { width: 340px; }
#panel.panel-closed { width: 28px; }

#panel-inner {
  flex: 1;
  background: #16213e;
  border-right: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s ease;
  min-width: 0;
}
#panel.panel-closed #panel-inner {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

/* Onglet de repliage (à droite du panneau) */
#panel-toggle {
  width: 28px;
  height: 60px;
  background: #0f3460;
  border: 1px solid #1a3a6a;
  border-left: none;
  border-radius: 0 6px 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #a0aec0;
  flex-shrink: 0;
  align-self: center;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
#panel-toggle:hover { background: #1a3a6a; color: #e0e0e0; }

#panel-header {
  padding: 8px 14px;
  background: #0f3460;
  border-bottom: 1px solid #1a3a6a;
  flex-shrink: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
}

/* Fil d'Ariane */
#panel-breadcrumb {
  font-size: 13px;
  color: #a0aec0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb-link {
  color: #3388ff;
  cursor: pointer;
}
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: #4a5568; }
.breadcrumb-current { color: #e0e0e0; font-weight: 600; }

#panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ── Carte ── */
#map { flex: 1; z-index: 1; }

/* ── Barres de statut ── */
.bar-hidden { display: none !important; }

#robot-bar, #preview-bar, #glace-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: rgba(22,33,62,0.96);
  border-top: 1px solid #0f3460;
  z-index: 1000;
  font-size: 13px;
}
#robot-bar span, #preview-bar span, #glace-bar span { color: #a0aec0; }
.badge { font-weight: 700; }
.badge-hidden { display: none; }
#robot-validated { color: #48bb78 !important; }
#robot-finished  { color: #e94560 !important; }
#robot-bar button, #preview-bar button {
  padding: 4px 10px;
  background: #0f3460;
  border: 1px solid #3388ff;
  border-radius: 3px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 13px;
}

/* ── Curseur lat/lon ── */
.rb-cursor-pos {
  background: rgba(22,33,62,0.92) !important;
  border: 1px solid #0f3460 !important;
  border-radius: 4px !important;
  padding: 5px 12px !important;
  font-family: monospace !important;
  font-size: 13px !important;
  line-height: 1.7 !important;
  pointer-events: none !important;
}
.cursor-ddmm { color: #e0e0e0; }
.cursor-dd   { color: #6b7a99; font-size: 12px; }
.cursor-zoom { color: #48bb78; font-size: 12px; }

/* ── Liste des parcours ── */
.btn-new-parcours {
  width: 100%;
  padding: 9px;
  background: #3388ff;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}
.btn-new-parcours:hover { background: #2266cc; }

.parcours-list { list-style: none; }
.parcours-item {
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
  transition: background 0.1s;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.parcours-item:hover  { background: #0f3460; }
.parcours-item.active { background: #0f3460; border-color: #3388ff; }
.parcours-item-info   { flex: 1; min-width: 0; }
.parcours-item-nom    { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.parcours-item-meta   { display: flex; gap: 10px; margin-top: 3px; }
.parcours-item-date   { font-size: 12px; color: #6b7a99; }
.parcours-item-dist   { font-size: 12px; color: #48bb78; }
.parcours-item-btns   { display: flex; gap: 2px; flex-shrink: 0; }
.parcours-item-btns button {
  background: none; border: none; color: #6b7a99;
  cursor: pointer; font-size: 15px; padding: 2px 4px; border-radius: 3px;
}
.parcours-item-btns button:hover { color: #e0e0e0; background: #1a2e4a; }

/* ── Édition parcours ── */
.parcours-nom-input {
  width: 100%;
  background: #0f3460;
  border: 1px solid #3388ff;
  border-radius: 3px;
  color: #e0e0e0;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.parcours-total-dist {
  font-size: 13px;
  color: #48bb78;
  margin-bottom: 12px;
  padding: 5px 10px;
  background: rgba(72,187,120,0.1);
  border-radius: 3px;
  border-left: 3px solid #48bb78;
}

/* ── Liste WPs ── */
.wp-list { list-style: none; }

.wp-segment-info {
  padding: 3px 8px 3px 36px;
  font-size: 12px;
  color: #6b7a99;
  display: flex;
  align-items: center;
  gap: 4px;
}
.wp-segment-info::before { content: '↓'; color: #3388ff; margin-right: 4px; }

.wp-item {
  border-radius: 4px;
  border: 1px solid transparent;
  margin-bottom: 3px;
  overflow: hidden;
}
.wp-item.selected { border-color: #3388ff; background: rgba(51,136,255,0.08); }

.wp-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.wp-item-header:hover { background: rgba(255,255,255,0.04); }

.wp-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.wp-nom          { flex: 1; font-size: 14px; font-weight: 600; }
.wp-type-badge   { font-size: 11px; padding: 2px 6px; border-radius: 3px; background: #0f3460; color: #a0aec0; }
.wp-visible-icon { font-size: 13px; color: #6b7a99; }
.wp-visible-icon.hidden { opacity: 0.35; }

/* ── Formulaire édition WP ── */
.wp-edit-form {
  padding: 10px 12px;
  border-top: 1px solid #0f3460;
  background: rgba(0,0,0,0.15);
}
.wp-edit-form label {
  display: block;
  color: #6b7a99;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
  margin-bottom: 3px;
}
.wp-edit-form label:first-child { margin-top: 0; }
.wp-edit-form input,
.wp-edit-form select {
  width: 100%;
  padding: 5px 8px;
  background: #0f3460;
  border: 1px solid #1a3a6a;
  border-radius: 3px;
  color: #e0e0e0;
  font-size: 13px;
}
.wp-edit-form input:focus,
.wp-edit-form select:focus { outline: none; border-color: #3388ff; }

/* ── Widget de saisie coordonnées (partagé parcours/bibliothèque) ── */
.coord-input-group { margin-top: 8px; }
.coord-input-group:first-child { margin-top: 0; }
.coord-input-label {
  color: #6b7a99; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 3px;
}
.coord-input-row { display: flex; align-items: center; gap: 4px; }
.coord-input-row input[type="number"] { width: 46px; flex: none; }
.coord-input-row .coord-mask-min {
  width: 64px; flex: none; font-family: 'Courier New', monospace; letter-spacing: 0.5px;
}
.coord-input-row select { width: 52px; flex: none; }

.coord-popup { font-size: 12px; }
.coord-popup .coord-input-label { color: #6b7a99; }
.coord-popup .coord-input-row input,
.coord-popup .coord-input-row select {
  padding: 3px 4px; font-size: 12px; border-radius: 3px;
  border: 1px solid #ccc; background: #fff; color: #222;
}

.wp-edit-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-save {
  flex: 1; padding: 6px; background: #3388ff;
  border: none; border-radius: 3px; color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-save:hover   { background: #2266cc; }
.btn-delete {
  padding: 6px 10px; background: #e94560;
  border: none; border-radius: 3px; color: #fff;
  font-size: 13px; cursor: pointer;
}
.btn-delete:hover { background: #c0392b; }
.btn-cancel {
  padding: 6px 10px; background: none; border: 1px solid #6b7a99;
  border-radius: 3px; color: #6b7a99; font-size: 13px; cursor: pointer;
}
.btn-cancel:hover { border-color: #e0e0e0; color: #e0e0e0; }

/* ── Pied de panneau ── */
.panel-footer {
  padding: 10px 12px;
  border-top: 1px solid #0f3460;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.panel-footer button {
  flex: 1; padding: 6px 10px;
  background: #0f3460; border: 1px solid #1a3a6a;
  border-radius: 3px; color: #e0e0e0;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.panel-footer button:hover { background: #1a3a6a; }
.panel-footer .btn-danger  { border-color: #e94560; }
.panel-footer .btn-danger:hover { background: #e94560; }

/* ── Leaflet overrides ── */
.leaflet-popup-content-wrapper {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border: 1px solid #0f3460 !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip { background: #16213e !important; }
.leaflet-popup-close-button { color: #a0aec0 !important; }
.leaflet-control-zoom a {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
}
.leaflet-control-layers {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border: 1px solid #0f3460 !important;
  font-size: 14px !important;
}
.leaflet-control-layers label { color: #e0e0e0 !important; font-size: 14px !important; }
.leaflet-control-attribution {
  background: rgba(22,33,62,0.7) !important;
  color: #6b7a99 !important;
  font-size: 12px !important;
}

/* ── Tooltip aperçu raceviewer ── */
.preview-tooltip .leaflet-tooltip {
  background: rgba(22,33,62,0.95) !important;
  border: 1px solid #FF6B00 !important;
  border-radius: 6px !important;
  color: #e0e0e0 !important;
  padding: 6px 10px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
}
.preview-tooltip .leaflet-tooltip-top::before {
  border-top-color: #FF6B00 !important;
}

/* ── Tooltip DTF du robot de test ── */
.robot-dtf-tooltip {
  background: rgba(22,33,62,0.95) !important;
  border: 1px solid #e94560 !important;
  border-radius: 6px !important;
  color: #e0e0e0 !important;
  font-weight: 700 !important;
  padding: 4px 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5) !important;
}
.robot-dtf-tooltip::before {
  border-right-color: #e94560 !important;
}

/* ── Mode aperçu : cache les layers d'édition, garde la biblio visible ── */
.preview-mode .leaflet-marker-pane,
.preview-mode .leaflet-overlay-pane {
  display: none !important;
}
.preview-mode .leaflet-preview-pane,
.preview-mode .leaflet-biblioGeomPane-pane,
.preview-mode .leaflet-biblioLabelPane-pane {
  display: block !important;
}

/* ── Boîtes d'aide contextuelles ── */
.rb-help-box {
  position: fixed;
  top: 80px;
  left: 340px;
  width: 340px;
  background: #16213e;
  border: 1px solid #3388ff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  z-index: 9000;
  color: #e0e0e0;
  font-size: 13px;
  user-select: none;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #0f3460;
  border-radius: 8px 8px 0 0;
  cursor: move;
}

.help-title {
  font-weight: 700;
  color: #3388ff;
  font-size: 14px;
}

.help-close {
  background: none;
  border: none;
  color: #a0aec0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}
.help-close:hover { color: #e94560; }

.help-body {
  padding: 14px 16px;
  line-height: 1.7;
}

.help-steps {
  padding-left: 18px;
  margin: 0;
}

.help-steps li {
  margin-bottom: 10px;
}

.help-steps li b {
  color: #48bb78;
}

.help-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #0f3460;
  font-size: 11px;
  color: #6b7a99;
  text-align: center;
  line-height: 1.5;
}

/* ── Étiquette fixe (objets bibliothèque) ── */
.biblio-label {
  background: rgba(22, 33, 62, 0.92);
  color: #e0e0e0;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #3388ff;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}
.biblio-label-handle {
  background: #16213e;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #3388ff;
  font-size: 11px;
  white-space: nowrap;
  cursor: move;
}

.biblio-label-handle-dot {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: move;
}