:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --sidebar-w: 400px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app { display: flex; height: 100vh; width: 100vw; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1e293b, #0b3b52);
}
#sidebar-header h1 { font-size: 18px; margin: 0 0 2px; letter-spacing: .3px; }
#sidebar-header .sub { font-size: 12px; color: var(--muted); }

.day-tabs { display: flex; gap: 4px; padding: 10px 12px 0; flex-wrap: wrap; }
.day-tab {
  flex: 1 1 auto;
  padding: 8px 6px;
  font-size: 12px;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  color: var(--muted);
  transition: .15s;
}
.day-tab .d-label { font-weight: 700; display: block; color: var(--text); }
.day-tab.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.day-tab.active .d-label { color: #fff; }
.day-tab:hover:not(.active) { background: #31425c; }

#day-body { flex: 1; overflow-y: auto; padding: 12px; }
#day-body::-webkit-scrollbar { width: 8px; }
#day-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.day-meta {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.day-meta h2 { margin: 0 0 4px; font-size: 14px; }
.day-meta .anchor { color: var(--muted); }
.day-meta .note { margin-top: 6px; color: #cbd5e1; line-height: 1.4; }
.badge-pass {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: #7c3aed; color: #fff; padding: 2px 6px; border-radius: 999px; margin-left: 6px;
}
.badge-off { background: #475569; }

.variant-row { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.variant-btn {
  font-size: 11.5px; padding: 6px 9px; border-radius: 8px; cursor: pointer;
  background: #0b3b52; color: var(--accent); border: 1px solid #0e5673;
}
.variant-btn:hover { background: #0e4d6b; }

/* ---------- Itinerary list ---------- */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 12px 0 6px; }

.stop {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  position: relative;
}
.stop.done { opacity: .6; }
.stop.done .stop-name { text-decoration: line-through; }
.stop.overtime { border-left-color: var(--bad); }
.stop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.stop-name { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.stop-times { font-size: 11.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.stop-times .travel { color: var(--accent); }
.stop-times .warn { color: var(--bad); font-weight: 700; }
.stop-tags { margin-top: 5px; display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: #33415580; color: #cbd5e1; }
.tag.pass { background: #7c3aed; color: #fff; }
.tag.book { background: #92400e; color: #fde68a; }
.stop-actions { display: flex; gap: 4px; margin-top: 7px; }
.mini-btn {
  font-size: 11px; padding: 3px 7px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: #1b2536; color: var(--text);
}
.mini-btn:hover { background: #2a3852; }
.mini-btn.ok { border-color: #166534; color: #86efac; }
.mini-btn.del { border-color: #7f1d1d; color: #fca5a5; }

.stop-links { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.mini-link { font-size: 11px; color: var(--accent); text-decoration: none; padding: 2px 4px; }
.mini-link:hover { text-decoration: underline; }

.empty-hint { color: var(--muted); font-size: 12.5px; text-align: center; padding: 18px 8px; line-height: 1.5; }

/* Day summary bar */
.summary {
  position: sticky; bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 12.5px;
}
.summary .row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.summary .big { font-size: 13px; font-weight: 700; }
.summary .ok { color: var(--ok); }
.summary .bad { color: var(--bad); }
.suggest-btn {
  width: 100%; margin-top: 8px; padding: 9px; border-radius: 8px; cursor: pointer;
  background: var(--accent-2); color: #fff; border: none; font-weight: 700; font-size: 13px;
}
.suggest-btn:hover { background: var(--accent); }
.gmaps-route-btn {
  display: block; width: 100%; margin-top: 7px; padding: 9px; border-radius: 8px;
  text-align: center; text-decoration: none; font-weight: 700; font-size: 13px;
  background: #14532d; color: #bbf7d0; border: 1px solid #166534;
}
.gmaps-route-btn:hover { background: #166534; color: #fff; }

/* ---------- Map ---------- */
#map { flex: 1; height: 100%; }

/* Map controls overlay */
#map-controls {
  position: absolute; top: 10px; right: 10px; z-index: 900;
  background: rgba(30,41,59,.95); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; max-width: 220px;
  backdrop-filter: blur(4px);
}
#map-controls h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.filter-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; cursor: pointer; }
.filter-row input { accent-color: var(--accent); }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.route-line-legend { width: 16px; height: 3px; display: inline-block; border-radius: 2px; }

/* Leaflet marker pin */
.pin {
  width: 22px; height: 22px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.pin b { transform: rotate(45deg); font-size: 10px; color: #fff; font-weight: 800; }
.pin.in-plan { box-shadow: 0 0 0 3px var(--accent), 0 1px 4px rgba(0,0,0,.5); }

/* Popup */
.leaflet-popup-content { margin: 10px 12px; font-size: 12.5px; line-height: 1.4; }
.popup-title { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; color: #0f172a; }
.popup-meta { color: #475569; font-size: 11.5px; margin-bottom: 5px; }
.popup-desc { color: #1e293b; margin-bottom: 7px; }
.popup-book { color: #b45309; font-size: 11.5px; margin-bottom: 7px; font-weight: 600; }
.popup-links { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.popup-links a { font-size: 12px; color: #0369a1; font-weight: 600; text-decoration: none; }
.popup-links a:hover { text-decoration: underline; }
.popup-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.popup-btn { font-size: 11px; padding: 4px 8px; border-radius: 6px; cursor: pointer; border: none; background: var(--accent-2); color: #fff; }
.popup-btn.sec { background: #64748b; }

/* Suggestions modal */
#suggest-modal {
  position: absolute; inset: 0; z-index: 1200; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,.5);
}
#suggest-modal.open { display: flex; }
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(520px, 92vw); max-height: 80vh; overflow-y: auto; padding: 16px 18px;
}
.modal-card h2 { margin: 0 0 4px; font-size: 16px; }
.modal-card .subtitle { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.sugg {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px; margin-bottom: 8px;
}
.sugg .info { font-size: 12.5px; }
.sugg .info .n { font-weight: 700; }
.sugg .info .m { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.sugg .fit { font-size: 11px; color: var(--ok); }
.modal-close { float: right; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }

/* Mobile */
#mobile-toggle, #filter-toggle { display: none; }
@media (max-width: 820px) {
  :root { --sidebar-w: 100vw; }
  #app { flex-direction: column; }
  #sidebar { position: absolute; z-index: 1000; height: 100%; transition: transform .25s; box-shadow: 0 0 30px rgba(0,0,0,.5); }
  #sidebar.collapsed { transform: translateX(-100%); }
  #map { height: 100vh; }

  #mobile-toggle {
    display: block; position: absolute; top: 10px; left: 10px; z-index: 1100;
    background: var(--accent-2); color: #fff; border: none; border-radius: 10px;
    padding: 11px 15px; font-weight: 700; font-size: 15px; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
  }
  #filter-toggle {
    display: block; position: absolute; top: 10px; right: 10px; z-index: 1100;
    background: rgba(30,41,59,.96); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 14px; font-weight: 700; font-size: 15px; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
  }
  /* Panel filtrů na mobilu skrytý, dokud ho uživatel nerozbalí */
  #map-controls { display: none; top: 58px; right: 10px; max-width: 260px; max-height: 70vh; overflow-y: auto; }
  #map-controls.show { display: block; }

  /* Větší dotykové cíle */
  .mini-btn { padding: 6px 10px; font-size: 12.5px; }
  .mini-link { padding: 5px 6px; font-size: 12.5px; }
  .day-tab { padding: 10px 6px; }
  .stop-links a, .popup-links a { padding: 4px 2px; }
  .leaflet-popup-content { font-size: 13.5px; }
  .popup-links a { font-size: 14px; }
}
/* Na desktopu je panel filtrů vždy vidět */
@media (min-width: 821px) { #map-controls { display: block !important; } }
