/* ====================================================================
   Mapa sítě MHD – layout a komponenty (doplněk k css/css.css)
   ==================================================================== */

.mapa-layout {
  display: flex;
  align-items: stretch;
  height: calc(100vh - 220px);
  min-height: 460px;
  max-width: 1400px;
  margin: 14px auto;
  padding: 0 10px;
  gap: 10px;
  box-sizing: border-box;
}

#mapa {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
  background: #e9eef2;
}

/* ── boční panel ─────────────────────────────────────────────────── */
#mapa-sidebar {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
  overflow: hidden;
  font-size: 14px;
}

.ms-search { padding: 10px; border-bottom: 1px solid #e3e7eb; }
.ms-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid #cfd6dd;
  border-radius: 5px;
  font-size: 14px;
}
.ms-search input:focus { outline: none; border-color: #0078c8; box-shadow: 0 0 0 2px rgba(0,120,200,.15); }

.ms-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-bottom: 1px solid #e3e7eb; }
.ms-chip {
  flex: 1 1 auto;
  min-width: 62px;
  padding: 6px 4px;
  border: 1px solid #cfd6dd;
  background: #f5f7f9;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  color: #33414d;
  white-space: nowrap;
}
.ms-chip.is-on { background: #0078c8; border-color: #0078c8; color: #fff; }

/* přepínač Linky / Zastávky */
.ms-modes { display: flex; border-bottom: 1px solid #e3e7eb; }
.ms-mode {
  flex: 1; padding: 11px 8px; border: none; background: #f5f7f9; cursor: pointer;
  font-size: 14px; color: #4a565f; border-bottom: 2px solid transparent;
}
.ms-mode.is-on { background: #fff; color: #1f2a33; font-weight: 700; border-bottom-color: #0078c8; }

/* filtr tram/bus musí jít skrýt v režimu Zastávky (jinak by display:flex přebil [hidden]) */
.ms-toolbar[hidden] { display: none; }

/* položka zastávky v panelu */
.ms-routes li.ms-stop-item { justify-content: space-between; }
.ms-stop-count { flex: 0 0 auto; color: #9aa4ad; font-size: 12px; }

/* seznam linek – #ms-browse musí být flex sloupec s min-height:0, aby ul mohl scrollovat
   (jen když není skrytý – jinak by display:flex přebil [hidden] a detail by se nezvětšil) */
#ms-browse:not([hidden]) { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.ms-routes { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.ms-routes li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-bottom: 1px solid #f0f2f4;
  cursor: pointer;
}
.ms-routes li:hover { background: #f3f8fc; }
.ms-routes li.is-hidden { display: none; }

.ms-badge {
  flex: 0 0 auto;
  min-width: 30px;
  height: 24px;
  padding: 0 6px;
  border-radius: 4px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ms-line-name { color: #4a565f; font-size: 12.5px; line-height: 1.25; }

/* detail (zastávka / linka) */
#ms-detail { padding: 12px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
#ms-detail .ms-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: #0078c8; cursor: pointer;
  font-size: 13px; padding: 0 0 8px;
}
#ms-detail h2 { font-size: 17px; margin: 2px 0 8px; color: #1f2a33; }
#ms-detail .ms-sub { color: #6a767f; font-size: 12.5px; margin: 0 0 10px; }
#ms-detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: #8893a0; margin: 14px 0 6px; }

/* prolink z detailu linky na její stránku s historií/místopisem */
.ms-detaillink {
  display: inline-block; margin: 0 0 12px;
  color: #0078c8; font-size: 13px; text-decoration: none;
}
.ms-detaillink:hover { text-decoration: underline; }

.ms-linechips { display: flex; flex-wrap: wrap; gap: 6px; }
.ms-linechips .ms-badge { cursor: pointer; }

.ms-stoplist { list-style: none; margin: 0; padding: 0; }
.ms-stoplist li {
  position: relative;
  padding: 5px 0 5px 20px;
  color: #2b343c;
  cursor: pointer;
  border-left: 3px solid #ccc;
  margin-left: 6px;
}
.ms-stoplist li:hover { color: #0078c8; }
.ms-stoplist li.ms-stop-noclick { cursor: default; }
.ms-stoplist li.ms-stop-noclick:hover { color: #2b343c; }

/* přepínač směru výpisu zastávek (linky s jednosměrnými zastávkami / závleky) */
.ms-dirswitch { display: flex; gap: 6px; margin: 0 0 8px; flex-wrap: wrap; }
.ms-dirbtn {
  flex: 1 1 0; min-width: 0; padding: 5px 8px; border: 1px solid #cdd6dd;
  background: #fff; color: #5a6b78; border-radius: 4px; cursor: pointer;
  font-size: 12px; line-height: 1.25;
}
.ms-dirbtn.is-on { background: #0078c8; border-color: #0078c8; color: #fff; }
.ms-dir.is-hidden { display: none; }
.ms-badge-link { cursor: pointer; }

/* vozidla na mapě (poloha dle JŘ) – kolečko + šipka ke směru jízdy */
.leaflet-div-icon.ms-veh { background: transparent; border: 0; }
.ms-veh-i { width: 36px; height: 36px; transform-origin: 18px 18px; }
.ms-veh-i svg { display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
/* tooltip vozidla: „linka → cíl" jako reálný ukazatel + aktuální zastávka */
.ms-veh-dest { display: inline-block; padding: 2px 7px; border-radius: 3px; color: #fff; font-weight: 700; text-transform: uppercase; }
.ms-veh-stop { color: #5a6b78; font-size: 12px; }

/* jízdní řád rozkliknutého spoje (zastávky + časy, klikací) */
.ms-tplist { list-style: none; margin: 0; padding: 0; }
.ms-tp { display: flex; gap: 9px; align-items: baseline; padding: 5px 0 5px 12px;
         border-left: 3px solid; cursor: pointer; }
.ms-tp-time { font-weight: 600; min-width: 44px; color: #2b343c; font-variant-numeric: tabular-nums; }
.ms-tp-name { color: #34495e; }
.ms-tp:hover .ms-tp-name { color: #0078c8; }
.ms-tp-past .ms-tp-time, .ms-tp-past .ms-tp-name { color: #9aa6ae; }  /* projetá část – ztlumeně */
.ms-tp-now { background: #eef6ff; border-radius: 0 4px 4px 0; }
.ms-tp-now .ms-tp-time, .ms-tp-now .ms-tp-name { color: #0d3c61; font-weight: 700; }

/* přepínače nad mapou (Vozidla / Barevné linky) */
.ms-toggles {
  background: #fff; padding: 6px 9px; font-size: 13px; color: #2b343c;
  border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: 3px;
}
.ms-toggles label { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
.ms-toggles input { cursor: pointer; }

/* odjezdy v detailu zastávky */
.ms-deplist { list-style: none; margin: 0; padding: 0; }
.ms-dep { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid #eef1f3; }
.ms-dep:first-child { border-top: 0; }
.ms-dep-time { font-weight: 600; color: #2b343c; min-width: 44px; font-variant-numeric: tabular-nums; }
.ms-dep .ms-badge { cursor: default; }
.ms-dep-head { color: #5a6b78; }
.ms-dep-empty { color: #7a858e; font-style: italic; margin: 4px 0 0; }

/* zaniklé / přejmenované zastávky (historie) – kurzívou, jako linky mimo provoz */
.ms-stoplist li.ms-stop-hist { font-style: italic; }
.ms-routes li.ms-stop-hist .ms-line-name { font-style: italic; color: #7a858e; }
.ms-sub.ms-stop-hist { font-style: italic; color: #7a858e; }
.ms-stoplist li::before {
  content: ""; position: absolute; left: -7px; top: 11px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 3px solid #999;
}

.ms-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 4px 8px; padding: 8px 10px; border-top: 1px solid #e3e7eb;
  font-size: 11.5px; color: #7a858e;
}
.ms-foot a { color: #0078c8; }
.ms-note { flex: 1 1 100%; line-height: 1.35; }   /* poznámka o polohách vozidel – na celý řádek */

/* stavová hláška uprostřed mapy */
.ms-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; color: #5a6670; font-size: 15px; padding: 20px; z-index: 500;
}

/* popisek linek u zastávky v Leaflet popupu */
.leaflet-popup-content .ms-badge { margin: 1px 3px 1px 0; cursor: pointer; }
.leaflet-popup-content b { display: block; margin-bottom: 4px; }

/* hlavička nad mapou – aby se jazykový dropdown nezobrazoval pod Leaflet mapou
   (jen hlavička; patička .paticka-wrap si z-index nebere) */
.mapa-body .roztahovak-modry:not(.paticka-wrap) { position: relative; z-index: 1000; }

/* legenda kategorií linek pod mapou */
.mapa-legenda {
  max-width: 1400px; margin: 0 auto 14px; padding: 6px 12px 12px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  font-size: 13px; color: #4a565f;
}
.mapa-legenda .ml-title { font-weight: 700; color: #33414d; }
.mapa-legenda .ml-item { display: inline-flex; align-items: center; gap: 7px; }
.mapa-legenda .ml-swatch { width: 18px; height: 4px; border-radius: 2px; flex: 0 0 auto; }

/* linky mimo provoz (legacy) – přibližná trasa po zastávkách */
.ms-routes li.ms-legacy .ms-badge { opacity: .8; }
.ms-routes li.ms-legacy .ms-line-name { font-style: italic; color: #7a858e; }
#ms-detail .ms-legacy-note {
  background: #fdf3e6; border: 1px solid #f0d9b5; color: #8a6d3b;
  padding: 6px 9px; border-radius: 4px; font-size: 12px; margin: 2px 0 10px;
}

/* ── responsivita ────────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* panel zůstává vlevo od mapy (side-by-side), jen užší, ať se vejde */
  .mapa-layout { height: calc(100vh - 150px); min-height: 400px; gap: 6px; padding: 0 6px; }
  #mapa-sidebar { flex: 0 0 44%; max-width: 240px; font-size: 13px; }
}
