/* === Basic Reset & Layout === */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  background-color: #ddd;
}

/* === Header (Dark Mode) === */
header {
  background-color: #222;
  color: #eee;
  padding: 10px 20px;
  text-align: center;
  border-bottom: 1px solid #444;
  flex-shrink: 0;
}
header h1 {
  margin: 0 0 5px 0;
  font-size: 1.8rem;
  color: #fff;
}
header p {
  font-size: 0.9rem;
  margin: 0;
  color: #bbb;
}

/* === Map Container === */
#map-container {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}
#map {
  width: 100%;
  height: 100%;
}

/* === Footer (Dark Mode) === */
footer {
  background-color: #222;
  color: #bbb;
  padding: 15px 20px;
  text-align: center;
  border-top: 1px solid #444;
  font-size: 0.8rem;
  flex-shrink: 0;
}
footer .heart {
  color: #e31b23;
}
footer a {
  color: #6cafff;
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* === Map Controls === */
#recenter-button {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  background-color: white;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  width: 34px;
  height: 34px;
  padding: 5px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
}
#recenter-button svg {
  fill: #333;
}
#recenter-button:hover {
  background-color: #f4f4f4;
}
#recenter-button:disabled {
  cursor: not-allowed;
  background-color: #e9ecef;
  opacity: 0.7;
}
#recenter-button:disabled svg {
  fill: #6c757d;
}
#route-button-container {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-height: calc(100% - 30px);
  overflow-y: auto;
  padding: 5px;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
#route-controls-header {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
  align-self: flex-end;
}
#clear-all-routes-button {
  background-color: #e0e0e0;
  color: #555;
  border: 1px solid #aaa;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 18px;
  font-weight: bold;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  min-width: 28px;
  transition: background-color 0.2s ease, transform 0.1s ease;
  flex-shrink: 0;
}
#clear-all-routes-button:hover {
  background-color: #f07a7a;
  color: white;
  border-color: #d9534f;
  transform: scale(1.05);
}

.route-button {
  background-color: white;
  border: 2px solid black;
  color: black;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  min-width: 40px;
  margin-top: 3px;
  position: relative;
  transition: background-color 0.2s ease, transform 0.1s ease;
  flex-shrink: 0;
}
.route-button:hover {
  background-color: #f0f0f0;
  transform: scale(1.05);
}

/* === Leaflet Specific Overrides === */
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255, 255, 255, 0.7) !important;
}
.leaflet-popup-content ul {
  list-style: none;
  padding-left: 0;
  margin-top: 5px;
  max-height: 220px;
  overflow-y: auto;
}
.leaflet-popup-content li {
  margin-bottom: 5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.destination-text {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.leaflet-popup-pane {
  z-index: 650 !important;
}
.stop-marker-shadow path {
  filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.4));
}

/* === Vehicle Marker Styles === */
.vehicle-marker-icon {
  width: 0;
  height: 0;
  /* Creates a triangle pointing UP */
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom-width: 24px; /* Triangle height */
  border-bottom-style: solid;
  border-bottom-color: black; /* Base color, overridden by JS */
  /* Adjust positioning so the APEX aligns with the lat/lng */
  margin-left: -12px; /* Half width */
  margin-top: -24px; /* Negative height to bring apex up to anchor */
}

/* Black border, 2px wide */
.vehicle-marker-border .vehicle-marker-icon {
  outline: 2px solid black;
  outline-offset: 1px; /* Offset slightly out */
}

/* === Utility Classes === */
.hidden {
  display: none !important;
}

/* === Responsive Adjustments === */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }
  header p {
    font-size: 0.8rem;
  }
  footer {
    font-size: 0.7rem;
  }
  #route-button-container {
    top: 10px;
    right: 5px;
    max-height: calc(100% - 20px);
    padding: 3px;
  }
  #clear-all-routes-button {
    min-width: 25px;
    padding: 0px 6px;
    font-size: 16px;
  }
  .route-button {
    font-size: 11px;
    padding: 3px 6px;
    min-width: 30px;
    margin-top: 2px;
  }
  .destination-text {
    max-width: 100px;
  }
  /* Adjust vehicle marker size on mobile */
  .vehicle-marker-icon {
    border-left-width: 9px;
    border-right-width: 9px;
    border-bottom-width: 18px;
    margin-left: -9px;
    margin-top: -18px;
  }
}
