/* Mobile-friendly enhancements */

/* Larger touch targets for mobile devices */
@media (max-width: 768px) {
  /* Make control buttons larger and more spaced for mobile */
  .leaflet-control-container .leaflet-bar {
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    margin: 10px !important;
  }
  
  .leaflet-bar button,
  .leaflet-bar button:hover {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 20px !important;
    margin: 0 !important;
  }

  .leaflet-touch .leaflet-bar button {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
  }

  /* Position controls for better mobile access */
  .leaflet-top.leaflet-left {
    top: 10px;
    left: 10px;
  }

  .leaflet-top.leaflet-right {
    top: 10px;
    right: 10px;
  }

  .leaflet-bottom.leaflet-left {
    bottom: 30px;
    left: 10px;
  }

  .leaflet-bottom.leaflet-right {
    bottom: 30px;
    right: 10px;
  }

  /* Optimize dialog sizes for mobile */
  .leaflet-control-dialog {
    max-width: 90vw !important;
    max-height: 80vh !important;
    overflow-y: auto;
  }

  .leaflet-control-window .leaflet-control-window-content {
    max-width: 85vw !important;
    padding: 15px !important;
    font-size: 14px !important;
  }

  /* Message box optimization */
  .leaflet-control-messagebox {
    max-width: calc(100vw - 40px) !important;
    font-size: 12px !important;
    padding: 10px !important;
  }

  /* Popup optimization for mobile */
  .leaflet-popup-content {
    max-width: 250px !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    font-size: 14px !important;
  }

  .leaflet-popup-content img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Hide background logo on mobile for better performance */
  html, body {
    background-image: none !important;
  }

  /* Scale adjustments for mobile */
  .leaflet-control-scale {
    font-size: 10px !important;
  }

  /* Touch-friendly layer control */
  .leaflet-control-layers {
    padding: 10px !important;
  }

  .leaflet-control-layers-toggle {
    width: 44px !important;
    height: 44px !important;
    background-size: 26px 26px !important;
  }

  .leaflet-control-layers-expanded {
    padding: 10px !important;
    font-size: 14px !important;
  }

  .leaflet-control-layers label {
    padding: 5px !important;
    margin: 5px 0 !important;
  }

  /* Ensure touch events work properly */
  .leaflet-control-layers-selector {
    width: 20px !important;
    height: 20px !important;
    margin-right: 8px !important;
  }
}

/* Bottom navigation bar for mobile */
@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    z-index: 1000;
  }

  .mobile-bottom-nav button {
    background: none;
    border: none;
    padding: 5px 10px;
    font-size: 20px;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .mobile-bottom-nav button span {
    font-size: 10px;
    font-family: sans-serif;
  }

  .mobile-bottom-nav button:active {
    background-color: #f0f0f0;
    border-radius: 8px;
  }

  /* Adjust map height to account for bottom nav */
  #map {
    height: calc(100% - 60px) !important;
  }
}

/* Improve dialog window for mobile */
.leaflet-control-dialog-inner {
  max-height: 70vh !important;
  overflow-y: auto !important;
}

.leaflet-control-dialog-inner img {
  max-width: 100% !important;
  height: auto !important;
}

/* Ensure proper touch scrolling */
.leaflet-popup-content,
.leaflet-control-dialog-inner,
.leaflet-control-window-content {
  -webkit-overflow-scrolling: touch;
}

/* Prevent accidental zoom on double tap */
@media (max-width: 768px) {
  * {
    touch-action: manipulation;
  }
}

/* Larger hit areas for markers on mobile */
@media (max-width: 768px) {
  .leaflet-marker-icon {
    margin: -20px !important;
  }
  
  .iconmarker,
  .icon_color_blue,
  .icon_color_red,
  .icon_color_green,
  .icon_color_yellow,
  .icon_color_orange {
    width: 40px !important;
    height: 40px !important;
    margin: -20px !important;
  }
}

/* Responsive text sizing */
@media (max-width: 768px) {
  p, a, div {
    line-height: 1.5;
  }
  
  .leaflet-control-attribution {
    font-size: 8px !important;
  }
}