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

html, body {
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: #333;
  background: #fff;
}

/* === TOP NAVBAR (DESKTOP) === */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: #fff;
  padding: 0;
  height: 48px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.top-nav .nav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 0 14px;
  height: 48px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.2);
  transition: opacity 0.2s;
  flex-shrink: 0;
}

/* Desktop: slightly larger nav label for the Private Mobility button */
@media (min-width: 769px) {
  .top-nav .nav-link {
    font-size: 1.05rem;
  }
}

.top-nav .nav-link:hover { opacity: 0.85; }

.top-nav .nav-home     { background: #6b0000; }
.top-nav .nav-private  { background: #4CAF50; }
.top-nav .nav-transit  { background: #0000ff; }
.top-nav .nav-scenario { background: #ffa500; }
.top-nav .nav-charge   { background: #326bbb; }
.top-nav .nav-impacts  { background: #76a5af; }
.top-nav .nav-best     { background: #326bbb; }
.top-nav .nav-iea,
.top-nav .nav-IEA      { background: #ededed; color: #0000ff !important; }
.top-nav .nav-cost     { background: red; color: #000 !important; }

/* === HAMBURGER (MOBILE) === */
.hamburger {
  display: none;
  position: fixed;
  top: 6px;
  right: 10px;
  z-index: 10001;
  background: #333;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  width: 38px;
  height: 38px;
  border-radius: 4px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* === SIDEBAR NAV (MOBILE) === */
.sidebar-nav {
  display: none;
  position: fixed;
  top: 0;
  left: -280px;
  width: 270px;
  height: 100%;
  z-index: 10000;
  background: #fff;
  box-shadow: 2px 0 12px rgba(0,0,0,0.3);
  overflow-y: auto;
  transition: left 0.3s ease;
  padding-top: 10px;
}

.sidebar-nav.open { left: 0; }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
}

.sidebar-overlay.show { display: block; }

.sidebar-nav .side-link {
  display: block;
  padding: 14px 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-nav .side-home     { background: #6b0000; }
.sidebar-nav .side-private  { background: #4CAF50; }
.sidebar-nav .side-transit  { background: #0000ff; }
.sidebar-nav .side-scenario { background: #ffa500; }
.sidebar-nav .side-charge   { background: #326bbb; }
.sidebar-nav .side-impacts  { background: #76a5af; }
.sidebar-nav .side-best     { background: #326bbb; }
.sidebar-nav .side-iea,
.sidebar-nav .side-IEA      { background: #ededed; color: #0000ff !important; }
.sidebar-nav .side-cost     { background: red; color: #000 !important; }

/* === MAIN CONTENT OFFSET === */
.page-content {
  padding-top: 48px;
  min-height: 100vh;
  position: relative;
}

.page-content-full {
  padding-top: 48px;
  height: calc(100vh - 48px);
  position: relative;
  display: flex;
}

.page-content-full #map {
  flex: 1;
  height: 100%;
}

/* === MAP (full height) === */
#map {
  width: 100%;
}

html, body, #map {
  height: 100%;
}

/* === DASHBOARD PANELS (desktop) === */
.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  height: calc(100% - 10px);
  overflow: hidden;
}

.dashboard-panel {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 150px;
  position: relative;
}

.dashboard-panel.resizable {
  resize: both;
  overflow: auto;
}

.dashboard-panel .panel-header {
  background: #f5f5f5;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: default;
  user-select: none;
}

.dashboard-panel .panel-body {
  flex: 1;
  padding: 6px;
  overflow: auto;
  position: relative;
}

.dashboard-panel .panel-body iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
}

/* === INFO / LEGEND === */
.info {
  padding: 6px 8px;
  font: 14px/16px Arial, Helvetica, sans-serif;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 0 15px rgba(0,0,0,0.2);
  border-radius: 5px;
}

.info h4 { margin: 0 0 5px; color: #777; }

.legend {
  text-align: left;
  line-height: 18px;
  color: #555;
  font-size: 0.9rem;
}

.legend i {
  width: 14px;
  height: 14px;
  float: left;
  margin-right: 5px;
  opacity: 0.7;
}

.legend_censuary {
  text-align: left;
  line-height: 10px;
  color: #555;
  font-size: 10px;
}

.legend_ZMU {
  text-align: left;
  line-height: 15px;
  color: #555;
  font-size: 12px;
}

/* === BUTTONS === */
.btn {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }

.btn-yellow {
  background: #ff0;
  color: #000;
}

.btn-blue {
  background: #009;
  color: #fff;
}

.btn-primary {
  color: #212529;
  background-color: #fff;
  border: 1px solid #5bc2c2;
}

.btn-primary:hover {
  background-color: #52bebe;
  border-color: #8ad3d3;
}

/* === LOADING SPINNER === */
#loader {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 120px;
  height: 120px;
  margin: -76px 0 0 -76px;
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid blue;
  border-right: 16px solid green;
  border-bottom: 16px solid red;
  border-left: 16px solid yellow;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 2s linear infinite;
}

@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#loading {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 700;
  width: 270px;
  height: 270px;
  margin: -135px 0 0 -135px;
  background: url(/static/loadingimage_TPL.gif) no-repeat center;
  cursor: wait;
}

/* === REFRESH / HOME LOCATION BUTTONS (map overlays) === */
#refreshButton {
  position: absolute;
  top: 60px;
  right: 20px;
  padding: 10px;
  z-index: 400;
  color: #000;
  background: #ff0;
  border: none;
  cursor: pointer;
}

#refreshButton:hover { opacity: 0.8; }

#home_locations {
  position: absolute;
  top: 60px;
  margin-top: 40px;
  right: 20px;
  padding: 10px;
  z-index: 400;
  color: #fff;
  background: #009;
}

/* === FOOTER === */
.footer {
  position: relative;
  width: 100%;
  padding: 10px 0;
  text-align: center;
  font-size: 0.85rem;
  color: #333;
  font-weight: bold;
  background: transparent;
}

.footer a {
  color: #333;
  text-decoration: underline;
}

.footer p { margin: 0; }

/* === GENERAL UTILITY === */
.box {
  width: 15px;
  height: 15px;
  border-radius: 25px;
  display: inline-block;
}

.img-logo {
  display: inline-block;
  margin: 10px 0;
}

.img-logo img {
  max-width: 100%;
  height: auto;
}

/* === SIDEBAR MENU (legacy support for .innerDiv) === */
.innerDiv {
  position: absolute;
  width: 10%;
  height: 15%;
  background: #b2b2ff;
  opacity: 0.8;
  margin-top: 1%;
  margin-left: 5%;
  z-index: 800;
  padding-top: 1%;
  text-overflow: ellipsis;
  overflow: auto;
}

/* === FORMS === */
form select, form input, form button {
  font-size: 0.9rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

form select:focus, form input:focus {
  outline: none;
  border-color: #326bbb;
}

/* === PLOTLY IFRAME CONTAINERS === */
.plotly-container {
  width: 100%;
  height: 100%;
  min-height: 200px;
  position: relative;
}

.plotly-container iframe {
  width: 100% !important;
  height: 100% !important;
  border: none;
}

/* === HEATMAP LEGENDS === */
#heatmapContainerWrapper {
  width: 100%;
  height: 100%;
  position: absolute;
  background: rgba(0,0,0,.1);
}

#heatmapContainer {
  width: 10%;
  height: 10%;
  z-index: 700;
}

#heatmapLegend_N_buses,
#heatmapLegend_N_vehicles,
#heatmapLegend_stoptime,
#heatmapLegend_tripdistance,
#heatmapLegend_triptime {
  background: #fff;
  position: absolute;
  right: 0;
  padding: 10px;
  z-index: 700;
  font-size: 16px;
}

#heatmapLegend_N_vehicles { bottom: 33%; }
#heatmapLegend_stoptime   { bottom: 23%; }
#heatmapLegend_tripdistance { bottom: 13%; }
#heatmapLegend_triptime   { bottom: 3%; }

/* === DASHBOARD HAMBURGER (mobile) — always slide-in === */
.dashboard-toggle {
  display: none;
  position: fixed;
  top: 6px;
  left: 10px;
  z-index: 10001;
  background: #326bbb;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  padding: 4px 14px;
  height: 38px;
  border-radius: 4px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
  gap: 6px;
}

.dashboard-toggle .dash-label {
  display: none;
}

.dashboard-panel {
  position: fixed;
  top: 0;
  left: -340px;
  width: 340px;
  height: 100%;
  max-height: 100%;
  background: rgba(255, 255, 255, 0.97);
  border: none;
  border-radius: 0;
  box-shadow: 2px 0 12px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10002;
  transition: left 0.3s ease;
}

.dashboard-panel.open { left: 0; }

.dashboard-panel .dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #326bbb;
  color: #fff;
  flex-shrink: 0;
}

.dashboard-panel .dashboard-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
  line-height: 1;
}

.dashboard-panel .dashboard-close {
  display: block;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.dashboard-panel .dashboard-body {
  padding: 10px 14px;
  overflow-y: auto;
  flex: 1;
}

.dashboard-panel .dashboard-body h3 {
  margin: 8px 0 4px;
  font-size: 0.9rem;
  font-weight: bold;
}

.dashboard-panel .dashboard-body form {
  margin-bottom: 8px;
}

.dashboard-panel .dashboard-body select,
.dashboard-panel .dashboard-body input,
.dashboard-panel .dashboard-body button {
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-panel .dashboard-body button {
  background: #326bbb;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.dashboard-panel .dashboard-body button:hover {
  opacity: 0.85;
}

.dashboard-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 899;
}

.dashboard-overlay.show { display: block; }

/* === DESKTOP: dashboard below nav (height: fit-content) === */
@media (min-width: 769px) {
  .page-content-full {
    flex-direction: row;
    align-items: flex-start;
  }

  .dashboard-toggle,
  .dashboard-overlay {
    display: none !important;
  }

  .dashboard-panel {
    position: static;
    width: 300px;
    min-width: 0;
    height: fit-content;
    background: #fff;
    border-right: 1px solid #ccc;
    border-bottom: none;
    border-radius: 0;
    box-shadow: none;
    z-index: auto;
    transition: none;
    flex-shrink: 0;
  }

  .dashboard-panel .dashboard-body {
    max-height: calc(100vh - 110px);
    overflow-y: auto;
  }

  .dashboard-panel.open {
    left: auto;
  }

  .dashboard-panel .dashboard-header {
    cursor: default;
  }

  .dashboard-panel .dashboard-close {
    display: none;
  }

  .page-content-full #map {
    flex: 1;
    height: 100%;
    min-height: 0;
  }

  .img-logo img {
    width: 30%;
  }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .top-nav { display: none; }
  .hamburger { display: flex; }
  .sidebar-nav { display: block; }
  .page-content-full { height: calc(100vh - 0px); padding-top: 0; }
  #refreshButton { top: 10px; right: 10px; font-size: 0.8rem; }

  /* Dashboard toggle visible as hamburger */
  .dashboard-toggle { display: flex; }
  .dashboard-toggle .dash-label { display: inline; font-size: 0.9rem; }

  /* Overlay layer control: 10% from top right, below hamburger */
  .leaflet-control-layers {
    position: fixed !important;
    top: 10% !important;
    right: 10px !important;
    margin-top: 0 !important;
    z-index: 999 !important;
  }

  /* Legend: 5% from bottom right of the viewport */
  .leaflet-control-container .leaflet-bottom.leaflet-right {
    bottom: 5% !important;
    right: 5% !important;
  }
}
