/**
 * Enhanced Map Style Selector
 * Professional map layer switching UI
 */

.map-style-selector {
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.map-style-button {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #2d3748;
  transition: all 0.2s ease;
  background: white;
  border-radius: 4px;
}

.map-style-button:hover {
  background: #f7fafc;
  color: #F59E0B;
}

.map-style-button svg {
  width: 20px;
  height: 20px;
}

.map-style-panel {
  position: absolute;
  top: 0;
  right: 45px;
  width: 320px;
  max-height: 500px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: none;
  overflow: hidden;
  z-index: 1000;
}

.map-style-header {
  padding: 16px;
  background: #F59E0B;
  color: #0B0F14;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.map-style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  max-height: 420px;
  overflow-y: auto;
}

.map-style-option {
  cursor: pointer;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  background: white;
}

.map-style-option:hover {
  border-color: #F59E0B;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
  transform: translateY(-2px);
}

.map-style-option.active {
  border-color: #F59E0B;
  background: #FDE68A;
}

.map-style-preview {
  width: 100%;
  height: 80px;
  background-size: cover;
  background-position: center;
  position: relative;
}

.map-style-option.active .map-style-preview::after {
  content: '\2713';  /* Unicode escape for checkmark ✓ */
  position: absolute;
  top: 8px;
  right: 8px;
  background: #F59E0B;
  color: #0B0F14;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
}

.map-style-name {
  padding: 8px 12px 4px;
  font-weight: 600;
  font-size: 13px;
  color: #2d3748;
}

.map-style-category {
  padding: 0 12px 8px;
  font-size: 11px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Scrollbar styling for the grid */
.map-style-grid::-webkit-scrollbar {
  width: 6px;
}

.map-style-grid::-webkit-scrollbar-track {
  background: #f7fafc;
}

.map-style-grid::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.map-style-grid::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .map-style-panel {
    right: 0;
    left: 0;
    width: calc(100% - 20px);
    margin: 0 10px;
    top: 50px;
  }
  
  .map-style-grid {
    grid-template-columns: 1fr;
  }
}

/* Enhanced Leaflet layer control styling */
.leaflet-control-layers {
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
  border: none !important;
}

.leaflet-control-layers-toggle {
  background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTMgOWw5LTcgOSA3djExYTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0yeiIgc3Ryb2tlPSIjMmQzNzQ4IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cG9seWxpbmUgcG9pbnRzPSI5IDIyIDkgMTIgMTUgMTIgMTUgMjIiIHN0cm9rZT0iIzJkMzc0OCIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+') !important;
  width: 34px !important;
  height: 34px !important;
  background-size: 20px 20px !important;
  background-position: center !important;
}

.leaflet-control-layers-expanded {
  padding: 12px !important;
  border-radius: 8px !important;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  padding: 8px 12px !important;
  margin: 4px 0 !important;
  border-radius: 4px !important;
  transition: background 0.2s ease !important;
  cursor: pointer !important;
}

.leaflet-control-layers-base label:hover,
.leaflet-control-layers-overlays label:hover {
  background: #f7fafc !important;
}

.leaflet-control-layers-separator {
  margin: 8px 0 !important;
  border-top: 1px solid #e2e8f0 !important;
}

/* ---- Leaflet Draw toolbar improvements ---- */
.leaflet-draw-toolbar a {
  background-color: white !important;
  border-radius: 4px !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
}
.leaflet-draw-toolbar a:hover {
  background-color: #FEF3C7 !important;
}
.leaflet-draw.leaflet-control {
  margin: 10px !important;
}
.leaflet-draw-actions a {
  background: #1F2937 !important;
  color: white !important;
  border-radius: 4px !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  line-height: 1.4 !important;
}
.leaflet-draw-actions a:hover {
  background: #374151 !important;
}

/* Cursor feedback during drawing */
.leaflet-draw-tooltip {
  background: rgba(31,41,55,0.9) !important;
  color: white !important;
  border: none !important;
  border-radius: 6px !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
.leaflet-draw-tooltip:before {
  border-right-color: rgba(31,41,55,0.9) !important;
}
.leaflet-draw-guide-dash {
  opacity: 0.6 !important;
}

/* Layer control toggle explicit color */
.leaflet-control-layers-toggle {
  color: #2d3748;
}

/* Ensure draw toolbar icons are visible — explicitly point to CDN sprite */
.leaflet-draw-toolbar a {
  background-image: url('https://unpkg.com/leaflet-draw@1.0.4/dist/images/spritesheet.png') !important;
  background-image: linear-gradient(transparent, transparent), url('https://unpkg.com/leaflet-draw@1.0.4/dist/images/spritesheet.svg') !important;
  background-repeat: no-repeat !important;
  background-size: 300px 30px !important;
}

/* ---- Dark mode for map controls ---- */
body.dark-mode .leaflet-control-layers {
  background: #1E2330 !important;
  color: #E5E7EB !important;
}
body.dark-mode .leaflet-control-layers-base label:hover,
body.dark-mode .leaflet-control-layers-overlays label:hover {
  background: #252B3B !important;
}
body.dark-mode .leaflet-draw-toolbar a {
  background-color: #1E2330 !important;
  border-color: #2D3548 !important;
}
body.dark-mode .leaflet-draw-toolbar a:hover {
  background-color: #252B3B !important;
}
body.dark-mode .map-style-panel {
  background: #1E2330;
}
body.dark-mode .map-style-header {
  background: #D97706;
}
body.dark-mode .map-style-option {
  background: #252B3B;
  border-color: #2D3548;
}
body.dark-mode .map-style-name {
  color: #E5E7EB;
}
body.dark-mode .map-style-category {
  color: #9CA3AF;
}
body.dark-mode .leaflet-control-zoom a {
  background-color: #1E2330 !important;
  color: #E5E7EB !important;
  border-color: #2D3548 !important;
}
body.dark-mode .leaflet-control-zoom a:hover {
  background-color: #252B3B !important;
}
