body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    

}

#map {
    height: 100vh;
    /*width: calc(100% - 20px);
    z-index: 1;
    padding: 10px;
    height: calc(100vh - 200px);
    border-radius: 10px;
    margin: 10px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.65);*/
}

.controls-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    /*background-color: rgba(255, 255, 255, 0.5);*/
}

.stats-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
background-color: #f8f9fa;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.65);
}


.stat-box {
    text-align: center;
    flex: 1;
    
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #666;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.stat-unit {
    font-size: 12px;
    color: #666;
}

.btn-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.btn-control {
    flex: 1 1 45%;
    min-width: 100px;
    padding: 12px 5px;
    font-size: 16px;
    margin: 2px;
}

.btn-lg {
    padding: 0.5rem;
    font-size: 0.8rem;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.65);
}

.basemap-selector {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    width: 150px;
}

.form-select {
    font-size: 14px;
}

/* Modal styles */
.modal-content {
    border-radius: 10px;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .btn-control {
        flex: 1 1 100%;
    }
    
    .stat-value {
        font-size: 16px;
    }
    
    .basemap-selector {
        width: 120px;
    }
}

/* Route line style */
.leaflet-interactive {
    stroke: #3388ff;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.start-marker, .end-marker {
    background: none;
    border: none;
    text-align: center;
    font-size: 20px;
    line-height: 1;
}

        .speed-circle {
            position: absolute;
            top: -30px;
            left: calc(50% - 50px);
            background: rgba(255, 255, 255);
            border-radius: 50%;
            width: 100px;
            height: 100px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            z-index: 1000;
            box-shadow: 0 3px 5px rgba(0, 0, 0, 0.65);
            border: 10px solid red;
        }

        #speed {
            font-size: 50px;
            line-height: 1;
        }

        #stat-unit {
            font-size: 10px;
            line-height: 1;
            margin-top: 5px;
        }

.leaflet-control-locate-location-arrow {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin: 7px;
    background-image: url( '/minimap10/assets/arrow.svg' );
}


/* === PWA / Mobile polish (appended 2025-10-22) === */
:root {
  --app-accent: #0a84ff;
  --app-bg: #0b0b0c;
  --app-fg: #f5f7fb;
  --app-muted: #9aa3b2;
  --control-height: 64px;
}

@supports (height: 100svh) {
  #map { height: calc(100svh - var(--control-height)); }
}
@supports not (height: 100svh) {
  #map { height: calc((var(--vh, 1vh) * 100) - var(--control-height)); }
}

body {
  background: var(--app-bg);
  color: var(--app-fg);
  accent-color: var(--app-accent);
  -webkit-tap-highlight-color: transparent;
}

a, .btn-link { color: var(--app-accent); }

/* Touch sizes for buttons */
.btn, .btn-sm, .btn-lg {
  min-height: 44px;
  border-radius: 12px;
}

/* Sticky bottom control bar (if you wrap your controls in .control-bar) */
.control-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px max(env(safe-area-inset-right),12px) max(env(safe-area-inset-bottom),8px) max(env(safe-area-inset-left),12px);
  background: rgba(16, 18, 24, 0.85);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  z-index: 999;
  border-top: 1px solid #1c2333;
}

/* Floating install button */
.install-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: none;
  background: var(--app-accent);
  color: white;
  box-shadow: 0 10px 24px rgba(10,132,255,0.35);
  z-index: 1000;
}
.install-fab:active { transform: translateY(1px) scale(0.98); }

/* Map control placement tweaks for small screens */
.leaflet-top.leaflet-left {
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
}
.leaflet-top.leaflet-right {
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
}
.leaflet-bottom.leaflet-right, .leaflet-bottom.leaflet-left {
  bottom: calc(var(--control-height) + max(6px, env(safe-area-inset-bottom)));
}

/* Better map marker popups on mobile */
.leaflet-popup-content-wrapper {
  border-radius: 14px;
}
.leaflet-popup-content {
  margin: 10px 12px;
  font-size: clamp(14px, 1.8vw, 16px);
  color: var(--app-fg);
}
.leaflet-container a.leaflet-popup-close-button {
  color: var(--app-fg);
  font-size: 20px;
  margin: 6px 8px 0 0;
}

/* Utility: hide on small screens */
@media (max-width: 480px) {
  .hide-xs { display: none !important; }
}

/* === Bottom control bar refinements (2025-10-22) === */
.control-bar .chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.control-bar .form-select {
  min-width: 140px;
  height: 40px;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
  color: var(--app-fg);
  border-color: #2a3348;
}
/* Hide legacy inline controls while keeping them functional */
/* removed legacy control hiding */

/* Theme system */
:root {
  --bg: #0b0b0c;
  --fg: #f5f7fb;
  --muted: #9aa3b2;
  --surface: #12141a;
  --border: #1c2333;
  --accent: #0a84ff;
}
:root, [data-theme="dark"] {
  --app-bg: var(--bg);
  --app-fg: var(--fg);
  --app-accent: var(--accent);
}
[data-theme="light"] {
  --app-bg: #ffffff;
  --app-fg: #0b1220;
  --app-accent: #0a84ff;
  --surface: #f5f7fb;
  --border: #dce2f0;
  --muted: #5b667a;
}
body { background: var(--app-bg); color: var(--app-fg); }

/* Better button contrast in light mode */
[data-theme="light"] .control-bar {
  background: rgba(255,255,255,0.92);
  border-top: 1px solid var(--border);
}
[data-theme="light"] .control-bar .chip {
  background: #fff;
  border-color: var(--border);
}

/* Improve icon alignment */
.bi { vertical-align: -0.125em; }

/* === Bottom Control Bar v2 (2025-10-22) === */
:root { --bar-h: 88px; } /* default; will be measured in JS */
#map {
  height: calc(100svh - var(--bar-h, 88px));
}
@supports not (height: 100svh) {
  #map { height: calc((var(--vh, 1vh) * 100) - var(--bar-h, 88px)); }
}
.control-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: rgba(16, 18, 24, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border, #1c2333);
  padding:
    8px max(env(safe-area-inset-right), 12px)
    max(env(safe-area-inset-bottom), 8px)
    max(env(safe-area-inset-left), 12px);
  display: grid;
  grid-template-columns: 1fr minmax(140px, 1fr) 1fr;
  gap: 10px;
}

[data-theme="light"] .control-bar {
  background: rgba(255,255,255,0.95);
}

.control-bar .cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0; /* allow shrinking */
}
.scrollrow {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.control-bar .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: nowrap;
}
.control-bar .btn .lbl { font-weight: 600; }

.control-bar .form-select {
  min-width: 140px;
  height: 40px;
  border-radius: 10px;
}

/* Chips */
.control-bar .chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  white-space: nowrap;
}
[data-theme="light"] .control-bar .chip {
  background: #ffffff;
  border-color: var(--border, #dce2f0);
}

/* Leaflet bottom controls offset from bar */
.leaflet-bottom.leaflet-right, .leaflet-bottom.leaflet-left {
  bottom: calc(var(--bar-h, 88px) + max(6px, env(safe-area-inset-bottom)));
}

/* Narrow phones: stack chips under actions; tools to the right */
@media (max-width: 480px) {
  .control-bar {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
  }
  .control-bar .actions { grid-column: 1 / -1; }
  .control-bar .stats { grid-column: 1 / -1; }
  .control-bar .tools { grid-column: 1 / -1; justify-content: flex-start; }
  .control-bar .btn .lbl { display: none; } /* icons only on very tight screens */
}

/* Hide legacy inline controls visually (keep for logic) */
/* removed legacy control hiding */

/* === Portrait-first layout pass (2025-10-22) === */
:root { --bar-h: 112px; } /* allow for two rows by default */

#bottomBar.control-bar {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: min-content;
  row-gap: 8px;
}

#bottomBar .cluster { min-width: 0; }
#bottomBar .actions,
#bottomBar .tools,
#bottomBar .stats {
  display: flex;
  align-items: center;
  gap: 8px;
}
#bottomBar .scrollrow {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

/* Order the rows explicitly for portrait */
#bottomBar .actions { order: 1; }
#bottomBar .tools   { order: 2; }
#bottomBar .stats   { order: 3; }

/* Keep labels visible in portrait except on ultra-narrow screens */
@media (max-width: 360px) {
  #bottomBar .btn .lbl { display: none; }
}

/* Landscape fallback: condense into two columns if height is tight */
@media (orientation: landscape) and (max-height: 480px) {
  #bottomBar.control-bar {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
    row-gap: 8px;
    column-gap: 10px;
  }
  #bottomBar .actions { grid-column: 1 / -1; }
  #bottomBar .stats { grid-column: 1 / -1; }
  #bottomBar .tools { grid-column: 1 / -1; }
}

/* Ensure bar overlays nothing functional and stays above map */
#bottomBar { z-index: 1100; }
.leaflet-bottom.leaflet-right, .leaflet-bottom.leaflet-left {
  bottom: calc(var(--bar-h, 112px) + max(6px, env(safe-area-inset-bottom)));
}

/* Map height respects dynamic bar height */
#map {
  height: calc(100svh - var(--bar-h, 112px));
}
@supports not (height: 100svh) {
  #map { height: calc((var(--vh, 1vh) * 100) - var(--bar-h, 112px)); }
}

/* === Ultra-Compact Bottom Bar (2025-10-22) === */
:root { --bar-h: 56px; }

#bottomBar.control-bar.compact {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1100;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px max(env(safe-area-inset-right), 10px) max(env(safe-area-inset-bottom), 8px) max(env(safe-area-inset-left), 10px);
  background: rgba(16, 18, 24, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border, #1c2333);
}
[data-theme="light"] #bottomBar.control-bar.compact {
  background: rgba(255,255,255,0.95);
}

#bottomBar .btn {
  padding: 8px 10px;
  border-radius: 12px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#bottomBar .form-select {
  height: 36px;
  min-width: 120px;
  max-width: min(38vw, 180px);
  border-radius: 10px;
}
#bottomBar .icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border, #2a3348);
  background: transparent;
  display: inline-grid; place-items: center;
}
#bottomBar .menu-wrap { position: relative; }
#bottomBar .menu {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  background: var(--surface, #12141a);
  color: var(--app-fg, #f5f7fb);
  border: 1px solid var(--border, #1c2333);
  border-radius: 12px;
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}
#bottomBar .menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: transparent; border: 0;
  text-align: left;
  padding: 8px 10px; border-radius: 8px;
}
#bottomBar .menu-item:hover { background: rgba(255,255,255,0.06); }

/* Stats HUD */
#hudStats.hud {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  top: max(10px, env(safe-area-inset-top));
  display: flex;
  gap: 6px;
  z-index: 1050;
}
#hudStats .chip {
  background: rgba(16,18,24,0.85);
  color: var(--app-fg, #f5f7fb);
  border: 1px solid var(--border, #1c2333);
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  display: inline-flex; align-items: center; gap: 6px;
}
[data-theme="light"] #hudStats .chip {
  background: #ffffff; border-color: var(--border, #dce2f0);
}

/* Map & Leaflet offsets */
#map { height: calc(100svh - var(--bar-h)); }
@supports not (height: 100svh) {
  #map { height: calc((var(--vh, 1vh) * 100) - var(--bar-h)); }
}
.leaflet-bottom.leaflet-right, .leaflet-bottom.leaflet-left {
  bottom: calc(var(--bar-h) + max(6px, env(safe-area-inset-bottom)));
}

/* Narrow phones: hide button text, keep icons */
@media (max-width: 420px) {
  #bottomBar .lbl, #bottomBar .hide-narrow { display: none !important; }
  #bottomBar .form-select { max-width: 34vw; }
}


/* === Safe revert: full-height map, show original controls === */
#map { height: 100svh; }
@supports not (height: 100svh) {
  #map { height: calc(var(--vh, 1vh) * 100); }
}

/* Explicitly re-show original controls if any inline styles linger */
#startBtn, #stopBtn, #clearBtn, #saveRouteBtn, #routesBtn, #logoutBtn, #basemapSelect {
  position: static !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  clip-path: none !important;
  border: initial !important;
  padding: initial !important;
  margin: initial !important;
}
