/**
 * Property Detail Map Component Styles
 * Leaflet.js map rendering for property detail pages
 */

/* Map Stage Container */
.property-detail-map-stage {
  width: 100%;
  height: 400px;
  border-radius: 1rem;
  overflow: hidden;
  background-color: var(--bs-light);
  position: relative;
}

@media (max-width: 767.98px) {
  .property-detail-map-stage {
    height: 300px;
  }
}

/* Map Canvas Wrapper */
.property-detail-map-canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Map Loading Container - positioned over the map canvas */
.property-detail-map-loading-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  pointer-events: none;
  border-radius: inherit;
}

.property-detail-map-loading-container:empty {
  display: none;
}

.property-detail-map-loading-container .gf-loading {
  pointer-events: auto;
}

/* Map Canvas */
.property-detail-map-canvas {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Leaflet overrides for detail map */
.property-detail-map-canvas .leaflet-container {
  width: 100%;
  height: 100%;
  border-radius: 1rem;
  font-family: var(--bs-font-sans-serif);
  cursor: default !important;
}

.property-detail-map-canvas .leaflet-container.leaflet-grab,
.property-detail-map-canvas .leaflet-container.leaflet-dragging {
  cursor: default !important;
}

/* Custom marker for headquarter - Simple green dot */
.property-detail-map-canvas .leaflet-marker-icon.headquarter-marker {
  background: transparent;
  border: none;
  box-shadow: none;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.property-detail-map-canvas .headquarter-dot {
  width: 12px;
  height: 12px;
  background-color: #28a745;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Popup styles */
.property-detail-map-canvas .leaflet-popup-content-wrapper {
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.property-detail-map-canvas .leaflet-popup-content {
  margin: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.property-detail-map-canvas .leaflet-popup-tip {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Polygon styles are driven dynamically via Leaflet setStyle; avoid CSS overrides */

/* Attribution styling - Hidden */
.property-detail-map-canvas .leaflet-control-attribution {
  display: none !important;
}

.property-detail-map-canvas .leaflet-bottom.leaflet-right {
  display: none !important;
}

/* Zoom control removed - map is non-interactive */
/* .property-detail-map-canvas .leaflet-control-zoom styles removed */

/* Map info section */
.property-detail-map-info {
  padding-top: 0.75rem;
  border-top: 1px solid var(--bs-border-color);
}

.property-detail-map-info .material-icons-outlined {
  font-size: 1.125rem;
}

/* Old loading state - DISABLED in favor of GFLoadingIndicator */
/* Keep is-loading class for JS logic but remove visual effects */
.property-detail-map-canvas.is-loading {
  /* No visual effects - handled by GFLoadingIndicator overlay */
}

/* Error state */
.property-detail-map-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
  color: var(--bs-text-muted);
}

.property-detail-map-error .material-icons-outlined {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Responsive adjustments */
@media (max-width: 575.98px) {
  .property-detail-map-stage {
    border-radius: 0.75rem;
  }

  .property-detail-map-canvas .leaflet-container {
    border-radius: 0.75rem;
  }
}

/* ========================================================================
   Earth Engine Satellite Layer Dropdown (public + preview parity)
   Reuses advertise page styling to keep selector identical across contexts
   ======================================================================== */
[data-ee-layer-selector] .dropdown-toggle {
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Hide icon when loading - use map overlay instead of button spinner */
[data-ee-layer-selector] .dropdown-toggle.loading [data-ee-icon],
[data-satellite-selector] .dropdown-toggle.loading [data-ee-icon],
[data-dev-satellite-selector] .dropdown-toggle.loading [data-dev-ee-icon] {
  opacity: 0.5;
}

/* Button spinner is deprecated - use GFLoadingIndicator map overlay instead
   Keep spinner hidden, don't show it on loading state */
[data-ee-layer-selector] .dropdown-toggle .spinner-border,
[data-satellite-selector] .dropdown-toggle .spinner-border,
[data-dev-satellite-selector] .dropdown-toggle .spinner-border {
  display: none !important;
}

[data-ee-layer-selector] .dropdown-toggle.active {
  background-color: rgba(var(--gf-color-primary-rgb), 0.1);
  border-color: var(--gf-color-primary);
  color: var(--gf-color-primary);
}

[data-ee-layer-selector] .dropdown-toggle.active [data-ee-icon] {
  color: var(--gf-color-primary);
}

[data-ee-layer-selector] .dropdown-menu {
  min-width: 200px;
}

[data-ee-layer-selector] .dropdown-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

[data-ee-layer-selector] .dropdown-item {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

/* ========================================================================
   Thematic Layer Popup Styles
   Styles for annotation layer info popups (name, description, area)
   ======================================================================== */

.thematic-layer-popup {
  max-width: 220px;
  min-width: 140px;
}

.thematic-layer-popup__title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--bs-dark);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.thematic-layer-popup__description {
  font-size: 0.8125rem;
  color: var(--bs-secondary);
  margin-bottom: 0.375rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.thematic-layer-popup__area {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--bs-border-color);
  color: var(--bs-secondary);
}

.thematic-layer-popup__area small {
  font-size: 0.75rem;
}

/* ========================================================================
   Inverse Mask Pane Styles (Security: public_map = false)
   Ensures the white mask always covers tiles during zoom/pan transitions
   ======================================================================== */

/* Mask pane: SVG overlay with polygon cutout - highest z-index */
.property-detail-map-canvas .leaflet-pane[class*="maskPane-"],
[data-preview-map-canvas] .leaflet-pane[class*="maskPane-"] {
  z-index: 650 !important;
  pointer-events: none !important;
}

/* Ensure SVG elements inside panes are full-size and cover viewport */
.property-detail-map-canvas .leaflet-overlay-pane svg,
[data-preview-map-canvas] .leaflet-overlay-pane svg {
  overflow: visible !important;
}

/* Force mask SVG to be visible beyond viewport bounds - critical for security */
.property-detail-map-canvas .leaflet-pane[class*="maskPane-"] svg,
[data-preview-map-canvas] .leaflet-pane[class*="maskPane-"] svg {
  overflow: visible !important;
  position: absolute !important;
}

/* Ensure mask rect covers everything during transitions */
.property-detail-map-canvas .leaflet-pane[class*="maskPane-"] rect,
[data-preview-map-canvas] .leaflet-pane[class*="maskPane-"] rect {
  shape-rendering: crispEdges;
}

/* ===== MOBILE SATELLITE SELECTOR LAYOUT ===== */
/* Ensure satellite selector dropdowns take full width in mobile grid layout */
@media (max-width: 767.98px) {
  .satellite-selector-dropdown {
    width: 100%;
  }
  
  .satellite-selector-dropdown > .dropdown-toggle {
    width: 100%;
    justify-content: center;
  }
}
