/* Convergy Map Styles */

/* Landscape orientation warning */
@media screen and (orientation: landscape) and (max-height: 500px) {
  body::before {
    content: "Please rotate your device to portrait mode";
    position: fixed;
    inset: 0;
    background: #0d1f15;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-size: 18px;
    text-align: center;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  }
}

/* Base layout */
html, body, #map {
  height: 100%;
  margin: 0;
}

/* Search box styles */
#search-container {
  position: absolute;
  z-index: 100;
}

/* Mobile: top bar */
@media (max-width: 768px) {
  #search-container {
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background: #0d1f15;
  }
  #map {
    position: absolute !important;
    top: 52px !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: auto !important;
  }
}

/* Desktop: inline with compass */
@media (min-width: 769px) {
  #search-container {
    top: 10px;
    left: 55px;
    width: 260px;
  }
}

/* Compass styling */
.mapboxgl-ctrl-group {
  background: #fff !important;
  box-shadow: 0 0 10px 2px rgba(0,0,0,0.1) !important;
  border-radius: 4px !important;
  border: none !important;
}

/* Desktop only: shrink compass to match search bar */
@media (min-width: 769px) {
  .mapboxgl-ctrl-group button {
    width: 20px !important;
    height: 20px !important;
  }
  .mapboxgl-ctrl-compass-arrow {
    width: 10px !important;
    height: 10px !important;
  }
}

/* EV Pin Marker Styles */
.ev-pin-marker {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ev-pin {
  width: 30px;
  height: 38px;
  position: relative;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

.ev-pin svg {
  width: 100%;
  height: 100%;
}

.ev-pin .pin-number {
  position: absolute;
  top: 37%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1;
}

.ev-pin.available .pin-number {
  color: #0d1f15;
}

.ev-pin.unavailable .pin-number {
  color: #DC143C;
}

/* Hover effect */
.ev-pin-marker:hover .ev-pin {
  transform: scale(1.1);
  transition: transform 0.15s ease;
}

/* Selected state - add prominent glow */
.ev-pin-marker.selected .ev-pin {
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.9)) drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
  transform: scale(1.05);
}

/* Filter Panel */
#filter-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  background: white;
  padding: 10px 11px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 150;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  min-width: 180px;
}

#filter-panel h3 {
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: 600;
}

#filter-panel label {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
  cursor: pointer;
}

#filter-panel input[type="checkbox"] {
  margin-right: 6px;
  cursor: pointer;
  accent-color: #0d1f15;
  width: 14px;
  height: 14px;
}

#filter-panel .filter-section {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e0e0e0;
}

#filter-panel .filter-section:last-child {
  border-bottom: none;
}

#filter-panel .select-all {
  font-weight: 600;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}

#filter-panel .slider-container {
  margin-top: 6px;
}

#filter-panel input[type="range"] {
  width: 100%;
  accent-color: #0d1f15;
  margin: 6px 0;
}

#filter-panel .slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #666;
}

/* Filter Toggle Button */
#filter-toggle {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
  border: none;
  border-radius: 4px;
  box-shadow: 0 0 10px 2px rgba(0,0,0,0.1);
  cursor: pointer;
  z-index: 200;
  width: 29px;
  height: 29px;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#filter-toggle svg {
  width: 18px;
  height: 18px;
  color: #228B22;
  fill: #228B22;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  #filter-toggle {
    display: flex;
    top: 62px;
  }

  #filter-panel {
    display: none;
    top: 57px;
    right: 5px;
    padding: 6px 8px;
    font-size: 13px;
    min-width: 160px;
    max-height: calc(100vh - 62px);
    overflow-y: auto;
  }

  #filter-panel.visible {
    display: block;
  }

  #filter-panel h3 {
    font-size: 13px;
    margin: 0 0 4px 0;
  }

  #filter-panel label {
    margin-bottom: 2px;
    font-size: 13px;
  }

  #filter-panel input[type="checkbox"] {
    width: 12px;
    height: 12px;
    margin-right: 4px;
  }

  #filter-panel .filter-section {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  #filter-panel .slider-labels {
    font-size: 9px;
  }

  #filter-panel .select-all {
    margin-bottom: 3px;
    padding-bottom: 3px;
  }
}

@media (max-width: 480px) {
  #filter-panel {
    top: 57px;
    right: 3px;
    padding: 5px 6px;
    font-size: 12px;
    min-width: 150px;
    max-height: calc(100vh - 62px);
  }

  #filter-panel h3 {
    font-size: 12px;
    margin: 0 0 3px 0;
  }

  #filter-panel label {
    margin-bottom: 1px;
    font-size: 12px;
  }

  #filter-panel input[type="checkbox"] {
    width: 11px;
    height: 11px;
    margin-right: 3px;
  }

  #filter-panel .filter-section {
    margin-bottom: 5px;
    padding-bottom: 5px;
  }

  #filter-panel .slider-labels {
    font-size: 8px;
  }

  #filter-panel .select-all {
    margin-bottom: 2px;
    padding-bottom: 2px;
  }
}

/* Power Marker Styles */
.power-marker-wrapper {
  width: 0;
  height: 0;
  position: relative;
}

.power-marker-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding-top: 0;
  padding-bottom: 4px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.power-marker {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  padding: 4px 8px 4px 4px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  border: 2px solid #0d1f15;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

.power-marker.no-available {
  border-color: #DC143C;
}

.power-marker.needs-detail {
  border-color: #888;
  background: #f9f9f9;
}

.operator-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.operator-logo img {
  height: 20px;
  max-height: 20px;
  max-width: 40px;
  width: auto;
  object-fit: contain;
}

.operator-logo.text-badge {
  background: #0d1f15;
  color: white;
  font-size: 9px;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 4px;
}

.power-marker.no-available .operator-logo.text-badge {
  background: #DC143C;
}

.power-marker.needs-detail .operator-logo.text-badge {
  background: #888;
}

.marker-text {
  white-space: nowrap;
  font-weight: 600;
}

.marker-text .avail {
  font-weight: bold;
  color: #228B22;
}

.power-marker.no-available .marker-text .avail {
  color: #DC143C;
}

/* Connector row visibility */
.conn-row.hidden {
  display: none !important;
}

/* Mapbox popup styling */
.mapboxgl-popup {
  max-width: none !important;
}

.mapboxgl-popup-content {
  padding: 0 !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2) !important;
  max-width: none !important;
  width: auto !important;
}

.mapboxgl-popup-content > div {
  max-height: 75vh;
  overflow-y: auto;
}

/* Mobile popup optimizations */
@media (max-width: 768px) {
  .mapboxgl-popup-content {
    max-width: 95vw !important;
    font-size: 9px !important;
  }

  .mapboxgl-popup-content h4 {
    font-size: 11px !important;
  }

  .mapboxgl-popup-content > div {
    max-height: 60vh;
  }
}

.mapboxgl-popup-content > div::-webkit-scrollbar {
  width: 6px;
}

.mapboxgl-popup-content > div::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.mapboxgl-popup-content > div::-webkit-scrollbar-thumb {
  background: #0d1f15;
  border-radius: 10px;
}

.mapboxgl-popup-content > div::-webkit-scrollbar-thumb:hover {
  background: #0a1610;
}

.mapboxgl-popup-close-button {
  font-size: 12px !important;
  color: white !important;
  right: 8px !important;
  top: 8px !important;
  width: 16px !important;
  height: 16px !important;
  background: rgba(0,0,0,0.3) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: bold !important;
  padding: 0 !important;
}

.mapboxgl-popup-close-button:hover {
  background: rgba(0,0,0,0.5) !important;
}

.mapboxgl-popup-tip {
  display: none !important;
}

/* User location marker */
.user-location {
  width: 9px;
  height: 9px;
  background: #4285F4;
  border: 1.5px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(66,133,244,0.3), 0 1px 2px rgba(0,0,0,0.3);
}

.user-location::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  width: 15px;
  height: 15px;
  background: rgba(66,133,244,0.2);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Bottom bar behind Mapbox controls */
#map::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: white;
  z-index: 1;
  pointer-events: none;
}

/* Vertically center Mapbox attribution in bottom bar */
.mapboxgl-ctrl-bottom-right {
  bottom: 9px !important;
}

.mapboxgl-ctrl-bottom-left {
  bottom: 0 !important;
  height: 34px !important;
  display: flex !important;
  align-items: center !important;
}

.mapboxgl-ctrl-attrib {
  background: transparent !important;
  margin: 0 8px !important;
}

.mapboxgl-ctrl-logo {
  margin: 0 0 0 8px !important;
}

/* Mobile: smaller logo, cleaner attribution */
@media (max-width: 768px) {
  .mapboxgl-ctrl-logo {
    transform: scale(0.8);
    transform-origin: left center;
  }

  /* Hide redundant Mapbox/OSM text when expanded, keep only "Improve this map" */
  .mapboxgl-ctrl-attrib.mapboxgl-compact-show a[href*="mapbox.com/about/maps"],
  .mapboxgl-ctrl-attrib.mapboxgl-compact-show a[href*="openstreetmap.org"] {
    display: none !important;
  }

  /* Keep attribution vertically centered and prevent jump */
  .mapboxgl-ctrl-attrib {
    z-index: 100 !important;
    display: inline-flex !important;
    align-items: center !important;
    height: 16px !important;
  }

  /* Make all attribution text smaller */
  .mapboxgl-ctrl-attrib-inner,
  .mapboxgl-ctrl-attrib-inner a {
    font-size: 9px !important;
    line-height: 1 !important;
    transform: translateY(1px) !important;
  }
}

/* Align any controls that appear on the right */
.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl {
  margin: 0 8px !important;
}

.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl {
  margin: 0 !important;
  float: none !important;
}

/* Convergy Branding */
#branding {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: white;
  padding: 5px 14px 8px 14px;
  border-radius: 12px 12px 0 0;
  transition: opacity 0.2s ease;
}

#branding:hover {
  opacity: 1;
}

#branding img {
  height: 32px;
  width: auto;
  display: block;
}

#branding .logo-mobile {
  display: none;
}

@media (max-width: 768px) {
  #branding {
    padding: 8px 12px 8px 12px;
    border-radius: 10px 10px 0 0;
  }
  #branding .logo-desktop {
    display: none;
  }
  #branding .logo-mobile {
    display: block;
    height: 26px;
  }
}

